cft-builder 0.2.57 → 0.2.59

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.
@@ -1,4 +1,4 @@
1
- import { D as s, C as o, E as a, F as d, R as i, T as u, A as B, z as l, B as m } from "./main-DqHMlALJ.js";
1
+ import { D as s, C as o, E as a, F as d, R as i, T as u, A as B, z as l, B as m } from "./main-BfqUxL-X.js";
2
2
  export {
3
3
  s as BuilderItems,
4
4
  o as BuilderItemsRender,
@@ -3864,7 +3864,7 @@ ${qh(e)}`),n.map&&!n.map.bytes&&(this.logger_("going to request init segment."),
3864
3864
  `.split("").map(t=>t.charCodeAt(0)));class a3e extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class s3e extends ow{constructor(e,n={}){super(e,n),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return Vs();const e=this.subtitlesTrack_.cues,n=e[0].startTime,r=e[e.length-1].startTime;return Vs([[n,r]])}initSegmentForMap(e,n=!1){if(!e)return null;const r=Qv(e);let i=this.initSegments_[r];if(n&&!i&&e.bytes){const a=BB.byteLength+e.bytes.byteLength,s=new Uint8Array(a);s.set(e.bytes),s.set(BB,e.bytes.byteLength),this.initSegments_[r]=i={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:s}}return i||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,n){Pg(e,n,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const n=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",n),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,n,r){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(n.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===Vu.TIMEOUT&&this.handleTimeout_(),e.code===Vu.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const i=this.pendingSegment_,a=r.mp4VttCues&&r.mp4VttCues.length;a&&(i.mp4VttCues=r.mp4VttCues),this.saveBandwidthRelatedStats_(i.duration,n.stats),n.key&&this.segmentKey(n.key,!0),this.state="APPENDING",this.trigger("appending");const s=i.segment;if(s.map&&(s.map.bytes=n.map.bytes),i.bytes=n.bytes,typeof We.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,n,r),()=>this.stopForError({message:"Error loading vtt.js"}));return}s.requested=!0;try{this.parseVTTCues_(i)}catch(l){this.stopForError({message:l.message,metadata:{errorType:_t.Error.StreamingVttParserError,error:l}});return}if(a||this.updateTimeMapping_(i,this.syncController_.timelines[i.timeline],this.playlist_),i.cues.length?i.timingInfo={start:i.cues[0].startTime,end:i.cues[i.cues.length-1].endTime}:i.timingInfo={start:i.startOfSegment,end:i.startOfSegment+i.duration},i.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}i.byteLength=i.bytes.byteLength,this.mediaSecondsLoaded+=s.duration,i.cues.forEach(l=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new We.VTTCue(l.startTime,l.endTime,l.text):l)}),jme(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,n){const r=e&&e.type==="vtt",i=n&&n.type==="text";r&&i&&super.handleData_(e,n)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(r=>{const i=r.start+n,a=r.end+n,s=new We.VTTCue(i,a,r.cueText);r.settings&&r.settings.split(" ").forEach(l=>{const c=l.split(":"),u=c[0],d=c[1];s[u]=isNaN(d)?d:Number(d)}),e.cues.push(s)})}parseVTTCues_(e){let n,r=!1;if(typeof We.WebVTT!="function")throw new a3e;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof We.TextDecoder=="function"?n=new We.TextDecoder("utf8"):(n=We.WebVTT.StringDecoder(),r=!0);const i=new We.WebVTT.Parser(We,We.vttjs,n);if(i.oncue=e.cues.push.bind(e.cues),i.ontimestampmap=s=>{e.timestampmap=s},i.onparsingerror=s=>{_t.log.warn("Error encountered when parsing cues: "+s.message)},e.segment.map){let s=e.segment.map.bytes;r&&(s=LB(s)),i.parse(s)}let a=e.bytes;r&&(a=LB(a)),i.parse(a),i.flush()}updateTimeMapping_(e,n,r){const i=e.segment;if(!n)return;if(!e.cues.length){i.empty=!0;return}const{MPEGTS:a,LOCAL:s}=e.timestampmap,c=a/E1.ONE_SECOND_IN_TS-s+n.mapping;if(e.cues.forEach(u=>{const d=u.endTime-u.startTime,f=this.handleRollover_(u.startTime+c,n.time);u.startTime=Math.max(f,0),u.endTime=Math.max(f+d,0)}),!r.syncInfo){const u=e.cues[0].startTime,d=e.cues[e.cues.length-1].startTime;r.syncInfo={mediaSequence:r.mediaSequence+e.mediaIndex,time:Math.min(u,d-i.duration)}}}handleRollover_(e,n){if(n===null)return e;let r=e*E1.ONE_SECOND_IN_TS;const i=n*E1.ONE_SECOND_IN_TS;let a;for(i<r?a=-8589934592:a=8589934592;Math.abs(r-i)>4294967296;)r+=a;return r/E1.ONE_SECOND_IN_TS}}const o3e=function(t,e){const n=t.cues;for(let r=0;r<n.length;r++){const i=n[r];if(e>=i.adStartTime&&e<=i.adEndTime)return i}return null},l3e=function(t,e,n=0){if(!t.segments)return;let r=n,i;for(let a=0;a<t.segments.length;a++){const s=t.segments[a];if(i||(i=o3e(e,r+s.duration/2)),i){if("cueIn"in s){i.endTime=r,i.adEndTime=r,r+=s.duration,i=null;continue}if(r<i.endTime){r+=s.duration;continue}i.endTime+=s.duration}else if("cueOut"in s&&(i=new We.VTTCue(r,r+s.duration,s.cueOut),i.adStartTime=r,i.adEndTime=r+parseFloat(s.cueOut),e.addCue(i)),"cueOutCont"in s){const[l,c]=s.cueOutCont.split("/").map(parseFloat);i=new We.VTTCue(r,r+s.duration,""),i.adStartTime=r-l,i.adEndTime=i.adStartTime+c,e.addCue(i)}r+=s.duration}};class VB{constructor({start:e,end:n,segmentIndex:r,partIndex:i=null,appended:a=!1}){this.start_=e,this.end_=n,this.segmentIndex_=r,this.partIndex_=i,this.appended_=a}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class c3e{constructor(e,n=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=n}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class UB{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,n){const{mediaSequence:r,segments:i}=e;if(this.isReliable_=this.isReliablePlaylist_(r,i),!!this.isReliable_)return this.updateStorage_(i,r,this.calculateBaseTime_(r,i,n))}getSyncInfoForTime(e){for(const{segmentSyncInfo:n,partsSyncInfo:r}of this.storage_.values())if(r.length){for(const i of r)if(i.isInRange(e))return i}else if(n.isInRange(e))return n;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,n,r){const i=new Map;let a=`
3865
3865
  `,s=r,l=n;this.start_=s,e.forEach((c,u)=>{const d=this.storage_.get(l),f=s,h=f+c.duration,g=!!(d&&d.segmentSyncInfo&&d.segmentSyncInfo.isAppended),v=new VB({start:f,end:h,appended:g,segmentIndex:u});c.syncInfo=v;let m=s;const A=(c.parts||[]).map((w,T)=>{const x=m,E=m+w.duration,S=!!(d&&d.partsSyncInfo&&d.partsSyncInfo[T]&&d.partsSyncInfo[T].isAppended),I=new VB({start:x,end:E,appended:S,segmentIndex:u,partIndex:T});return m=E,a+=`Media Sequence: ${l}.${T} | Range: ${x} --> ${E} | Appended: ${S}
3866
3866
  `,w.syncInfo=I,I});i.set(l,new c3e(v,A)),a+=`${IB(c.resolvedUri)} | Media Sequence: ${l} | Range: ${f} --> ${h} | Appended: ${g}
3867
- `,l++,s=h}),this.end_=s,this.storage_=i,this.diagnostics_=a}calculateBaseTime_(e,n,r){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const i=Math.min(...this.storage_.keys());if(e<i){const a=i-e;let s=this.storage_.get(i).segmentSyncInfo.start;for(let l=0;l<a;l++){const c=n[l];s-=c.duration}return s}return r}isReliablePlaylist_(e,n){return e!=null&&Array.isArray(n)&&n.length}}class qB extends UB{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,n,r){if(!this.storage_.size){const i=this.parent_.getSyncInfoForMediaSequence(e);return i?i.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,n,r)}}const u3e=86400,cw=[{name:"VOD",run:(t,e,n,r,i)=>n!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(t,e,n,r,i,a)=>{const s=t.getMediaSequenceSync(a);if(!s||!s.isReliable)return null;const l=s.getSyncInfoForTime(i);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(t,e,n,r,i)=>{if(!Object.keys(t.timelineToDatetimeMappings).length)return null;let a=null,s=null;const l=KA(e);i=i||0;for(let c=0;c<l.length;c++){const u=e.endList||i===0?c:l.length-(c+1),d=l[u],f=d.segment,h=t.timelineToDatetimeMappings[f.timeline];if(!h||!f.dateTimeObject)continue;let v=f.dateTimeObject.getTime()/1e3+h;if(f.parts&&typeof d.partIndex=="number")for(let A=0;A<d.partIndex;A++)v+=f.parts[A].duration;const m=Math.abs(i-v);if(s!==null&&(m===0||s<m))break;s=m,a={time:v,segmentIndex:d.segmentIndex,partIndex:d.partIndex}}return a}},{name:"Segment",run:(t,e,n,r,i)=>{let a=null,s=null;i=i||0;const l=KA(e);for(let c=0;c<l.length;c++){const u=e.endList||i===0?c:l.length-(c+1),d=l[u],f=d.segment,h=d.part&&d.part.start||f&&f.start;if(f.timeline===r&&typeof h<"u"){const g=Math.abs(i-h);if(s!==null&&s<g)break;(!a||s===null||s>=g)&&(s=g,a={time:h,segmentIndex:d.segmentIndex,partIndex:d.partIndex})}}return a}},{name:"Discontinuity",run:(t,e,n,r,i)=>{let a=null;if(i=i||0,e.discontinuityStarts&&e.discontinuityStarts.length){let s=null;for(let l=0;l<e.discontinuityStarts.length;l++){const c=e.discontinuityStarts[l],u=e.discontinuitySequence+l+1,d=t.discontinuities[u];if(d){const f=Math.abs(i-d.time);if(s!==null&&s<f)break;(!a||s===null||s>=f)&&(s=f,a={time:d.time,segmentIndex:c,partIndex:null})}}}return a}},{name:"Playlist",run:(t,e,n,r,i)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class d3e extends _t.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const n=new UB,r=new qB(n),i=new qB(n);this.mediaSequenceStorage_={main:n,audio:r,vtt:i},this.logger_=pc("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,n,r,i,a){if(n!==1/0)return cw.find(({name:c})=>c==="VOD").run(this,e,n);const s=this.runStrategies_(e,n,r,i,a);if(!s.length)return null;for(const l of s){const{syncPoint:c,strategy:u}=l,{segmentIndex:d,time:f}=c;if(d<0)continue;const h=e.segments[d],g=f,v=g+h.duration;if(this.logger_(`Strategy: ${u}. Current time: ${i}. selected segment: ${d}. Time: [${g} -> ${v}]}`),i>=g&&i<v)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(s,{key:"time",value:i})}getExpiredTime(e,n){if(!e||!e.segments)return null;const r=this.runStrategies_(e,n,e.discontinuitySequence,0);if(!r.length)return null;const i=this.selectSyncPoint_(r,{key:"segmentIndex",value:0});return i.segmentIndex>0&&(i.time*=-1),Math.abs(i.time+Og({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:i.segmentIndex,endIndex:0}))}runStrategies_(e,n,r,i,a){const s=[];for(let l=0;l<cw.length;l++){const c=cw[l],u=c.run(this,e,n,r,i,a);u&&(u.strategy=c.name,s.push({strategy:c.name,syncPoint:u}))}return s}selectSyncPoint_(e,n){let r=e[0].syncPoint,i=Math.abs(e[0].syncPoint[n.key]-n.value),a=e[0].strategy;for(let s=1;s<e.length;s++){const l=Math.abs(e[s].syncPoint[n.key]-n.value);l<i&&(i=l,r=e[s].syncPoint,a=e[s].strategy)}return this.logger_(`syncPoint for [${n.key}: ${n.value}] chosen with strategy [${a}]: [time:${r.time}, segmentIndex:${r.segmentIndex}`+(typeof r.partIndex=="number"?`,partIndex:${r.partIndex}`:"")+"]"),r}saveExpiredSegmentInfo(e,n){const r=n.mediaSequence-e.mediaSequence;if(r>u3e){_t.log.warn(`Not saving expired segment info. Media sequence gap ${r} is too large.`);return}for(let i=r-1;i>=0;i--){const a=e.segments[i];if(a&&typeof a.start<"u"){n.syncInfo={mediaSequence:e.mediaSequence+i,time:a.start},this.logger_(`playlist refresh sync: [time:${n.syncInfo.time}, mediaSequence: ${n.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const n=e.segments[0],r=n.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[n.timeline]=-r}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:n}){const r=this.calculateSegmentTimeMapping_(e,e.timingInfo,n),i=e.segment;r&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:i.start}));const a=i.dateTimeObject;i.discontinuity&&n&&a&&(this.timelineToDatetimeMappings[i.timeline]=-(a.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,n,r){const i=e.segment,a=e.part;let s=this.timelines[e.timeline],l,c;if(typeof e.timestampOffset=="number")s={time:e.startOfSegment,mapping:e.startOfSegment-n.start},r&&(this.timelines[e.timeline]=s,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${s.time}] [mapping: ${s.mapping}]`)),l=e.startOfSegment,c=n.end+s.mapping;else if(s)l=n.start+s.mapping,c=n.end+s.mapping;else return!1;return a&&(a.start=l,a.end=c),(!i.start||l<i.start)&&(i.start=l),i.end=c,!0}saveDiscontinuitySyncInfo_(e){const n=e.playlist,r=e.segment;if(r.discontinuity)this.discontinuities[r.timeline]={time:r.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(let i=0;i<n.discontinuityStarts.length;i++){const a=n.discontinuityStarts[i],s=n.discontinuitySequence+i+1,l=a-e.mediaIndex,c=Math.abs(l);if(!this.discontinuities[s]||this.discontinuities[s].accuracy>c){let u;l<0?u=r.start-Og({defaultDuration:n.targetDuration,durationList:n.segments,startIndex:e.mediaIndex,endIndex:a}):u=r.end+Og({defaultDuration:n.targetDuration,durationList:n.segments,startIndex:e.mediaIndex+1,endIndex:a}),this.discontinuities[s]={time:u,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class f3e extends _t.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:n,to:r}){return typeof n=="number"&&typeof r=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:n,to:r},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:n,to:r}){if(typeof n=="number"&&typeof r=="number"){this.lastTimelineChanges_[e]={type:e,from:n,to:r},delete this.pendingTimelineChanges_[e];const i={timelineChangeInfo:{from:n,to:r}};this.trigger({type:"timelinechange",metadata:i})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const h3e=uB(dB(function(){var t=function(){function m(){this.listeners={}}var A=m.prototype;return A.on=function(T,x){this.listeners[T]||(this.listeners[T]=[]),this.listeners[T].push(x)},A.off=function(T,x){if(!this.listeners[T])return!1;var E=this.listeners[T].indexOf(x);return this.listeners[T]=this.listeners[T].slice(0),this.listeners[T].splice(E,1),E>-1},A.trigger=function(T){var x=this.listeners[T];if(x)if(arguments.length===2)for(var E=x.length,S=0;S<E;++S)x[S].call(this,arguments[1]);else for(var I=Array.prototype.slice.call(arguments,1),_=x.length,O=0;O<_;++O)x[O].apply(this,I)},A.dispose=function(){this.listeners={}},A.pipe=function(T){this.on("data",function(x){T.push(x)})},m}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(m){return m.subarray(0,m.byteLength-m[m.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const n=function(){const m=[[[],[],[],[],[]],[[],[],[],[],[]]],A=m[0],w=m[1],T=A[4],x=w[4];let E,S,I;const _=[],O=[];let P,B,V,z,k,j;for(E=0;E<256;E++)O[(_[E]=E<<1^(E>>7)*283)^E]=E;for(S=I=0;!T[S];S^=P||1,I=O[I]||1)for(z=I^I<<1^I<<2^I<<3^I<<4,z=z>>8^z&255^99,T[S]=z,x[z]=S,V=_[B=_[P=_[S]]],j=V*16843009^B*65537^P*257^S*16843008,k=_[z]*257^z*16843008,E=0;E<4;E++)A[E][S]=k=k<<24^k>>>8,w[E][z]=j=j<<24^j>>>8;for(E=0;E<5;E++)A[E]=A[E].slice(0),w[E]=w[E].slice(0);return m};let r=null;class i{constructor(A){r||(r=n()),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let w,T,x;const E=this._tables[0][4],S=this._tables[1],I=A.length;let _=1;if(I!==4&&I!==6&&I!==8)throw new Error("Invalid aes key size");const O=A.slice(0),P=[];for(this._key=[O,P],w=I;w<4*I+28;w++)x=O[w-1],(w%I===0||I===8&&w%I===4)&&(x=E[x>>>24]<<24^E[x>>16&255]<<16^E[x>>8&255]<<8^E[x&255],w%I===0&&(x=x<<8^x>>>24^_<<24,_=_<<1^(_>>7)*283)),O[w]=O[w-I]^x;for(T=0;w;T++,w--)x=O[T&3?w:w-4],w<=4||T<4?P[T]=x:P[T]=S[0][E[x>>>24]]^S[1][E[x>>16&255]]^S[2][E[x>>8&255]]^S[3][E[x&255]]}decrypt(A,w,T,x,E,S){const I=this._key[1];let _=A^I[0],O=x^I[1],P=T^I[2],B=w^I[3],V,z,k;const j=I.length/4-2;let le,fe=4;const Z=this._tables[1],W=Z[0],ce=Z[1],K=Z[2],pe=Z[3],te=Z[4];for(le=0;le<j;le++)V=W[_>>>24]^ce[O>>16&255]^K[P>>8&255]^pe[B&255]^I[fe],z=W[O>>>24]^ce[P>>16&255]^K[B>>8&255]^pe[_&255]^I[fe+1],k=W[P>>>24]^ce[B>>16&255]^K[_>>8&255]^pe[O&255]^I[fe+2],B=W[B>>>24]^ce[_>>16&255]^K[O>>8&255]^pe[P&255]^I[fe+3],fe+=4,_=V,O=z,P=k;for(le=0;le<4;le++)E[(3&-le)+S]=te[_>>>24]<<24^te[O>>16&255]<<16^te[P>>8&255]<<8^te[B&255]^I[fe++],V=_,_=O,O=P,P=B,B=V}}class a extends t{constructor(){super(t),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const s=function(m){return m<<24|(m&65280)<<8|(m&16711680)>>8|m>>>24},l=function(m,A,w){const T=new Int32Array(m.buffer,m.byteOffset,m.byteLength>>2),x=new i(Array.prototype.slice.call(A)),E=new Uint8Array(m.byteLength),S=new Int32Array(E.buffer);let I,_,O,P,B,V,z,k,j;for(I=w[0],_=w[1],O=w[2],P=w[3],j=0;j<T.length;j+=4)B=s(T[j]),V=s(T[j+1]),z=s(T[j+2]),k=s(T[j+3]),x.decrypt(B,V,z,k,S,j),S[j]=s(S[j]^I),S[j+1]=s(S[j+1]^_),S[j+2]=s(S[j+2]^O),S[j+3]=s(S[j+3]^P),I=B,_=V,O=z,P=k;return E};class c{constructor(A,w,T,x){const E=c.STEP,S=new Int32Array(A.buffer),I=new Uint8Array(A.byteLength);let _=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(S.subarray(_,_+E),w,T,I)),_=E;_<S.length;_+=E)T=new Uint32Array([s(S[_-4]),s(S[_-3]),s(S[_-2]),s(S[_-1])]),this.asyncStream_.push(this.decryptChunk_(S.subarray(_,_+E),w,T,I));this.asyncStream_.push(function(){x(null,e(I))})}static get STEP(){return 32e3}decryptChunk_(A,w,T,x){return function(){const E=l(A,w,T);x.set(E,A.byteOffset)}}}var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d;typeof window<"u"?d=window:typeof u<"u"?d=u:typeof self<"u"?d=self:d={};var f=d,h=function(A){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(A):A&&A.buffer instanceof ArrayBuffer},g=f.BigInt||Number;g("0x1"),g("0x100"),g("0x10000"),g("0x1000000"),g("0x100000000"),g("0x10000000000"),g("0x1000000000000"),g("0x100000000000000"),g("0x10000000000000000"),function(){var m=new Uint16Array([65484]),A=new Uint8Array(m.buffer,m.byteOffset,m.byteLength);return A[0]===255?"big":A[0]===204?"little":"unknown"}();const v=function(m){const A={};return Object.keys(m).forEach(w=>{const T=m[w];h(T)?A[w]={bytes:T.buffer,byteOffset:T.byteOffset,byteLength:T.byteLength}:A[w]=T}),A};self.onmessage=function(m){const A=m.data,w=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),T=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),x=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new c(w,T,x,function(E,S){self.postMessage(v({source:A.source,decrypted:S}),[S.buffer])})}}));var p3e=cB(h3e);const g3e=t=>{let e=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},$B=(t,e)=>{t.abort(),t.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},uw=(t,e)=>{e.activePlaylistLoader=t,t.load()},m3e=(t,e)=>()=>{const{segmentLoaders:{[t]:n,main:r},mediaTypes:{[t]:i}}=e,a=i.activeTrack(),s=i.getActiveGroup(),l=i.activePlaylistLoader,c=i.lastGroup_;if(!(s&&c&&s.id===c.id)&&(i.lastGroup_=s,i.lastTrack_=a,$B(n,i),!(!s||s.isMainPlaylist))){if(!s.playlistLoader){l&&r.resetEverything();return}n.resyncLoader(),uw(s.playlistLoader,i)}},v3e=(t,e)=>()=>{const{segmentLoaders:{[t]:n},mediaTypes:{[t]:r}}=e;r.lastGroup_=null,n.abort(),n.pause()},b3e=(t,e)=>()=>{const{mainPlaylistLoader:n,segmentLoaders:{[t]:r,main:i},mediaTypes:{[t]:a}}=e,s=a.activeTrack(),l=a.getActiveGroup(),c=a.activePlaylistLoader,u=a.lastTrack_;if(!(u&&s&&u.id===s.id)&&(a.lastGroup_=l,a.lastTrack_=s,$B(r,a),!!l)){if(l.isMainPlaylist){if(!s||!u||s.id===u.id)return;const d=e.vhs.playlistController_,f=d.selectPlaylist();if(d.media()===f)return;a.logger_(`track change. Switching main audio from ${u.id} to ${s.id}`),n.pause(),i.resetEverything(),d.fastQualityChange_(f);return}if(t==="AUDIO"){if(!l.playlistLoader){i.setAudio(!0),i.resetEverything();return}r.setAudio(!0),i.setAudio(!1)}if(c===l.playlistLoader){uw(l.playlistLoader,a);return}r.track&&r.track(s),r.resetEverything(),uw(l.playlistLoader,a)}},n5={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:n},excludePlaylist:r}=e,i=n.activeTrack(),a=n.activeGroup(),s=(a.filter(c=>c.default)[0]||a[0]).id,l=n.tracks[s];if(i===l){r({error:{message:"Problem encountered loading the default audio track."}});return}_t.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in n.tracks)n.tracks[c].enabled=n.tracks[c]===l;n.onTrackChanged()},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:n}}=e;_t.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const r=n.activeTrack();r&&(r.mode="disabled"),n.onTrackChanged()}},jB={AUDIO:(t,e,n)=>{if(!e)return;const{tech:r,requestOptions:i,segmentLoaders:{[t]:a}}=n;e.on("loadedmetadata",()=>{const s=e.media();a.playlist(s,i),(!r.paused()||s.endList&&r.preload()!=="none")&&a.load()}),e.on("loadedplaylist",()=>{a.playlist(e.media(),i),r.paused()||a.load()}),e.on("error",n5[t](t,n))},SUBTITLES:(t,e,n)=>{const{tech:r,requestOptions:i,segmentLoaders:{[t]:a},mediaTypes:{[t]:s}}=n;e.on("loadedmetadata",()=>{const l=e.media();a.playlist(l,i),a.track(s.activeTrack()),(!r.paused()||l.endList&&r.preload()!=="none")&&a.load()}),e.on("loadedplaylist",()=>{a.playlist(e.media(),i),r.paused()||a.load()}),e.on("error",n5[t](t,n))}},y3e={AUDIO:(t,e)=>{const{vhs:n,sourceType:r,segmentLoaders:{[t]:i},requestOptions:a,main:{mediaGroups:s},mediaTypes:{[t]:{groups:l,tracks:c,logger_:u}},mainPlaylistLoader:d}=e,f=Fg(d.main);(!s[t]||Object.keys(s[t]).length===0)&&(s[t]={main:{default:{default:!0}}},f&&(s[t].main.default.playlists=d.main.playlists));for(const h in s[t]){l[h]||(l[h]=[]);for(const g in s[t][h]){let v=s[t][h][g],m;if(f?(u(`AUDIO group '${h}' label '${g}' is a main playlist`),v.isMainPlaylist=!0,m=null):r==="vhs-json"&&v.playlists?m=new Bh(v.playlists[0],n,a):v.resolvedUri?m=new Bh(v.resolvedUri,n,a):v.playlists&&r==="dash"?m=new tw(v.playlists[0],n,a,d):m=null,v=Qi({id:g,playlistLoader:m},v),jB[t](t,v.playlistLoader,e),l[h].push(v),typeof c[g]>"u"){const A=new _t.AudioTrack({id:g,kind:g3e(v),enabled:!1,language:v.language,default:v.default,label:g});c[g]=A}}}i.on("error",n5[t](t,e))},SUBTITLES:(t,e)=>{const{tech:n,vhs:r,sourceType:i,segmentLoaders:{[t]:a},requestOptions:s,main:{mediaGroups:l},mediaTypes:{[t]:{groups:c,tracks:u}},mainPlaylistLoader:d}=e;for(const f in l[t]){c[f]||(c[f]=[]);for(const h in l[t][f]){if(!r.options_.useForcedSubtitles&&l[t][f][h].forced)continue;let g=l[t][f][h],v;if(i==="hls")v=new Bh(g.resolvedUri,r,s);else if(i==="dash"){if(!g.playlists.filter(A=>A.excludeUntil!==1/0).length)return;v=new tw(g.playlists[0],r,s,d)}else i==="vhs-json"&&(v=new Bh(g.playlists?g.playlists[0]:g.resolvedUri,r,s));if(g=Qi({id:h,playlistLoader:v},g),jB[t](t,g.playlistLoader,e),c[f].push(g),typeof u[h]>"u"){const m=n.addRemoteTextTrack({id:h,kind:"subtitles",default:g.default&&g.autoselect,language:g.language,label:h},!1).track;u[h]=m}}}a.on("error",n5[t](t,e))},"CLOSED-CAPTIONS":(t,e)=>{const{tech:n,main:{mediaGroups:r},mediaTypes:{[t]:{groups:i,tracks:a}}}=e;for(const s in r[t]){i[s]||(i[s]=[]);for(const l in r[t][s]){const c=r[t][s][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const u=n.options_.vhs&&n.options_.vhs.captionServices||{};let d={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(u[d.instreamId]&&(d=Qi(d,u[d.instreamId])),d.default===void 0&&delete d.default,i[s].push(Qi({id:l},c)),typeof a[l]>"u"){const f=n.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track;a[l]=f}}}}},zB=(t,e)=>{for(let n=0;n<t.length;n++)if(GA(e,t[n])||t[n].playlists&&zB(t[n].playlists,e))return!0;return!1},A3e=(t,e)=>n=>{const{mainPlaylistLoader:r,mediaTypes:{[t]:{groups:i}}}=e,a=r.media();if(!a)return null;let s=null;a.attributes[t]&&(s=i[a.attributes[t]]);const l=Object.keys(i);if(!s)if(t==="AUDIO"&&l.length>1&&Fg(e.main))for(let c=0;c<l.length;c++){const u=i[l[c]];if(zB(u,a)){s=u;break}}else i.main?s=i.main:l.length===1&&(s=i[l[0]]);return typeof n>"u"?s:n===null||!s?null:s.filter(c=>c.id===n.id)[0]||null},w3e={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:n}}}=e;for(const r in n)if(n[r].enabled)return n[r];return null},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:n}}}=e;for(const r in n)if(n[r].mode==="showing"||n[r].mode==="hidden")return n[r];return null}},S3e=(t,{mediaTypes:e})=>()=>{const n=e[t].activeTrack();return n?e[t].activeGroup(n):null},x3e=t=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(u=>{y3e[u](u,t)});const{mediaTypes:e,mainPlaylistLoader:n,tech:r,vhs:i,segmentLoaders:{["AUDIO"]:a,main:s}}=t;["AUDIO","SUBTITLES"].forEach(u=>{e[u].activeGroup=A3e(u,t),e[u].activeTrack=w3e[u](u,t),e[u].onGroupChanged=m3e(u,t),e[u].onGroupChanging=v3e(u,t),e[u].onTrackChanged=b3e(u,t),e[u].getActiveGroup=S3e(u,t)});const l=e.AUDIO.activeGroup();if(l){const u=(l.filter(f=>f.default)[0]||l[0]).id;e.AUDIO.tracks[u].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(s.setAudio(!1),a.setAudio(!0)):s.setAudio(!0)}n.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanged())}),n.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),r.trigger({type:"usage",name:"vhs-audio-change"})};r.audioTracks().addEventListener("change",c),r.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),i.on("dispose",()=>{r.audioTracks().removeEventListener("change",c),r.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),r.clearTracks("audio");for(const u in e.AUDIO.tracks)r.audioTracks().addTrack(e.AUDIO.tracks[u])},C3e=()=>{const t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{t[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Fd,activeTrack:Fd,getActiveGroup:Fd,onGroupChanged:Fd,onTrackChanged:Fd,lastTrack_:null,logger_:pc(`MediaGroups[${e}]`)}}),t};class HB{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=ll(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(n=>[n.ID,n])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class T3e extends _t.EventTarget{constructor(e,n){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new HB,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=pc("Content Steering"),this.xhr_=e,this.getBandwidth_=n}assignTagProperties(e,n){this.manifestType_=n.serverUri?"HLS":"DASH";const r=n.serverUri||n.serverURL;if(!r){this.logger_(`steering manifest URL is ${r}, cannot request steering manifest.`),this.trigger("error");return}if(r.startsWith("data:")){this.decodeDataUriManifest_(r.substring(r.indexOf(",")+1));return}this.steeringManifest.reloadUri=ll(e,r),this.defaultPathway=n.pathwayId||n.defaultServiceLocation,this.queryBeforeStart=n.queryBeforeStart,this.proxyServerUrl_=n.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const n=this.steeringManifest.reloadUri;if(!n)return;const r=e?n:this.getRequestURI(n);if(!r){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const i={contentSteeringInfo:{uri:r}};this.trigger({type:"contentsteeringloadstart",metadata:i}),this.request_=this.xhr_({uri:r,requestType:"content-steering-manifest"},(a,s)=>{if(a){if(s.status===410){this.logger_(`manifest request 410 ${a}.`),this.logger_(`There will be no more content steering requests to ${r} this session.`),this.excludedSteeringManifestURLs.add(r);return}if(s.status===429){const u=s.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${a}.`),this.logger_(`content steering will retry in ${u} seconds.`),this.startTTLTimeout_(parseInt(u,10));return}this.logger_(`manifest failed to load ${a}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:i});let l;try{l=JSON.parse(this.request_.responseText)}catch(u){const d={errorType:_t.Error.StreamingContentSteeringParserError,error:u};this.trigger({type:"error",metadata:d})}this.assignSteeringProperties_(l);const c={contentSteeringInfo:i.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const n=new We.URL(e),r=new We.URL(this.proxyServerUrl_);return r.searchParams.set("url",encodeURI(n.toString())),this.setSteeringParams_(r.toString())}decodeDataUriManifest_(e){const n=JSON.parse(We.atob(e));this.assignSteeringProperties_(n)}setSteeringParams_(e){const n=new We.URL(e),r=this.getPathway(),i=this.getBandwidth_();if(r){const a=`_${this.manifestType_}_pathway`;n.searchParams.set(a,r)}if(i){const a=`_${this.manifestType_}_throughput`;n.searchParams.set(a,i)}return n.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const r=(i=>{for(const a of i)if(this.availablePathways_.has(a))return a;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==r&&(this.currentPathway=r,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const n=i=>this.excludedSteeringManifestURLs.has(i);if(this.proxyServerUrl_){const i=this.setProxyServerUrl_(e);if(!n(i))return i}const r=this.setSteeringParams_(e);return n(r)?null:r}startTTLTimeout_(e=this.steeringManifest.ttl){const n=e*1e3;this.ttlTimeout_=We.setTimeout(()=>{this.requestSteeringManifest()},n)}clearTTLTimeout_(){We.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new HB}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,n){return!n&&this.steeringManifest.reloadUri||n&&(ll(e,n.serverURL)!==this.steeringManifest.reloadUri||n.defaultServiceLocation!==this.defaultPathway||n.queryBeforeStart!==this.queryBeforeStart||n.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const E3e=(t,e)=>{let n=null;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{t.apply(null,r)},e)}},I3e=10;let x0;const _3e=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],D3e=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},N3e=function({currentPlaylist:t,buffered:e,currentTime:n,nextPlaylist:r,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:s,bufferBasedABR:l,log:c}){if(!r)return _t.log.warn("We received no playlist to switch to. Please check your stream."),!1;const u=`allowing switch ${t&&t.id||"null"} -> ${r.id}`;if(!t)return c(`${u} as current playlist is not set`),!0;if(r.id===t.id)return!1;const d=!!Ph(e,n).length;if(!t.endList)return!d&&typeof t.partTargetDuration=="number"?(c(`not ${u} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${u} as current playlist is live`),!0);const f=HA(e,n),h=l?Us.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Us.MAX_BUFFER_LOW_WATER_LINE;if(s<h)return c(`${u} as duration < max low water line (${s} < ${h})`),!0;const g=r.attributes.BANDWIDTH,v=t.attributes.BANDWIDTH;if(g<v&&(!l||f<a)){let m=`${u} as next bandwidth < current bandwidth (${g} < ${v})`;return l&&(m+=` and forwardBuffer < bufferHighWaterLine (${f} < ${a})`),c(m),!0}if((!l||g>v)&&f>=i){let m=`${u} as forwardBuffer >= bufferLowWaterLine (${f} >= ${i})`;return l&&(m+=` and next bandwidth > current bandwidth (${g} > ${v})`),c(m),!0}return c(`not ${u} as no switching criteria met`),!1};class O3e extends _t.EventTarget{constructor(e){super(),this.fastQualityChange_=E3e(this.fastQualityChange_.bind(this),100);const{src:n,withCredentials:r,tech:i,bandwidth:a,externVhs:s,useCueTags:l,playlistExclusionDuration:c,enableLowInitialPlaylist:u,sourceType:d,cacheEncryptionKeys:f,bufferBasedABR:h,leastPixelDiffSelector:g,captionServices:v,experimentalUseMMS:m}=e;if(!n)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:A}=e;(A===null||typeof A>"u")&&(A=1/0),x0=s,this.bufferBasedABR=!!h,this.leastPixelDiffSelector=!!g,this.withCredentials=r,this.tech_=i,this.vhs_=i.vhs,this.player_=e.player_,this.sourceType_=d,this.useCueTags_=l,this.playlistExclusionDuration=c,this.maxPlaylistRetries=A,this.enableLowInitialPlaylist=u,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:r,maxPlaylistRetries:A,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=C3e(),m&&We.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new We.ManagedMediaSource,this.usingManagedMediaSource_=!0,_t.log("Using ManagedMediaSource")):We.MediaSource&&(this.mediaSource=new We.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=Vs(),this.hasPlayed_=!1,this.syncController_=new d3e(e),this.segmentMetadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new p3e,this.sourceUpdater_=new MB(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new f3e,this.keyStatusMap_=new Map;const w={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:v,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:a,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:f,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new tw(n,this.vhs_,Qi(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Bh(n,this.vhs_,Qi(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new ow(Qi(w,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new ow(Qi(w,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new s3e(Qi(w,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((E,S)=>{function I(){i.off("vttjserror",_),E()}function _(){i.off("vttjsloaded",I),S()}i.one("vttjsloaded",I),i.one("vttjserror",_),i.addWebVttScript_()})}),e);const T=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new T3e(this.vhs_.xhr,T),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),_3e.forEach(E=>{this[E+"_"]=D3e.bind(this,E)}),this.logger_=pc("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const x=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(x,()=>{const E=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-E,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),n=this.audioAppendsToLoadedData_();return e===-1||n===-1?-1:e+n}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const n=this.selectPlaylist();n&&this.shouldSwitchToMedia_(n)&&this.switchMedia_(n,e)}switchMedia_(e,n,r){const i=this.media(),a=i&&(i.id||i.uri),s=e&&(e.id||e.uri);if(a&&a!==s){this.logger_(`switch media ${a} -> ${s} from ${n}`);const l={renditionInfo:{id:s,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:n};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${n}`})}this.mainPlaylistLoader_.media(e,r)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const n=this.mediaTypes_[e],r=n?n.activeGroup():null,i=this.contentSteeringController_.getPathway();if(r&&i){const s=(r.length?r[0].playlists:r.playlists).filter(l=>l.attributes.serviceLocation===i);s.length&&this.mediaTypes_[e].activePlaylistLoader.media(s[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=We.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(We.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),n=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return n;const r=e.mediaGroups.AUDIO,i=Object.keys(r);let a;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)a=this.mediaTypes_.AUDIO.activeTrack();else{const l=r.main||i.length&&r[i[0]];for(const c in l)if(l[c].default){a={label:c};break}}if(!a)return n;const s=[];for(const l in r)if(r[l][a.label]){const c=r[l][a.label];if(c.playlists&&c.playlists.length)s.push.apply(s,c.playlists);else if(c.uri)s.push(c);else if(e.playlists.length)for(let u=0;u<e.playlists.length;u++){const d=e.playlists[u];d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===l&&s.push(d)}}return s.length?s:n}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const n=this.mainPlaylistLoader_.media(),r=n.targetDuration*1.5*1e3;RA(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=r,n.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(n,this.requestOptions_),this.mainSegmentLoader_.load()),x3e({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),n),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let n=this.mainPlaylistLoader_.media();if(!n){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let r;if(this.enableLowInitialPlaylist&&(r=this.selectInitialPlaylist()),r||(r=this.selectPlaylist()),!r||!this.shouldSwitchToMedia_(r)||(this.initialMedia_=r,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;n=this.initialMedia_}this.handleUpdatedMediaPlaylist(n)}),this.mainPlaylistLoader_.on("error",()=>{const n=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:n.playlist,error:n})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const n=this.mainPlaylistLoader_.media(),r=n.targetDuration*1.5*1e3;RA(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=r,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(n,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const n=this.mainPlaylistLoader_.media();if(n.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(n)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(n=>{this.mainPlaylistLoader_.on(n,r=>{this.player_.trigger(Ea({},r))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,n){const r=e.mediaGroups||{};let i=!0;const a=Object.keys(r.AUDIO);for(const s in r.AUDIO)for(const l in r.AUDIO[s])r.AUDIO[s][l].uri||(i=!1);i&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(r.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),x0.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),a.length&&Object.keys(r.AUDIO[a[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const n=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,r=this.tech_.currentTime(),i=this.bufferLowWaterLine(),a=this.bufferHighWaterLine(),s=this.tech_.buffered();return N3e({buffered:s,currentTime:r,currentPlaylist:n,nextPlaylist:e,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const r=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:r.playlist,error:r})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const r=this.audioSegmentLoader_.pendingSegment_;if(!r||!r.segment||!r.segment.syncInfo)return;const i=r.segment.syncInfo.end+.01;this.tech_.setCurrentTime(i)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",r=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:I3e}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const r=this.getCodecsOrExclude_();r&&this.sourceUpdater_.addOrChangeSourceBuffers(r)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(r=>{this.mainSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))}),this.audioSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))}),this.subtitleSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const n=this.seekable();if(!n.length)return!1;const r=n.end(0);let i=r;if(e.start){const a=e.start.timeOffset;a<0?i=Math.max(r+a,n.start(0)):i=Math.min(r,a)}this.trigger("firstplay"),this.tech_.setCurrentTime(i)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,n=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const n=this.duration();e[e.length-1].endTime=isNaN(n)||Math.abs(n)===1/0?Number.MAX_VALUE:n}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const n=this.mainSegmentLoader_.getCurrentMediaInfo_();!n||n.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const r=this.syncController_.getExpiredTime(e,this.duration());if(r===null)return!1;const i=x0.Playlist.playlistEnd(e,r),a=this.tech_.currentTime(),s=this.tech_.buffered();if(!s.length)return i-a<=Bu;const l=s.end(s.length-1);return l-a<=Bu&&i-l<=Bu}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:n={},playlistExclusionDuration:r}){if(e=e||this.mainPlaylistLoader_.media(),r=r||n.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=n,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const i=this.mainPlaylistLoader_.main.playlists,a=i.filter(Wv),s=a.length===1&&a[0]===e;if(i.length===1&&r!==1/0)return _t.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(s);if(s){if(this.main().contentSteering){const v=this.pathwayAttribute_(e),m=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(v),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(v)},m);return}let g=!1;i.forEach(v=>{if(v===e)return;const m=v.excludeUntil;typeof m<"u"&&m!==1/0&&(g=!0,delete v.excludeUntil)}),g&&(_t.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+r*1e3,e.excludeUntil=l,n.reason&&(e.lastExcludeReason_=n.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const u=n.internal?this.logger_:_t.log.warn,d=n.message?" "+n.message:"";u(`${n.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${d} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const f=c.targetDuration/2*1e3||5*1e3,h=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=f;return this.switchMedia_(c,"exclude",s||h)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,n){const r=[],i=e==="all";(i||e==="main")&&r.push(this.mainPlaylistLoader_);const a=[];(i||e==="audio")&&a.push("AUDIO"),(i||e==="subtitle")&&(a.push("CLOSED-CAPTIONS"),a.push("SUBTITLES")),a.forEach(s=>{const l=this.mediaTypes_[s]&&this.mediaTypes_[s].activePlaylistLoader;l&&r.push(l)}),["main","audio","subtitle"].forEach(s=>{const l=this[`${s}SegmentLoader_`];l&&(e===s||e==="all")&&r.push(l)}),r.forEach(s=>n.forEach(l=>{typeof s[l]=="function"&&s[l]()}))}setCurrentTime(e){const n=Ph(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(n&&n.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:x0.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,n){const r=e.media();if(!r)return null;const i=this.syncController_.getMediaSequenceSync(n);if(i&&i.isReliable){const l=i.start,c=i.end;if(!isFinite(l)||!isFinite(c))return null;const u=x0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r),d=Math.max(0,c-u);return d<l?null:Vs([[l,d]])}const a=this.syncController_.getExpiredTime(r,this.duration());if(a===null)return null;const s=x0.Playlist.seekable(r,a,x0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r));return s.length?s:null}computeFinalSeekable_(e,n){if(!n)return e;const r=e.start(0),i=e.end(0),a=n.start(0),s=n.end(0);return a>i||r>s?e:Vs([[Math.max(r,a),Math.min(i,s)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let n;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(n=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!n))return;const r=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,n),!this.seekable_||r&&r.length&&this.seekable_.length&&r.start(0)===this.seekable_.start(0)&&r.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${PL(this.seekable_)}]`);const i={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:i}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const i=this.seekable();if(!i.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<i.end(i.length-1))&&this.sourceUpdater_.setDuration(i.end(i.length-1));return}const n=this.tech_.buffered();let r=x0.Playlist.duration(this.mainPlaylistLoader_.media());n.length>0&&(r=Math.max(r,n.end(n.length-1))),this.mediaSource.duration!==r&&this.sourceUpdater_.setDuration(r)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const n=this.mediaTypes_[e].groups;for(const r in n)n[r].forEach(i=>{i.playlistLoader&&i.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,n=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),r=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!n||!r)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},n=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const r=kg(this.main(),n),i={},a=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(i.video=r.video||e.main.videoCodec||Zfe),e.main.isMuxed&&(i.video+=`,${r.audio||e.main.audioCodec||Tk}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||a)&&(i.audio=r.audio||e.main.audioCodec||e.audio.audioCodec||Tk,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!i.audio&&!i.video){this.excludePlaylist({playlistToExclude:n,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const s=(u,d)=>u?ig(d,this.usingManagedMediaSource_):Sy(d),l={};let c;if(["video","audio"].forEach(function(u){if(i.hasOwnProperty(u)&&!s(e[u].isFmp4,i[u])){const d=e[u].isFmp4?"browser":"muxer";l[d]=l[d]||[],l[d].push(i[u]),u==="audio"&&(c=d)}}),a&&c&&n.attributes.AUDIO){const u=n.attributes.AUDIO;this.main().playlists.forEach(d=>{(d.attributes&&d.attributes.AUDIO)===u&&d!==n&&(d.excludeUntil=1/0)}),this.logger_(`excluding audio group ${u} as ${c} does not support codec(s): "${i.audio}"`)}if(Object.keys(l).length){const u=Object.keys(l).reduce((d,f)=>(d&&(d+=", "),d+=`${f} does not support codec(s): "${l[f].join(",")}"`,d),"")+".";this.excludePlaylist({playlistToExclude:n,error:{internal:!0,message:u},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const u=[];if(["video","audio"].forEach(d=>{const f=(_u(this.sourceUpdater_.codecs[d]||"")[0]||{}).type,h=(_u(i[d]||"")[0]||{}).type;f&&h&&f.toLowerCase()!==h.toLowerCase()&&u.push(`"${this.sourceUpdater_.codecs[d]}" -> "${i[d]}"`)}),u.length){this.excludePlaylist({playlistToExclude:n,error:{message:`Codec switching not supported: ${u.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return i}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const n=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(n)}excludeUnsupportedVariants_(){const e=this.main().playlists,n=[];Object.keys(e).forEach(r=>{const i=e[r];if(n.indexOf(i.id)!==-1)return;n.push(i.id);const a=kg(this.main,i),s=[];a.audio&&!Sy(a.audio)&&!ig(a.audio,this.usingManagedMediaSource_)&&s.push(`audio codec ${a.audio}`),a.video&&!Sy(a.video)&&!ig(a.video,this.usingManagedMediaSource_)&&s.push(`video codec ${a.video}`),a.text&&a.text==="stpp.ttml.im1t"&&s.push(`text codec ${a.text}`),s.length&&(i.excludeUntil=1/0,this.logger_(`excluding ${i.id} for unsupported: ${s.join(", ")}`))})}excludeIncompatibleVariants_(e){const n=[],r=this.main().playlists,i=Jv(_u(e)),a=xB(i),s=i.video&&_u(i.video)[0]||null,l=i.audio&&_u(i.audio)[0]||null;Object.keys(r).forEach(c=>{const u=r[c];if(n.indexOf(u.id)!==-1||u.excludeUntil===1/0)return;n.push(u.id);const d=[],f=kg(this.mainPlaylistLoader_.main,u),h=xB(f);if(!(!f.audio&&!f.video)){if(h!==a&&d.push(`codec count "${h}" !== "${a}"`),!this.sourceUpdater_.canChangeType()){const g=f.video&&_u(f.video)[0]||null,v=f.audio&&_u(f.audio)[0]||null;g&&s&&g.type.toLowerCase()!==s.type.toLowerCase()&&d.push(`video codec "${g.type}" !== "${s.type}"`),v&&l&&v.type.toLowerCase()!==l.type.toLowerCase()&&d.push(`audio codec "${v.type}" !== "${l.type}"`)}d.length&&(u.excludeUntil=1/0,this.logger_(`excluding ${u.id}: ${d.join(" && ")}`))}})}updateAdCues_(e){let n=0;const r=this.seekable();r.length&&(n=r.start(0)),l3e(e,this.cueTagsTrack_,n)}goalBufferLength(){const e=this.tech_.currentTime(),n=Us.GOAL_BUFFER_LENGTH,r=Us.GOAL_BUFFER_LENGTH_RATE,i=Math.max(n,Us.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+e*r,i)}bufferLowWaterLine(){const e=this.tech_.currentTime(),n=Us.BUFFER_LOW_WATER_LINE,r=Us.BUFFER_LOW_WATER_LINE_RATE,i=Math.max(n,Us.MAX_BUFFER_LOW_WATER_LINE),a=Math.max(n,Us.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+e*r,this.bufferBasedABR?a:i)}bufferHighWaterLine(){return Us.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){_B(this.inbandTextTracks_,"com.apple.streaming",this.tech_),$me({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,n,r){const i=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();_B(this.inbandTextTracks_,e,this.tech_),Vme({inbandTextTracks:this.inbandTextTracks_,metadataArray:n,timestampOffset:i,videoDuration:r})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const n of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(n));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(n=>{this.contentSteeringController_.on(n,r=>{this.trigger(Ea({},r))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const n=this.main();(this.contentSteeringController_.didDASHTagChange(n.uri,n.contentSteering)||(()=>{const a=this.contentSteeringController_.getAvailablePathways(),s=[];for(const l of n.playlists){const c=l.attributes.serviceLocation;if(c&&(s.push(c),!a.has(c)))return!0}return!!(!s.length&&a.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const r=this.main().playlists,i=new Set;let a=!1;Object.keys(r).forEach(s=>{const l=r[s],c=this.pathwayAttribute_(l),u=c&&e!==c;l.excludeUntil===1/0&&l.lastExcludeReason_==="content-steering"&&!u&&(delete l.excludeUntil,delete l.lastExcludeReason_,a=!0);const f=!l.excludeUntil&&l.excludeUntil!==1/0;!i.has(l.id)&&u&&f&&(i.add(l.id),l.excludeUntil=1/0,l.lastExcludeReason_="content-steering",this.logger_(`excluding ${l.id} for ${l.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(s=>{const l=this.mediaTypes_[s];if(l.activePlaylistLoader){const c=l.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(a=!0)}}),a&&this.changeSegmentPathway_()}handlePathwayClones_(){const n=this.main().playlists,r=this.contentSteeringController_.currentPathwayClones,i=this.contentSteeringController_.nextPathwayClones;if(r&&r.size||i&&i.size){for(const[s,l]of r.entries())i.get(s)||(this.mainPlaylistLoader_.updateOrDeleteClone(l),this.contentSteeringController_.excludePathway(s));for(const[s,l]of i.entries()){const c=r.get(s);if(!c){n.filter(d=>d.attributes["PATHWAY-ID"]===l["BASE-ID"]).forEach(d=>{this.mainPlaylistLoader_.addClonePathway(l,d)}),this.contentSteeringController_.addAvailablePathway(s);continue}this.equalPathwayClones_(c,l)||(this.mainPlaylistLoader_.updateOrDeleteClone(l,!0),this.contentSteeringController_.addAvailablePathway(s))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...i])))}}equalPathwayClones_(e,n){if(e["BASE-ID"]!==n["BASE-ID"]||e.ID!==n.ID||e["URI-REPLACEMENT"].HOST!==n["URI-REPLACEMENT"].HOST)return!1;const r=e["URI-REPLACEMENT"].PARAMS,i=n["URI-REPLACEMENT"].PARAMS;for(const a in r)if(r[a]!==i[a])return!1;for(const a in i)if(r[a]!==i[a])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const n="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(r=>{const i=this.mainPlaylistLoader_.getKeyIdSet(r);!i||!i.size||i.forEach(a=>{const s="usable",l=this.keyStatusMap_.has(a)&&this.keyStatusMap_.get(a)===s,c=r.lastExcludeReason_===n&&r.excludeUntil===1/0;l?l&&c&&(delete r.excludeUntil,delete r.lastExcludeReason_,this.logger_(`enabling playlist ${r.id} because key ID ${a} is ${s}`)):(r.excludeUntil!==1/0&&r.lastExcludeReason_!==n&&(r.excludeUntil=1/0,r.lastExcludeReason_=n,this.logger_(`excluding playlist ${r.id} because the key ID ${a} doesn't exist in the keyStatusMap or is not ${s}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(r=>{const i=r&&r.attributes&&r.attributes.RESOLUTION&&r.attributes.RESOLUTION.height<720,a=r.excludeUntil===1/0&&r.lastExcludeReason_===n;i&&a&&(delete r.excludeUntil,_t.log.warn(`enabling non-HD playlist ${r.id} because all playlists were excluded due to ${n} key IDs`))})}addKeyStatus_(e,n){const a=(typeof e=="string"?e:i3e(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${n}' with key ID ${a} added to the keyStatusMap`),this.keyStatusMap_.set(a,n)}updatePlaylistByKeyStatus(e,n){this.addKeyStatus_(e,n),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const F3e=(t,e,n)=>r=>{const i=t.main.playlists[e],a=XA(i),s=Wv(i);if(typeof r>"u")return s;r?delete i.disabled:i.disabled=!0;const l={renditionInfo:{id:e,bandwidth:i.attributes.BANDWIDTH,resolution:i.attributes.RESOLUTION,codecs:i.attributes.CODECS},cause:"fast-quality"};return r!==s&&!a&&(r?(n(i),t.trigger({type:"renditionenabled",metadata:l})):t.trigger({type:"renditiondisabled",metadata:l})),r};class k3e{constructor(e,n,r){const{playlistController_:i}=e,a=i.fastQualityChange_.bind(i);if(n.attributes){const s=n.attributes.RESOLUTION;this.width=s&&s.width,this.height=s&&s.height,this.bandwidth=n.attributes.BANDWIDTH,this.frameRate=n.attributes["FRAME-RATE"]}this.codecs=kg(i.main(),n),this.playlist=n,this.id=r,this.enabled=F3e(e.playlists,n.id,a)}}const P3e=function(t){t.representations=()=>{const e=t.playlistController_.main(),n=Fg(e)?t.playlistController_.getAudioTrackPlaylists_():e.playlists;return n?n.filter(r=>!XA(r)).map((r,i)=>new k3e(t,r,r.id)):[]}},YB=["seeking","seeked","pause","playing","error"];class M3e extends _t.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=pc("PlaybackWatcher"),this.logger_("initialize");const n=()=>this.monitorCurrentTime_(),r=()=>this.monitorCurrentTime_(),i=()=>this.techWaiting_(),a=()=>this.resetTimeUpdate_(),s=this.playlistController_,l=["main","subtitle","audio"],c={};l.forEach(d=>{c[d]={reset:()=>this.resetSegmentDownloads_(d),updateend:()=>this.checkSegmentDownloads_(d)},s[`${d}SegmentLoader_`].on("appendsdone",c[d].updateend),s[`${d}SegmentLoader_`].on("playlistupdate",c[d].reset),this.tech_.on(["seeked","seeking"],c[d].reset)});const u=d=>{["main","audio"].forEach(f=>{s[`${f}SegmentLoader_`][d]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),u("off"))},this.clearSeekingAppendCheck_=()=>u("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),u("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",i),this.tech_.on(YB,a),this.tech_.on("canplay",r),this.tech_.one("play",n),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",i),this.tech_.off(YB,a),this.tech_.off("canplay",r),this.tech_.off("play",n),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(d=>{s[`${d}SegmentLoader_`].off("appendsdone",c[d].updateend),s[`${d}SegmentLoader_`].off("playlistupdate",c[d].reset),this.tech_.off(["seeked","seeking"],c[d].reset)}),this.checkCurrentTimeTimeout_&&We.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&We.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=We.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const n=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=n.buffered_()}checkSegmentDownloads_(e){const n=this.playlistController_,r=n[`${e}SegmentLoader_`],i=r.buffered_(),a=Sge(this[`${e}Buffered_`],i);if(this[`${e}Buffered_`]=i,a){const s={bufferedRanges:i};n.trigger({type:"bufferedrangeschanged",metadata:s}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:r.playlist_&&r.playlist_.id,buffered:k1(i)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&n.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),n=this.tech_.buffered();if(this.lastRecordedTime===e&&(!n.length||e+Bu>=n.end(n.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Vs([this.lastRecordedTime,e]));const r={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:r}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const n=this.seekable(),r=this.tech_.currentTime(),i=this.afterSeekableWindow_(n,r,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let a;if(i&&(a=n.end(n.length-1)),this.beforeSeekableWindow_(n,r)){const v=n.start(0);a=v+(v===n.end(0)?0:Bu)}if(typeof a<"u")return this.logger_(`Trying to seek outside of seekable at time ${r} with seekable range ${PL(n)}. Seeking to ${a}.`),this.tech_.setCurrentTime(a),!0;const s=this.playlistController_.sourceUpdater_,l=this.tech_.buffered(),c=s.audioBuffer?s.audioBuffered():null,u=s.videoBuffer?s.videoBuffered():null,d=this.media(),f=d.partTargetDuration?d.partTargetDuration:(d.targetDuration-Lu)*2,h=[c,u];for(let v=0;v<h.length;v++){if(!h[v])continue;if(HA(h[v],r)<f)return!1}const g=Gv(l,r);return g.length===0?!1:(a=g.start(0)+Bu,this.logger_(`Buffered region starts (${g.start(0)}) just beyond seek point (${r}). Seeking to ${a}.`),this.tech_.setCurrentTime(a),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),n=this.tech_.buffered(),r=Ph(n,e);if(r.length&&e+3<=r.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${r.start(0)} -> ${r.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),n=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,n)){const l=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${n}. Seeking to live point (seekable end) ${l}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(l),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const r=this.tech_.vhs.playlistController_.sourceUpdater_,i=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:r.audioBuffered(),videoBuffered:r.videoBuffered(),currentTime:n}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(n),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const s=Gv(i,n);return s.length>0?(this.logger_(`Stopped at ${n} and seeking to ${s.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(n),!0):!1}afterSeekableWindow_(e,n,r,i=!1){if(!e.length)return!1;let a=e.end(e.length-1)+Bu;const s=!r.endList,l=typeof r.partTargetDuration=="number";return s&&(l||i)&&(a=e.end(e.length-1)+r.targetDuration*3),n>a}beforeSeekableWindow_(e,n){return!!(e.length&&e.start(0)>0&&n<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:n,currentTime:r}){if(!e)return;let i;if(e.length&&n.length){const a=Ph(e,r-3),s=Ph(e,r),l=Ph(n,r);l.length&&!s.length&&a.length&&(i={start:a.end(0),end:l.end(0)})}else Gv(e,r).length||(i=this.gapFromVideoUnderflow_(e,r));return i?(this.logger_(`Encountered a gap in video from ${i.start} to ${i.end}. Seeking to current time ${r}`),!0):!1}skipTheGap_(e){const n=this.tech_.buffered(),r=this.tech_.currentTime(),i=Gv(n,r);if(this.resetTimeUpdate_(),i.length===0||r!==e)return;this.logger_("skipTheGap_:","currentTime:",r,"scheduled currentTime:",e,"nextRange start:",i.start(0)),this.tech_.setCurrentTime(i.start(0)+Lu);const a={gapInfo:{from:r,to:i.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:a}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,n){const r=yge(e);for(let i=0;i<r.length;i++){const a=r.start(i),s=r.end(i);if(n-a<4&&n-a>2)return{start:a,end:s}}return null}}const L3e={errorInterval:30,getSource(t){const n=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return t(n)}},KB=function(t,e){let n=0,r=0;const i=Qi(L3e,e);t.ready(()=>{t.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const a=function(){r&&t.currentTime(r)},s=function(d){d!=null&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",a),t.src(d),t.trigger({type:"usage",name:"vhs-error-reload"}),t.play())},l=function(){if(Date.now()-n<i.errorInterval*1e3){t.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!i.getSource||typeof i.getSource!="function"){_t.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return n=Date.now(),i.getSource.call(t,s)},c=function(){t.off("loadedmetadata",a),t.off("error",l),t.off("dispose",c)},u=function(d){c(),KB(t,d)};t.on("error",l),t.on("dispose",c),t.reloadSourceOnError=u},B3e=function(t){KB(this,t)};var XB="3.16.2",V3e="7.1.0",U3e="1.3.1",q3e="7.2.0",$3e="4.0.2";const Ra={PlaylistLoader:Bh,Playlist:cl,utils:Hge,STANDARD_PLAYLIST_SELECTOR:EB,INITIAL_PLAYLIST_SELECTOR:kme,lastBandwidthSelector:EB,movingAverageBandwidthSelector:Ome,comparePlaylistBandwidth:aw,comparePlaylistResolution:Nme,xhr:eB()};Object.keys(Us).forEach(t=>{Object.defineProperty(Ra,t,{get(){return _t.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),Us[t]},set(e){if(_t.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){_t.log.warn(`value of Vhs.${t} must be greater than or equal to 0`);return}Us[t]=e}})});const RB="videojs-vhs",GB=function(t,e){const n=e.media();let r=-1;for(let i=0;i<t.length;i++)if(t[i].id===n.id){r=i;break}t.selectedIndex_=r,t.trigger({selectedIndex:r,type:"change"})},j3e=function(t,e){e.representations().forEach(n=>{t.addQualityLevel(n)}),GB(t,e.playlists)};Ra.canPlaySource=function(){return _t.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const z3e=(t,e,n)=>{if(!t)return t;let r={};e&&e.attributes&&e.attributes.CODECS&&(r=Jv(_u(e.attributes.CODECS))),n&&n.attributes&&n.attributes.CODECS&&(r.audio=n.attributes.CODECS);const i=rh(r.video),a=rh(r.audio),s={};for(const l in t)s[l]={},a&&(s[l].audioContentType=a),i&&(s[l].videoContentType=i),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(s[l].pssh=e.contentProtection[l].pssh),typeof t[l]=="string"&&(s[l].url=t[l]);return Qi(t,s)},H3e=(t,e)=>t.reduce((n,r)=>{if(!r.contentProtection)return n;const i=e.reduce((a,s)=>{const l=r.contentProtection[s];return l&&l.pssh&&(a[s]={pssh:l.pssh}),a},{});return Object.keys(i).length&&n.push(i),n},[]),Y3e=({player:t,sourceKeySystems:e,audioMedia:n,mainPlaylists:r})=>{if(!t.eme.initializeMediaKeys)return Promise.resolve();const i=n?r.concat([n]):r,a=H3e(i,Object.keys(e)),s=[],l=[];return a.forEach(c=>{l.push(new Promise((u,d)=>{t.tech_.one("keysessioncreated",u)})),s.push(new Promise((u,d)=>{t.eme.initializeMediaKeys({keySystems:c},f=>{if(f){d(f);return}u()})}))}),Promise.race([Promise.all(s),Promise.race(l)])},K3e=({player:t,sourceKeySystems:e,media:n,audioMedia:r})=>{const i=z3e(e,n,r);return i?(t.currentSource().keySystems=i,i&&!t.eme?(_t.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},WB=()=>{if(!We.localStorage)return null;const t=We.localStorage.getItem(RB);if(!t)return null;try{return JSON.parse(t)}catch{return null}},X3e=t=>{if(!We.localStorage)return!1;let e=WB();e=e?Qi(e,t):t;try{We.localStorage.setItem(RB,JSON.stringify(e))}catch{return!1}return e},R3e=t=>t.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(t.substring(t.indexOf(",")+1)):t,QB=(t,e)=>{t._requestCallbackSet||(t._requestCallbackSet=new Set),t._requestCallbackSet.add(e)},JB=(t,e)=>{t._responseCallbackSet||(t._responseCallbackSet=new Set),t._responseCallbackSet.add(e)},ZB=(t,e)=>{t._requestCallbackSet&&(t._requestCallbackSet.delete(e),t._requestCallbackSet.size||delete t._requestCallbackSet)},eV=(t,e)=>{t._responseCallbackSet&&(t._responseCallbackSet.delete(e),t._responseCallbackSet.size||delete t._responseCallbackSet)};Ra.supportsNativeHls=function(){if(!Tn||!Tn.createElement)return!1;const t=Tn.createElement("video");return _t.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(n){return/maybe|probably/i.test(t.canPlayType(n))}):!1}(),Ra.supportsNativeDash=function(){return!Tn||!Tn.createElement||!_t.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(Tn.createElement("video").canPlayType("application/dash+xml"))}(),Ra.supportsTypeNatively=t=>t==="hls"?Ra.supportsNativeHls:t==="dash"?Ra.supportsNativeDash:!1,Ra.isSupported=function(){return _t.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")},Ra.xhr.onRequest=function(t){QB(Ra.xhr,t)},Ra.xhr.onResponse=function(t){JB(Ra.xhr,t)},Ra.xhr.offRequest=function(t){ZB(Ra.xhr,t)},Ra.xhr.offResponse=function(t){eV(Ra.xhr,t)};const G3e=_t.getComponent("Component");class tV extends G3e{constructor(e,n,r){if(super(n,r.vhs),typeof r.initialBandwidth=="number"&&(this.options_.bandwidth=r.initialBandwidth),this.logger_=pc("VhsHandler"),n.options_&&n.options_.playerId){const i=_t.getPlayer(n.options_.playerId);this.player_=i}if(this.tech_=n,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&n.overrideNativeAudioTracks&&n.overrideNativeVideoTracks)n.overrideNativeAudioTracks(!0),n.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(n.featuresNativeVideoTracks||n.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(Tn,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],i=>{const a=Tn.fullscreenElement||Tn.webkitFullscreenElement||Tn.mozFullScreenElement||Tn.msFullscreenElement;a&&a.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=Qi(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const r=WB();r&&r.bandwidth&&(this.options_.bandwidth=r.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),r&&r.throughput&&(this.options_.throughput=r.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Us.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Us.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(r=>{typeof this.source_[r]<"u"&&(this.options_[r]=this.source_[r])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const n=this.options_.customPixelRatio;typeof n=="number"&&n>=0&&(this.customPixelRatio=n)}setOptions(e={}){this.setOptions_(e)}src(e,n){if(!e)return;this.setOptions_(),this.options_.src=R3e(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ra,this.options_.sourceType=Ek(n),this.options_.seekTo=a=>{this.tech_.setCurrentTime(a)},this.options_.player_=this.player_,this.playlistController_=new O3e(this.options_);const r=Qi({liveRangeSafeTimeDelta:Bu},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new M3e(r),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const a=_t.players[this.tech_.options_.playerId];let s=this.playlistController_.error;typeof s=="object"&&!s.code?s.code=3:typeof s=="string"&&(s={message:s,code:3}),a.error(s)});const i=this.options_.bufferBasedABR?Ra.movingAverageBandwidthSelector(.55):Ra.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):i.bind(this),this.playlistController_.selectInitialPlaylist=Ra.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(a){this.playlistController_.selectPlaylist=a.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(a){this.playlistController_.mainSegmentLoader_.throughput.rate=a,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let a=this.playlistController_.mainSegmentLoader_.bandwidth;const s=We.navigator.connection||We.navigator.mozConnection||We.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&s){const c=s.downlink*1e3*1e3;c>=l&&a>=l?a=Math.max(a,c):a=c}return a},set(a){this.playlistController_.mainSegmentLoader_.bandwidth=a,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const a=1/(this.bandwidth||1);let s;return this.throughput>0?s=1/this.throughput:s=0,Math.floor(1/(a+s))},set(){_t.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:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>k1(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>k1(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&X3e({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{P3e(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=We.URL.createObjectURL(this.playlistController_.mediaSource),(_t.browser.IS_ANY_SAFARI||_t.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),Y3e({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(n=>{this.logger_("error while creating EME key session",n),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,n=K3e({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",r=>{this.playlistController_.updatePlaylistByKeyStatus(r.keyId,r.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!n){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=_t.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{j3e(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{GB(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":XB,"mux.js":V3e,"mpd-parser":U3e,"m3u8-parser":q3e,"aes-decrypter":$3e}}version(){return this.constructor.version()}canChangeType(){return MB.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&We.URL.revokeObjectURL&&(We.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,n){return Qge({playlist:this.playlistController_.media(),time:e,callback:n})}seekToProgramTime(e,n,r=!0,i=2){return aB({programTime:e,playlist:this.playlistController_.media(),retryCount:i,pauseAfterSeek:r,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}setupXhrHooks_(){this.xhr.onRequest=e=>{QB(this.xhr,e)},this.xhr.onResponse=e=>{JB(this.xhr,e)},this.xhr.offRequest=e=>{ZB(this.xhr,e)},this.xhr.offResponse=e=>{eV(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],n=["gapjumped","playedrangeschanged"];e.forEach(r=>{this.playlistController_.on(r,i=>{this.player_.trigger(Ea({},i))})}),n.forEach(r=>{this.playbackWatcher_.on(r,i=>{this.player_.trigger(Ea({},i))})})}}const r5={name:"videojs-http-streaming",VERSION:XB,canHandleSource(t,e={}){const n=Qi(_t.options,e);return!n.vhs.experimentalUseMMS&&!ig("avc1.4d400d,mp4a.40.2",!1)?!1:r5.canPlayType(t.type,n)},handleSource(t,e,n={}){const r=Qi(_t.options,n);return e.vhs=new tV(t,e,r),e.vhs.xhr=eB(),e.vhs.setupXhrHooks_(),e.vhs.src(t.src,t.type),e.vhs},canPlayType(t,e){const n=Ek(t);if(!n)return"";const r=r5.getOverrideNative(e);return!Ra.supportsTypeNatively(n)||r?"maybe":""},getOverrideNative(t={}){const{vhs:e={}}=t,n=!(_t.browser.IS_ANY_SAFARI||_t.browser.IS_IOS),{overrideNative:r=n}=e;return r}};ig("avc1.4d400d,mp4a.40.2",!0)&&_t.getTech("Html5").registerSourceHandler(r5,0),_t.VhsHandler=tV,_t.VhsSourceHandler=r5,_t.Vhs=Ra,_t.use||_t.registerComponent("Vhs",Ra),_t.options.vhs=_t.options.vhs||{},(!_t.getPlugin||!_t.getPlugin("reloadSourceOnError"))&&_t.registerPlugin("reloadSourceOnError",B3e);const nV=t=>{const{userTrainingSaveData:e,updateUserTraining:n}=yr(),r=M.useRef(null),i=M.useRef(null),{options:a,onReady:s,currentItem:l}=t,[c,u]=M.useState(!1),d=g=>{if(e!==null){const v=e==null?void 0:e.findIndex(m=>(m==null?void 0:m.fieldId)===(l==null?void 0:l.uuid));if(v>=0){const m=g.target;e[v].seenTime=m.currentTime}}},f=g=>{const v=[...e],m=v==null?void 0:v.findIndex(A=>(A==null?void 0:A.fieldId)===(g==null?void 0:g.uuid));m>=0&&(v[m]={...e[m],isSeen:!0},n(v),h("Ended"))};M.useEffect(()=>{if(i.current){const g=i.current;g.autoplay(a.autoplay),g.src(a.sources)}else{const g=r.current;if(!g)return;const v=i.current=_t(g,a,()=>{_t.log("player is ready"),s&&s(v)})}},[a,r]);const h=g=>{const v=i.current,m=e!==null?e.findIndex(A=>(A==null?void 0:A.fieldId)===(l==null?void 0:l.uuid)):-1;m>=0&&(e[m].logs.push({action:g,videoTime:e[m].seenTime,totalTime:v.duration(),timeState:new Date}),n(e))};return M.useEffect(()=>{if(!c&&e!==null){const g=e.findIndex(v=>(v==null?void 0:v.fieldId)===(l==null?void 0:l.uuid));g>=0&&(u(!0),i.current.currentTime(e[g].seenTime))}},[e]),M.useEffect(()=>{const g=i.current;return()=>{g&&(g.dispose(),i.current=null)}},[i]),o.jsx("div",{"data-vjs-player":!0,children:o.jsx("video",{onPause:()=>{h("Pause")},onPlay:()=>{h("Play")},onEnded:()=>{f(l)},onTimeUpdate:d,ref:r,className:"video-js vjs-big-play-centered"})})},W3e=t=>{var x,E,S,I,_;const{field:e}=t,n=M.useRef(null),{userSelectedLanguage:r}=cn(),{isPreview:i,media:a}=Jt(),s=(x=a==null?void 0:a.video)!=null&&x.MediaVideo?(E=a==null?void 0:a.video)==null?void 0:E.MediaVideo:()=>o.jsx(o.Fragment,{}),l=O=>{n.current=O,O.on("waiting",()=>{_t.log("player is waiting")}),O.on("dispose",()=>{_t.log("player will dispose")})},[c,u]=M.useState(!1),[d,f]=M.useState(!1),h=()=>{f(!0)},g=()=>{f(!1)},v=O=>{u(O)},m=()=>{u(!1)},A=M.useCallback(O=>o.jsx(nV,{options:{autoplay:!1,controls:!0,responsive:!0,fluid:!0,sources:[{src:O}]},currentItem:e,onReady:l,onUpdate:()=>{}}),[e==null?void 0:e.media_file_id]),w=M.useCallback(O=>o.jsx(s,{mediaId:O,alt:""}),[e==null?void 0:e.media_file_id]),T=o.jsxs("div",{onMouseOver:h,onMouseOut:g,children:[!i&&d&&o.jsx(Xr,{handleFieldSettingsSidebar:v,...t}),o.jsx("div",{className:i?"py-4 px-2":"field-form-builder py-4 px-2",children:o.jsx("div",{className:"field",children:o.jsx("div",{className:"grid",children:o.jsx("div",{className:"col-12",children:o.jsxs("div",{className:"mt-3",children:[o.jsxs("label",{className:"flex font-medium mb-3 text-700 text-2xl",children:[" ",(S=e==null?void 0:e.title)==null?void 0:S[r==null?void 0:r.type]," -"," ",e==null?void 0:e.videoDuration]}),(e==null?void 0:e.isExternalSource)===!0&&o.jsx(o.Fragment,{children:(e==null?void 0:e.media_url)&&A((I=e==null?void 0:e.media_url)==null?void 0:I[r==null?void 0:r.type])}),(e==null?void 0:e.isExternalSource)===!1?(e==null?void 0:e.media_file_id)!==void 0&&(e==null?void 0:e.media_file_id)!==null?o.jsx(o.Fragment,{children:w(e==null?void 0:e.media_file_id)}):o.jsx(o.Fragment,{children:(e==null?void 0:e.media_url)&&A((_=e==null?void 0:e.media_url)==null?void 0:_[r==null?void 0:r.type])}):o.jsx(o.Fragment,{})]})})})})})]});return o.jsxs(o.Fragment,{children:[o.jsx(Y1e,{visibilty:c,closeSettingFieldSidebar:m,...t}),o.jsx(Si,{...t,fieldWrap:T})]})},Q3e=t=>{const{isPreview:e}=Jt(),[n,r]=M.useState(!1),i=()=>{r(!0)},a=()=>{r(!1)},s=o.jsxs("div",{onMouseOver:i,onMouseOut:a,children:[!e&&n&&o.jsx(Xr,{handleFieldSettingsSidebar:()=>{},...t}),o.jsx("div",{className:e?"":"field-form-builder",children:o.jsx("div",{className:"grid",children:o.jsxs("div",{className:"col-12",children:[o.jsx(ra,{}),o.jsx("div",{className:"hr-divider"})]})})})]});return o.jsx(o.Fragment,{children:o.jsx(Si,{...t,fieldWrap:s})})},J3e=t=>{var K,pe,te,ee,Y,J,he,be,Ee,ye,Ae;const{isPreview:e,isAdmin:n,isRenderView:r}=Jt(),{field:i,fieldIndex:a,row:s}=t,{task_status:l,taskRegisterData:c,updateTaskRegisterData:u,updateTaskProgressValue:d,userTaskSubmitFormData:f,updateUserFormDataSubmit:h,TASK_PUBLISHED:g}=yr(),{userSelectedLanguage:v}=cn(),[m,A]=M.useState(!1),[w,T]=M.useState(""),[x,E]=M.useState(0),[S,I]=M.useState(!1),[_,O]=M.useState(!1),P=()=>{O(!0)},B=()=>{O(!1)},V=ne=>new Date(ne),z=()=>{var ne,U,re;if(s!=null&&s.rowIsRepeatable){if(s!=null&&s.repeatableFields){const G=[...s.repeatableFields],de=It.findIndex(G,function(Ie){return Ie.uuid===(i==null?void 0:i.uuid)});de>=0&&G[de].fieldData?T(G[de].fieldData):T("")}}else{const G=f;if(G!=null&&G.length){for(const de of G)if(de.fieldId===t.field.uuid&&((ne=de==null?void 0:de.postData[0])==null?void 0:ne.postValue)!==""&&((U=de==null?void 0:de.postData[0])!=null&&U.postValue)){T(V((re=de==null?void 0:de.postData[0])==null?void 0:re.postValue));break}}}I(!0)};M.useEffect(()=>{S||z();const ne=Zt.addListener("clearRepeatableFields",de=>{de===(s==null?void 0:s.uuid)&&(T(""),E(0),i.isValid=0)}),U=Zt.addListener("onSubmitUserForm",()=>{var de;(de=i==null?void 0:i.attributes)!=null&&de.required?w?i.isValid=1:i.isValid=0:i.isValid=1}),re=Zt.addListener("OnInvalidFieldCatch",de=>{i.uuid===(de==null?void 0:de.fieldId)?E(1):E(0)}),G=Zt.addListener("OnGetFieldValue",de=>{var Te;const Ie=(Te=de==null?void 0:de.repeatableColumn)==null?void 0:Te.filter(ve=>(ve==null?void 0:ve.fieldUuid)===(i==null?void 0:i.uuid));Ie!=null&&Ie.length});return()=>{U.remove(),re.remove(),ne.remove(),G.remove()}});const k=ne=>{A(ne)},j=()=>{A(!1)},le=ne=>{var G,de;T(ne.target.value);const U=f,re=It.cloneDeep(c);if(U!==null){if((G=ne==null?void 0:ne.target)!=null&&G.value){if(re[i==null?void 0:i.uuid]=(de=ne==null?void 0:ne.target)==null?void 0:de.value,(U==null?void 0:U.length)>0)for(const Ie of U)Ie.fieldId===t.field.uuid&&(Ie.postData[0]={postValue:ne.target.value})}else if(delete re[i==null?void 0:i.uuid],(U==null?void 0:U.length)>0)for(const Ie of U)Ie.fieldId===t.field.uuid&&(Ie.postData[0]={postValue:""})}if(!(s!=null&&s.rowIsRepeatable)){u(re);const Ie=Object.keys(re).length;d(Ie)}},fe=(ne,U)=>{var re;if(T(U),(f==null?void 0:f.length)>0){const G=[...f],de=It.findIndex(G,function(Te){return Te.rowId===(s==null?void 0:s.uuid)});let Ie=(re=f[de])==null?void 0:re.repeatableFields;Ie={...Ie,[ne.uuid]:U},G[de]={...G[de],repeatableFields:Ie},h(G),U!==""?ne.isValid=1:ne.isValid=0}},Z=new Date(i==null?void 0:i.minDate),W=new Date(i==null?void 0:i.maxDate),ce=o.jsxs("div",{onMouseOver:P,onMouseOut:B,children:[!r&&!e&&_&&o.jsx(Xr,{type:"",handleFieldSettingsSidebar:k,...t}),o.jsxs("div",{className:`field ${e?" ":" builder-element-wrapper "}${(i==null?void 0:i.isFluid)===!0?" card py-3 px-4 p-fluid":"card py-3 px-4"}`,children:[o.jsx("div",{className:"grid",children:o.jsxs("div",{className:"col-12 ",children:[(i==null?void 0:i.showHeaderText)&&o.jsx("h6",{children:(K=i==null?void 0:i.headerText)==null?void 0:K[v==null?void 0:v.type]}),(i==null?void 0:i.showLabel)&&o.jsxs("label",{htmlFor:a,className:"flex font-medium mb-3 text-700 text-2xl",children:[o.jsx(da,{update:function(){throw new Error("Function not implemented.")},value:{fieldId:void 0,uuid:void 0},...t}),((pe=i==null?void 0:i.attributes)==null?void 0:pe.required)&&o.jsx("span",{className:"must-required mr-1",children:"*"})," ",e?o.jsx(o.Fragment,{children:(te=i==null?void 0:i.label)==null?void 0:te[v==null?void 0:v.type]}):o.jsx(sa,{...t}),(i==null?void 0:i.showToolTip)&&o.jsx("span",{className:"ml-3",children:(i==null?void 0:i.showToolTip)&&o.jsx(Mi,{message:(ee=i==null?void 0:i.toolTip)==null?void 0:ee[v==null?void 0:v.type],position:"right"})})]}),o.jsxs("div",{className:"mt-3",children:[o.jsxs("span",{className:"p-input-icon-"+(i==null?void 0:i.iconAlignment),children:[(i==null?void 0:i.showIcon)&&o.jsx("i",{className:"pi pi-"+((J=(Y=i==null?void 0:i.icon)==null?void 0:Y.properties)==null?void 0:J.name)}),o.jsx(If,{readOnlyInput:!0,numberOfMonths:i==null?void 0:i.noOfMonths,selectionMode:(i==null?void 0:i.dateRange)||"single",view:(i==null?void 0:i.calenderView)||!1,showButtonBar:(i==null?void 0:i.isTodayBtn)||!1,showIcon:(i==null?void 0:i.isIcon)||!1,id:i==null?void 0:i.uuid,dateFormat:i==null?void 0:i.dateFormat,placeholder:(he=i==null?void 0:i.placeholder)==null?void 0:he[v==null?void 0:v.type],value:w,onFocus:()=>E(1),onChange:ne=>{s!=null&&s.rowIsRepeatable?fe(i,ne.target.value):le(ne)},minDate:Z,maxDate:W,className:x===1&&((be=i==null?void 0:i.attributes)!=null&&be.required)?w?"valid":"invalid":"valid'",disabled:l===g})]}),o.jsx("div",{children:((Ee=i==null?void 0:i.attributes)==null?void 0:Ee.required)&&o.jsx("small",{className:"error",children:x===1&&!w?(ye=i==null?void 0:i.validationMesssage)==null?void 0:ye.english:""})}),o.jsx("div",{children:(i==null?void 0:i.showHelperText)&&o.jsx("small",{children:(Ae=i==null?void 0:i.helperText)==null?void 0:Ae[v==null?void 0:v.type]})})]})]})}),n&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{}),o.jsx(Ni,{...t})]})]})]});return o.jsxs(o.Fragment,{children:[m===!0&&o.jsx(Wi,{visibilty:m,closeSettingFieldSidebar:j,...t},i==null?void 0:i.uuid),o.jsx(Si,{...t,fieldWrap:ce})]})},Z3e=t=>{var he,be,Ee,ye,Ae,ne,U,re;const e=M.useRef(null),{task_status:n,taskRegisterData:r,updateTaskRegisterData:i,updateTaskProgressValue:a,updateUserFormDataSubmit:s,userTaskSubmitFormData:l,onSetValuetoPostDataHook:c,TASK_PUBLISHED:u}=yr(),{userSelectedLanguage:d,fieldSettingUpdate:f}=cn(),{field:h,fieldIndex:g,columnIndex:v,sectionIndex:m,rowIndex:A,pageIndex:w,row:T}=t,{isAdmin:x,isPreview:E,isRenderView:S}=Jt(),[I,_]=M.useState(!1),[O,P]=M.useState(0),[B,V]=M.useState(!1),[z,k]=M.useState(null),[j,le]=M.useState(!1),fe=()=>{le(!0)},Z=()=>{le(!1)},W=()=>{var de,Ie,Te;(de=e==null?void 0:e.current)==null||de.clear(),h.isValid=0,f(w,m,A,v,g,h),k(null);const G=l;if(l!=null&&l.length){const ve=It.cloneDeep(r);if(ve[h==null?void 0:h.uuid]=(Ie=e.current)==null?void 0:Ie.toDataURL(),(G==null?void 0:G.length)>0){for(const me of G)if(me.fieldId===t.field.uuid){me.postData[0]={postValue:null},k(null);break}}if(!(T!=null&&T.rowIsRepeatable)){i(ve);const me=(Te=Object.keys(ve))==null?void 0:Te.length;a(me)}}},ce=()=>{var de,Ie,Te;const G=l;if((G==null?void 0:G.length)>0)for(const ve of G)ve.fieldId===t.field.uuid&&((de=ve==null?void 0:ve.postData[0])!=null&&de.postValue&&((Ie=ve==null?void 0:ve.postData[0])==null?void 0:Ie.postValue)!==""&&(k((Te=ve==null?void 0:ve.postData[0])==null?void 0:Te.postValue),V(!0)),h.isValid=1);V(!0)},K=()=>{var G,de,Ie,Te;if(l!=null&&l.length){const ve=[...l],me=It.findIndex(ve,function(De){return De.rowId===(T==null?void 0:T.uuid)});let Se=(G=l[me])==null?void 0:G.repeatableFields;Se={...Se,[h==null?void 0:h.uuid]:`<img src="${(de=e.current)==null?void 0:de.toDataURL()}" >`},ve[me]={...ve[me],repeatableFields:Se},s(ve)}k(((Ie=e.current)==null?void 0:Ie.toDataURL())||""),((Te=e.current)==null?void 0:Te.toDataURL())!==""?h.isValid=1:h.isValid=0};M.useEffect(()=>{B||ce();const G=Zt.addListener("clearRepeatableFields",ve=>{ve===(T==null?void 0:T.uuid)&&(k(null),W(),P(0),h.isValid=0,f(w,m,A,v,g,h))}),de=Zt.addListener("onSubmitUserForm",()=>{var ve;(ve=h==null?void 0:h.attributes)!=null&&ve.required?(z!==null?h.isValid=1:h.isValid=0,f(w,m,A,v,g,h)):h.isValid=1}),Ie=Zt.addListener("OnInvalidFieldCatch",ve=>{h.uuid===(ve==null?void 0:ve.fieldId)?P(1):P(0)}),Te=Zt.addListener("OnSignatureSettingChange",()=>{W()});return()=>{de.remove(),Ie.remove(),Te.remove(),G.remove()}});const pe=G=>{_(G)},te=()=>{_(!1)},ee=()=>{var de,Ie,Te,ve;const G=l;if(l!=null&&l.length){const me=It.cloneDeep(r);if(me[h==null?void 0:h.uuid]=(de=e.current)==null?void 0:de.toDataURL(),(G==null?void 0:G.length)>0){for(const Se of G)if(Se.fieldId===t.field.uuid){Se.postData[0]={postValue:(Ie=e.current)==null?void 0:Ie.toDataURL()},k(((Te=e.current)==null?void 0:Te.toDataURL())||null);break}}if(!(T!=null&&T.rowIsRepeatable)){i(me);const Se=(ve=Object.keys(me))==null?void 0:ve.length;a(Se)}}},Y=()=>{var G,de,Ie;return`rgba(${(G=h==null?void 0:h.backgroundColor)==null?void 0:G.r}, ${(de=h==null?void 0:h.backgroundColor)==null?void 0:de.g}, ${(Ie=h==null?void 0:h.backgroundColor)==null?void 0:Ie.b}, 0.8)`},J=o.jsxs("div",{onMouseOver:fe,onMouseOut:Z,children:[!S&&!E&&j&&o.jsx(Xr,{handleFieldSettingsSidebar:pe,...t}),o.jsx("div",{className:`field ${E?" ":" builder-element-wrapper "}${(h==null?void 0:h.isFluid)===!0?" card py-3 px-4 p-fluid":"card py-3 px-4"}`,children:o.jsxs("div",{className:"grid",children:[o.jsxs("div",{className:E?"col-12":"col-11",children:[(h==null?void 0:h.showHeaderText)&&o.jsx("h6",{children:(he=h==null?void 0:h.headerText)==null?void 0:he[d==null?void 0:d.type]}),(h==null?void 0:h.showLabel)&&o.jsxs("label",{htmlFor:h.uuid,className:"flex font-medium mb-3 text-700 text-2xl",children:[o.jsx(da,{...t}),((be=h==null?void 0:h.attributes)==null?void 0:be.required)&&o.jsx("span",{className:"must-required mr-1",children:"*"})," ",E?o.jsx(o.Fragment,{children:(Ee=h==null?void 0:h.label)==null?void 0:Ee[d==null?void 0:d.type]}):o.jsx(sa,{...t}),o.jsx("span",{className:"ml-3",children:(h==null?void 0:h.showToolTip)&&o.jsx(Mi,{message:(ye=h==null?void 0:h.toolTip)==null?void 0:ye[d==null?void 0:d.type],position:"right"})})]}),o.jsxs("div",{className:"mt-3",children:[n!==u&&z===null&&!x&&o.jsx(FE,{backgroundColor:Y(),penColor:`#${h==null?void 0:h.penColor}`,canvasProps:{width:`${h==null?void 0:h.canvasWidth}`,height:h==null?void 0:h.canvasHeight,className:"sigCanvas"},ref:e,onEnd:()=>{T!=null&&T.rowIsRepeatable?K():ee()}},h==null?void 0:h.uuid),n===u&&z==null&&o.jsx("p",{children:"Not signed"}),n===u&&z!==null&&o.jsx("img",{alt:"",src:z,style:{width:350,height:200}}),n!==u&&z!==null&&o.jsx("img",{alt:"",src:z,style:{width:350,height:200}}),o.jsx("div",{children:((Ae=h==null?void 0:h.attributes)==null?void 0:Ae.required)&&o.jsx("small",{className:"error",children:O===1&&!z?(ne=h==null?void 0:h.validationMesssage)==null?void 0:ne.english:""})}),o.jsx("div",{className:"mt-3",children:(h==null?void 0:h.showHelperText)&&o.jsx("small",{children:(U=h==null?void 0:h.helperText)==null?void 0:U[d==null?void 0:d.type]})}),n===L3&&o.jsx(o.Fragment,{children:x===!1&&o.jsx(Ft,{text:!0,label:(re=h==null?void 0:h.clearSignatureButtonLabel)==null?void 0:re[d==null?void 0:d.type],onClick:()=>W(),className:"p-button-raised p-button-text mt-3"})})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{}),o.jsx(Ni,{...t})]})]})})]});return o.jsxs(o.Fragment,{children:[I===!0&&o.jsx(Wi,{visibilty:I,closeSettingFieldSidebar:te,...t}),o.jsx(Si,{...t,fieldWrap:J})]})};function L1(){return L1=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},L1.apply(null,arguments)}function Lg(t){"@babel/helpers - typeof";return Lg=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lg(t)}function e4e(t,e){if(Lg(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Lg(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function t4e(t){var e=e4e(t,"string");return Lg(e)=="symbol"?e:e+""}function dw(t,e,n){return(e=t4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n4e(t){if(Array.isArray(t))return t}function r4e(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,a,s,l=[],c=!0,u=!1;try{if(a=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(l.push(r.value),l.length!==e);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return l}}function fw(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function rV(t,e){if(t){if(typeof t=="string")return fw(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fw(t,e):void 0}}function i4e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3867
+ `,l++,s=h}),this.end_=s,this.storage_=i,this.diagnostics_=a}calculateBaseTime_(e,n,r){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const i=Math.min(...this.storage_.keys());if(e<i){const a=i-e;let s=this.storage_.get(i).segmentSyncInfo.start;for(let l=0;l<a;l++){const c=n[l];s-=c.duration}return s}return r}isReliablePlaylist_(e,n){return e!=null&&Array.isArray(n)&&n.length}}class qB extends UB{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,n,r){if(!this.storage_.size){const i=this.parent_.getSyncInfoForMediaSequence(e);return i?i.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,n,r)}}const u3e=86400,cw=[{name:"VOD",run:(t,e,n,r,i)=>n!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(t,e,n,r,i,a)=>{const s=t.getMediaSequenceSync(a);if(!s||!s.isReliable)return null;const l=s.getSyncInfoForTime(i);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(t,e,n,r,i)=>{if(!Object.keys(t.timelineToDatetimeMappings).length)return null;let a=null,s=null;const l=KA(e);i=i||0;for(let c=0;c<l.length;c++){const u=e.endList||i===0?c:l.length-(c+1),d=l[u],f=d.segment,h=t.timelineToDatetimeMappings[f.timeline];if(!h||!f.dateTimeObject)continue;let v=f.dateTimeObject.getTime()/1e3+h;if(f.parts&&typeof d.partIndex=="number")for(let A=0;A<d.partIndex;A++)v+=f.parts[A].duration;const m=Math.abs(i-v);if(s!==null&&(m===0||s<m))break;s=m,a={time:v,segmentIndex:d.segmentIndex,partIndex:d.partIndex}}return a}},{name:"Segment",run:(t,e,n,r,i)=>{let a=null,s=null;i=i||0;const l=KA(e);for(let c=0;c<l.length;c++){const u=e.endList||i===0?c:l.length-(c+1),d=l[u],f=d.segment,h=d.part&&d.part.start||f&&f.start;if(f.timeline===r&&typeof h<"u"){const g=Math.abs(i-h);if(s!==null&&s<g)break;(!a||s===null||s>=g)&&(s=g,a={time:h,segmentIndex:d.segmentIndex,partIndex:d.partIndex})}}return a}},{name:"Discontinuity",run:(t,e,n,r,i)=>{let a=null;if(i=i||0,e.discontinuityStarts&&e.discontinuityStarts.length){let s=null;for(let l=0;l<e.discontinuityStarts.length;l++){const c=e.discontinuityStarts[l],u=e.discontinuitySequence+l+1,d=t.discontinuities[u];if(d){const f=Math.abs(i-d.time);if(s!==null&&s<f)break;(!a||s===null||s>=f)&&(s=f,a={time:d.time,segmentIndex:c,partIndex:null})}}}return a}},{name:"Playlist",run:(t,e,n,r,i)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class d3e extends _t.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const n=new UB,r=new qB(n),i=new qB(n);this.mediaSequenceStorage_={main:n,audio:r,vtt:i},this.logger_=pc("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,n,r,i,a){if(n!==1/0)return cw.find(({name:c})=>c==="VOD").run(this,e,n);const s=this.runStrategies_(e,n,r,i,a);if(!s.length)return null;for(const l of s){const{syncPoint:c,strategy:u}=l,{segmentIndex:d,time:f}=c;if(d<0)continue;const h=e.segments[d],g=f,v=g+h.duration;if(this.logger_(`Strategy: ${u}. Current time: ${i}. selected segment: ${d}. Time: [${g} -> ${v}]}`),i>=g&&i<v)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(s,{key:"time",value:i})}getExpiredTime(e,n){if(!e||!e.segments)return null;const r=this.runStrategies_(e,n,e.discontinuitySequence,0);if(!r.length)return null;const i=this.selectSyncPoint_(r,{key:"segmentIndex",value:0});return i.segmentIndex>0&&(i.time*=-1),Math.abs(i.time+Og({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:i.segmentIndex,endIndex:0}))}runStrategies_(e,n,r,i,a){const s=[];for(let l=0;l<cw.length;l++){const c=cw[l],u=c.run(this,e,n,r,i,a);u&&(u.strategy=c.name,s.push({strategy:c.name,syncPoint:u}))}return s}selectSyncPoint_(e,n){let r=e[0].syncPoint,i=Math.abs(e[0].syncPoint[n.key]-n.value),a=e[0].strategy;for(let s=1;s<e.length;s++){const l=Math.abs(e[s].syncPoint[n.key]-n.value);l<i&&(i=l,r=e[s].syncPoint,a=e[s].strategy)}return this.logger_(`syncPoint for [${n.key}: ${n.value}] chosen with strategy [${a}]: [time:${r.time}, segmentIndex:${r.segmentIndex}`+(typeof r.partIndex=="number"?`,partIndex:${r.partIndex}`:"")+"]"),r}saveExpiredSegmentInfo(e,n){const r=n.mediaSequence-e.mediaSequence;if(r>u3e){_t.log.warn(`Not saving expired segment info. Media sequence gap ${r} is too large.`);return}for(let i=r-1;i>=0;i--){const a=e.segments[i];if(a&&typeof a.start<"u"){n.syncInfo={mediaSequence:e.mediaSequence+i,time:a.start},this.logger_(`playlist refresh sync: [time:${n.syncInfo.time}, mediaSequence: ${n.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const n=e.segments[0],r=n.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[n.timeline]=-r}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:n}){const r=this.calculateSegmentTimeMapping_(e,e.timingInfo,n),i=e.segment;r&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:i.start}));const a=i.dateTimeObject;i.discontinuity&&n&&a&&(this.timelineToDatetimeMappings[i.timeline]=-(a.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,n,r){const i=e.segment,a=e.part;let s=this.timelines[e.timeline],l,c;if(typeof e.timestampOffset=="number")s={time:e.startOfSegment,mapping:e.startOfSegment-n.start},r&&(this.timelines[e.timeline]=s,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${s.time}] [mapping: ${s.mapping}]`)),l=e.startOfSegment,c=n.end+s.mapping;else if(s)l=n.start+s.mapping,c=n.end+s.mapping;else return!1;return a&&(a.start=l,a.end=c),(!i.start||l<i.start)&&(i.start=l),i.end=c,!0}saveDiscontinuitySyncInfo_(e){const n=e.playlist,r=e.segment;if(r.discontinuity)this.discontinuities[r.timeline]={time:r.start,accuracy:0};else if(n.discontinuityStarts&&n.discontinuityStarts.length)for(let i=0;i<n.discontinuityStarts.length;i++){const a=n.discontinuityStarts[i],s=n.discontinuitySequence+i+1,l=a-e.mediaIndex,c=Math.abs(l);if(!this.discontinuities[s]||this.discontinuities[s].accuracy>c){let u;l<0?u=r.start-Og({defaultDuration:n.targetDuration,durationList:n.segments,startIndex:e.mediaIndex,endIndex:a}):u=r.end+Og({defaultDuration:n.targetDuration,durationList:n.segments,startIndex:e.mediaIndex+1,endIndex:a}),this.discontinuities[s]={time:u,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class f3e extends _t.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:n,to:r}){return typeof n=="number"&&typeof r=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:n,to:r},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:n,to:r}){if(typeof n=="number"&&typeof r=="number"){this.lastTimelineChanges_[e]={type:e,from:n,to:r},delete this.pendingTimelineChanges_[e];const i={timelineChangeInfo:{from:n,to:r}};this.trigger({type:"timelinechange",metadata:i})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const h3e=uB(dB(function(){var t=function(){function m(){this.listeners={}}var A=m.prototype;return A.on=function(T,x){this.listeners[T]||(this.listeners[T]=[]),this.listeners[T].push(x)},A.off=function(T,x){if(!this.listeners[T])return!1;var E=this.listeners[T].indexOf(x);return this.listeners[T]=this.listeners[T].slice(0),this.listeners[T].splice(E,1),E>-1},A.trigger=function(T){var x=this.listeners[T];if(x)if(arguments.length===2)for(var E=x.length,S=0;S<E;++S)x[S].call(this,arguments[1]);else for(var I=Array.prototype.slice.call(arguments,1),_=x.length,O=0;O<_;++O)x[O].apply(this,I)},A.dispose=function(){this.listeners={}},A.pipe=function(T){this.on("data",function(x){T.push(x)})},m}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(m){return m.subarray(0,m.byteLength-m[m.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const n=function(){const m=[[[],[],[],[],[]],[[],[],[],[],[]]],A=m[0],w=m[1],T=A[4],x=w[4];let E,S,I;const _=[],O=[];let P,B,V,z,k,j;for(E=0;E<256;E++)O[(_[E]=E<<1^(E>>7)*283)^E]=E;for(S=I=0;!T[S];S^=P||1,I=O[I]||1)for(z=I^I<<1^I<<2^I<<3^I<<4,z=z>>8^z&255^99,T[S]=z,x[z]=S,V=_[B=_[P=_[S]]],j=V*16843009^B*65537^P*257^S*16843008,k=_[z]*257^z*16843008,E=0;E<4;E++)A[E][S]=k=k<<24^k>>>8,w[E][z]=j=j<<24^j>>>8;for(E=0;E<5;E++)A[E]=A[E].slice(0),w[E]=w[E].slice(0);return m};let r=null;class i{constructor(A){r||(r=n()),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let w,T,x;const E=this._tables[0][4],S=this._tables[1],I=A.length;let _=1;if(I!==4&&I!==6&&I!==8)throw new Error("Invalid aes key size");const O=A.slice(0),P=[];for(this._key=[O,P],w=I;w<4*I+28;w++)x=O[w-1],(w%I===0||I===8&&w%I===4)&&(x=E[x>>>24]<<24^E[x>>16&255]<<16^E[x>>8&255]<<8^E[x&255],w%I===0&&(x=x<<8^x>>>24^_<<24,_=_<<1^(_>>7)*283)),O[w]=O[w-I]^x;for(T=0;w;T++,w--)x=O[T&3?w:w-4],w<=4||T<4?P[T]=x:P[T]=S[0][E[x>>>24]]^S[1][E[x>>16&255]]^S[2][E[x>>8&255]]^S[3][E[x&255]]}decrypt(A,w,T,x,E,S){const I=this._key[1];let _=A^I[0],O=x^I[1],P=T^I[2],B=w^I[3],V,z,k;const j=I.length/4-2;let le,fe=4;const Z=this._tables[1],W=Z[0],ce=Z[1],K=Z[2],pe=Z[3],te=Z[4];for(le=0;le<j;le++)V=W[_>>>24]^ce[O>>16&255]^K[P>>8&255]^pe[B&255]^I[fe],z=W[O>>>24]^ce[P>>16&255]^K[B>>8&255]^pe[_&255]^I[fe+1],k=W[P>>>24]^ce[B>>16&255]^K[_>>8&255]^pe[O&255]^I[fe+2],B=W[B>>>24]^ce[_>>16&255]^K[O>>8&255]^pe[P&255]^I[fe+3],fe+=4,_=V,O=z,P=k;for(le=0;le<4;le++)E[(3&-le)+S]=te[_>>>24]<<24^te[O>>16&255]<<16^te[P>>8&255]<<8^te[B&255]^I[fe++],V=_,_=O,O=P,P=B,B=V}}class a extends t{constructor(){super(t),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(A){this.jobs.push(A),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const s=function(m){return m<<24|(m&65280)<<8|(m&16711680)>>8|m>>>24},l=function(m,A,w){const T=new Int32Array(m.buffer,m.byteOffset,m.byteLength>>2),x=new i(Array.prototype.slice.call(A)),E=new Uint8Array(m.byteLength),S=new Int32Array(E.buffer);let I,_,O,P,B,V,z,k,j;for(I=w[0],_=w[1],O=w[2],P=w[3],j=0;j<T.length;j+=4)B=s(T[j]),V=s(T[j+1]),z=s(T[j+2]),k=s(T[j+3]),x.decrypt(B,V,z,k,S,j),S[j]=s(S[j]^I),S[j+1]=s(S[j+1]^_),S[j+2]=s(S[j+2]^O),S[j+3]=s(S[j+3]^P),I=B,_=V,O=z,P=k;return E};class c{constructor(A,w,T,x){const E=c.STEP,S=new Int32Array(A.buffer),I=new Uint8Array(A.byteLength);let _=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(S.subarray(_,_+E),w,T,I)),_=E;_<S.length;_+=E)T=new Uint32Array([s(S[_-4]),s(S[_-3]),s(S[_-2]),s(S[_-1])]),this.asyncStream_.push(this.decryptChunk_(S.subarray(_,_+E),w,T,I));this.asyncStream_.push(function(){x(null,e(I))})}static get STEP(){return 32e3}decryptChunk_(A,w,T,x){return function(){const E=l(A,w,T);x.set(E,A.byteOffset)}}}var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d;typeof window<"u"?d=window:typeof u<"u"?d=u:typeof self<"u"?d=self:d={};var f=d,h=function(A){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(A):A&&A.buffer instanceof ArrayBuffer},g=f.BigInt||Number;g("0x1"),g("0x100"),g("0x10000"),g("0x1000000"),g("0x100000000"),g("0x10000000000"),g("0x1000000000000"),g("0x100000000000000"),g("0x10000000000000000"),function(){var m=new Uint16Array([65484]),A=new Uint8Array(m.buffer,m.byteOffset,m.byteLength);return A[0]===255?"big":A[0]===204?"little":"unknown"}();const v=function(m){const A={};return Object.keys(m).forEach(w=>{const T=m[w];h(T)?A[w]={bytes:T.buffer,byteOffset:T.byteOffset,byteLength:T.byteLength}:A[w]=T}),A};self.onmessage=function(m){const A=m.data,w=new Uint8Array(A.encrypted.bytes,A.encrypted.byteOffset,A.encrypted.byteLength),T=new Uint32Array(A.key.bytes,A.key.byteOffset,A.key.byteLength/4),x=new Uint32Array(A.iv.bytes,A.iv.byteOffset,A.iv.byteLength/4);new c(w,T,x,function(E,S){self.postMessage(v({source:A.source,decrypted:S}),[S.buffer])})}}));var p3e=cB(h3e);const g3e=t=>{let e=t.default?"main":"alternative";return t.characteristics&&t.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},$B=(t,e)=>{t.abort(),t.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},uw=(t,e)=>{e.activePlaylistLoader=t,t.load()},m3e=(t,e)=>()=>{const{segmentLoaders:{[t]:n,main:r},mediaTypes:{[t]:i}}=e,a=i.activeTrack(),s=i.getActiveGroup(),l=i.activePlaylistLoader,c=i.lastGroup_;if(!(s&&c&&s.id===c.id)&&(i.lastGroup_=s,i.lastTrack_=a,$B(n,i),!(!s||s.isMainPlaylist))){if(!s.playlistLoader){l&&r.resetEverything();return}n.resyncLoader(),uw(s.playlistLoader,i)}},v3e=(t,e)=>()=>{const{segmentLoaders:{[t]:n},mediaTypes:{[t]:r}}=e;r.lastGroup_=null,n.abort(),n.pause()},b3e=(t,e)=>()=>{const{mainPlaylistLoader:n,segmentLoaders:{[t]:r,main:i},mediaTypes:{[t]:a}}=e,s=a.activeTrack(),l=a.getActiveGroup(),c=a.activePlaylistLoader,u=a.lastTrack_;if(!(u&&s&&u.id===s.id)&&(a.lastGroup_=l,a.lastTrack_=s,$B(r,a),!!l)){if(l.isMainPlaylist){if(!s||!u||s.id===u.id)return;const d=e.vhs.playlistController_,f=d.selectPlaylist();if(d.media()===f)return;a.logger_(`track change. Switching main audio from ${u.id} to ${s.id}`),n.pause(),i.resetEverything(),d.fastQualityChange_(f);return}if(t==="AUDIO"){if(!l.playlistLoader){i.setAudio(!0),i.resetEverything();return}r.setAudio(!0),i.setAudio(!1)}if(c===l.playlistLoader){uw(l.playlistLoader,a);return}r.track&&r.track(s),r.resetEverything(),uw(l.playlistLoader,a)}},n5={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:n},excludePlaylist:r}=e,i=n.activeTrack(),a=n.activeGroup(),s=(a.filter(c=>c.default)[0]||a[0]).id,l=n.tracks[s];if(i===l){r({error:{message:"Problem encountered loading the default audio track."}});return}_t.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in n.tracks)n.tracks[c].enabled=n.tracks[c]===l;n.onTrackChanged()},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:n}}=e;_t.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const r=n.activeTrack();r&&(r.mode="disabled"),n.onTrackChanged()}},jB={AUDIO:(t,e,n)=>{if(!e)return;const{tech:r,requestOptions:i,segmentLoaders:{[t]:a}}=n;e.on("loadedmetadata",()=>{const s=e.media();a.playlist(s,i),(!r.paused()||s.endList&&r.preload()!=="none")&&a.load()}),e.on("loadedplaylist",()=>{a.playlist(e.media(),i),r.paused()||a.load()}),e.on("error",n5[t](t,n))},SUBTITLES:(t,e,n)=>{const{tech:r,requestOptions:i,segmentLoaders:{[t]:a},mediaTypes:{[t]:s}}=n;e.on("loadedmetadata",()=>{const l=e.media();a.playlist(l,i),a.track(s.activeTrack()),(!r.paused()||l.endList&&r.preload()!=="none")&&a.load()}),e.on("loadedplaylist",()=>{a.playlist(e.media(),i),r.paused()||a.load()}),e.on("error",n5[t](t,n))}},y3e={AUDIO:(t,e)=>{const{vhs:n,sourceType:r,segmentLoaders:{[t]:i},requestOptions:a,main:{mediaGroups:s},mediaTypes:{[t]:{groups:l,tracks:c,logger_:u}},mainPlaylistLoader:d}=e,f=Fg(d.main);(!s[t]||Object.keys(s[t]).length===0)&&(s[t]={main:{default:{default:!0}}},f&&(s[t].main.default.playlists=d.main.playlists));for(const h in s[t]){l[h]||(l[h]=[]);for(const g in s[t][h]){let v=s[t][h][g],m;if(f?(u(`AUDIO group '${h}' label '${g}' is a main playlist`),v.isMainPlaylist=!0,m=null):r==="vhs-json"&&v.playlists?m=new Bh(v.playlists[0],n,a):v.resolvedUri?m=new Bh(v.resolvedUri,n,a):v.playlists&&r==="dash"?m=new tw(v.playlists[0],n,a,d):m=null,v=Qi({id:g,playlistLoader:m},v),jB[t](t,v.playlistLoader,e),l[h].push(v),typeof c[g]>"u"){const A=new _t.AudioTrack({id:g,kind:g3e(v),enabled:!1,language:v.language,default:v.default,label:g});c[g]=A}}}i.on("error",n5[t](t,e))},SUBTITLES:(t,e)=>{const{tech:n,vhs:r,sourceType:i,segmentLoaders:{[t]:a},requestOptions:s,main:{mediaGroups:l},mediaTypes:{[t]:{groups:c,tracks:u}},mainPlaylistLoader:d}=e;for(const f in l[t]){c[f]||(c[f]=[]);for(const h in l[t][f]){if(!r.options_.useForcedSubtitles&&l[t][f][h].forced)continue;let g=l[t][f][h],v;if(i==="hls")v=new Bh(g.resolvedUri,r,s);else if(i==="dash"){if(!g.playlists.filter(A=>A.excludeUntil!==1/0).length)return;v=new tw(g.playlists[0],r,s,d)}else i==="vhs-json"&&(v=new Bh(g.playlists?g.playlists[0]:g.resolvedUri,r,s));if(g=Qi({id:h,playlistLoader:v},g),jB[t](t,g.playlistLoader,e),c[f].push(g),typeof u[h]>"u"){const m=n.addRemoteTextTrack({id:h,kind:"subtitles",default:g.default&&g.autoselect,language:g.language,label:h},!1).track;u[h]=m}}}a.on("error",n5[t](t,e))},"CLOSED-CAPTIONS":(t,e)=>{const{tech:n,main:{mediaGroups:r},mediaTypes:{[t]:{groups:i,tracks:a}}}=e;for(const s in r[t]){i[s]||(i[s]=[]);for(const l in r[t][s]){const c=r[t][s][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const u=n.options_.vhs&&n.options_.vhs.captionServices||{};let d={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(u[d.instreamId]&&(d=Qi(d,u[d.instreamId])),d.default===void 0&&delete d.default,i[s].push(Qi({id:l},c)),typeof a[l]>"u"){const f=n.addRemoteTextTrack({id:d.instreamId,kind:"captions",default:d.default,language:d.language,label:d.label},!1).track;a[l]=f}}}}},zB=(t,e)=>{for(let n=0;n<t.length;n++)if(GA(e,t[n])||t[n].playlists&&zB(t[n].playlists,e))return!0;return!1},A3e=(t,e)=>n=>{const{mainPlaylistLoader:r,mediaTypes:{[t]:{groups:i}}}=e,a=r.media();if(!a)return null;let s=null;a.attributes[t]&&(s=i[a.attributes[t]]);const l=Object.keys(i);if(!s)if(t==="AUDIO"&&l.length>1&&Fg(e.main))for(let c=0;c<l.length;c++){const u=i[l[c]];if(zB(u,a)){s=u;break}}else i.main?s=i.main:l.length===1&&(s=i[l[0]]);return typeof n>"u"?s:n===null||!s?null:s.filter(c=>c.id===n.id)[0]||null},w3e={AUDIO:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:n}}}=e;for(const r in n)if(n[r].enabled)return n[r];return null},SUBTITLES:(t,e)=>()=>{const{mediaTypes:{[t]:{tracks:n}}}=e;for(const r in n)if(n[r].mode==="showing"||n[r].mode==="hidden")return n[r];return null}},S3e=(t,{mediaTypes:e})=>()=>{const n=e[t].activeTrack();return n?e[t].activeGroup(n):null},x3e=t=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(u=>{y3e[u](u,t)});const{mediaTypes:e,mainPlaylistLoader:n,tech:r,vhs:i,segmentLoaders:{["AUDIO"]:a,main:s}}=t;["AUDIO","SUBTITLES"].forEach(u=>{e[u].activeGroup=A3e(u,t),e[u].activeTrack=w3e[u](u,t),e[u].onGroupChanged=m3e(u,t),e[u].onGroupChanging=v3e(u,t),e[u].onTrackChanged=b3e(u,t),e[u].getActiveGroup=S3e(u,t)});const l=e.AUDIO.activeGroup();if(l){const u=(l.filter(f=>f.default)[0]||l[0]).id;e.AUDIO.tracks[u].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(s.setAudio(!1),a.setAudio(!0)):s.setAudio(!0)}n.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanged())}),n.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(u=>e[u].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),r.trigger({type:"usage",name:"vhs-audio-change"})};r.audioTracks().addEventListener("change",c),r.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),i.on("dispose",()=>{r.audioTracks().removeEventListener("change",c),r.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),r.clearTracks("audio");for(const u in e.AUDIO.tracks)r.audioTracks().addTrack(e.AUDIO.tracks[u])},C3e=()=>{const t={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{t[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Fd,activeTrack:Fd,getActiveGroup:Fd,onGroupChanged:Fd,onTrackChanged:Fd,lastTrack_:null,logger_:pc(`MediaGroups[${e}]`)}}),t};class HB{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=ll(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(n=>[n.ID,n])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class T3e extends _t.EventTarget{constructor(e,n){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new HB,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=pc("Content Steering"),this.xhr_=e,this.getBandwidth_=n}assignTagProperties(e,n){this.manifestType_=n.serverUri?"HLS":"DASH";const r=n.serverUri||n.serverURL;if(!r){this.logger_(`steering manifest URL is ${r}, cannot request steering manifest.`),this.trigger("error");return}if(r.startsWith("data:")){this.decodeDataUriManifest_(r.substring(r.indexOf(",")+1));return}this.steeringManifest.reloadUri=ll(e,r),this.defaultPathway=n.pathwayId||n.defaultServiceLocation,this.queryBeforeStart=n.queryBeforeStart,this.proxyServerUrl_=n.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const n=this.steeringManifest.reloadUri;if(!n)return;const r=e?n:this.getRequestURI(n);if(!r){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const i={contentSteeringInfo:{uri:r}};this.trigger({type:"contentsteeringloadstart",metadata:i}),this.request_=this.xhr_({uri:r,requestType:"content-steering-manifest"},(a,s)=>{if(a){if(s.status===410){this.logger_(`manifest request 410 ${a}.`),this.logger_(`There will be no more content steering requests to ${r} this session.`),this.excludedSteeringManifestURLs.add(r);return}if(s.status===429){const u=s.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${a}.`),this.logger_(`content steering will retry in ${u} seconds.`),this.startTTLTimeout_(parseInt(u,10));return}this.logger_(`manifest failed to load ${a}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:i});let l;try{l=JSON.parse(this.request_.responseText)}catch(u){const d={errorType:_t.Error.StreamingContentSteeringParserError,error:u};this.trigger({type:"error",metadata:d})}this.assignSteeringProperties_(l);const c={contentSteeringInfo:i.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const n=new We.URL(e),r=new We.URL(this.proxyServerUrl_);return r.searchParams.set("url",encodeURI(n.toString())),this.setSteeringParams_(r.toString())}decodeDataUriManifest_(e){const n=JSON.parse(We.atob(e));this.assignSteeringProperties_(n)}setSteeringParams_(e){const n=new We.URL(e),r=this.getPathway(),i=this.getBandwidth_();if(r){const a=`_${this.manifestType_}_pathway`;n.searchParams.set(a,r)}if(i){const a=`_${this.manifestType_}_throughput`;n.searchParams.set(a,i)}return n.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const r=(i=>{for(const a of i)if(this.availablePathways_.has(a))return a;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==r&&(this.currentPathway=r,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const n=i=>this.excludedSteeringManifestURLs.has(i);if(this.proxyServerUrl_){const i=this.setProxyServerUrl_(e);if(!n(i))return i}const r=this.setSteeringParams_(e);return n(r)?null:r}startTTLTimeout_(e=this.steeringManifest.ttl){const n=e*1e3;this.ttlTimeout_=We.setTimeout(()=>{this.requestSteeringManifest()},n)}clearTTLTimeout_(){We.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new HB}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,n){return!n&&this.steeringManifest.reloadUri||n&&(ll(e,n.serverURL)!==this.steeringManifest.reloadUri||n.defaultServiceLocation!==this.defaultPathway||n.queryBeforeStart!==this.queryBeforeStart||n.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const E3e=(t,e)=>{let n=null;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{t.apply(null,r)},e)}},I3e=10;let x0;const _3e=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],D3e=function(t){return this.audioSegmentLoader_[t]+this.mainSegmentLoader_[t]},N3e=function({currentPlaylist:t,buffered:e,currentTime:n,nextPlaylist:r,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:s,bufferBasedABR:l,log:c}){if(!r)return _t.log.warn("We received no playlist to switch to. Please check your stream."),!1;const u=`allowing switch ${t&&t.id||"null"} -> ${r.id}`;if(!t)return c(`${u} as current playlist is not set`),!0;if(r.id===t.id)return!1;const d=!!Ph(e,n).length;if(!t.endList)return!d&&typeof t.partTargetDuration=="number"?(c(`not ${u} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${u} as current playlist is live`),!0);const f=HA(e,n),h=l?Us.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:Us.MAX_BUFFER_LOW_WATER_LINE;if(s<h)return c(`${u} as duration < max low water line (${s} < ${h})`),!0;const g=r.attributes.BANDWIDTH,v=t.attributes.BANDWIDTH;if(g<v&&(!l||f<a)){let m=`${u} as next bandwidth < current bandwidth (${g} < ${v})`;return l&&(m+=` and forwardBuffer < bufferHighWaterLine (${f} < ${a})`),c(m),!0}if((!l||g>v)&&f>=i){let m=`${u} as forwardBuffer >= bufferLowWaterLine (${f} >= ${i})`;return l&&(m+=` and next bandwidth > current bandwidth (${g} > ${v})`),c(m),!0}return c(`not ${u} as no switching criteria met`),!1};class O3e extends _t.EventTarget{constructor(e){super(),this.fastQualityChange_=E3e(this.fastQualityChange_.bind(this),100);const{src:n,withCredentials:r,tech:i,bandwidth:a,externVhs:s,useCueTags:l,playlistExclusionDuration:c,enableLowInitialPlaylist:u,sourceType:d,cacheEncryptionKeys:f,bufferBasedABR:h,leastPixelDiffSelector:g,captionServices:v,experimentalUseMMS:m}=e;if(!n)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:A}=e;(A===null||typeof A>"u")&&(A=1/0),x0=s,this.bufferBasedABR=!!h,this.leastPixelDiffSelector=!!g,this.withCredentials=r,this.tech_=i,this.vhs_=i.vhs,this.player_=e.player_,this.sourceType_=d,this.useCueTags_=l,this.playlistExclusionDuration=c,this.maxPlaylistRetries=A,this.enableLowInitialPlaylist=u,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:r,maxPlaylistRetries:A,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=C3e(),m&&We.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new We.ManagedMediaSource,this.usingManagedMediaSource_=!0,_t.log("Using ManagedMediaSource")):We.MediaSource&&(this.mediaSource=new We.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=Vs(),this.hasPlayed_=!1,this.syncController_=new d3e(e),this.segmentMetadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new p3e,this.sourceUpdater_=new MB(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new f3e,this.keyStatusMap_=new Map;const w={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:v,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:a,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:f,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new tw(n,this.vhs_,Qi(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Bh(n,this.vhs_,Qi(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new ow(Qi(w,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new ow(Qi(w,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new s3e(Qi(w,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((E,S)=>{function I(){i.off("vttjserror",_),E()}function _(){i.off("vttjsloaded",I),S()}i.one("vttjsloaded",I),i.one("vttjserror",_),i.addWebVttScript_()})}),e);const T=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new T3e(this.vhs_.xhr,T),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),_3e.forEach(E=>{this[E+"_"]=D3e.bind(this,E)}),this.logger_=pc("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const x=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(x,()=>{const E=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-E,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),n=this.audioAppendsToLoadedData_();return e===-1||n===-1?-1:e+n}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const n=this.selectPlaylist();n&&this.shouldSwitchToMedia_(n)&&this.switchMedia_(n,e)}switchMedia_(e,n,r){const i=this.media(),a=i&&(i.id||i.uri),s=e&&(e.id||e.uri);if(a&&a!==s){this.logger_(`switch media ${a} -> ${s} from ${n}`);const l={renditionInfo:{id:s,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:n};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${n}`})}this.mainPlaylistLoader_.media(e,r)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const n=this.mediaTypes_[e],r=n?n.activeGroup():null,i=this.contentSteeringController_.getPathway();if(r&&i){const s=(r.length?r[0].playlists:r.playlists).filter(l=>l.attributes.serviceLocation===i);s.length&&this.mediaTypes_[e].activePlaylistLoader.media(s[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=We.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(We.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),n=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return n;const r=e.mediaGroups.AUDIO,i=Object.keys(r);let a;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)a=this.mediaTypes_.AUDIO.activeTrack();else{const l=r.main||i.length&&r[i[0]];for(const c in l)if(l[c].default){a={label:c};break}}if(!a)return n;const s=[];for(const l in r)if(r[l][a.label]){const c=r[l][a.label];if(c.playlists&&c.playlists.length)s.push.apply(s,c.playlists);else if(c.uri)s.push(c);else if(e.playlists.length)for(let u=0;u<e.playlists.length;u++){const d=e.playlists[u];d.attributes&&d.attributes.AUDIO&&d.attributes.AUDIO===l&&s.push(d)}}return s.length?s:n}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const n=this.mainPlaylistLoader_.media(),r=n.targetDuration*1.5*1e3;RA(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=r,n.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(n,this.requestOptions_),this.mainSegmentLoader_.load()),x3e({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),n),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let n=this.mainPlaylistLoader_.media();if(!n){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let r;if(this.enableLowInitialPlaylist&&(r=this.selectInitialPlaylist()),r||(r=this.selectPlaylist()),!r||!this.shouldSwitchToMedia_(r)||(this.initialMedia_=r,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;n=this.initialMedia_}this.handleUpdatedMediaPlaylist(n)}),this.mainPlaylistLoader_.on("error",()=>{const n=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:n.playlist,error:n})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const n=this.mainPlaylistLoader_.media(),r=n.targetDuration*1.5*1e3;RA(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=r,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(n,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const n=this.mainPlaylistLoader_.media();if(n.lastExcludeReason_==="playlist-unchanged")return;this.stuckAtPlaylistEnd_(n)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(n=>{this.mainPlaylistLoader_.on(n,r=>{this.player_.trigger(Ea({},r))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,n){const r=e.mediaGroups||{};let i=!0;const a=Object.keys(r.AUDIO);for(const s in r.AUDIO)for(const l in r.AUDIO[s])r.AUDIO[s][l].uri||(i=!1);i&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(r.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),x0.Playlist.isAes(n)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),a.length&&Object.keys(r.AUDIO[a[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const n=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,r=this.tech_.currentTime(),i=this.bufferLowWaterLine(),a=this.bufferHighWaterLine(),s=this.tech_.buffered();return N3e({buffered:s,currentTime:r,currentPlaylist:n,nextPlaylist:e,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const r=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:r.playlist,error:r})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const r=this.audioSegmentLoader_.pendingSegment_;if(!r||!r.segment||!r.segment.syncInfo)return;const i=r.segment.syncInfo.end+.01;this.tech_.setCurrentTime(i)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",r=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:I3e}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const r=this.getCodecsOrExclude_();r&&this.sourceUpdater_.addOrChangeSourceBuffers(r)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(r=>{this.mainSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))}),this.audioSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))}),this.subtitleSegmentLoader_.on(r,i=>{this.player_.trigger(Ea({},i))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const n=this.seekable();if(!n.length)return!1;const r=n.end(0);let i=r;if(e.start){const a=e.start.timeOffset;a<0?i=Math.max(r+a,n.start(0)):i=Math.min(r,a)}this.trigger("firstplay"),this.tech_.setCurrentTime(i)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,n=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const n=this.duration();e[e.length-1].endTime=isNaN(n)||Math.abs(n)===1/0?Number.MAX_VALUE:n}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const n=this.mainSegmentLoader_.getCurrentMediaInfo_();!n||n.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const r=this.syncController_.getExpiredTime(e,this.duration());if(r===null)return!1;const i=x0.Playlist.playlistEnd(e,r),a=this.tech_.currentTime(),s=this.tech_.buffered();if(!s.length)return i-a<=Bu;const l=s.end(s.length-1);return l-a<=Bu&&i-l<=Bu}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:n={},playlistExclusionDuration:r}){if(e=e||this.mainPlaylistLoader_.media(),r=r||n.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=n,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const i=this.mainPlaylistLoader_.main.playlists,a=i.filter(Wv),s=a.length===1&&a[0]===e;if(i.length===1&&r!==1/0)return _t.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(s);if(s){if(this.main().contentSteering){const v=this.pathwayAttribute_(e),m=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(v),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(v)},m);return}let g=!1;i.forEach(v=>{if(v===e)return;const m=v.excludeUntil;typeof m<"u"&&m!==1/0&&(g=!0,delete v.excludeUntil)}),g&&(_t.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+r*1e3,e.excludeUntil=l,n.reason&&(e.lastExcludeReason_=n.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const u=n.internal?this.logger_:_t.log.warn,d=n.message?" "+n.message:"";u(`${n.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${d} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const f=c.targetDuration/2*1e3||5*1e3,h=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=f;return this.switchMedia_(c,"exclude",s||h)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,n){const r=[],i=e==="all";(i||e==="main")&&r.push(this.mainPlaylistLoader_);const a=[];(i||e==="audio")&&a.push("AUDIO"),(i||e==="subtitle")&&(a.push("CLOSED-CAPTIONS"),a.push("SUBTITLES")),a.forEach(s=>{const l=this.mediaTypes_[s]&&this.mediaTypes_[s].activePlaylistLoader;l&&r.push(l)}),["main","audio","subtitle"].forEach(s=>{const l=this[`${s}SegmentLoader_`];l&&(e===s||e==="all")&&r.push(l)}),r.forEach(s=>n.forEach(l=>{typeof s[l]=="function"&&s[l]()}))}setCurrentTime(e){const n=Ph(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(n&&n.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:x0.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,n){const r=e.media();if(!r)return null;const i=this.syncController_.getMediaSequenceSync(n);if(i&&i.isReliable){const l=i.start,c=i.end;if(!isFinite(l)||!isFinite(c))return null;const u=x0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r),d=Math.max(0,c-u);return d<l?null:Vs([[l,d]])}const a=this.syncController_.getExpiredTime(r,this.duration());if(a===null)return null;const s=x0.Playlist.seekable(r,a,x0.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,r));return s.length?s:null}computeFinalSeekable_(e,n){if(!n)return e;const r=e.start(0),i=e.end(0),a=n.start(0),s=n.end(0);return a>i||r>s?e:Vs([[Math.max(r,a),Math.min(i,s)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let n;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(n=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!n))return;const r=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,n),!this.seekable_||r&&r.length&&this.seekable_.length&&r.start(0)===this.seekable_.start(0)&&r.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${PL(this.seekable_)}]`);const i={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:i}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const i=this.seekable();if(!i.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<i.end(i.length-1))&&this.sourceUpdater_.setDuration(i.end(i.length-1));return}const n=this.tech_.buffered();let r=x0.Playlist.duration(this.mainPlaylistLoader_.media());n.length>0&&(r=Math.max(r,n.end(n.length-1))),this.mediaSource.duration!==r&&this.sourceUpdater_.setDuration(r)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const n=this.mediaTypes_[e].groups;for(const r in n)n[r].forEach(i=>{i.playlistLoader&&i.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,n=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),r=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!n||!r)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},n=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const r=kg(this.main(),n),i={},a=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(i.video=r.video||e.main.videoCodec||Zfe),e.main.isMuxed&&(i.video+=`,${r.audio||e.main.audioCodec||Tk}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||a)&&(i.audio=r.audio||e.main.audioCodec||e.audio.audioCodec||Tk,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!i.audio&&!i.video){this.excludePlaylist({playlistToExclude:n,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const s=(u,d)=>u?ig(d,this.usingManagedMediaSource_):Sy(d),l={};let c;if(["video","audio"].forEach(function(u){if(i.hasOwnProperty(u)&&!s(e[u].isFmp4,i[u])){const d=e[u].isFmp4?"browser":"muxer";l[d]=l[d]||[],l[d].push(i[u]),u==="audio"&&(c=d)}}),a&&c&&n.attributes.AUDIO){const u=n.attributes.AUDIO;this.main().playlists.forEach(d=>{(d.attributes&&d.attributes.AUDIO)===u&&d!==n&&(d.excludeUntil=1/0)}),this.logger_(`excluding audio group ${u} as ${c} does not support codec(s): "${i.audio}"`)}if(Object.keys(l).length){const u=Object.keys(l).reduce((d,f)=>(d&&(d+=", "),d+=`${f} does not support codec(s): "${l[f].join(",")}"`,d),"")+".";this.excludePlaylist({playlistToExclude:n,error:{internal:!0,message:u},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const u=[];if(["video","audio"].forEach(d=>{const f=(_u(this.sourceUpdater_.codecs[d]||"")[0]||{}).type,h=(_u(i[d]||"")[0]||{}).type;f&&h&&f.toLowerCase()!==h.toLowerCase()&&u.push(`"${this.sourceUpdater_.codecs[d]}" -> "${i[d]}"`)}),u.length){this.excludePlaylist({playlistToExclude:n,error:{message:`Codec switching not supported: ${u.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return i}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const n=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(n)}excludeUnsupportedVariants_(){const e=this.main().playlists,n=[];Object.keys(e).forEach(r=>{const i=e[r];if(n.indexOf(i.id)!==-1)return;n.push(i.id);const a=kg(this.main,i),s=[];a.audio&&!Sy(a.audio)&&!ig(a.audio,this.usingManagedMediaSource_)&&s.push(`audio codec ${a.audio}`),a.video&&!Sy(a.video)&&!ig(a.video,this.usingManagedMediaSource_)&&s.push(`video codec ${a.video}`),a.text&&a.text==="stpp.ttml.im1t"&&s.push(`text codec ${a.text}`),s.length&&(i.excludeUntil=1/0,this.logger_(`excluding ${i.id} for unsupported: ${s.join(", ")}`))})}excludeIncompatibleVariants_(e){const n=[],r=this.main().playlists,i=Jv(_u(e)),a=xB(i),s=i.video&&_u(i.video)[0]||null,l=i.audio&&_u(i.audio)[0]||null;Object.keys(r).forEach(c=>{const u=r[c];if(n.indexOf(u.id)!==-1||u.excludeUntil===1/0)return;n.push(u.id);const d=[],f=kg(this.mainPlaylistLoader_.main,u),h=xB(f);if(!(!f.audio&&!f.video)){if(h!==a&&d.push(`codec count "${h}" !== "${a}"`),!this.sourceUpdater_.canChangeType()){const g=f.video&&_u(f.video)[0]||null,v=f.audio&&_u(f.audio)[0]||null;g&&s&&g.type.toLowerCase()!==s.type.toLowerCase()&&d.push(`video codec "${g.type}" !== "${s.type}"`),v&&l&&v.type.toLowerCase()!==l.type.toLowerCase()&&d.push(`audio codec "${v.type}" !== "${l.type}"`)}d.length&&(u.excludeUntil=1/0,this.logger_(`excluding ${u.id}: ${d.join(" && ")}`))}})}updateAdCues_(e){let n=0;const r=this.seekable();r.length&&(n=r.start(0)),l3e(e,this.cueTagsTrack_,n)}goalBufferLength(){const e=this.tech_.currentTime(),n=Us.GOAL_BUFFER_LENGTH,r=Us.GOAL_BUFFER_LENGTH_RATE,i=Math.max(n,Us.MAX_GOAL_BUFFER_LENGTH);return Math.min(n+e*r,i)}bufferLowWaterLine(){const e=this.tech_.currentTime(),n=Us.BUFFER_LOW_WATER_LINE,r=Us.BUFFER_LOW_WATER_LINE_RATE,i=Math.max(n,Us.MAX_BUFFER_LOW_WATER_LINE),a=Math.max(n,Us.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(n+e*r,this.bufferBasedABR?a:i)}bufferHighWaterLine(){return Us.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){_B(this.inbandTextTracks_,"com.apple.streaming",this.tech_),$me({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,n,r){const i=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();_B(this.inbandTextTracks_,e,this.tech_),Vme({inbandTextTracks:this.inbandTextTracks_,metadataArray:n,timestampOffset:i,videoDuration:r})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const n of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(n));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(n=>{this.contentSteeringController_.on(n,r=>{this.trigger(Ea({},r))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const n=this.main();(this.contentSteeringController_.didDASHTagChange(n.uri,n.contentSteering)||(()=>{const a=this.contentSteeringController_.getAvailablePathways(),s=[];for(const l of n.playlists){const c=l.attributes.serviceLocation;if(c&&(s.push(c),!a.has(c)))return!0}return!!(!s.length&&a.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const r=this.main().playlists,i=new Set;let a=!1;Object.keys(r).forEach(s=>{const l=r[s],c=this.pathwayAttribute_(l),u=c&&e!==c;l.excludeUntil===1/0&&l.lastExcludeReason_==="content-steering"&&!u&&(delete l.excludeUntil,delete l.lastExcludeReason_,a=!0);const f=!l.excludeUntil&&l.excludeUntil!==1/0;!i.has(l.id)&&u&&f&&(i.add(l.id),l.excludeUntil=1/0,l.lastExcludeReason_="content-steering",this.logger_(`excluding ${l.id} for ${l.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(s=>{const l=this.mediaTypes_[s];if(l.activePlaylistLoader){const c=l.activePlaylistLoader.media_;c&&c.attributes.serviceLocation!==e&&(a=!0)}}),a&&this.changeSegmentPathway_()}handlePathwayClones_(){const n=this.main().playlists,r=this.contentSteeringController_.currentPathwayClones,i=this.contentSteeringController_.nextPathwayClones;if(r&&r.size||i&&i.size){for(const[s,l]of r.entries())i.get(s)||(this.mainPlaylistLoader_.updateOrDeleteClone(l),this.contentSteeringController_.excludePathway(s));for(const[s,l]of i.entries()){const c=r.get(s);if(!c){n.filter(d=>d.attributes["PATHWAY-ID"]===l["BASE-ID"]).forEach(d=>{this.mainPlaylistLoader_.addClonePathway(l,d)}),this.contentSteeringController_.addAvailablePathway(s);continue}this.equalPathwayClones_(c,l)||(this.mainPlaylistLoader_.updateOrDeleteClone(l,!0),this.contentSteeringController_.addAvailablePathway(s))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...i])))}}equalPathwayClones_(e,n){if(e["BASE-ID"]!==n["BASE-ID"]||e.ID!==n.ID||e["URI-REPLACEMENT"].HOST!==n["URI-REPLACEMENT"].HOST)return!1;const r=e["URI-REPLACEMENT"].PARAMS,i=n["URI-REPLACEMENT"].PARAMS;for(const a in r)if(r[a]!==i[a])return!1;for(const a in i)if(r[a]!==i[a])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const n="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(r=>{const i=this.mainPlaylistLoader_.getKeyIdSet(r);!i||!i.size||i.forEach(a=>{const s="usable",l=this.keyStatusMap_.has(a)&&this.keyStatusMap_.get(a)===s,c=r.lastExcludeReason_===n&&r.excludeUntil===1/0;l?l&&c&&(delete r.excludeUntil,delete r.lastExcludeReason_,this.logger_(`enabling playlist ${r.id} because key ID ${a} is ${s}`)):(r.excludeUntil!==1/0&&r.lastExcludeReason_!==n&&(r.excludeUntil=1/0,r.lastExcludeReason_=n,this.logger_(`excluding playlist ${r.id} because the key ID ${a} doesn't exist in the keyStatusMap or is not ${s}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(r=>{const i=r&&r.attributes&&r.attributes.RESOLUTION&&r.attributes.RESOLUTION.height<720,a=r.excludeUntil===1/0&&r.lastExcludeReason_===n;i&&a&&(delete r.excludeUntil,_t.log.warn(`enabling non-HD playlist ${r.id} because all playlists were excluded due to ${n} key IDs`))})}addKeyStatus_(e,n){const a=(typeof e=="string"?e:i3e(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${n}' with key ID ${a} added to the keyStatusMap`),this.keyStatusMap_.set(a,n)}updatePlaylistByKeyStatus(e,n){this.addKeyStatus_(e,n),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const F3e=(t,e,n)=>r=>{const i=t.main.playlists[e],a=XA(i),s=Wv(i);if(typeof r>"u")return s;r?delete i.disabled:i.disabled=!0;const l={renditionInfo:{id:e,bandwidth:i.attributes.BANDWIDTH,resolution:i.attributes.RESOLUTION,codecs:i.attributes.CODECS},cause:"fast-quality"};return r!==s&&!a&&(r?(n(i),t.trigger({type:"renditionenabled",metadata:l})):t.trigger({type:"renditiondisabled",metadata:l})),r};class k3e{constructor(e,n,r){const{playlistController_:i}=e,a=i.fastQualityChange_.bind(i);if(n.attributes){const s=n.attributes.RESOLUTION;this.width=s&&s.width,this.height=s&&s.height,this.bandwidth=n.attributes.BANDWIDTH,this.frameRate=n.attributes["FRAME-RATE"]}this.codecs=kg(i.main(),n),this.playlist=n,this.id=r,this.enabled=F3e(e.playlists,n.id,a)}}const P3e=function(t){t.representations=()=>{const e=t.playlistController_.main(),n=Fg(e)?t.playlistController_.getAudioTrackPlaylists_():e.playlists;return n?n.filter(r=>!XA(r)).map((r,i)=>new k3e(t,r,r.id)):[]}},YB=["seeking","seeked","pause","playing","error"];class M3e extends _t.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=pc("PlaybackWatcher"),this.logger_("initialize");const n=()=>this.monitorCurrentTime_(),r=()=>this.monitorCurrentTime_(),i=()=>this.techWaiting_(),a=()=>this.resetTimeUpdate_(),s=this.playlistController_,l=["main","subtitle","audio"],c={};l.forEach(d=>{c[d]={reset:()=>this.resetSegmentDownloads_(d),updateend:()=>this.checkSegmentDownloads_(d)},s[`${d}SegmentLoader_`].on("appendsdone",c[d].updateend),s[`${d}SegmentLoader_`].on("playlistupdate",c[d].reset),this.tech_.on(["seeked","seeking"],c[d].reset)});const u=d=>{["main","audio"].forEach(f=>{s[`${f}SegmentLoader_`][d]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),u("off"))},this.clearSeekingAppendCheck_=()=>u("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),u("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",i),this.tech_.on(YB,a),this.tech_.on("canplay",r),this.tech_.one("play",n),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",i),this.tech_.off(YB,a),this.tech_.off("canplay",r),this.tech_.off("play",n),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(d=>{s[`${d}SegmentLoader_`].off("appendsdone",c[d].updateend),s[`${d}SegmentLoader_`].off("playlistupdate",c[d].reset),this.tech_.off(["seeked","seeking"],c[d].reset)}),this.checkCurrentTimeTimeout_&&We.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&We.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=We.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const n=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=n.buffered_()}checkSegmentDownloads_(e){const n=this.playlistController_,r=n[`${e}SegmentLoader_`],i=r.buffered_(),a=Sge(this[`${e}Buffered_`],i);if(this[`${e}Buffered_`]=i,a){const s={bufferedRanges:i};n.trigger({type:"bufferedrangeschanged",metadata:s}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:r.playlist_&&r.playlist_.id,buffered:k1(i)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&n.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),n=this.tech_.buffered();if(this.lastRecordedTime===e&&(!n.length||e+Bu>=n.end(n.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Vs([this.lastRecordedTime,e]));const r={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:r}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const n=this.seekable(),r=this.tech_.currentTime(),i=this.afterSeekableWindow_(n,r,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let a;if(i&&(a=n.end(n.length-1)),this.beforeSeekableWindow_(n,r)){const v=n.start(0);a=v+(v===n.end(0)?0:Bu)}if(typeof a<"u")return this.logger_(`Trying to seek outside of seekable at time ${r} with seekable range ${PL(n)}. Seeking to ${a}.`),this.tech_.setCurrentTime(a),!0;const s=this.playlistController_.sourceUpdater_,l=this.tech_.buffered(),c=s.audioBuffer?s.audioBuffered():null,u=s.videoBuffer?s.videoBuffered():null,d=this.media(),f=d.partTargetDuration?d.partTargetDuration:(d.targetDuration-Lu)*2,h=[c,u];for(let v=0;v<h.length;v++){if(!h[v])continue;if(HA(h[v],r)<f)return!1}const g=Gv(l,r);return g.length===0?!1:(a=g.start(0)+Bu,this.logger_(`Buffered region starts (${g.start(0)}) just beyond seek point (${r}). Seeking to ${a}.`),this.tech_.setCurrentTime(a),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),n=this.tech_.buffered(),r=Ph(n,e);if(r.length&&e+3<=r.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${r.start(0)} -> ${r.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),n=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,n)){const l=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${n}. Seeking to live point (seekable end) ${l}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(l),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const r=this.tech_.vhs.playlistController_.sourceUpdater_,i=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:r.audioBuffered(),videoBuffered:r.videoBuffered(),currentTime:n}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(n),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const s=Gv(i,n);return s.length>0?(this.logger_(`Stopped at ${n} and seeking to ${s.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(n),!0):!1}afterSeekableWindow_(e,n,r,i=!1){if(!e.length)return!1;let a=e.end(e.length-1)+Bu;const s=!r.endList,l=typeof r.partTargetDuration=="number";return s&&(l||i)&&(a=e.end(e.length-1)+r.targetDuration*3),n>a}beforeSeekableWindow_(e,n){return!!(e.length&&e.start(0)>0&&n<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:n,currentTime:r}){if(!e)return;let i;if(e.length&&n.length){const a=Ph(e,r-3),s=Ph(e,r),l=Ph(n,r);l.length&&!s.length&&a.length&&(i={start:a.end(0),end:l.end(0)})}else Gv(e,r).length||(i=this.gapFromVideoUnderflow_(e,r));return i?(this.logger_(`Encountered a gap in video from ${i.start} to ${i.end}. Seeking to current time ${r}`),!0):!1}skipTheGap_(e){const n=this.tech_.buffered(),r=this.tech_.currentTime(),i=Gv(n,r);if(this.resetTimeUpdate_(),i.length===0||r!==e)return;this.logger_("skipTheGap_:","currentTime:",r,"scheduled currentTime:",e,"nextRange start:",i.start(0)),this.tech_.setCurrentTime(i.start(0)+Lu);const a={gapInfo:{from:r,to:i.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:a}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,n){const r=yge(e);for(let i=0;i<r.length;i++){const a=r.start(i),s=r.end(i);if(n-a<4&&n-a>2)return{start:a,end:s}}return null}}const L3e={errorInterval:30,getSource(t){const n=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return t(n)}},KB=function(t,e){let n=0,r=0;const i=Qi(L3e,e);t.ready(()=>{t.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const a=function(){r&&t.currentTime(r)},s=function(d){d!=null&&(r=t.duration()!==1/0&&t.currentTime()||0,t.one("loadedmetadata",a),t.src(d),t.trigger({type:"usage",name:"vhs-error-reload"}),t.play())},l=function(){if(Date.now()-n<i.errorInterval*1e3){t.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!i.getSource||typeof i.getSource!="function"){_t.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return n=Date.now(),i.getSource.call(t,s)},c=function(){t.off("loadedmetadata",a),t.off("error",l),t.off("dispose",c)},u=function(d){c(),KB(t,d)};t.on("error",l),t.on("dispose",c),t.reloadSourceOnError=u},B3e=function(t){KB(this,t)};var XB="3.16.2",V3e="7.1.0",U3e="1.3.1",q3e="7.2.0",$3e="4.0.2";const Ra={PlaylistLoader:Bh,Playlist:cl,utils:Hge,STANDARD_PLAYLIST_SELECTOR:EB,INITIAL_PLAYLIST_SELECTOR:kme,lastBandwidthSelector:EB,movingAverageBandwidthSelector:Ome,comparePlaylistBandwidth:aw,comparePlaylistResolution:Nme,xhr:eB()};Object.keys(Us).forEach(t=>{Object.defineProperty(Ra,t,{get(){return _t.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),Us[t]},set(e){if(_t.log.warn(`using Vhs.${t} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){_t.log.warn(`value of Vhs.${t} must be greater than or equal to 0`);return}Us[t]=e}})});const RB="videojs-vhs",GB=function(t,e){const n=e.media();let r=-1;for(let i=0;i<t.length;i++)if(t[i].id===n.id){r=i;break}t.selectedIndex_=r,t.trigger({selectedIndex:r,type:"change"})},j3e=function(t,e){e.representations().forEach(n=>{t.addQualityLevel(n)}),GB(t,e.playlists)};Ra.canPlaySource=function(){return _t.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const z3e=(t,e,n)=>{if(!t)return t;let r={};e&&e.attributes&&e.attributes.CODECS&&(r=Jv(_u(e.attributes.CODECS))),n&&n.attributes&&n.attributes.CODECS&&(r.audio=n.attributes.CODECS);const i=rh(r.video),a=rh(r.audio),s={};for(const l in t)s[l]={},a&&(s[l].audioContentType=a),i&&(s[l].videoContentType=i),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(s[l].pssh=e.contentProtection[l].pssh),typeof t[l]=="string"&&(s[l].url=t[l]);return Qi(t,s)},H3e=(t,e)=>t.reduce((n,r)=>{if(!r.contentProtection)return n;const i=e.reduce((a,s)=>{const l=r.contentProtection[s];return l&&l.pssh&&(a[s]={pssh:l.pssh}),a},{});return Object.keys(i).length&&n.push(i),n},[]),Y3e=({player:t,sourceKeySystems:e,audioMedia:n,mainPlaylists:r})=>{if(!t.eme.initializeMediaKeys)return Promise.resolve();const i=n?r.concat([n]):r,a=H3e(i,Object.keys(e)),s=[],l=[];return a.forEach(c=>{l.push(new Promise((u,d)=>{t.tech_.one("keysessioncreated",u)})),s.push(new Promise((u,d)=>{t.eme.initializeMediaKeys({keySystems:c},f=>{if(f){d(f);return}u()})}))}),Promise.race([Promise.all(s),Promise.race(l)])},K3e=({player:t,sourceKeySystems:e,media:n,audioMedia:r})=>{const i=z3e(e,n,r);return i?(t.currentSource().keySystems=i,i&&!t.eme?(_t.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},WB=()=>{if(!We.localStorage)return null;const t=We.localStorage.getItem(RB);if(!t)return null;try{return JSON.parse(t)}catch{return null}},X3e=t=>{if(!We.localStorage)return!1;let e=WB();e=e?Qi(e,t):t;try{We.localStorage.setItem(RB,JSON.stringify(e))}catch{return!1}return e},R3e=t=>t.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(t.substring(t.indexOf(",")+1)):t,QB=(t,e)=>{t._requestCallbackSet||(t._requestCallbackSet=new Set),t._requestCallbackSet.add(e)},JB=(t,e)=>{t._responseCallbackSet||(t._responseCallbackSet=new Set),t._responseCallbackSet.add(e)},ZB=(t,e)=>{t._requestCallbackSet&&(t._requestCallbackSet.delete(e),t._requestCallbackSet.size||delete t._requestCallbackSet)},eV=(t,e)=>{t._responseCallbackSet&&(t._responseCallbackSet.delete(e),t._responseCallbackSet.size||delete t._responseCallbackSet)};Ra.supportsNativeHls=function(){if(!Tn||!Tn.createElement)return!1;const t=Tn.createElement("video");return _t.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(n){return/maybe|probably/i.test(t.canPlayType(n))}):!1}(),Ra.supportsNativeDash=function(){return!Tn||!Tn.createElement||!_t.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(Tn.createElement("video").canPlayType("application/dash+xml"))}(),Ra.supportsTypeNatively=t=>t==="hls"?Ra.supportsNativeHls:t==="dash"?Ra.supportsNativeDash:!1,Ra.isSupported=function(){return _t.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")},Ra.xhr.onRequest=function(t){QB(Ra.xhr,t)},Ra.xhr.onResponse=function(t){JB(Ra.xhr,t)},Ra.xhr.offRequest=function(t){ZB(Ra.xhr,t)},Ra.xhr.offResponse=function(t){eV(Ra.xhr,t)};const G3e=_t.getComponent("Component");class tV extends G3e{constructor(e,n,r){if(super(n,r.vhs),typeof r.initialBandwidth=="number"&&(this.options_.bandwidth=r.initialBandwidth),this.logger_=pc("VhsHandler"),n.options_&&n.options_.playerId){const i=_t.getPlayer(n.options_.playerId);this.player_=i}if(this.tech_=n,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&n.overrideNativeAudioTracks&&n.overrideNativeVideoTracks)n.overrideNativeAudioTracks(!0),n.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(n.featuresNativeVideoTracks||n.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(Tn,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],i=>{const a=Tn.fullscreenElement||Tn.webkitFullscreenElement||Tn.mozFullScreenElement||Tn.msFullscreenElement;a&&a.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=Qi(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const r=WB();r&&r.bandwidth&&(this.options_.bandwidth=r.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),r&&r.throughput&&(this.options_.throughput=r.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=Us.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===Us.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(r=>{typeof this.source_[r]<"u"&&(this.options_[r]=this.source_[r])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const n=this.options_.customPixelRatio;typeof n=="number"&&n>=0&&(this.customPixelRatio=n)}setOptions(e={}){this.setOptions_(e)}src(e,n){if(!e)return;this.setOptions_(),this.options_.src=R3e(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Ra,this.options_.sourceType=Ek(n),this.options_.seekTo=a=>{this.tech_.setCurrentTime(a)},this.options_.player_=this.player_,this.playlistController_=new O3e(this.options_);const r=Qi({liveRangeSafeTimeDelta:Bu},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new M3e(r),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const a=_t.players[this.tech_.options_.playerId];let s=this.playlistController_.error;typeof s=="object"&&!s.code?s.code=3:typeof s=="string"&&(s={message:s,code:3}),a.error(s)});const i=this.options_.bufferBasedABR?Ra.movingAverageBandwidthSelector(.55):Ra.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):i.bind(this),this.playlistController_.selectInitialPlaylist=Ra.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(a){this.playlistController_.selectPlaylist=a.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(a){this.playlistController_.mainSegmentLoader_.throughput.rate=a,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let a=this.playlistController_.mainSegmentLoader_.bandwidth;const s=We.navigator.connection||We.navigator.mozConnection||We.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&s){const c=s.downlink*1e3*1e3;c>=l&&a>=l?a=Math.max(a,c):a=c}return a},set(a){this.playlistController_.mainSegmentLoader_.bandwidth=a,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const a=1/(this.bandwidth||1);let s;return this.throughput>0?s=1/this.throughput:s=0,Math.floor(1/(a+s))},set(){_t.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:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>k1(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>k1(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&X3e({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{P3e(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=We.URL.createObjectURL(this.playlistController_.mediaSource),(_t.browser.IS_ANY_SAFARI||_t.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),Y3e({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(n=>{this.logger_("error while creating EME key session",n),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,n=K3e({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",r=>{this.playlistController_.updatePlaylistByKeyStatus(r.keyId,r.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!n){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=_t.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{j3e(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{GB(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":XB,"mux.js":V3e,"mpd-parser":U3e,"m3u8-parser":q3e,"aes-decrypter":$3e}}version(){return this.constructor.version()}canChangeType(){return MB.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&We.URL.revokeObjectURL&&(We.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,n){return Qge({playlist:this.playlistController_.media(),time:e,callback:n})}seekToProgramTime(e,n,r=!0,i=2){return aB({programTime:e,playlist:this.playlistController_.media(),retryCount:i,pauseAfterSeek:r,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:n})}setupXhrHooks_(){this.xhr.onRequest=e=>{QB(this.xhr,e)},this.xhr.onResponse=e=>{JB(this.xhr,e)},this.xhr.offRequest=e=>{ZB(this.xhr,e)},this.xhr.offResponse=e=>{eV(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],n=["gapjumped","playedrangeschanged"];e.forEach(r=>{this.playlistController_.on(r,i=>{this.player_.trigger(Ea({},i))})}),n.forEach(r=>{this.playbackWatcher_.on(r,i=>{this.player_.trigger(Ea({},i))})})}}const r5={name:"videojs-http-streaming",VERSION:XB,canHandleSource(t,e={}){const n=Qi(_t.options,e);return!n.vhs.experimentalUseMMS&&!ig("avc1.4d400d,mp4a.40.2",!1)?!1:r5.canPlayType(t.type,n)},handleSource(t,e,n={}){const r=Qi(_t.options,n);return e.vhs=new tV(t,e,r),e.vhs.xhr=eB(),e.vhs.setupXhrHooks_(),e.vhs.src(t.src,t.type),e.vhs},canPlayType(t,e){const n=Ek(t);if(!n)return"";const r=r5.getOverrideNative(e);return!Ra.supportsTypeNatively(n)||r?"maybe":""},getOverrideNative(t={}){const{vhs:e={}}=t,n=!(_t.browser.IS_ANY_SAFARI||_t.browser.IS_IOS),{overrideNative:r=n}=e;return r}};ig("avc1.4d400d,mp4a.40.2",!0)&&_t.getTech("Html5").registerSourceHandler(r5,0),_t.VhsHandler=tV,_t.VhsSourceHandler=r5,_t.Vhs=Ra,_t.use||_t.registerComponent("Vhs",Ra),_t.options.vhs=_t.options.vhs||{},(!_t.getPlugin||!_t.getPlugin("reloadSourceOnError"))&&_t.registerPlugin("reloadSourceOnError",B3e);const nV=t=>{const{userTrainingSaveData:e,updateUserTraining:n}=yr(),r=M.useRef(null),i=M.useRef(null),{options:a,onReady:s,currentItem:l}=t,[c,u]=M.useState(!1),d=g=>{if(e!==null){const v=e==null?void 0:e.findIndex(m=>(m==null?void 0:m.fieldId)===(l==null?void 0:l.uuid));if(v>=0){const m=g.target;e[v].seenTime=m.currentTime}}},f=g=>{const v=[...e],m=v==null?void 0:v.findIndex(A=>(A==null?void 0:A.fieldId)===(g==null?void 0:g.uuid));m>=0&&(v[m]={...e[m],isSeen:!0},n(v),h("Ended"))};M.useEffect(()=>{if(i.current){const g=i.current;g.autoplay(a.autoplay),g.src(a.sources)}else{const g=r.current;if(!g)return;const v=i.current=_t(g,a,()=>{_t.log("player is ready"),s&&s(v)})}},[a,r]);const h=g=>{const v=i.current,m=e!==null?e.findIndex(A=>(A==null?void 0:A.fieldId)===(l==null?void 0:l.uuid)):-1;m>=0&&e[m].logs.push({action:g,videoTime:e[m].seenTime,totalTime:v.duration(),timeState:new Date}),n(e)};return M.useEffect(()=>{if(!c&&e!==null){const g=e.findIndex(v=>(v==null?void 0:v.fieldId)===(l==null?void 0:l.uuid));g>=0&&(u(!0),i.current.currentTime(e[g].seenTime))}},[e]),M.useEffect(()=>{const g=i.current;return()=>{g&&(g.dispose(),i.current=null)}},[i]),o.jsx("div",{"data-vjs-player":!0,children:o.jsx("video",{onPause:()=>{h("Pause")},onPlay:()=>{h("Play")},onEnded:()=>{f(l)},onTimeUpdate:d,ref:r,className:"video-js vjs-big-play-centered"})})},W3e=t=>{var x,E,S,I,_;const{field:e}=t,n=M.useRef(null),{userSelectedLanguage:r}=cn(),{isPreview:i,media:a}=Jt(),s=(x=a==null?void 0:a.video)!=null&&x.MediaVideo?(E=a==null?void 0:a.video)==null?void 0:E.MediaVideo:()=>o.jsx(o.Fragment,{}),l=O=>{n.current=O,O.on("waiting",()=>{_t.log("player is waiting")}),O.on("dispose",()=>{_t.log("player will dispose")})},[c,u]=M.useState(!1),[d,f]=M.useState(!1),h=()=>{f(!0)},g=()=>{f(!1)},v=O=>{u(O)},m=()=>{u(!1)},A=M.useCallback(O=>o.jsx(nV,{options:{autoplay:!1,controls:!0,responsive:!0,fluid:!0,sources:[{src:O}]},currentItem:e,onReady:l,onUpdate:()=>{}}),[e==null?void 0:e.media_file_id]),w=M.useCallback(O=>o.jsx(s,{mediaId:O,alt:""}),[e==null?void 0:e.media_file_id]),T=o.jsxs("div",{onMouseOver:h,onMouseOut:g,children:[!i&&d&&o.jsx(Xr,{handleFieldSettingsSidebar:v,...t}),o.jsx("div",{className:i?"py-4 px-2":"field-form-builder py-4 px-2",children:o.jsx("div",{className:"field",children:o.jsx("div",{className:"grid",children:o.jsx("div",{className:"col-12",children:o.jsxs("div",{className:"mt-3",children:[o.jsxs("label",{className:"flex font-medium mb-3 text-700 text-2xl",children:[" ",(S=e==null?void 0:e.title)==null?void 0:S[r==null?void 0:r.type]," -"," ",e==null?void 0:e.videoDuration]}),(e==null?void 0:e.isExternalSource)===!0&&o.jsx(o.Fragment,{children:(e==null?void 0:e.media_url)&&A((I=e==null?void 0:e.media_url)==null?void 0:I[r==null?void 0:r.type])}),(e==null?void 0:e.isExternalSource)===!1?(e==null?void 0:e.media_file_id)!==void 0&&(e==null?void 0:e.media_file_id)!==null?o.jsx(o.Fragment,{children:w(e==null?void 0:e.media_file_id)}):o.jsx(o.Fragment,{children:(e==null?void 0:e.media_url)&&A((_=e==null?void 0:e.media_url)==null?void 0:_[r==null?void 0:r.type])}):o.jsx(o.Fragment,{})]})})})})})]});return o.jsxs(o.Fragment,{children:[o.jsx(Y1e,{visibilty:c,closeSettingFieldSidebar:m,...t}),o.jsx(Si,{...t,fieldWrap:T})]})},Q3e=t=>{const{isPreview:e}=Jt(),[n,r]=M.useState(!1),i=()=>{r(!0)},a=()=>{r(!1)},s=o.jsxs("div",{onMouseOver:i,onMouseOut:a,children:[!e&&n&&o.jsx(Xr,{handleFieldSettingsSidebar:()=>{},...t}),o.jsx("div",{className:e?"":"field-form-builder",children:o.jsx("div",{className:"grid",children:o.jsxs("div",{className:"col-12",children:[o.jsx(ra,{}),o.jsx("div",{className:"hr-divider"})]})})})]});return o.jsx(o.Fragment,{children:o.jsx(Si,{...t,fieldWrap:s})})},J3e=t=>{var K,pe,te,ee,Y,J,he,be,Ee,ye,Ae;const{isPreview:e,isAdmin:n,isRenderView:r}=Jt(),{field:i,fieldIndex:a,row:s}=t,{task_status:l,taskRegisterData:c,updateTaskRegisterData:u,updateTaskProgressValue:d,userTaskSubmitFormData:f,updateUserFormDataSubmit:h,TASK_PUBLISHED:g}=yr(),{userSelectedLanguage:v}=cn(),[m,A]=M.useState(!1),[w,T]=M.useState(""),[x,E]=M.useState(0),[S,I]=M.useState(!1),[_,O]=M.useState(!1),P=()=>{O(!0)},B=()=>{O(!1)},V=ne=>new Date(ne),z=()=>{var ne,U,re;if(s!=null&&s.rowIsRepeatable){if(s!=null&&s.repeatableFields){const G=[...s.repeatableFields],de=It.findIndex(G,function(Ie){return Ie.uuid===(i==null?void 0:i.uuid)});de>=0&&G[de].fieldData?T(G[de].fieldData):T("")}}else{const G=f;if(G!=null&&G.length){for(const de of G)if(de.fieldId===t.field.uuid&&((ne=de==null?void 0:de.postData[0])==null?void 0:ne.postValue)!==""&&((U=de==null?void 0:de.postData[0])!=null&&U.postValue)){T(V((re=de==null?void 0:de.postData[0])==null?void 0:re.postValue));break}}}I(!0)};M.useEffect(()=>{S||z();const ne=Zt.addListener("clearRepeatableFields",de=>{de===(s==null?void 0:s.uuid)&&(T(""),E(0),i.isValid=0)}),U=Zt.addListener("onSubmitUserForm",()=>{var de;(de=i==null?void 0:i.attributes)!=null&&de.required?w?i.isValid=1:i.isValid=0:i.isValid=1}),re=Zt.addListener("OnInvalidFieldCatch",de=>{i.uuid===(de==null?void 0:de.fieldId)?E(1):E(0)}),G=Zt.addListener("OnGetFieldValue",de=>{var Te;const Ie=(Te=de==null?void 0:de.repeatableColumn)==null?void 0:Te.filter(ve=>(ve==null?void 0:ve.fieldUuid)===(i==null?void 0:i.uuid));Ie!=null&&Ie.length});return()=>{U.remove(),re.remove(),ne.remove(),G.remove()}});const k=ne=>{A(ne)},j=()=>{A(!1)},le=ne=>{var G,de;T(ne.target.value);const U=f,re=It.cloneDeep(c);if(U!==null){if((G=ne==null?void 0:ne.target)!=null&&G.value){if(re[i==null?void 0:i.uuid]=(de=ne==null?void 0:ne.target)==null?void 0:de.value,(U==null?void 0:U.length)>0)for(const Ie of U)Ie.fieldId===t.field.uuid&&(Ie.postData[0]={postValue:ne.target.value})}else if(delete re[i==null?void 0:i.uuid],(U==null?void 0:U.length)>0)for(const Ie of U)Ie.fieldId===t.field.uuid&&(Ie.postData[0]={postValue:""})}if(!(s!=null&&s.rowIsRepeatable)){u(re);const Ie=Object.keys(re).length;d(Ie)}},fe=(ne,U)=>{var re;if(T(U),(f==null?void 0:f.length)>0){const G=[...f],de=It.findIndex(G,function(Te){return Te.rowId===(s==null?void 0:s.uuid)});let Ie=(re=f[de])==null?void 0:re.repeatableFields;Ie={...Ie,[ne.uuid]:U},G[de]={...G[de],repeatableFields:Ie},h(G),U!==""?ne.isValid=1:ne.isValid=0}},Z=new Date(i==null?void 0:i.minDate),W=new Date(i==null?void 0:i.maxDate),ce=o.jsxs("div",{onMouseOver:P,onMouseOut:B,children:[!r&&!e&&_&&o.jsx(Xr,{type:"",handleFieldSettingsSidebar:k,...t}),o.jsxs("div",{className:`field ${e?" ":" builder-element-wrapper "}${(i==null?void 0:i.isFluid)===!0?" card py-3 px-4 p-fluid":"card py-3 px-4"}`,children:[o.jsx("div",{className:"grid",children:o.jsxs("div",{className:"col-12 ",children:[(i==null?void 0:i.showHeaderText)&&o.jsx("h6",{children:(K=i==null?void 0:i.headerText)==null?void 0:K[v==null?void 0:v.type]}),(i==null?void 0:i.showLabel)&&o.jsxs("label",{htmlFor:a,className:"flex font-medium mb-3 text-700 text-2xl",children:[o.jsx(da,{update:function(){throw new Error("Function not implemented.")},value:{fieldId:void 0,uuid:void 0},...t}),((pe=i==null?void 0:i.attributes)==null?void 0:pe.required)&&o.jsx("span",{className:"must-required mr-1",children:"*"})," ",e?o.jsx(o.Fragment,{children:(te=i==null?void 0:i.label)==null?void 0:te[v==null?void 0:v.type]}):o.jsx(sa,{...t}),(i==null?void 0:i.showToolTip)&&o.jsx("span",{className:"ml-3",children:(i==null?void 0:i.showToolTip)&&o.jsx(Mi,{message:(ee=i==null?void 0:i.toolTip)==null?void 0:ee[v==null?void 0:v.type],position:"right"})})]}),o.jsxs("div",{className:"mt-3",children:[o.jsxs("span",{className:"p-input-icon-"+(i==null?void 0:i.iconAlignment),children:[(i==null?void 0:i.showIcon)&&o.jsx("i",{className:"pi pi-"+((J=(Y=i==null?void 0:i.icon)==null?void 0:Y.properties)==null?void 0:J.name)}),o.jsx(If,{readOnlyInput:!0,numberOfMonths:i==null?void 0:i.noOfMonths,selectionMode:(i==null?void 0:i.dateRange)||"single",view:(i==null?void 0:i.calenderView)||!1,showButtonBar:(i==null?void 0:i.isTodayBtn)||!1,showIcon:(i==null?void 0:i.isIcon)||!1,id:i==null?void 0:i.uuid,dateFormat:i==null?void 0:i.dateFormat,placeholder:(he=i==null?void 0:i.placeholder)==null?void 0:he[v==null?void 0:v.type],value:w,onFocus:()=>E(1),onChange:ne=>{s!=null&&s.rowIsRepeatable?fe(i,ne.target.value):le(ne)},minDate:Z,maxDate:W,className:x===1&&((be=i==null?void 0:i.attributes)!=null&&be.required)?w?"valid":"invalid":"valid'",disabled:l===g})]}),o.jsx("div",{children:((Ee=i==null?void 0:i.attributes)==null?void 0:Ee.required)&&o.jsx("small",{className:"error",children:x===1&&!w?(ye=i==null?void 0:i.validationMesssage)==null?void 0:ye.english:""})}),o.jsx("div",{children:(i==null?void 0:i.showHelperText)&&o.jsx("small",{children:(Ae=i==null?void 0:i.helperText)==null?void 0:Ae[v==null?void 0:v.type]})})]})]})}),n&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{}),o.jsx(Ni,{...t})]})]})]});return o.jsxs(o.Fragment,{children:[m===!0&&o.jsx(Wi,{visibilty:m,closeSettingFieldSidebar:j,...t},i==null?void 0:i.uuid),o.jsx(Si,{...t,fieldWrap:ce})]})},Z3e=t=>{var he,be,Ee,ye,Ae,ne,U,re;const e=M.useRef(null),{task_status:n,taskRegisterData:r,updateTaskRegisterData:i,updateTaskProgressValue:a,updateUserFormDataSubmit:s,userTaskSubmitFormData:l,onSetValuetoPostDataHook:c,TASK_PUBLISHED:u}=yr(),{userSelectedLanguage:d,fieldSettingUpdate:f}=cn(),{field:h,fieldIndex:g,columnIndex:v,sectionIndex:m,rowIndex:A,pageIndex:w,row:T}=t,{isAdmin:x,isPreview:E,isRenderView:S}=Jt(),[I,_]=M.useState(!1),[O,P]=M.useState(0),[B,V]=M.useState(!1),[z,k]=M.useState(null),[j,le]=M.useState(!1),fe=()=>{le(!0)},Z=()=>{le(!1)},W=()=>{var de,Ie,Te;(de=e==null?void 0:e.current)==null||de.clear(),h.isValid=0,f(w,m,A,v,g,h),k(null);const G=l;if(l!=null&&l.length){const ve=It.cloneDeep(r);if(ve[h==null?void 0:h.uuid]=(Ie=e.current)==null?void 0:Ie.toDataURL(),(G==null?void 0:G.length)>0){for(const me of G)if(me.fieldId===t.field.uuid){me.postData[0]={postValue:null},k(null);break}}if(!(T!=null&&T.rowIsRepeatable)){i(ve);const me=(Te=Object.keys(ve))==null?void 0:Te.length;a(me)}}},ce=()=>{var de,Ie,Te;const G=l;if((G==null?void 0:G.length)>0)for(const ve of G)ve.fieldId===t.field.uuid&&((de=ve==null?void 0:ve.postData[0])!=null&&de.postValue&&((Ie=ve==null?void 0:ve.postData[0])==null?void 0:Ie.postValue)!==""&&(k((Te=ve==null?void 0:ve.postData[0])==null?void 0:Te.postValue),V(!0)),h.isValid=1);V(!0)},K=()=>{var G,de,Ie,Te;if(l!=null&&l.length){const ve=[...l],me=It.findIndex(ve,function(De){return De.rowId===(T==null?void 0:T.uuid)});let Se=(G=l[me])==null?void 0:G.repeatableFields;Se={...Se,[h==null?void 0:h.uuid]:`<img src="${(de=e.current)==null?void 0:de.toDataURL()}" >`},ve[me]={...ve[me],repeatableFields:Se},s(ve)}k(((Ie=e.current)==null?void 0:Ie.toDataURL())||""),((Te=e.current)==null?void 0:Te.toDataURL())!==""?h.isValid=1:h.isValid=0};M.useEffect(()=>{B||ce();const G=Zt.addListener("clearRepeatableFields",ve=>{ve===(T==null?void 0:T.uuid)&&(k(null),W(),P(0),h.isValid=0,f(w,m,A,v,g,h))}),de=Zt.addListener("onSubmitUserForm",()=>{var ve;(ve=h==null?void 0:h.attributes)!=null&&ve.required?(z!==null?h.isValid=1:h.isValid=0,f(w,m,A,v,g,h)):h.isValid=1}),Ie=Zt.addListener("OnInvalidFieldCatch",ve=>{h.uuid===(ve==null?void 0:ve.fieldId)?P(1):P(0)}),Te=Zt.addListener("OnSignatureSettingChange",()=>{W()});return()=>{de.remove(),Ie.remove(),Te.remove(),G.remove()}});const pe=G=>{_(G)},te=()=>{_(!1)},ee=()=>{var de,Ie,Te,ve;const G=l;if(l!=null&&l.length){const me=It.cloneDeep(r);if(me[h==null?void 0:h.uuid]=(de=e.current)==null?void 0:de.toDataURL(),(G==null?void 0:G.length)>0){for(const Se of G)if(Se.fieldId===t.field.uuid){Se.postData[0]={postValue:(Ie=e.current)==null?void 0:Ie.toDataURL()},k(((Te=e.current)==null?void 0:Te.toDataURL())||null);break}}if(!(T!=null&&T.rowIsRepeatable)){i(me);const Se=(ve=Object.keys(me))==null?void 0:ve.length;a(Se)}}},Y=()=>{var G,de,Ie;return`rgba(${(G=h==null?void 0:h.backgroundColor)==null?void 0:G.r}, ${(de=h==null?void 0:h.backgroundColor)==null?void 0:de.g}, ${(Ie=h==null?void 0:h.backgroundColor)==null?void 0:Ie.b}, 0.8)`},J=o.jsxs("div",{onMouseOver:fe,onMouseOut:Z,children:[!S&&!E&&j&&o.jsx(Xr,{handleFieldSettingsSidebar:pe,...t}),o.jsx("div",{className:`field ${E?" ":" builder-element-wrapper "}${(h==null?void 0:h.isFluid)===!0?" card py-3 px-4 p-fluid":"card py-3 px-4"}`,children:o.jsxs("div",{className:"grid",children:[o.jsxs("div",{className:E?"col-12":"col-11",children:[(h==null?void 0:h.showHeaderText)&&o.jsx("h6",{children:(he=h==null?void 0:h.headerText)==null?void 0:he[d==null?void 0:d.type]}),(h==null?void 0:h.showLabel)&&o.jsxs("label",{htmlFor:h.uuid,className:"flex font-medium mb-3 text-700 text-2xl",children:[o.jsx(da,{...t}),((be=h==null?void 0:h.attributes)==null?void 0:be.required)&&o.jsx("span",{className:"must-required mr-1",children:"*"})," ",E?o.jsx(o.Fragment,{children:(Ee=h==null?void 0:h.label)==null?void 0:Ee[d==null?void 0:d.type]}):o.jsx(sa,{...t}),o.jsx("span",{className:"ml-3",children:(h==null?void 0:h.showToolTip)&&o.jsx(Mi,{message:(ye=h==null?void 0:h.toolTip)==null?void 0:ye[d==null?void 0:d.type],position:"right"})})]}),o.jsxs("div",{className:"mt-3",children:[n!==u&&z===null&&!x&&o.jsx(FE,{backgroundColor:Y(),penColor:`#${h==null?void 0:h.penColor}`,canvasProps:{width:`${h==null?void 0:h.canvasWidth}`,height:h==null?void 0:h.canvasHeight,className:"sigCanvas"},ref:e,onEnd:()=>{T!=null&&T.rowIsRepeatable?K():ee()}},h==null?void 0:h.uuid),n===u&&z==null&&o.jsx("p",{children:"Not signed"}),n===u&&z!==null&&o.jsx("img",{alt:"",src:z,style:{width:350,height:200}}),n!==u&&z!==null&&o.jsx("img",{alt:"",src:z,style:{width:350,height:200}}),o.jsx("div",{children:((Ae=h==null?void 0:h.attributes)==null?void 0:Ae.required)&&o.jsx("small",{className:"error",children:O===1&&!z?(ne=h==null?void 0:h.validationMesssage)==null?void 0:ne.english:""})}),o.jsx("div",{className:"mt-3",children:(h==null?void 0:h.showHelperText)&&o.jsx("small",{children:(U=h==null?void 0:h.helperText)==null?void 0:U[d==null?void 0:d.type]})}),n===L3&&o.jsx(o.Fragment,{children:x===!1&&o.jsx(Ft,{text:!0,label:(re=h==null?void 0:h.clearSignatureButtonLabel)==null?void 0:re[d==null?void 0:d.type],onClick:()=>W(),className:"p-button-raised p-button-text mt-3"})})]})]}),x&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{}),o.jsx(Ni,{...t})]})]})})]});return o.jsxs(o.Fragment,{children:[I===!0&&o.jsx(Wi,{visibilty:I,closeSettingFieldSidebar:te,...t}),o.jsx(Si,{...t,fieldWrap:J})]})};function L1(){return L1=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},L1.apply(null,arguments)}function Lg(t){"@babel/helpers - typeof";return Lg=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lg(t)}function e4e(t,e){if(Lg(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(Lg(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function t4e(t){var e=e4e(t,"string");return Lg(e)=="symbol"?e:e+""}function dw(t,e,n){return(e=t4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n4e(t){if(Array.isArray(t))return t}function r4e(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,a,s,l=[],c=!0,u=!1;try{if(a=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(l.push(r.value),l.length!==e);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return l}}function fw(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function rV(t,e){if(t){if(typeof t=="string")return fw(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fw(t,e):void 0}}function i4e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3868
3868
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B1(t,e){return n4e(t)||r4e(t,e)||rV(t,e)||i4e()}var a4e={header:"p-galleria-header",footer:"p-galleria-footer",closeIcon:"p-galleria-close-icon",closeButton:"p-galleria-close p-link",root:function(e){var n=e.props,r=e.context,i=e.thumbnailsPosClassName,a=e.indicatorPosClassName;return dt("p-galleria p-component",{"p-galleria-fullscreen":n.fullScreen,"p-galleria-indicator-onitem":n.showIndicatorsOnItem,"p-galleria-item-nav-onhover":n.showItemNavigatorsOnHover&&!n.fullScreen,"p-input-filled":r&&r.inputStyle==="filled"||jn.inputStyle==="filled","p-ripple-disabled":r&&r.ripple===!1||jn.ripple===!1},i,a)},content:"p-galleria-content",mask:function(e){var n=e.visibleState;return dt("p-galleria-mask",{"p-galleria-visible":n})},thumbnailItem:function(e){var n=e.subProps;return dt("p-galleria-thumbnail-item",{"p-galleria-thumbnail-item-current":n.current,"p-galleria-thumbnail-item-active":n.active,"p-galleria-thumbnail-item-start":n.start,"p-galleria-thumbnail-item-end":n.end})},thumbnailItemContent:"p-galleria-thumbnail-item-content",previousThumbnailIcon:"p-galleria-thumbnail-prev-icon",previousThumbnailButton:function(e){var n=e.isDisabled;return dt("p-galleria-thumbnail-prev p-link",{"p-disabled":n})},nextThumbnailIcon:"p-galleria-thumbnail-next-icon",nextThumbnailButton:function(e){var n=e.isDisabled;return dt("p-galleria-thumbnail-next p-link",{"p-disabled":n})},thumbnailContainer:"p-galleria-thumbnail-container",thumbnailItemsContainer:"p-galleria-thumbnail-items-container",thumbnailItems:"p-galleria-thumbnail-items",thumbnailWrapper:"p-galleria-thumbnail-wrapper",previousItemIcon:"p-galleria-item-prev-icon",previousItemButton:function(e){var n=e.isDisabled;return dt("p-galleria-item-prev p-galleria-item-nav p-link",{"p-disabled":n})},nextItemIcon:"p-galleria-item-next-icon",nextItemButton:function(e){var n=e.isDisabled;return dt("p-galleria-item-next p-galleria-item-nav p-link",{"p-disabled":n})},caption:"p-galleria-caption",indicator:function(e){var n=e.isActive;return dt("p-galleria-indicator",{"p-highlight":n})},indicators:"p-galleria-indicators p-reset",itemWrapper:"p-galleria-item-wrapper",itemContainer:"p-galleria-item-container",item:"p-galleria-item",transition:"p-galleria"},s4e=`
3869
3869
  @layer primereact {
3870
3870
  .p-galleria-content {
@@ -58129,7 +58129,7 @@ var Uue = function() {
58129
58129
  theme: i.theme,
58130
58130
  formats: i.formats
58131
58131
  };
58132
- Uue ? A(new Quill(d.current, V)) : import("./quill-BF0rGVwH.js").then(function(q) {
58132
+ Uue ? A(new Quill(d.current, V)) : import("./quill-DkHqeh2Z.js").then(function(q) {
58133
58133
  if (q && Se.isExist(d.current)) {
58134
58134
  var P;
58135
58135
  q.default ? P = new q.default(d.current, V) : P = new q(d.current, V), A(P);
@@ -101952,12 +101952,12 @@ const dB = (t) => {
101952
101952
  const v = i.current, m = e !== null ? e.findIndex(
101953
101953
  (x) => (x == null ? void 0 : x.fieldId) === (o == null ? void 0 : o.uuid)
101954
101954
  ) : -1;
101955
- m >= 0 && (e[m].logs.push({
101955
+ m >= 0 && e[m].logs.push({
101956
101956
  action: g,
101957
101957
  videoTime: e[m].seenTime,
101958
101958
  totalTime: v.duration(),
101959
101959
  timeState: /* @__PURE__ */ new Date()
101960
- }), n(e));
101960
+ }), n(e);
101961
101961
  };
101962
101962
  return gn(() => {
101963
101963
  if (!l && e !== null) {
@@ -1,7 +1,7 @@
1
1
  var Bl = Object.defineProperty;
2
2
  var Ml = (n, t, e) => t in n ? Bl(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var T = (n, t, e) => Ml(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { d as ti, i as Rr, a as Hi, b as Dl, e as Br, M as Ul, S as ei, U as si, g as ni, c as ri, f as fr, h as zs, j as $i, k as Vs, l as dr, m as Pl, n as jl, o as Fi, p as Hl, q as $l, r as Fl, s as zl, t as ii, u as Kl, v as Gl, w as Ft, x as zi, y as xe } from "./main-DqHMlALJ.js";
4
+ import { d as ti, i as Rr, a as Hi, b as Dl, e as Br, M as Ul, S as ei, U as si, g as ni, c as ri, f as fr, h as zs, j as $i, k as Vs, l as dr, m as Pl, n as jl, o as Fi, p as Hl, q as $l, r as Fl, s as zl, t as ii, u as Kl, v as Gl, w as Ft, x as zi, y as xe } from "./main-BfqUxL-X.js";
5
5
  function Ki(n) {
6
6
  return n;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cft-builder",
3
- "version": "0.2.57",
3
+ "version": "0.2.59",
4
4
  "type": "module",
5
5
  "types": "dist/types/index",
6
6
  "files": [