@maveio/components 0.0.170 → 0.0.171
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.
- package/dist/{chunk-YWYZKUFB.cjs → chunk-26IKHTYO.cjs} +1 -1
- package/dist/{chunk-EA4QYQHD.js → chunk-4HURBTSI.js} +2 -2
- package/dist/{chunk-OFBA5VRE.cjs → chunk-CQU5634L.cjs} +2 -2
- package/dist/{chunk-GRBSIFM2.js → chunk-GWLFO35M.js} +1 -1
- package/dist/chunk-HMVS6DJE.js +1 -1
- package/dist/{chunk-ITC5FANW.cjs → chunk-PUSIMWBW.cjs} +2 -2
- package/dist/{chunk-ZWLZE25P.js → chunk-TQYBNODL.js} +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/player.cjs +1 -1
- package/dist/components/player.js +1 -1
- package/dist/components/pop.cjs +1 -1
- package/dist/components/pop.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/themes/dolphin.cjs +5 -0
- package/dist/themes/dolphin.js +5 -0
- package/dist/themes/loader.cjs +1 -1
- package/dist/themes/loader.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +1 -1
- package/package.json +5 -5
- /package/dist/{chunk-CZUMF7SR.cjs → chunk-5QB22TB5.cjs} +0 -0
- /package/dist/{chunk-RWRHU74Q.js → chunk-CSURX7CD.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk5QB22TB5_cjs=require('./chunk-5QB22TB5.cjs'),chunk5QLIDHRT_cjs=require('./chunk-5QLIDHRT.cjs'),chunkQQDH35OW_cjs=require('./chunk-QQDH35OW.cjs'),chunkLVGLIRQU_cjs=require('./chunk-LVGLIRQU.cjs'),chunk3BAQWQNY_cjs=require('./chunk-3BAQWQNY.cjs'),chunk474VILDO_cjs=require('./chunk-474VILDO.cjs'),chunkBTCK3T4L_cjs=require('./chunk-BTCK3T4L.cjs'),chunkSDKTBB4N_cjs=require('./chunk-SDKTBB4N.cjs'),chunkTKJYRGEU_cjs=require('./chunk-TKJYRGEU.cjs'),chunkRQN3DXJB_cjs=require('./chunk-RQN3DXJB.cjs'),chunkDL4BV5IH_cjs=require('./chunk-DL4BV5IH.cjs'),chunk2E5GLLOS_cjs=require('./chunk-2E5GLLOS.cjs'),chunkNPP5B5PV_cjs=require('./chunk-NPP5B5PV.cjs'),chunkEVKPEPYP_cjs=require('./chunk-EVKPEPYP.cjs'),chunkJHSFSCC2_cjs=require('./chunk-JHSFSCC2.cjs');function Vh(s){return s?.map(B0).join(" ")}function Wh(s){return s?.split(/\s+/).map(G0)}function B0(s){if(s){let{id:e,width:t,height:i}=s;return [e,t,i].filter(r=>r!=null).join(":")}}function G0(s){if(s){let[e,t,i]=s.split(":");return {id:e,width:+t,height:+i}}}function Yh(s){return s?.map(H0).join(" ")}function qh(s){return s?.split(/\s+/).map(K0)}function H0(s){if(s){let{id:e,kind:t,language:i,label:r}=s;return [e,t,i,r].filter(n=>n!=null).join(":")}}function K0(s){if(s){let[e,t,i,r]=s.split(":");return {id:e,kind:t,language:i,label:r}}}function vs(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}var Zn=s=>new Promise(e=>setTimeout(e,s));var jh=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],V0=(s,e)=>{let t=s===1?jh[e].singular:jh[e].plural;return `${s} ${t}`},Wi=s=>{if(!vs(s))return "";let e=Math.abs(s),t=e!==s,i=new Date(0,0,0,0,0,e,0);return `${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,d)=>o&&V0(o,d)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Nt(s,e){let t=false;s<0&&(t=true,s=0-s),s=s<0?0:s;let i=Math.floor(s%60),r=Math.floor(s/60%60),n=Math.floor(s/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return (isNaN(s)||s===1/0)&&(n=r=i="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",i=i<10?"0"+i:i,(t?"-":"")+n+r+i}var zh=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},xi=(s,e,t)=>(zh(s,e,"read from private field"),t?t.call(s):e.get(s)),Y0=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t);},Jn=(s,e,t,i)=>(zh(s,e,"write to private field"),e.set(s,t),t),lt;function q0(s){return `
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
@@ -1492,7 +1492,7 @@ Schedule: ${d.map(g=>Gt(g))} pos: ${this.timelinePos}`),c.length&&this.log(`Remo
|
|
|
1492
1492
|
`).split(`
|
|
1493
1493
|
`),l=[],c=e?MS(e.baseTime,e.timescale):0,u="00:00.000",h=0,f=0,m,g=true;o.oncue=function(E){let v=t[i],T=t.ccOffset,S=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?T=t.ccOffset=v.start:eA(t,i,S)),S){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=S-t.presentationOffset;}let b=E.endTime-E.startTime,_=St((E.startTime+T-f)*9e4,r*9e4)/9e4;E.startTime=Math.max(_,0),E.endTime=Math.max(_+b,0);let D=E.text.trim();E.text=decodeURIComponent(encodeURIComponent(D)),E.id||(E.id=oh(E.startTime,E.endTime,D)),E.endTime>0&&l.push(E);},o.onparsingerror=function(E){m=E;},o.onflush=function(){if(m){a(m);return}n(l);},d.forEach(E=>{if(g)if(vc(E,"X-TIMESTAMP-MAP=")){g=false,E.slice(16).split(",").forEach(v=>{vc(v,"LOCAL:")?u=v.slice(6):vc(v,"MPEGTS:")&&(h=parseInt(v.slice(7)));});try{f=Jb(u)/1e3;}catch(v){m=v;}return}else E===""&&(g=false);o.parse(E+`
|
|
1494
1494
|
`);}),o.flush();}var Tc="stpp.ttml.im1t",s0=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,r0=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,iA={left:"start",center:"center",right:"end",start:"start",end:"end"};function Mg(s,e,t,i){let r=de(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}let n=r.map(o=>At(o)),a=CS(e.baseTime,1,e.timescale);try{n.forEach(o=>t(sA(o,a)));}catch(o){i(o);}}function sA(s,e){let r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",d=wg(yc(r,"styling","style")),l=wg(yc(r,"layout","region")),c=yc(r,"body","[begin]");return [].map.call(c,u=>{let h=n0(u,o);if(!h||!u.hasAttribute("begin"))return null;let f=bc(u.getAttribute("begin"),a),m=bc(u.getAttribute("dur"),a),g=bc(u.getAttribute("end"),a);if(f===null)throw Pg(u);if(g===null){if(m===null)throw Pg(u);g=f+m;}let E=new ah(f-e,g-e,h);E.id=oh(E.startTime,E.endTime,E.text);let v=l[u.getAttribute("region")],T=d[u.getAttribute("style")],S=rA(v,T,d),{textAlign:b}=S;if(b){let _=iA[b];_&&(E.lineAlign=_),E.align=b;}return Se(E,S),E}).filter(u=>u!==null)}function yc(s,e,t){let i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function wg(s){return s.reduce((e,t)=>{let i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function n0(s,e){return [].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
|
|
1495
|
-
`:(n=i.childNodes)!=null&&n.length?n0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function rA(s,e,t){let i="http://www.w3.org/ns/ttml#styling",r=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,d)=>{let l=Sc(e,i,d)||Sc(s,i,d)||Sc(r,i,d);return l&&(o[d]=l),o},{})}function Sc(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Pg(s){return new Error(`Could not parse ttml timestamp ${s}`)}function bc(s,e){if(!s)return null;let t=e0(s);return t===null&&(s0.test(s)?t=nA(s,e):r0.test(s)&&(t=aA(s,e))),t}function nA(s,e){let t=s0.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return (t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function aA(s,e){let t=r0.exec(s),i=Number(t[1]);switch(t[2]){case "h":return i*3600;case "m":return i*60;case "ms":return i*1e3;case "f":return i/e.frameRate;case "t":return i/e.tickRate}return i}var lr=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t;}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null);}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName);}reset(){this.cueRanges=[],this.startTime=null;}},Pu=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=true,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Fg(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this);}destroy(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){let e=new lr(this,"textTrack1"),t=new lr(this,"textTrack2"),i=new lr(this,"textTrack3"),r=new lr(this,"textTrack4");this.cea608Parser1=new yl(1,e,t),this.cea608Parser2=new yl(3,i,r);}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let d=n[o],l=oA(d[0],d[1],t,i);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=true,l/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r);}else {let o=this.Cues.newCue(null,t,i,r);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:o,track:e});}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){let{unparsedVttFrags:o}=this;i===Y.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(d=>{this.initPTS[d.frag.cc]?this.onFragLoaded(p.FRAG_LOADED,d):this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:d.frag,error:new Error("Subtitle discontinuity domain does not match main")});}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if(Og(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e);}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,or(i[e]),Qp(i[e],r);else {let d=this.createTextTrack("captions",n,a);d&&(d[e]=true,i[e]=d);}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:false,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]});}createTextTrack(e,t,i){let r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks();}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(n=>{or(r[n]),delete r[n];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Fg(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset());}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let i=0;i<t.length;i++)or(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===Tc);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Up(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?zo(a.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&Og(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u);}if(c)or(c);else {let u=a0(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled");}c&&this.textTracks.push(c);}),o!=null&&o.length){let d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${d.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`);}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a});}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;let n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i);});}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===Y.MAIN){var i,r;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c;}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===Y.SUBTITLE)if(r.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:true},this.prevCC=i.cc),o&&o.textCodec===Tc?this._parseIMSC1(i,r):this._parseVTTs(t);}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:new Error("Empty subtitle payload")});}_parseIMSC1(e,t){let i=this.hls;Mg(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{i.logger.log(`Failed to parse IMSC1: ${r}`),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:e,error:r});});}_parseVTTs(e){var t;let{frag:i,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}let d=this.hls,l=(t=i.initSegment)!=null&&t.data?Dt(i.initSegment.data,new Uint8Array(r)).buffer:r;tA(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i});},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,r),d.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:c});});}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||Mg(t,this.initPTS[e.cc],()=>{i.textCodec=Tc,this._parseIMSC1(e,t);},()=>{i.textCodec="wvtt";});}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Xp(r,n));}else {let r=this.tracks[t];if(!r)return;let n=r.default?"default":"subtitles"+t;i.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:n});}}onFragDecrypted(e,t){let{frag:i}=t;i.type===Y.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(!(i.type===Y.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){let a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();let o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1]);}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,r));}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,r=2;for(let n=0;n<i;n++){let a=e[r++],o=127&e[r++],d=127&e[r++];if(o===0&&d===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(d));}}return t}};function a0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function Og(s,e){return !!s&&s.kind===a0(e)&&au(e,s)}function oA(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Fg(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var lA=/\s/,dA={newCue(s,e,t,i){let r=[],n,a,o,d,l,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=true,d=0,l="",!n.isEmpty()){var u;for(let g=0;g<n.chars.length;g++)lA.test(n.chars[g].uchar)&&o?d++:(l+=n.chars[g].uchar,o=false);n.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;let f=i0(l.trim()),m=oh(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(d*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Xp(s,h))),r}};function cA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var uA=/(\d+)-(\d+)\/(\d+)/,Sl=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||gA,this.controller=new self.AbortController,this.stats=new In;}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null;}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=true,this.controller.abort());}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response);}load(e,t,i){let r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();let n=hA(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&H(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},t.timeout),(Pn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;let f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},l-(f-r.loading.start)),!u.ok){let{status:g,statusText:E}=u;throw new Ou(E||"fetch, bad network response",g,u)}r.loading.first=f,r.total=mA(u.headers)||r.total;let m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&H(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;let m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let g=u[o];g&&(r.loaded=r.total=g);let E={url:m.url,data:u,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!H(t.highWaterMark)&&v(r,e,u,m),(f=this.callbacks)==null||f.onSuccess(E,r,e,m);}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;let f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,r);});}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){let a=new cl,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let c=l.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}};function hA(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Se({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function fA(s){let e=uA.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function mA(s){let e=s.get("Content-Range");if(e){let i=fA(e);if(H(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function gA(s,e){return new self.Request(s.url,e)}var Ou=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},pA=/^age:\s*[\d.]+\s*$/im,bl=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new In,this.retryDelay=0;}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null;}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=true,e.abort()));}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader);}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal();}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=false;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,true),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e);}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r);}):this.openAndSendXhr(i,t,e);}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,true);let r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&H(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send();}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){let m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);let g=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=g,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);let E=(a=this.callbacks)==null?void 0:a.onProgress;E&&E(i,e,m,t);let v={url:t.responseURL,data:m,code:l};(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}let u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(rl(u,h,false,f))this.retry(u);else {var d;ye.error(`${l} while loading ${e.url}`),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,i);}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(rl(e,t,true))this.retry(e);else {var i;ye.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);let r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader));}}retry(e){let{context:t,stats:i}=this;this.retryDelay=zu(e,i.retry),i.retry++,ye.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay);}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total);}getCacheAge(){let e=null;if(this.loader&&pA.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}},EA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},vA=Te(Te({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:false,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:true,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:false,loader:bl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Mc,bufferController:cu,capLevelController:uu,errorController:Pc,fpsController:Eu,stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:cp,requireKeySystemAccessOnStart:false,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableEmsgKLVMetadata:false,enableID3MetadataCues:true,enableInterstitialPlayback:true,interstitialAppendInPlace:true,interstitialLiveLookAhead:10,useMediaCapabilities:true,preserveManualLevelOnError:false,certLoadPolicy:{default:EA},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},TA()),{},{subtitleStreamController:Iu,subtitleTrackController:Tu,timelineController:Pu,audioStreamController:nu,audioTrackController:ou,emeController:pl,cmcdController:gu,contentSteeringController:pu,interstitialsController:_u});function TA(){return {cueHandler:dA,enableWebVTT:true,enableIMSC1:true,enableCEA708Captions:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function yA(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let i=Fu(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{let o=`${a==="level"?"playlist":a}LoadPolicy`,d=e[o]===void 0,l=[];n.forEach(c=>{let u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&d){l.push(u);let f=i[o].default;switch(e[o]={default:f},c){case "TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case "MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${Ae(e[o])}`);}),Te(Te({},i),e)}function Fu(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Fu):Object.keys(s).reduce((e,t)=>(e[t]=Fu(s[t]),e),{}):s}function SA(s,e){let t=s.loader;t!==Sl&&t!==bl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):cA()&&(s.loader=Sl,s.progressive=true,s.enableSoftwareAES=true,e.log("[config]: Progressive streaming enabled, using FetchLoader"));}var Qo=2,bA=.1,AA=.05,_A=100,Nu=class extends nl{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0;},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick());},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false});}},this.hls=e,this.fragmentTracker=t,this.registerListeners();}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this));}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0;}onMediaAttached(e,t){this.setInterval(_A),this.mediaSource=t.mediaSource;let i=this.media=t.media;at(i,"playing",this.onMediaPlaying),at(i,"waiting",this.onMediaWaiting),at(i,"ended",this.onMediaEnded);}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"waiting",this.onMediaWaiting),ut(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0;}onBufferAppended(e,t){this.buffered=t.timeRanges;}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t;}poll(e,t){var i,r;let n=(i=this.hls)==null?void 0:i.config;if(!n)return;let a=this.media;if(!a)return;let{seeking:o}=a,d=this.seeking&&!o,l=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=true,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false}));return}if(!ne.getBuffered(a).length){this.nudgeRetry=0;return}let u=ne.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){let D=Ng(this.hls.inFlightFragments,e),I=u.len>Qo,k=!h||D||h-e>Qo&&!f.getPartialFragment(e);if(I||k)return;this.moved=false;}let m=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;let I=Math.max(h,u.start||0)-e,R=!!(m!=null&&m.live)?m.targetduration*2:Qo,L=Ho(e,f);if(I>0&&(I<=R||L)){a.paused||this._trySkipBufferHole(L);return}}let g=n.detectStallWithCurrentTimeMs,E=self.performance.now(),v=this.waiting,T=this.stalled;if(T===null)if(v>0&&E-v<g)T=this.stalled=v;else {this.stalled=E;return}let S=E-T;if(!o&&(S>=g||v)&&this.hls){var b;if(((b=this.mediaSource)==null?void 0:b.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:true});return}if(this._reportStall(u),!this.media||!this.hls)return}let _=ne.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,S,e);}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=false,this.waiting=0,this.hls.trigger(p.STALL_RESOLVED,{});}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){let n=ne.bufferedInfo(ne.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){let a=ne.timeRangesToArray(r),o=ne.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){let d=ne.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,c=a[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){let u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${d}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Ho(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);let f=ne.bufferInfo(this.media,e,0);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f});}}}}}_tryFixBufferStall(e,t,i){var r,n;let{fragmentTracker:a,media:o}=this,d=(r=this.hls)==null?void 0:r.config;if(!o||!a||!d)return;let l=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Ho(i,a);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-i<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e));}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let n=i.getFragAtPos(t,Y.MAIN),a=i.getFragAtPos(r,Y.MAIN);if(n&&a)return a.sn-n.sn<2}return false}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=true;let a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ae(e)})`);this.warn(a.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:false,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}});}}_trySkipBufferHole(e){var t;let{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;let a=r.currentTime,o=ne.bufferInfo(r,a,0),d=a<o.start?o.start:o.nextStart;if(d&&this.hls){let c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&r.readyState<3,h=d-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let m=false;if(a===0){let g=i.getAppendedFrag(0,Y.MAIN);g&&d<g.end&&(m=true);}if(!m&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||Ng(this.hls.inFlightFragments,d))return 0;let E=false,v=e.end;for(;v<d;){let T=Ho(v,i);if(T)v+=T.duration;else {E=true;break}}if(E)return 0}}let f=Math.max(d+AA,a+bA);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=true,r.currentTime=f,!(e!=null&&e.gap)){let m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),g={type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(p.ERROR,g);}return f}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){let o=a+(r+1)*n.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(d.message),i.currentTime=o,t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:d,fatal:false,buffer:e.len,bufferInfo:e});}else {let o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:o,fatal:true,buffer:e.len,bufferInfo:e});}}};function Ng(s,e){let t=Ug(s.main);if(t&&t.start<=e)return t;let i=Ug(s.audio);return i&&i.start<=e?i:null}function Ug(s){if(!s)return null;switch(s.state){case M.IDLE:case M.STOPPED:case M.ENDED:case M.ERROR:return null}return s.frag}function Ho(s,e){return e.getAppendedFrag(s,Y.MAIN)||e.getPartialFragment(s)}var IA=.25;function Uu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ac(s,e,t,i,r){let n=new s(e,t,"");try{n.value=i,r&&(n.type=r);}catch{n=new s(e,t,Ae(r?Te({type:r},i):i));}return n}var Ko=(()=>{let s=Uu();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),$u=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=true,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(p.EVENT_CUE_ENTER,{});},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null;}_registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}_unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===false&&(this.removeCues=false);}onMediaAttached(){var e;let t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t);}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&or(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={});}onManifestLoading(){this.dateRangeCuesAppended={};}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Qp(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Uu();if(a)for(let o=0;o<n.length;o++){let d=n[o].type;if(d===bt.emsg&&!i||!r)continue;let l=xp(n[o].data),c=n[o].pts,u=c+n[o].duration;u>Ko&&(u=Ko),u-c<=0&&(u=c+IA);for(let f=0;f<l.length;f++){let m=l[f];if(!Rp(m)){this.updateId3CueEnds(c,d);let g=Ac(a,c,u,m,d);g&&this.id3Track.addCue(g);}}}}updateId3CueEnds(e,t){var i;let r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let n=r.length;n--;){let a=r[n];a.type===t&&a.startTime<e&&a.endTime===Ko&&(a.endTime=e);}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=a;if(n&&(o||d)){let l;r==="audio"?l=c=>c.type===bt.audioId3&&d:r==="video"?l=c=>c.type===bt.emsg&&o:l=c=>c.type===bt.audioId3&&d||c.type===bt.emsg&&o,vu(n,t,i,l);}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,true);}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details);}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;let{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;let o=Uu();if(i&&r&&!a){let{fragmentStart:g,fragmentEnd:E}=e,v=this.assetCue;v?(v.startTime=g,v.endTime=E):o&&(v=this.assetCue=Ac(o,g,E,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)));}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:l}=e,c=Object.keys(l),u=this.dateRangeCuesAppended;if(d&&t){var h;if((h=d.cues)!=null&&h.length){let g=Object.keys(u).filter(E=>!c.includes(E));for(let E=g.length;E--;){var f;let v=g[E],T=(f=u[v])==null?void 0:f.cues;delete u[v],T&&Object.keys(T).forEach(S=>{let b=T[S];if(b){b.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(b);}catch{}}});}}else u=this.dateRangeCuesAppended={};}let m=e.fragments[e.fragments.length-1];if(!(c.length===0||!H(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<c.length;g++){let E=c[g],v=l[E],T=v.startTime,S=u[E],b=S?.cues||{},_=S?.durationKnown||false,D=Ko,{duration:I,endDate:k}=v;if(k&&I!==null)D=T+I,_=true;else if(v.endOnNext&&!_){let L=c.reduce((w,B)=>{if(B!==v.id){let K=l[B];if(K.class===v.class&&K.startDate>v.startDate&&(!w||v.startDate<w.startDate))return K}return w},null);L&&(D=L.startTime,_=true);}let R=Object.keys(v.attr);for(let L=0;L<R.length;L++){let w=R[L];if(!Dy(w))continue;let B=b[w];if(B)_&&!(S!=null&&S.durationKnown)?B.endTime=D:Math.abs(B.startTime-T)>.01&&(B.startTime=T,B.endTime=D);else if(o){let K=v.attr[w];Cy(w)&&(K=Hg(K));let V=Ac(o,T,D,{key:w,data:K},bt.dateRange);V&&(V.id=E,this.id3Track.addCue(V),b[w]=V,a&&(w==="X-ASSET-LIST"||w==="X-ASSET-URL")&&V.addEventListener("enter",this.onEventCueEnter));}}u[E]={cues:b,dateRange:v,durationKnown:_};}}}},Bu=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=false,this.onTimeupdate=()=>{let{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;let o=this.targetLatency;if(o===null)return;let d=r-o,l=Math.min(this.maxLatency,o+i.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-0.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f);}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1);},this.hls=e,this.config=e.config,this.registerListeners();}get levelDetails(){var e;return ((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(e===null||this.hls===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,d=this.hls.userConfig,l=o&&i||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:a*r);let c=r;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=true;}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;let i=this.levelDetails;if(i===null)return null;let r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null;}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.ERROR,this.onError,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.ERROR,this.onError,this));}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null);}onManifestLoading(){this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate);}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"));}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t);}estimateLiveEdge(){let e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Gu=class extends On{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners();}_registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.ERROR,this.onError,this);}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy();}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0;}),super.stopLoad();}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1;}onManifestLoading(e,t){this.resetLevels();}onManifestLoaded(e,t){let i=this.hls.config.preferManagedMediaSource,r=[],n={},a={},o=false,d=false,l=false;t.levels.forEach(c=>{let u=c.attrs,{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=Jo(h,i)||void 0),f&&(f=c.videoCodec=ey(f));let{width:m,height:g,unknownCodecs:E}=c,v=E?.length||0;if(o||(o=!!(m&&g)),d||(d=!!f),l||(l=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}let{CODECS:T,"FRAME-RATE":S,"HDCP-LEVEL":b,"PATHWAY-ID":_,RESOLUTION:D,"VIDEO-RANGE":I}=u,R=`${`${_||"."}-`}${c.bitrate}-${D}-${S}-${T}-${I}-${b}`;if(n[R])if(n[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let L=a[R]+=1;c.attrs["PATHWAY-ID"]=new Array(L+1).join(".");let w=this.createLevel(c);n[R]=w,r.push(w);}else n[R].addGroupId("audio",u.AUDIO),n[R].addGroupId("text",u.SUBTITLES);else {let L=this.createLevel(c);n[R]=L,a[R]=1,r.push(L);}}),this.filterAndSortMediaOptions(r,t,o,d,l);}createLevel(e){let t=new fs(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=Jg(r,[]);}return t}isAudioSupported(e){return Ln(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Ln(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){var a;let o=[],d=[],l=e,c=((a=t.stats)==null?void 0:a.parsing)||{};if((i||r)&&n&&(l=l.filter(({videoCodec:T,videoRange:S,width:b,height:_})=>(!!T||!!(b&&_))&&cy(S))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let T="no level with compatible codecs found in manifest",S=T;t.levels.length&&(S=`one or more CODECS in variant not supported: ${Ae(t.levels.map(_=>_.attrs.CODECS).filter((_,D,I)=>I.indexOf(_)===D))}`,this.warn(S),T+=` (${S})`);let b=new Error(T);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:b,reason:S});}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(T=>!T.audioCodec||this.isAudioSupported(T.audioCodec)),$g(o)),t.subtitles&&(d=t.subtitles,$g(d));let u=l.slice(0);l.sort((T,S)=>{if(T.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return (T.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&T.height!==S.height)return T.height-S.height;if(T.frameRate!==S.frameRate)return T.frameRate-S.frameRate;if(T.videoRange!==S.videoRange)return el.indexOf(T.videoRange)-el.indexOf(S.videoRange);if(T.videoCodec!==S.videoCodec){let b=Om(T.videoCodec),_=Om(S.videoCodec);if(b!==_)return _-b}if(T.uri===S.uri&&T.codecSet!==S.codecSet){let b=Zo(T.codecSet),_=Zo(S.codecSet);if(b!==_)return _-b}return T.averageBitrate!==S.averageBitrate?T.averageBitrate-S.averageBitrate:0});let h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==u.length)){for(let T=0;T<u.length;T++)if(u[T].pathwayId===l[0].pathwayId){h=u[T];break}}this._levels=l;for(let T=0;T<l.length;T++)if(l[T]===h){var f;this._firstLevel=T;let S=h.bitrate,b=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${S}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){let _=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);_>b&&b===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=_);}break}let m=n&&!r,g=this.hls.config,E=!!(g.audioStreamController&&g.audioTrackController),v={levels:l,audioTracks:o,subtitleTracks:d,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:E&&!m&&o.some(T=>!!T.url)};c.end=performance.now(),this.hls.trigger(p.MANIFEST_PARSED,v);}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1);}let i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let d={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,d);let l=a.details;if(!l||l.live){let c=this.switchParams(a.uri,r?.details,l);this.loadPlaylist(c);}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e);}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e;}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e;}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i;}}onError(e,t){t.fatal||!t.context||t.context.type===ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===Y.MAIN){let i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;let r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0);}}onLevelLoaded(e,t){var i;let{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let d=a.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(r,t,d);}else (i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(p.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null});}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e);}removeLevel(e){var t;if(this._levels.length===1)return;let i=this._levels.filter((n,a)=>a!==e?true:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),false));vp(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(p.LEVELS_UPDATED,{levels:i});}onLevelsUpdated(e,{levels:t}){this._levels=t;}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}));}};function $g(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}function o0(){return self.SourceBuffer||self.WebKitSourceBuffer}function l0(){if(!$i())return false;let e=o0();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function LA(){if(!l0())return false;let s=$i();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(xn(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(xn(e,"audio"))))}function xA(){var s;let e=o0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var RA=100,Hu=class extends Dn{constructor(e,t,i){super(e,t,i,"stream-controller",Y.MAIN),this.audioCodecSwap=false,this.level=-1,this._forceStartLoad=false,this._hasEnoughToStart=false,this.altAudio=0,this.audioOnly=false,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick();},this.onMediaSeeked=()=>{let r=this.media,n=r?r.currentTime:null;if(n===null||!H(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;let a=this.getFwdBufferInfoAtPos(r,n,Y.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick();},this.registerListeners();}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this);}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying();}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(RA),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=true):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t;}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=M.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}else this._forceStartLoad=true,this.state=M.STOPPED;}stopLoad(){this._forceStartLoad=false,super.stopLoad();}doTick(){switch(this.state){case M.WAITING_LEVEL:{let{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd();}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===false&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){let g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let l=a.details;if(!l||this.state===M.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=M.WAITING_LEVEL,this.startFragRequested=false;return}let c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&Fe(f)&&this.fragmentTracker.getState(f)!==We.OK){var m;let E=((m=this.backtrackFragment)!=null?m:f).sn-l.startSN,v=l.fragments[E-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v));}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let E=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(E===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,E,Y.MAIN);}f=this.getNextFragmentLoopLoading(f,l,o,Y.MAIN,u);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===We.NOT_LOADED||r===We.PARTIAL?Fe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Y.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY);}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:i=0;}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(a.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY);}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition();}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;at(i,"playing",this.onMediaPlaying),at(i,"seeked",this.onMediaSeeked);}onMediaDetaching(e,t){let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=false);}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.couldBacktrack=false,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=false;}onManifestParsed(e,t){let i=false,r=false;for(let n=0;n<t.levels.length;n++){let a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1);}this.audioCodecSwitch=i&&r&&!xA(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=false;}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==M.IDLE)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,d=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${d}`);let l=t.levelInfo,c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,u),this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:a}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=M.IDLE;}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick();}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,d=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!d)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;let u=ne.bufferInfo(i,r,0);if(!((l=u.buffered)!=null&&l.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}let{nextStart:f}=ne.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f);}else i.currentTime=r;}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}let d=o.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ml(this.hls,Y.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,E=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,u,h,l,i,r,d.totalduration,c,E,v);}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio!==0;if(il(t.url,i))this.altAudio=1;else {if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState();}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(p.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(p.AUDIO_TRACK_SWITCHED,t);}),i.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(p.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=il(t.url,this.hls);if(i){let r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r);}this.altAudio=i?2:0,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let d=i[o];if(d.id==="main"){if(n=o,r=d,o==="video"){let l=i[o];l&&(this.videoBuffer=l.buffer);}}else a=true;}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media;}onFragBuffered(e,t){let{frag:i,part:r}=t,n=i.type===Y.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}let o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Fe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}let a=this.media;a&&(!this._hasEnoughToStart&&ne.getBuffered(a).length&&(this._hasEnoughToStart=true,this.seekToStartPos()),n&&this.tick());}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Y.MAIN,t);break;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ue.LEVEL&&(this.state=M.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=true:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this._hasEnoughToStart||(this.startFragRequested=false,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||!this.altAudio){let i=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,Y.MAIN),this.tick());}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=this.timelineOffset;r&&i&&(i+=r);let n=this.getLevelDetails(),a=ne.getBuffered(e),o=a.length?a.start(0):0,d=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${d} to match buffer start`),i+=d,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i);}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=true,this._doFragLoad(e,t).then(i=>{let{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=false,this.bitrateTest=false;let a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),n.bitrateTest=false;}).catch(i=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}let{frag:o,part:d,level:l}=a,{video:c,text:u,id3:h,initSegment:f}=r,{details:m}=l,g=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=M.PARSING,f){let E=f.tracks;if(E){let b=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,E,b,n),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:t,tracks:E});}let v=f.initPTS,T=f.timescale,S=this.initPTS[o.cc];if(H(v)&&(!S||S.baseTime!==v||S.timescale!==T)){let b=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:T,trackId:b},i.trigger(p.INIT_PTS_FOUND,{frag:o,id:t,initPTS:v,timescale:T,trackId:b});}}if(c&&m){g&&c.type==="audiovideo"&&this.logMuxedErr(o);let E=m.fragments[o.sn-1-m.startSN],v=o.sn===m.startSN,T=!E||o.cc>E.cc;if(r.independent!==false){let{startPTS:S,endPTS:b,startDTS:_,endDTS:D}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:b,startDTS:_,endDTS:D};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!T&&(this.couldBacktrack=true),c.dropped&&c.independent){let I=this.getMainFwdBufferInfo(),k=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,R=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!v&&k<R-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=true);o.setElementaryStreamInfo(c.type,o.start,b,o.start,D,true);}else v&&S-(m.appliedTimelineOffset||0)>Qo&&(o.gap=true);o.setElementaryStreamInfo(c.type,S,b,_,D),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,d,n,v||T);}else if(v||T)o.gap=true;else {this.backtrack(o);return}}if(g){let{startPTS:E,endPTS:v,startDTS:T,endDTS:S}=g;d&&(d.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:T,endDTS:S}),o.setElementaryStreamInfo(be.AUDIO,E,v,T,S),this.bufferFragmentData(g,o,d,n);}if(m&&h!=null&&h.samples.length){let E={id:t,frag:o,details:m,samples:h.samples};i.trigger(p.FRAG_PARSING_METADATA,E);}if(m&&u){let E={id:t,frag:o,details:m,samples:u.samples};i.trigger(p.FRAG_PARSING_USERDATA,E);}}logMuxedErr(e){this.warn(`${Fe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`);}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,c=Vo(n.codec,l);c==="mp4a"&&(c="mp4a.40.5");let u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");let h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5");}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),n.levelCodec=c,n.id=Y.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${n.codec}]`),delete t.audiovideo;}if(a){a.levelCodec=e.videoCodec,a.id=Y.MAIN;let l=a.codec;if(l?.length===4)switch(l){case "hvc1":case "hev1":a.codec="hvc1.1.6.L120.90";break;case "av01":a.codec="av01.0.04M.08";break;case "avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo;}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);let d=Object.keys(t);if(d.length){if(this.hls.trigger(p.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type});});}this.tickImmediate();}getMainFwdBufferInfo(){let e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,Y.MAIN)}get maxBufferLength(){let{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=true,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE;}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===false){let i=e.currentTime;if(ne.isBuffered(e,i)?t=this.getAppendedFrag(i):ne.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}));}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return H(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(H(t)){let i=this.getLevelDetails(),r=this.currentFrag||(i?ms(null,i.fragments,t):null);if(r){let n=r.programDateTime;if(n!==null){let a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Ku=class extends ht{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e;}abort(e){for(let i in this.keyIdToKeyInfo){let r=this.keyIdToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort();}}}detach(){for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e];}}destroy(){this.detach();for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy();}this.keyIdToKeyInfo={};}createKeyLoadError(e,t=x.KEY_LOAD_ERROR,i,r,n){return new Kt({type:Q.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){let a=t[r];if(e.cc<=a.cc&&(!Fe(e)||!Fe(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);let d=Yo(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){let r=yn(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}load(e){return !e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,l))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=_c(n),d=this.keyIdToKeyInfo[o];if((i=d)!=null&&i.decryptdata.key)return n.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if(this.emeController&&(r=d)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(d.decryptdata)){case "usable":case "usable-in-future":return d.keyLoadPromise.then(c=>{let{keyInfo:u}=c;return n.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+Ze(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),d=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case "SAMPLE-AES":case "SAMPLE-AES-CENC":case "SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case "AES-128":case "AES-256":case "AES-256-CTR":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){let a=HT(t.initSegment.data);if(a.length){let o=a[0];o.some(d=>d!==0)?(this.log(`Using keyId found in init segment ${Ze(o)}`),mr.setKeyIdForUri(e.decryptdata.uri,o)):(o=mr.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Ze(o)}`)),e.decryptdata.keyId=o;}}if(!e.decryptdata.keyId&&!Fe(t))return Promise.resolve(i);let n=this.emeController.loadKey(i);return (e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{let{frag:E,keyInfo:v}=m,T=_c(v.decryptdata);if(!E.decryptdata||v!==this.keyIdToKeyInfo[T])return o(this.createKeyLoadError(E,x.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=E.decryptdata.key=new Uint8Array(h.data),E.keyLoader=null,v.loader=null,a({frag:E,keyInfo:v});},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,Te({url:d.url,data:void 0},h)));},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(d,c,u);})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);let a=_c(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],n&&n.destroy();}};function _c(s){if(s.keyFormat!==Je.FAIRPLAY){let e=s.keyId;if(e)return Ze(e)}return s.uri}function Bg(s){let{type:e}=s;switch(e){case ue.AUDIO_TRACK:return Y.AUDIO;case ue.SUBTITLE_TRACK:return Y.SUBTITLE;default:return Y.MAIN}}function Ic(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Vu=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e];}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e);}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders();}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ue.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:d}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ue.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:d});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onLevelsUpdated(e,t){let i=this.loaders[ue.LEVEL];if(i){let r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ue.LEVEL]);}}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let l=this.hls.logger,c=r.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===ue.MANIFEST?n=i.manifestLoadPolicy.default:n=Se({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),H((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===ue.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===ue.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===ue.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){let c=l.partTarget,u=l.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=Se({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)});}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},d={onSuccess:(l,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let m=l.data;c.parsing.start=performance.now(),cs.isMediaPlaylist(m)||u.type!==ue.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h);},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,false,l,h);},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,true,void 0,l);}};r.load(e,o,d);}checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t));}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=Ic(e,i),d=cs.parseMasterPlaylist(a,o);if(d.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,d.playlistParsingError,r,t);return}let{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=d;this.variableList=m,c.forEach(T=>{let{unknownCodecs:S}=T;if(S){let{preferManagedMediaSource:b}=this.hls.config,{audioCodec:_,videoCodec:D}=T;for(let I=S.length;I--;){let k=S[I];Ln(k,"audio",b)?(T.audioCodec=_=_?`${_},${k}`:k,fr.audio[_.substring(0,4)]=2,S.splice(I,1)):Ln(k,"video",b)&&(T.videoCodec=D=D?`${D},${k}`:k,fr.video[D.substring(0,4)]=2,S.splice(I,1));}}});let{AUDIO:g=[],SUBTITLES:E,"CLOSED-CAPTIONS":v}=cs.parseMasterPlaylistMedia(a,o,d);g.length&&!g.some(S=>!S.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new De({}),bitrate:0,url:""})),n.trigger(p.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:E,captions:v,contentSteering:l,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:d,type:l}=i,c=Ic(e,i),u=H(d)?d:H(o)?o:0,h=Bg(i),f=cs.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===ue.MANIFEST){let m={attrs:new De({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+gp(f,0),a.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===ue.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:n});}handleNetworkError(e,t,i=false,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ue.AUDIO_TRACK||e.type===ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let d=x.UNKNOWN,l=false,c=this.getInternalLoader(e);switch(e.type){case ue.MANIFEST:d=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,l=true;break;case ue.LEVEL:d=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,l=false;break;case ue.AUDIO_TRACK:d=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,l=false;break;case ue.SUBTITLE_TRACK:d=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,l=false;break}c&&this.resetInternalLoader(e.type);let u={type:Q.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=t?.url||e.url;u.response=Te({url:h,data:void 0},r);}this.hls.trigger(p.ERROR,u);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:d,level:l,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=r,m=Ic(t,r),g=Bg(r),E=typeof r.level=="number"&&g===Y.MAIN?l:void 0,v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:m,error:v,reason:v.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}e.playlistParsingError=null;}if(!e.fragments.length){let T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:false,url:m,error:T,reason:T.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case ue.MANIFEST:case ue.LEVEL:if(E){if(!c)E=0;else if(c!==o.levels[E]){let T=o.levels.indexOf(c);T>-1&&(E=T);}}o.trigger(p.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:E||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:d===ue.MANIFEST});break;case ue.AUDIO_TRACK:o.trigger(p.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break;case ue.SUBTITLE_TRACK:o.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break}}},gi=class s{static get version(){return Cn}static isMSESupported(){return l0()}static isSupported(){return LA()}static getMediaSource(){return $i()}static get Events(){return p}static get MetadataSchema(){return bt}static get ErrorTypes(){return Q}static get ErrorDetails(){return x}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:vA}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Zu,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=false;let t=this.logger=CT(e.debug||false,"Hls instance",e.assetPlayerId),i=this.config=yA(s.DefaultConfig,e,t);this.userConfig=e,i.progressive&&SA(i,t);let{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:d}=i,l=new o(this),c=this.abrController=new r(this),u=new Oc(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,s):null,m=this.bufferController=new n(this,u),g=this.capLevelController=new a(this),E=new d(this),v=new Vu(this),T=i.contentSteeringController,S=T?new T(this):null,b=this.levelController=new Gu(this,S),_=new $u(this),D=new Ku(this.config,this.logger),I=this.streamController=new Hu(this,u,D),k=this.gapController=new Nu(this,u);g.setStreamController(I),E.setStreamController(I);let R=[v,b,I];f&&R.splice(1,0,f),S&&R.splice(1,0,S),this.networkControllers=R;let L=[c,m,k,g,E,_,u];this.audioTrackController=this.createController(i.audioTrackController,R);let w=i.audioStreamController;w&&R.push(this.audioStreamController=new w(this,u,D)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);let B=i.subtitleStreamController;B&&R.push(this.subtititleStreamController=new B(this,u,D)),this.createController(i.timelineController,L),D.emeController=this.emeController=this.createController(i.emeController,L),this.cmcdController=this.createController(i.cmcdController,L),this.latencyController=this.createController(Bu,L),this.coreComponents=L,R.push(l);let K=l.onErrorOut;typeof K=="function"&&this.on(p.ERROR,K,l),this.on(p.MANIFEST_LOADED,v.onManifestLoaded,v);}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i);}once(e,t,i=this){this._emitter.once(e,t,i);}removeAllListeners(e){this._emitter.removeAllListeners(e);}off(e,t,i=this,r){this._emitter.off(e,t,i,r);}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=true;let r=e===p.ERROR;this.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=false;}}return false}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null;}attachMedia(e){if(!e||"media"in e&&!e.media){let n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.ATTACH_MEDIA_ERROR,fatal:true,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(p.MEDIA_ATTACHING,r);}detachMedia(){this.logger.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,{}),this._media=null;}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(p.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=Wu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e});}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=true,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=false;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering();}));}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering();}));}get inFlightFragments(){let e={[Y.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Y.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Y.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t));}removeLevel(e){this.levelController.removeLevel(e);}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Bb()),e}get levels(){let e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e;}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e;}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e;}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e;}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t);}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e);}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){dy(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated());}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e;}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return ((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return ((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e);}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e);}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:false}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e);}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e;}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e;}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e;}get bufferedToEnd(){var e;return !!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return ((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){let i=ip(t);return ep(e,i,navigator.mediaCapabilities)}};gi.defaultConfig=void 0;var c0=Symbol.for(""),kA=s=>{if(s?.r===c0)return s?._$litStatic$},lh=s=>({_$litStatic$:s,r:c0});var d0=new Map,dh=s=>(e,...t)=>{let i=t.length,r,n,a=[],o=[],d,l=0,c=false;for(;l<i;){for(d=e[l];l<i&&(n=t[l],(r=kA(n))!==void 0);)d+=r+e[++l],c=true;l!==i&&o.push(n),a.push(d),l++;}if(l===i&&a.push(e[i]),c){let u=a.join("$$lit$$");(e=d0.get(u))===void 0&&(a.raw=a,d0.set(u,e=a)),t=o;}return s(e,...t)},u0=dh(chunk2E5GLLOS_cjs.a);var C,h0,f0,Ll,m0,g0,ch,p0,E0,uh,v0,T0,hh,xl,y0,S0,b0,A0,fh,mh,gh,Rl,_0,ph,Eh,I0,vh,kl,Th,Nn,L0,yh,x0,Dl,R0,k0,D0,Cl,C0,M0,w0,P0,O0,F0,N0,pr,Ml,U0,$0;exports.a=class ge extends chunkTKJYRGEU_cjs.a{constructor(){super(...arguments);chunkJHSFSCC2_cjs.e(this,C);this._controls=["play","time","seek","volume","audiotracks","fullscreen","subtitles"];this.popped=false;this._isProcessing=false;this._startedPlaying=false;this._audioTrackCount=0;this._hlsAudioTracks=[];this._hlsAudioTrackIdMap=new Map;this._intersectionObserver=new chunkBTCK3T4L_cjs.a(this,{callback:chunkJHSFSCC2_cjs.g(this,C,b0).bind(this)});this.embedController=new chunkRQN3DXJB_cjs.b(this);this._intersected=false;this._queue=[];this.languageController=new chunk5QLIDHRT_cjs.d(this);}get embed(){return this._embedId}set embed(t){this._embedId!=t&&(this._embedId=t,this.embedController.embed=this.embed,this.updateStylePoster(),this.loadTheme());}get token(){return this._token}set token(t){this._token!=t&&(this._token=t,this.requestUpdate("token"),this.embedController.token=this._token);}set loop(t){this._loop=(t===""||t=="true"||t==true)??false;}get loop(){return this._loop}get controls(){return this._controls}set controls(t){typeof t=="string"?this._controls=t.split(" "):Array.isArray(t)?this._controls=t:this._controls=[],this.requestUpdate("controls");}get cache(){return this._cache}set cache(t){this._cache!=t&&(typeof t=="string"?this._cache=t==="true"||t==="":this._cache=false,this.requestUpdate("caching"),this.embedController.caching=this._cache);}get quality(){return this._quality}set quality(t){this._quality!=t&&(this._quality=t);}get theme(){return this._theme||"default"}set theme(t){this._theme!=t&&(this._theme=t,this.requestUpdate("theme"),this.loadTheme());}get poster(){return !this.embed||!this._embedObj||!chunkJHSFSCC2_cjs.g(this,C,hh).call(this,"thumbnail","jpg")?null:this._poster&&this._poster=="custom"?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"custom_thumbnail")):this._poster&&(!Number.isNaN(parseFloat(this._poster))||!Number.isNaN(parseInt(this._poster)))?this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(t=>t.type=="custom_thumbnail")?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"custom_thumbnail")):`https://image.mave.io/${this.embedController.spaceId}${this.embedController.embedId}.jpg?time=${this._poster}`:this._poster?this._poster:this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"thumbnail"))}set poster(t){t&&(this._poster=t,this.requestUpdate("poster"));}pop(){this.popped=true;}close(){this.popped=false;}set muted(t){let i=(t===""||t=="true"||t==true)??false;this._videoElement?this._videoElement.muted=i:this._queue.push(()=>this._videoElement.muted=i);}get muted(){return this._videoElement?.muted||false}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this._queue.push(()=>this._videoElement.currentTime=t);}get currentTime(){return this._videoElement?this._videoElement?.currentTime:0}get duration(){return new Promise((t,i)=>{if(this._videoElement&&!isNaN(this._videoElement.duration))return t(this._videoElement.duration);let r=()=>{this._videoElement?.addEventListener("loadedmetadata",()=>{this._videoElement&&t(this._videoElement.duration);}),this._videoElement?.addEventListener("error",()=>{i(new Error("Failed to load video metadata."));});};this._videoElement?r():this.addEventListener("mave:video_element_ready",()=>{r();});})}get paused(){return this._videoElement?this._videoElement.paused:true}play(){this._videoElement&&!this.embedController.loading?chunkJHSFSCC2_cjs.g(this,C,Rl).call(this):this._queue.push(()=>chunkJHSFSCC2_cjs.g(this,C,Rl).call(this));}restart(){this._videoElement&&(this.pause(),this._videoElement.currentTime=0,this.play());}pause(){this._videoElement?this._videoElement.pause():this._queue.push(()=>this._videoElement?.pause());}updateStylePoster(){this.poster&&this.style.setProperty("background",`center / contain no-repeat url(${this.poster})`);}connectedCallback(){super.connectedCallback(),this.languageController.locale=this.locale||"en",this.loadTheme(),typeof window<"u"&&window.matchMedia&&(this._contrastQuery=window.matchMedia("(prefers-contrast: more)"),this._contrastQueryHandler=()=>{this._controlColorsKey=void 0,this._controlColors=void 0,this.requestUpdate();},this._contrastQuery.addEventListener?this._contrastQuery.addEventListener("change",this._contrastQueryHandler):this._contrastQuery.addListener&&this._contrastQuery.addListener(this._contrastQueryHandler)),this.addEventListener("mave:video_element_ready",chunkJHSFSCC2_cjs.g(this,C,f0).bind(this));}requestUpdate(t,i){t==="locale"&&(this.languageController.locale=this.locale||"en"),super.requestUpdate(t,i);}disconnectedCallback(){super.disconnectedCallback(),this._contrastQuery&&this._contrastQueryHandler&&(this._contrastQuery.removeEventListener?this._contrastQuery.removeEventListener("change",this._contrastQueryHandler):this._contrastQuery.removeListener&&this._contrastQuery.removeListener(this._contrastQueryHandler)),this._contrastQuery=void 0,this._contrastQueryHandler=void 0,this._metricsInstance?.demonitor(),chunkJHSFSCC2_cjs.g(this,C,uh).call(this),this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._currentAudioTrackMenu=void 0,this._themeMutationObserver?.disconnect(),this._themeMutationObserver=void 0,this._themeMutationObserverRoot=void 0;}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(this.theme&&this.theme.endsWith(".js")?chunkCZUMF7SR_cjs.a.external(this.theme):chunkCZUMF7SR_cjs.a.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=chunkCZUMF7SR_cjs.a.getTheme());}updateEmbed(t){this._embedObj=t,this._audioTrackCount=t.audio_tracks?.length??0,this.updateStylePoster(),chunkJHSFSCC2_cjs.g(this,C,Ll).call(this),this.poster=this._embedObj.settings.poster,this.attributes.getNamedItem("color")||(this.color=this._embedObj.settings.color),this.attributes.getNamedItem("opacity")||(this.opacity=this._embedObj.settings.opacity?this._embedObj.settings.opacity:void 0),this.attributes.getNamedItem("aspect-ratio")||(this.aspect_ratio=this._embedObj.settings.aspect_ratio),this.attributes.getNamedItem("width")||(this.width=this._embedObj.settings.width),this.attributes.getNamedItem("height")||(this.height=this._embedObj.settings.height),this.attributes.getNamedItem("autoplay")||(this.autoplay=this._embedObj.settings.autoplay=="on_show"?"lazy":this._embedObj.settings.autoplay),this.attributes.getNamedItem("controls")||(this.controls=this._embedObj.settings.controls),this.attributes.getNamedItem("loop")||(this.loop=this._embedObj.settings.loop);}get styles(){let t={},i=!!this._embedObj?.subtitles?.length,r=this.subtitles==="none"||this.subtitles==="off"||!i,n=this.controls.includes("volume")||this.controls.includes("full"),a=this.color||this._embedObj?.settings.color,o=this.opacity||this._embedObj?.settings.opacity,d=a?`${a}${o||""}`:void 0;if(d){t["--primary-color"]=d;let f=chunkJHSFSCC2_cjs.g(this,C,L0).call(this,d);f&&(t["--mave-control-bg"]=f.bg,t["--mave-control-fg"]=f.fg,t["--mave-control-fg-muted"]=f.fgMuted,t["--mave-control-fg-weak"]=f.fgWeak,t["--media-control-background"]=f.bg,t["--media-menu-background"]=f.bg,t["--media-settings-menu-background"]=f.bg);}else chunkJHSFSCC2_cjs.g(this,C,yh).call(this)&&(t["--mave-control-bg"]="rgba(0, 0, 0, 0.85)",t["--mave-control-fg"]="rgb(255, 255, 255)",t["--mave-control-fg-muted"]="rgba(255, 255, 255, 0.85)",t["--mave-control-fg-weak"]="rgba(255, 255, 255, 0.6)");if(this.aspect_ratio=="auto"||this._embedObj?.settings.aspect_ratio=="auto"&&!this.aspect_ratio?t["--aspect-ratio"]=this._embedObj?.video.aspect_ratio:t["--aspect-ratio"]=this.aspect_ratio||this._embedObj?.settings.aspect_ratio,(this.width||this._embedObj?.settings.width)&&(t["--width"]=this.width||this._embedObj?.settings.width),(this.height||this._embedObj?.settings.height)&&(t["--height"]=this.height||this._embedObj?.settings.height),!this.controls.includes("full")&&!this.controls.includes("big")&&!this.controls.includes("none")){t["--play-display"]=this.controls.includes("play")?"flex":"none",t["--time-display"]=this.controls.includes("time")?"flex":"none",t["--seek-bar-visibility"]=this.controls.includes("seek")?"visible":"hidden",t["--volume-display"]=this.controls.includes("volume")?"flex":"none",t["--fullscreen-display"]=this.controls.includes("fullscreen")?"flex":"none";let f=this.controls.includes("subtitles")?"flex":"none";t["--media-captions-menu-button-display"]=f,t["--mave-captions-menu-button-display"]=f;}t["--playbackrate-display"]=this.controls.includes("rate")?"flex":"none",(r||this._embedObj?.created_at<1740674988&&!this.subtitles&&!this.active_subtitle)&&(t["--media-captions-menu-button-display"]="none",t["--mave-captions-menu-button-display"]="none"),this.controls.includes("full")||this._embedObj?.settings.controls=="full"&&!this.controls.includes("big")&&!this.controls.includes("none")?t["--media-control-bar-display"]="flex":t["--media-control-bar-display"]="none",this.controls.includes("big")||this._embedObj?.settings.controls=="big"&&!this.controls.includes("full")&&!this.controls.includes("none")?t["--big-button-display"]="flex":t["--big-button-display"]="none",this._embedObj?.video.audio===false?t["--media-mute-button-display"]="none":n?t["--media-mute-button-display"]="flex":t["--media-mute-button-display"]="none";let l=this._audioTrackCount??0,c=this.controls.includes("audiotracks")||this.controls.includes("full"),u=this.audioTracks??"auto",h=c&&l>1;return u==="off"?h=false:u==="on"&&(h=c&&l>0),t["--media-audio-track-menu-button-display"]=h?"flex":"none",chunkQQDH35OW_cjs.a(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return chunk2E5GLLOS_cjs.a`
|
|
1495
|
+
`:(n=i.childNodes)!=null&&n.length?n0(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function rA(s,e,t){let i="http://www.w3.org/ns/ttml#styling",r=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,d)=>{let l=Sc(e,i,d)||Sc(s,i,d)||Sc(r,i,d);return l&&(o[d]=l),o},{})}function Sc(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Pg(s){return new Error(`Could not parse ttml timestamp ${s}`)}function bc(s,e){if(!s)return null;let t=e0(s);return t===null&&(s0.test(s)?t=nA(s,e):r0.test(s)&&(t=aA(s,e))),t}function nA(s,e){let t=s0.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return (t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function aA(s,e){let t=r0.exec(s),i=Number(t[1]);switch(t[2]){case "h":return i*3600;case "m":return i*60;case "ms":return i*1e3;case "f":return i/e.frameRate;case "t":return i/e.tickRate}return i}var lr=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t;}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null);}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName);}reset(){this.cueRanges=[],this.startTime=null;}},Pu=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=true,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Fg(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this);}destroy(){let{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0;}initCea608Parsers(){let e=new lr(this,"textTrack1"),t=new lr(this,"textTrack2"),i=new lr(this,"textTrack3"),r=new lr(this,"textTrack4");this.cea608Parser1=new yl(1,e,t),this.cea608Parser2=new yl(3,i,r);}addCues(e,t,i,r,n){let a=false;for(let o=n.length;o--;){let d=n[o],l=oA(d[0],d[1],t,i);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=true,l/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r);}else {let o=this.Cues.newCue(null,t,i,r);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:o,track:e});}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){let{unparsedVttFrags:o}=this;i===Y.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(d=>{this.initPTS[d.frag.cc]?this.onFragLoaded(p.FRAG_LOADED,d):this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:d.frag,error:new Error("Subtitle discontinuity domain does not match main")});}));}getExistingTrack(e,t){let{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){let n=i.textTracks[r];if(Og(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e);}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,or(i[e]),Qp(i[e],r);else {let d=this.createTextTrack("captions",n,a);d&&(d[e]=true,i[e]=d);}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:false,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]});}createTextTrack(e,t,i){let r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks();}onMediaDetaching(e,t){let i=!!t.transferMedia;if(this.media=null,i)return;let{captionsTracks:r}=this;Object.keys(r).forEach(n=>{or(r[n]),delete r[n];}),this.nonNativeCaptionsTracks={};}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Fg(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset());}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let i=0;i<t.length;i++)or(t[i]);}onSubtitleTracksUpdated(e,t){let i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===Tc);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Up(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){let a=this.media,o=a?zo(a.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&Og(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u);}if(c)or(c);else {let u=a0(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled");}c&&this.textTracks.push(c);}),o!=null&&o.length){let d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${d.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`);}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a});}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{let r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;let n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i);});}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===Y.MAIN){var i,r;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c;}}onFragLoaded(e,t){let{frag:i,payload:r}=t;if(i.type===Y.SUBTITLE)if(r.byteLength){let n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[i.level],d=this.vttCCs;d[i.cc]||(d[i.cc]={start:i.start,prevCC:this.prevCC,new:true},this.prevCC=i.cc),o&&o.textCodec===Tc?this._parseIMSC1(i,r):this._parseVTTs(t);}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:new Error("Empty subtitle payload")});}_parseIMSC1(e,t){let i=this.hls;Mg(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e});},r=>{i.logger.log(`Failed to parse IMSC1: ${r}`),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:e,error:r});});}_parseVTTs(e){var t;let{frag:i,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}let d=this.hls,l=(t=i.initSegment)!=null&&t.data?Dt(i.initSegment.data,new Uint8Array(r)).buffer:r;tA(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i});},c=>{let u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(i,r),d.logger.log(`Failed to parse VTT cue: ${c}`),!(u&&o>i.cc)&&d.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:c});});}_fallbackToIMSC1(e,t){let i=this.tracks[e.level];i.textCodec||Mg(t,this.initPTS[e.cc],()=>{i.textCodec=Tc,this._parseIMSC1(e,t);},()=>{i.textCodec="wvtt";});}_appendCues(e,t){let i=this.hls;if(this.config.renderTextTracksNatively){let r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Xp(r,n));}else {let r=this.tracks[t];if(!r)return;let n=r.default?"default":"subtitles"+t;i.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:n});}}onFragDecrypted(e,t){let{frag:i}=t;i.type===Y.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t);}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={};}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;let{frag:i,samples:r}=t;if(!(i.type===Y.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){let a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();let o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1]);}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){let{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,i));}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(d=>vu(o[d],t,r));}}}extractCea608Data(e){let t=[[],[]],i=e[0]&31,r=2;for(let n=0;n<i;n++){let a=e[r++],o=127&e[r++],d=127&e[r++];if(o===0&&d===0)continue;if((4&a)!==0){let c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(d));}}return t}};function a0(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function Og(s,e){return !!s&&s.kind===a0(e)&&au(e,s)}function oA(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Fg(){return {ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var lA=/\s/,dA={newCue(s,e,t,i){let r=[],n,a,o,d,l,c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=true,d=0,l="",!n.isEmpty()){var u;for(let g=0;g<n.chars.length;g++)lA.test(n.chars[g].uchar)&&o?d++:(l+=n.chars[g].uchar,o=false);n.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;let f=i0(l.trim()),m=oh(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(d*8/32)*10),r.push(a));}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Xp(s,h))),r}};function cA(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return false}var uA=/(\d+)-(\d+)\/(\d+)/,Sl=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||gA,this.controller=new self.AbortController,this.stats=new In;}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null;}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=true,this.controller.abort());}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response);}load(e,t,i){let r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();let n=hA(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&H(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},t.timeout),(Pn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;let f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response));},l-(f-r.loading.start)),!u.ok){let{status:g,statusText:E}=u;throw new Ou(E||"fetch, bad network response",g,u)}r.loading.first=f,r.total=mA(u.headers)||r.total;let m=(h=this.callbacks)==null?void 0:h.onProgress;return m&&H(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,m):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;let m=this.response;if(!m)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);let g=u[o];g&&(r.loaded=r.total=g);let E={url:m.url,data:u,code:m.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!H(t.highWaterMark)&&v(r,e,u,m),(f=this.callbacks)==null||f.onSuccess(E,r,e,m);}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;let f=u&&u.code||0,m=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:m},e,u?u.details:null,r);});}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){let a=new cl,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));let c=l.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}};function hA(s,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Se({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function fA(s){let e=uA.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function mA(s){let e=s.get("Content-Range");if(e){let i=fA(e);if(H(i))return i}let t=s.get("Content-Length");if(t)return parseInt(t)}function gA(s,e){return new self.Request(s.url,e)}var Ou=class extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i;}},pA=/^age:\s*[\d.]+\s*$/im,bl=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new In,this.retryDelay=0;}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null;}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=true,e.abort()));}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader);}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal();}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=false;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,true),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e);}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r);}):this.openAndSendXhr(i,t,e);}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,true);let r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(let o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&H(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send();}readystatechange(){let{context:e,loader:t,stats:i}=this;if(!e||!t)return;let r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){let m=c??t.response;if(m!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);let g=t.responseType==="arraybuffer"?m.byteLength:m.length;i.loaded=i.total=g,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);let E=(a=this.callbacks)==null?void 0:a.onProgress;E&&E(i,e,m,t);let v={url:t.responseURL,data:m,code:l};(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}let u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(rl(u,h,false,f))this.retry(u);else {var d;ye.error(`${l} while loading ${e.url}`),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,i);}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(rl(e,t,true))this.retry(e);else {var i;ye.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);let r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader));}}retry(e){let{context:t,stats:i}=this;this.retryDelay=zu(e,i.retry),i.retry++,ye.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay);}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total);}getCacheAge(){let e=null;if(this.loader&&pA.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null;}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}},EA={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},vA=Te(Te({autoStartLoad:true,startPosition:-1,defaultAudioCodec:void 0,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:true,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:false,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:true,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:void 0,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:false,loader:bl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Mc,bufferController:cu,capLevelController:uu,errorController:Pc,fpsController:Eu,stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:cp,requireKeySystemAccessOnStart:false,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:void 0,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableEmsgKLVMetadata:false,enableID3MetadataCues:true,enableInterstitialPlayback:true,interstitialAppendInPlace:true,interstitialLiveLookAhead:10,useMediaCapabilities:true,preserveManualLevelOnError:false,certLoadPolicy:{default:EA},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},TA()),{},{subtitleStreamController:Iu,subtitleTrackController:Tu,timelineController:Pu,audioStreamController:nu,audioTrackController:ou,emeController:pl,cmcdController:gu,contentSteeringController:pu,interstitialsController:_u});function TA(){return {cueHandler:dA,enableWebVTT:true,enableIMSC1:true,enableCEA708Captions:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function yA(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let i=Fu(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{let o=`${a==="level"?"playlist":a}LoadPolicy`,d=e[o]===void 0,l=[];n.forEach(c=>{let u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&d){l.push(u);let f=i[o].default;switch(e[o]={default:f},c){case "TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case "MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case "RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case "MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${Ae(e[o])}`);}),Te(Te({},i),e)}function Fu(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Fu):Object.keys(s).reduce((e,t)=>(e[t]=Fu(s[t]),e),{}):s}function SA(s,e){let t=s.loader;t!==Sl&&t!==bl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=false):cA()&&(s.loader=Sl,s.progressive=true,s.enableSoftwareAES=true,e.log("[config]: Progressive streaming enabled, using FetchLoader"));}var Qo=2,bA=.1,AA=.05,_A=100,Nu=class extends nl{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=false,this.stalled=null,this.moved=false,this.seeking=false,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0;},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick());},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false});}},this.hls=e,this.fragmentTracker=t,this.registerListeners();}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.BUFFER_APPENDED,this.onBufferAppended,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.BUFFER_APPENDED,this.onBufferAppended,this));}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0;}onMediaAttached(e,t){this.setInterval(_A),this.mediaSource=t.mediaSource;let i=this.media=t.media;at(i,"playing",this.onMediaPlaying),at(i,"waiting",this.onMediaWaiting),at(i,"ended",this.onMediaEnded);}onMediaDetaching(e,t){this.clearInterval();let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"waiting",this.onMediaWaiting),ut(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0;}onBufferAppended(e,t){this.buffered=t.timeRanges;}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;let t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t;}poll(e,t){var i,r;let n=(i=this.hls)==null?void 0:i.config;if(!n)return;let a=this.media;if(!a)return;let{seeking:o}=a,d=this.seeking&&!o,l=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=true,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:false}));return}if(!ne.getBuffered(a).length){this.nudgeRetry=0;return}let u=ne.bufferInfo(a,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){let D=Ng(this.hls.inFlightFragments,e),I=u.len>Qo,k=!h||D||h-e>Qo&&!f.getPartialFragment(e);if(I||k)return;this.moved=false;}let m=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;let I=Math.max(h,u.start||0)-e,R=!!(m!=null&&m.live)?m.targetduration*2:Qo,L=Ho(e,f);if(I>0&&(I<=R||L)){a.paused||this._trySkipBufferHole(L);return}}let g=n.detectStallWithCurrentTimeMs,E=self.performance.now(),v=this.waiting,T=this.stalled;if(T===null)if(v>0&&E-v<g)T=this.stalled=v;else {this.stalled=E;return}let S=E-T;if(!o&&(S>=g||v)&&this.hls){var b;if(((b=this.mediaSource)==null?void 0:b.readyState)==="ended"&&!(m!=null&&m.live)&&Math.abs(e-(m?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(p.MEDIA_ENDED,{stalled:true});return}if(this._reportStall(u),!this.media||!this.hls)return}let _=ne.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,S,e);}stallResolved(e){let t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){let i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=false,this.waiting=0,this.hls.trigger(p.STALL_RESOLVED,{});}}nudgeOnVideoHole(e,t){var i;let r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){let n=ne.bufferedInfo(ne.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){let a=ne.timeRangesToArray(r),o=ne.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){let d=ne.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,c=a[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){let u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${d}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Ho(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);let f=ne.bufferInfo(this.media,e,0);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f});}}}}}_tryFixBufferStall(e,t,i){var r,n;let{fragmentTracker:a,media:o}=this,d=(r=this.hls)==null?void 0:r.config;if(!o||!a||!d)return;let l=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Ho(i,a);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;let u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-i<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e));}adjacentTraversal(e,t){let i=this.fragmentTracker,r=e.nextStart;if(i&&r){let n=i.getFragAtPos(t,Y.MAIN),a=i.getFragAtPos(r,Y.MAIN);if(n&&a)return a.sn-n.sn<2}return false}_reportStall(e){let{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=true;let a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Ae(e)})`);this.warn(a.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:false,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}});}}_trySkipBufferHole(e){var t;let{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;let a=r.currentTime,o=ne.bufferInfo(r,a,0),d=a<o.start?o.start:o.nextStart;if(d&&this.hls){let c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&r.readyState<3,h=d-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let m=false;if(a===0){let g=i.getAppendedFrag(0,Y.MAIN);g&&d<g.end&&(m=true);}if(!m&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||Ng(this.hls.inFlightFragments,d))return 0;let E=false,v=e.end;for(;v<d;){let T=Ho(v,i);if(T)v+=T.duration;else {E=true;break}}if(E)return 0}}let f=Math.max(d+AA,a+bA);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=true,r.currentTime=f,!(e!=null&&e.gap)){let m=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),g={type:Q.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:false,error:m,reason:m.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?g.part=e:g.frag=e),this.hls.trigger(p.ERROR,g);}return f}}return 0}_tryNudgeBuffer(e){let{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;let a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){let o=a+(r+1)*n.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(d.message),i.currentTime=o,t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:d,fatal:false,buffer:e.len,bufferInfo:e});}else {let o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:o,fatal:true,buffer:e.len,bufferInfo:e});}}};function Ng(s,e){let t=Ug(s.main);if(t&&t.start<=e)return t;let i=Ug(s.audio);return i&&i.start<=e?i:null}function Ug(s){if(!s)return null;switch(s.state){case M.IDLE:case M.STOPPED:case M.ENDED:case M.ERROR:return null}return s.frag}function Ho(s,e){return e.getAppendedFrag(s,Y.MAIN)||e.getPartialFragment(s)}var IA=.25;function Uu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Ac(s,e,t,i,r){let n=new s(e,t,"");try{n.value=i,r&&(n.type=r);}catch{n=new s(e,t,Ae(r?Te({type:r},i):i));}return n}var Ko=(()=>{let s=Uu();try{s&&new s(0,Number.POSITIVE_INFINITY,"");}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),$u=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=true,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(p.EVENT_CUE_ENTER,{});},this.hls=e,this._registerListeners();}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null;}_registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}_unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this));}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===false&&(this.removeCues=false);}onMediaAttached(){var e;let t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t);}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&or(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={});}onManifestLoading(){this.dateRangeCuesAppended={};}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Qp(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;let{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Uu();if(a)for(let o=0;o<n.length;o++){let d=n[o].type;if(d===bt.emsg&&!i||!r)continue;let l=xp(n[o].data),c=n[o].pts,u=c+n[o].duration;u>Ko&&(u=Ko),u-c<=0&&(u=c+IA);for(let f=0;f<l.length;f++){let m=l[f];if(!Rp(m)){this.updateId3CueEnds(c,d);let g=Ac(a,c,u,m,d);g&&this.id3Track.addCue(g);}}}}updateId3CueEnds(e,t){var i;let r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let n=r.length;n--;){let a=r[n];a.type===t&&a.startTime<e&&a.endTime===Ko&&(a.endTime=e);}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=a;if(n&&(o||d)){let l;r==="audio"?l=c=>c.type===bt.audioId3&&d:r==="video"?l=c=>c.type===bt.emsg&&o:l=c=>c.type===bt.audioId3&&d||c.type===bt.emsg&&o,vu(n,t,i,l);}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,true);}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details);}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;let{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;let o=Uu();if(i&&r&&!a){let{fragmentStart:g,fragmentEnd:E}=e,v=this.assetCue;v?(v.startTime=g,v.endTime=E):o&&(v=this.assetCue=Ac(o,g,E,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)));}if(!e.hasProgramDateTime)return;let{id3Track:d}=this,{dateRanges:l}=e,c=Object.keys(l),u=this.dateRangeCuesAppended;if(d&&t){var h;if((h=d.cues)!=null&&h.length){let g=Object.keys(u).filter(E=>!c.includes(E));for(let E=g.length;E--;){var f;let v=g[E],T=(f=u[v])==null?void 0:f.cues;delete u[v],T&&Object.keys(T).forEach(S=>{let b=T[S];if(b){b.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(b);}catch{}}});}}else u=this.dateRangeCuesAppended={};}let m=e.fragments[e.fragments.length-1];if(!(c.length===0||!H(m?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let g=0;g<c.length;g++){let E=c[g],v=l[E],T=v.startTime,S=u[E],b=S?.cues||{},_=S?.durationKnown||false,D=Ko,{duration:I,endDate:k}=v;if(k&&I!==null)D=T+I,_=true;else if(v.endOnNext&&!_){let L=c.reduce((w,B)=>{if(B!==v.id){let K=l[B];if(K.class===v.class&&K.startDate>v.startDate&&(!w||v.startDate<w.startDate))return K}return w},null);L&&(D=L.startTime,_=true);}let R=Object.keys(v.attr);for(let L=0;L<R.length;L++){let w=R[L];if(!Dy(w))continue;let B=b[w];if(B)_&&!(S!=null&&S.durationKnown)?B.endTime=D:Math.abs(B.startTime-T)>.01&&(B.startTime=T,B.endTime=D);else if(o){let K=v.attr[w];Cy(w)&&(K=Hg(K));let V=Ac(o,T,D,{key:w,data:K},bt.dateRange);V&&(V.id=E,this.id3Track.addCue(V),b[w]=V,a&&(w==="X-ASSET-LIST"||w==="X-ASSET-URL")&&V.addEventListener("enter",this.onEventCueEnter));}}u[E]={cues:b,dateRange:v,durationKnown:_};}}}},Bu=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=false,this.onTimeupdate=()=>{let{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;let o=this.targetLatency;if(o===null)return;let d=r-o,l=Math.min(this.maxLatency,o+i.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-0.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f);}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1);},this.hls=e,this.config=e.config,this.registerListeners();}get levelDetails(){var e;return ((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){let{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;let t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let e=this.levelDetails;if(e===null||this.hls===null)return null;let{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,d=this.hls.userConfig,l=o&&i||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:a*r);let c=r;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=true;}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;let i=this.levelDetails;if(i===null)return null;let r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){let e=this.levelDetails;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;let i=e.buffered.length;return (i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null;}registerListeners(){let{hls:e}=this;e&&(e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.ERROR,this.onError,this));}unregisterListeners(){let{hls:e}=this;e&&(e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.ERROR,this.onError,this));}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate);}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null);}onManifestLoading(){this._latency=null,this.stallCount=0;}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate);}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"));}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t);}estimateLiveEdge(){let e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Gu=class extends On{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners();}_registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.ERROR,this.onError,this);}_unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.ERROR,this.onError,this);}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy();}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0;}),super.stopLoad();}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1;}onManifestLoading(e,t){this.resetLevels();}onManifestLoaded(e,t){let i=this.hls.config.preferManagedMediaSource,r=[],n={},a={},o=false,d=false,l=false;t.levels.forEach(c=>{let u=c.attrs,{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=Jo(h,i)||void 0),f&&(f=c.videoCodec=ey(f));let{width:m,height:g,unknownCodecs:E}=c,v=E?.length||0;if(o||(o=!!(m&&g)),d||(d=!!f),l||(l=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${u.CODECS}"`);return}let{CODECS:T,"FRAME-RATE":S,"HDCP-LEVEL":b,"PATHWAY-ID":_,RESOLUTION:D,"VIDEO-RANGE":I}=u,R=`${`${_||"."}-`}${c.bitrate}-${D}-${S}-${T}-${I}-${b}`;if(n[R])if(n[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){let L=a[R]+=1;c.attrs["PATHWAY-ID"]=new Array(L+1).join(".");let w=this.createLevel(c);n[R]=w,r.push(w);}else n[R].addGroupId("audio",u.AUDIO),n[R].addGroupId("text",u.SUBTITLES);else {let L=this.createLevel(c);n[R]=L,a[R]=1,r.push(L);}}),this.filterAndSortMediaOptions(r,t,o,d,l);}createLevel(e){let t=new fs(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){let r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=Jg(r,[]);}return t}isAudioSupported(e){return Ln(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Ln(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){var a;let o=[],d=[],l=e,c=((a=t.stats)==null?void 0:a.parsing)||{};if((i||r)&&n&&(l=l.filter(({videoCodec:T,videoRange:S,width:b,height:_})=>(!!T||!!(b&&_))&&cy(S))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let T="no level with compatible codecs found in manifest",S=T;t.levels.length&&(S=`one or more CODECS in variant not supported: ${Ae(t.levels.map(_=>_.attrs.CODECS).filter((_,D,I)=>I.indexOf(_)===D))}`,this.warn(S),T+=` (${S})`);let b=new Error(T);this.hls.trigger(p.ERROR,{type:Q.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:b,reason:S});}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(T=>!T.audioCodec||this.isAudioSupported(T.audioCodec)),$g(o)),t.subtitles&&(d=t.subtitles,$g(d));let u=l.slice(0);l.sort((T,S)=>{if(T.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"])return (T.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&T.height!==S.height)return T.height-S.height;if(T.frameRate!==S.frameRate)return T.frameRate-S.frameRate;if(T.videoRange!==S.videoRange)return el.indexOf(T.videoRange)-el.indexOf(S.videoRange);if(T.videoCodec!==S.videoCodec){let b=Om(T.videoCodec),_=Om(S.videoCodec);if(b!==_)return _-b}if(T.uri===S.uri&&T.codecSet!==S.codecSet){let b=Zo(T.codecSet),_=Zo(S.codecSet);if(b!==_)return _-b}return T.averageBitrate!==S.averageBitrate?T.averageBitrate-S.averageBitrate:0});let h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==u.length)){for(let T=0;T<u.length;T++)if(u[T].pathwayId===l[0].pathwayId){h=u[T];break}}this._levels=l;for(let T=0;T<l.length;T++)if(l[T]===h){var f;this._firstLevel=T;let S=h.bitrate,b=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${S}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){let _=Math.min(S,this.hls.config.abrEwmaDefaultEstimateMax);_>b&&b===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=_);}break}let m=n&&!r,g=this.hls.config,E=!!(g.audioStreamController&&g.audioTrackController),v={levels:l,audioTracks:o,subtitleTracks:d,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:E&&!m&&o.some(T=>!!T.url)};c.end=performance.now(),this.hls.trigger(p.MANIFEST_PARSED,v);}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1);}let i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);let d={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(p.LEVEL_SWITCHING,d);let l=a.details;if(!l||l.live){let c=this.switchParams(a.uri,r?.details,l);this.loadPlaylist(c);}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e);}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e;}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e;}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){let t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i;}}onError(e,t){t.fatal||!t.context||t.context.type===ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t);}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===Y.MAIN){let i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;let r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0);}}onLevelLoaded(e,t){var i;let{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=true);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let d=a.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(r,t,d);}else (i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=true);}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e);}loadingPlaylist(e,t){super.loadingPlaylist(e,t);let i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(p.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null});}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e);}removeLevel(e){var t;if(this._levels.length===1)return;let i=this._levels.filter((n,a)=>a!==e?true:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),false));vp(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);let r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(p.LEVELS_UPDATED,{levels:i});}onLevelsUpdated(e,{levels:t}){this._levels=t;}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(p.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}));}};function $g(s){let e={};s.forEach(t=>{let i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++;});}function o0(){return self.SourceBuffer||self.WebKitSourceBuffer}function l0(){if(!$i())return false;let e=o0();return !e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function LA(){if(!l0())return false;let s=$i();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(xn(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(xn(e,"audio"))))}function xA(){var s;let e=o0();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var RA=100,Hu=class extends Dn{constructor(e,t,i){super(e,t,i,"stream-controller",Y.MAIN),this.audioCodecSwap=false,this.level=-1,this._forceStartLoad=false,this._hasEnoughToStart=false,this.altAudio=0,this.audioOnly=false,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=false,this.backtrackFragment=null,this.audioCodecSwitch=false,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick();},this.onMediaSeeked=()=>{let r=this.media,n=r?r.currentTime:null;if(n===null||!H(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;let a=this.getFwdBufferInfoAtPos(r,n,Y.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick();},this.registerListeners();}registerListeners(){super.registerListeners();let{hls:e}=this;e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this);}unregisterListeners(){super.unregisterListeners();let{hls:e}=this;e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this);}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying();}startLoad(e,t){if(this.levels){let{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(RA),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=true):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t;}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=M.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick();}else this._forceStartLoad=true,this.state=M.STOPPED;}stopLoad(){this._forceStartLoad=false,super.stopLoad();}doTick(){switch(this.state){case M.WAITING_LEVEL:{let{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd();}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===false&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged();}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;let a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;let d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){let g={};this.altAudio===2&&(g.type="video"),this.hls.trigger(p.BUFFER_EOS,g),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let l=a.details;if(!l||this.state===M.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=M.WAITING_LEVEL,this.startFragRequested=false;return}let c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&Fe(f)&&this.fragmentTracker.getState(f)!==We.OK){var m;let E=((m=this.backtrackFragment)!=null?m:f).sn-l.startSN,v=l.fragments[E-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v));}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let E=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(E===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,E,Y.MAIN);}f=this.getNextFragmentLoopLoading(f,l,o,Y.MAIN,u);}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h));}loadFragment(e,t,i){let r=this.fragmentTracker.getState(e);r===We.NOT_LOADED||r===We.PARTIAL?Fe(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e);}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Y.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY);}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:i=0;}else i=0;let a=this.getBufferedFrag(t.currentTime+i);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(a.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY);}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition();}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null);}onMediaAttached(e,t){super.onMediaAttached(e,t);let i=t.media;at(i,"playing",this.onMediaPlaying),at(i,"seeked",this.onMediaSeeked);}onMediaDetaching(e,t){let{media:i}=this;i&&(ut(i,"playing",this.onMediaPlaying),ut(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=false);}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.couldBacktrack=false,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=false;}onManifestParsed(e,t){let i=false,r=false;for(let n=0;n<t.levels.length;n++){let a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1);}this.audioCodecSwitch=i&&r&&!xA(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=false;}onLevelLoading(e,t){let{levels:i}=this;if(!i||this.state!==M.IDLE)return;let r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL);}onLevelLoaded(e,t){var i;let{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,d=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${d}`);let l=t.levelInfo,c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details);}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,u),this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:a}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=M.IDLE;}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick();}synchronizeToLiveEdge(e){let{config:t,media:i}=this;if(!i)return;let r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,d=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!d)){let c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;let u=ne.bufferInfo(i,r,0);if(!((l=u.buffered)!=null&&l.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}let{nextStart:f}=ne.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f);}else i.currentTime=r;}}_handleFragmentLoadProgress(e){var t;let i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}let o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}let d=o.details;if(!d){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}let l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ml(this.hls,Y.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,g=m!==-1,E=new kn(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,g),v=this.initPTS[i.cc];f.push(n,u,h,l,i,r,d.totalduration,c,E,v);}onAudioTrackSwitching(e,t){let i=this.hls,r=this.altAudio!==0;if(il(t.url,i))this.altAudio=1;else {if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState();}else this.audioOnly&&this.resetTransmuxer();if(r){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(p.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(p.AUDIO_TRACK_SWITCHED,t);}),i.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(p.AUDIO_TRACK_SWITCHED,t);}}onAudioTrackSwitched(e,t){let i=il(t.url,this.hls);if(i){let r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r);}this.altAudio=i?2:0,this.tick();}onBufferCreated(e,t){let i=t.tracks,r,n,a=false;for(let o in i){let d=i[o];if(d.id==="main"){if(n=o,r=d,o==="video"){let l=i[o];l&&(this.videoBuffer=l.buffer);}}else a=true;}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media;}onFragBuffered(e,t){let{frag:i,part:r}=t,n=i.type===Y.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}let o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Fe(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r);}let a=this.media;a&&(!this._hasEnoughToStart&&ne.getBuffered(a).length&&(this._hasEnoughToStart=true,this.seekToStartPos()),n&&this.tick());}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Y.MAIN,t);break;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ue.LEVEL&&(this.state=M.IDLE);break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=true:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this._hasEnoughToStart||(this.startFragRequested=false,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate();}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||!this.altAudio){let i=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,Y.MAIN),this.tick());}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels;}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap;}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}let r=this.timelineOffset;r&&i&&(i+=r);let n=this.getLevelDetails(),a=ne.getBuffered(e),o=a.length?a.start(0):0,d=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${d} to match buffer start`),i+=d,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i);}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=true,this._doFragLoad(e,t).then(i=>{let{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=false,this.bitrateTest=false;let a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,i),n.bitrateTest=false;}).catch(i=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(i),this.resetFragmentLoading(e));});}_handleTransmuxComplete(e){let t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}let{frag:o,part:d,level:l}=a,{video:c,text:u,id3:h,initSegment:f}=r,{details:m}=l,g=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=M.PARSING,f){let E=f.tracks;if(E){let b=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,E,b,n),i.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:t,tracks:E});}let v=f.initPTS,T=f.timescale,S=this.initPTS[o.cc];if(H(v)&&(!S||S.baseTime!==v||S.timescale!==T)){let b=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:T,trackId:b},i.trigger(p.INIT_PTS_FOUND,{frag:o,id:t,initPTS:v,timescale:T,trackId:b});}}if(c&&m){g&&c.type==="audiovideo"&&this.logMuxedErr(o);let E=m.fragments[o.sn-1-m.startSN],v=o.sn===m.startSN,T=!E||o.cc>E.cc;if(r.independent!==false){let{startPTS:S,endPTS:b,startDTS:_,endDTS:D}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:b,startDTS:_,endDTS:D};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!T&&(this.couldBacktrack=true),c.dropped&&c.independent){let I=this.getMainFwdBufferInfo(),k=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,R=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!v&&k<R-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=true);o.setElementaryStreamInfo(c.type,o.start,b,o.start,D,true);}else v&&S-(m.appliedTimelineOffset||0)>Qo&&(o.gap=true);o.setElementaryStreamInfo(c.type,S,b,_,D),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,d,n,v||T);}else if(v||T)o.gap=true;else {this.backtrack(o);return}}if(g){let{startPTS:E,endPTS:v,startDTS:T,endDTS:S}=g;d&&(d.elementaryStreams[be.AUDIO]={startPTS:E,endPTS:v,startDTS:T,endDTS:S}),o.setElementaryStreamInfo(be.AUDIO,E,v,T,S),this.bufferFragmentData(g,o,d,n);}if(m&&h!=null&&h.samples.length){let E={id:t,frag:o,details:m,samples:h.samples};i.trigger(p.FRAG_PARSING_METADATA,E);}if(m&&u){let E={id:t,frag:o,details:m,samples:u.samples};i.trigger(p.FRAG_PARSING_USERDATA,E);}}logMuxedErr(e){this.warn(`${Fe(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`);}_bufferInitSegment(e,t,i,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,c=Vo(n.codec,l);c==="mp4a"&&(c="mp4a.40.5");let u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");let h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5");}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),n.levelCodec=c,n.id=Y.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${n.codec}]`),delete t.audiovideo;}if(a){a.levelCodec=e.videoCodec,a.id=Y.MAIN;let l=a.codec;if(l?.length===4)switch(l){case "hvc1":case "hev1":a.codec="hvc1.1.6.L120.90";break;case "av01":a.codec="av01.0.04M.08";break;case "avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo;}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);let d=Object.keys(t);if(d.length){if(this.hls.trigger(p.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:i,part:null,chunkMeta:r,parent:i.type});});}this.tickImmediate();}getMainFwdBufferInfo(){let e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,Y.MAIN)}get maxBufferLength(){let{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=true,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE;}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===false){let i=e.currentTime;if(ne.isBuffered(e,i)?t=this.getAppendedFrag(i):ne.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;let r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}));}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return H(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;let t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(H(t)){let i=this.getLevelDetails(),r=this.currentFrag||(i?ms(null,i.fragments,t):null);if(r){let n=r.programDateTime;if(n!==null){let a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},Ku=class extends ht{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e;}abort(e){for(let i in this.keyIdToKeyInfo){let r=this.keyIdToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort();}}}detach(){for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e];}}destroy(){this.detach();for(let e in this.keyIdToKeyInfo){let t=this.keyIdToKeyInfo[e].loader;t&&t.destroy();}this.keyIdToKeyInfo={};}createKeyLoadError(e,t=x.KEY_LOAD_ERROR,i,r,n){return new Kt({type:Q.NETWORK_ERROR,details:t,fatal:false,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){let a=t[r];if(e.cc<=a.cc&&(!Fe(e)||!Fe(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);let d=Yo(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){let r=yn(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}load(e){return !e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,l))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=_c(n),d=this.keyIdToKeyInfo[o];if((i=d)!=null&&i.decryptdata.key)return n.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if(this.emeController&&(r=d)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(d.decryptdata)){case "usable":case "usable-in-future":return d.keyLoadPromise.then(c=>{let{keyInfo:u}=c;return n.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+Ze(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),d=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case "SAMPLE-AES":case "SAMPLE-AES-CENC":case "SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case "AES-128":case "AES-256":case "AES-256-CTR":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,x.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){let a=HT(t.initSegment.data);if(a.length){let o=a[0];o.some(d=>d!==0)?(this.log(`Using keyId found in init segment ${Ze(o)}`),mr.setKeyIdForUri(e.decryptdata.uri,o)):(o=mr.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${Ze(o)}`)),e.decryptdata.keyId=o;}}if(!e.decryptdata.keyId&&!Fe(t))return Promise.resolve(i);let n=this.emeController.loadKey(i);return (e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){let i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,g)=>{let{frag:E,keyInfo:v}=m,T=_c(v.decryptdata);if(!E.decryptdata||v!==this.keyIdToKeyInfo[T])return o(this.createKeyLoadError(E,x.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),g));v.decryptdata.key=E.decryptdata.key=new Uint8Array(h.data),E.keyLoader=null,v.loader=null,a({frag:E,keyInfo:v});},onError:(h,f,m,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,Te({url:d.url,data:void 0},h)));},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m));},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,x.INTERNAL_ABORTED,new Error("key loading aborted"),m));}};n.load(d,c,u);})}resetLoader(e){let{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);let a=_c(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],n&&n.destroy();}};function _c(s){if(s.keyFormat!==Je.FAIRPLAY){let e=s.keyId;if(e)return Ze(e)}return s.uri}function Bg(s){let{type:e}=s;switch(e){case ue.AUDIO_TRACK:return Y.AUDIO;case ue.SUBTITLE_TRACK:return Y.SUBTITLE;default:return Y.MAIN}}function Ic(s,e){let t=s.url;return (t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Vu=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners();}startLoad(e){}stopLoad(){this.destroyInternalLoaders();}registerListeners(){let{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}unregisterListeners(){let{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this);}createInternalLoader(e){let t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e];}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e);}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders();}onManifestLoading(e,t){let{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ue.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null});}onLevelLoading(e,t){let{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:d}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ue.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:d});}onAudioTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onSubtitleTrackLoading(e,t){let{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o});}onLevelsUpdated(e,t){let i=this.loaders[ue.LEVEL];if(i){let r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ue.LEVEL]);}}load(e){var t;let i=this.hls.config,r=this.getInternalLoader(e);if(r){let l=this.hls.logger,c=r.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort();}let n;if(e.type===ue.MANIFEST?n=i.manifestLoadPolicy.default:n=Se({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),H((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===ue.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===ue.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===ue.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){let c=l.partTarget,u=l.targetduration;if(c&&u){let h=Math.max(c*3,u*.8)*1e3;n=Se({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)});}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},d={onSuccess:(l,c,u,h)=>{let f=this.getInternalLoader(u);this.resetInternalLoader(u.type);let m=l.data;c.parsing.start=performance.now(),cs.isMediaPlaylist(m)||u.type!==ue.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h);},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,false,l,h);},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,true,void 0,l);}};r.load(e,o,d);}checkAutostartLoad(){if(!this.hls)return;let{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t));}handleMasterPlaylist(e,t,i,r){let n=this.hls,a=e.data,o=Ic(e,i),d=cs.parseMasterPlaylist(a,o);if(d.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,d.playlistParsingError,r,t);return}let{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=d;this.variableList=m,c.forEach(T=>{let{unknownCodecs:S}=T;if(S){let{preferManagedMediaSource:b}=this.hls.config,{audioCodec:_,videoCodec:D}=T;for(let I=S.length;I--;){let k=S[I];Ln(k,"audio",b)?(T.audioCodec=_=_?`${_},${k}`:k,fr.audio[_.substring(0,4)]=2,S.splice(I,1)):Ln(k,"video",b)&&(T.videoCodec=D=D?`${D},${k}`:k,fr.video[D.substring(0,4)]=2,S.splice(I,1));}}});let{AUDIO:g=[],SUBTITLES:E,"CLOSED-CAPTIONS":v}=cs.parseMasterPlaylistMedia(a,o,d);g.length&&!g.some(S=>!S.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new De({}),bitrate:0,url:""})),n.trigger(p.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:E,captions:v,contentSteering:l,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m});}handleTrackOrLevelPlaylist(e,t,i,r,n){let a=this.hls,{id:o,level:d,type:l}=i,c=Ic(e,i),u=H(d)?d:H(o)?o:0,h=Bg(i),f=cs.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===ue.MANIFEST){let m={attrs:new De({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+gp(f,0),a.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null});}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n);}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===ue.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:n});}handleNetworkError(e,t,i=false,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ue.AUDIO_TRACK||e.type===ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let d=x.UNKNOWN,l=false,c=this.getInternalLoader(e);switch(e.type){case ue.MANIFEST:d=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,l=true;break;case ue.LEVEL:d=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,l=false;break;case ue.AUDIO_TRACK:d=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,l=false;break;case ue.SUBTITLE_TRACK:d=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,l=false;break}c&&this.resetInternalLoader(e.type);let u={type:Q.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=t?.url||e.url;u.response=Te({url:h,data:void 0},r);}this.hls.trigger(p.ERROR,u);}handlePlaylistLoaded(e,t,i,r,n,a){let o=this.hls,{type:d,level:l,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=r,m=Ic(t,r),g=Bg(r),E=typeof r.level=="number"&&g===Y.MAIN?l:void 0,v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:false,url:m,error:v,reason:v.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}e.playlistParsingError=null;}if(!e.fragments.length){let T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(p.ERROR,{type:Q.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:false,url:m,error:T,reason:T.message,response:t,context:r,level:E,parent:g,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case ue.MANIFEST:case ue.LEVEL:if(E){if(!c)E=0;else if(c!==o.levels[E]){let T=o.levels.indexOf(c);T>-1&&(E=T);}}o.trigger(p.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:E||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:d===ue.MANIFEST});break;case ue.AUDIO_TRACK:o.trigger(p.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break;case ue.SUBTITLE_TRACK:o.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break}}},gi=class s{static get version(){return Cn}static isMSESupported(){return l0()}static isSupported(){return LA()}static getMediaSource(){return $i()}static get Events(){return p}static get MetadataSchema(){return bt}static get ErrorTypes(){return Q}static get ErrorDetails(){return x}static get DefaultConfig(){return s.defaultConfig?s.defaultConfig:vA}static set DefaultConfig(e){s.defaultConfig=e;}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Zu,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=false;let t=this.logger=CT(e.debug||false,"Hls instance",e.assetPlayerId),i=this.config=yA(s.DefaultConfig,e,t);this.userConfig=e,i.progressive&&SA(i,t);let{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:d}=i,l=new o(this),c=this.abrController=new r(this),u=new Oc(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,s):null,m=this.bufferController=new n(this,u),g=this.capLevelController=new a(this),E=new d(this),v=new Vu(this),T=i.contentSteeringController,S=T?new T(this):null,b=this.levelController=new Gu(this,S),_=new $u(this),D=new Ku(this.config,this.logger),I=this.streamController=new Hu(this,u,D),k=this.gapController=new Nu(this,u);g.setStreamController(I),E.setStreamController(I);let R=[v,b,I];f&&R.splice(1,0,f),S&&R.splice(1,0,S),this.networkControllers=R;let L=[c,m,k,g,E,_,u];this.audioTrackController=this.createController(i.audioTrackController,R);let w=i.audioStreamController;w&&R.push(this.audioStreamController=new w(this,u,D)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);let B=i.subtitleStreamController;B&&R.push(this.subtititleStreamController=new B(this,u,D)),this.createController(i.timelineController,L),D.emeController=this.emeController=this.createController(i.emeController,L),this.cmcdController=this.createController(i.cmcdController,L),this.latencyController=this.createController(Bu,L),this.coreComponents=L,R.push(l);let K=l.onErrorOut;typeof K=="function"&&this.on(p.ERROR,K,l),this.on(p.MANIFEST_LOADED,v.onManifestLoaded,v);}createController(e,t){if(e){let i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i);}once(e,t,i=this){this._emitter.once(e,t,i);}removeAllListeners(e){this._emitter.removeAllListeners(e);}off(e,t,i=this,r){this._emitter.off(e,t,i,r);}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=true;let r=e===p.ERROR;this.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=false;}}return false}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null;}attachMedia(e){if(!e||"media"in e&&!e.media){let n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(p.ERROR,{type:Q.OTHER_ERROR,details:x.ATTACH_MEDIA_ERROR,fatal:true,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());let t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(p.MEDIA_ATTACHING,r);}detachMedia(){this.logger.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,{}),this._media=null;}transferMedia(){this._media=null;let e=this.bufferController.transferMedia();return this.trigger(p.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();let t=this.media,i=this._url,r=this._url=Wu.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e});}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=true,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=false;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering();}));}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering();}));}get inFlightFragments(){let e={[Y.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Y.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Y.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec();}recoverMediaError(){this.logger.log("recoverMediaError");let e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t));}removeLevel(e){this.levelController.removeLevel(e);}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Bb()),e}get levels(){let e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch();}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch();}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e;}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e;}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e;}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e;}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t);}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e);}get abrEwmaDefaultEstimate(){let{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated());}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){dy(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated());}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this,r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e;}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return ((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return ((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e);}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e);}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:false}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e);}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e;}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e;}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e;}get bufferedToEnd(){var e;return !!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return ((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){let i=ip(t);return ep(e,i,navigator.mediaCapabilities)}};gi.defaultConfig=void 0;var c0=Symbol.for(""),kA=s=>{if(s?.r===c0)return s?._$litStatic$},lh=s=>({_$litStatic$:s,r:c0});var d0=new Map,dh=s=>(e,...t)=>{let i=t.length,r,n,a=[],o=[],d,l=0,c=false;for(;l<i;){for(d=e[l];l<i&&(n=t[l],(r=kA(n))!==void 0);)d+=r+e[++l],c=true;l!==i&&o.push(n),a.push(d),l++;}if(l===i&&a.push(e[i]),c){let u=a.join("$$lit$$");(e=d0.get(u))===void 0&&(a.raw=a,d0.set(u,e=a)),t=o;}return s(e,...t)},u0=dh(chunk2E5GLLOS_cjs.a);var C,h0,f0,Ll,m0,g0,ch,p0,E0,uh,v0,T0,hh,xl,y0,S0,b0,A0,fh,mh,gh,Rl,_0,ph,Eh,I0,vh,kl,Th,Nn,L0,yh,x0,Dl,R0,k0,D0,Cl,C0,M0,w0,P0,O0,F0,N0,pr,Ml,U0,$0;exports.a=class ge extends chunkTKJYRGEU_cjs.a{constructor(){super(...arguments);chunkJHSFSCC2_cjs.e(this,C);this._controls=["play","time","seek","volume","audiotracks","fullscreen","subtitles"];this.popped=false;this._isProcessing=false;this._startedPlaying=false;this._audioTrackCount=0;this._hlsAudioTracks=[];this._hlsAudioTrackIdMap=new Map;this._intersectionObserver=new chunkBTCK3T4L_cjs.a(this,{callback:chunkJHSFSCC2_cjs.g(this,C,b0).bind(this)});this.embedController=new chunkRQN3DXJB_cjs.b(this);this._intersected=false;this._queue=[];this.languageController=new chunk5QLIDHRT_cjs.d(this);}get embed(){return this._embedId}set embed(t){this._embedId!=t&&(this._embedId=t,this.embedController.embed=this.embed,this.updateStylePoster(),this.loadTheme());}get token(){return this._token}set token(t){this._token!=t&&(this._token=t,this.requestUpdate("token"),this.embedController.token=this._token);}set loop(t){this._loop=(t===""||t=="true"||t==true)??false;}get loop(){return this._loop}get controls(){return this._controls}set controls(t){typeof t=="string"?this._controls=t.split(" "):Array.isArray(t)?this._controls=t:this._controls=[],this.requestUpdate("controls");}get cache(){return this._cache}set cache(t){this._cache!=t&&(typeof t=="string"?this._cache=t==="true"||t==="":this._cache=false,this.requestUpdate("caching"),this.embedController.caching=this._cache);}get quality(){return this._quality}set quality(t){this._quality!=t&&(this._quality=t);}get theme(){return this._theme||"default"}set theme(t){this._theme!=t&&(this._theme=t,this.requestUpdate("theme"),this.loadTheme());}get poster(){return !this.embed||!this._embedObj||!chunkJHSFSCC2_cjs.g(this,C,hh).call(this,"thumbnail","jpg")?null:this._poster&&this._poster=="custom"?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"custom_thumbnail")):this._poster&&(!Number.isNaN(parseFloat(this._poster))||!Number.isNaN(parseInt(this._poster)))?this._embedObj.poster&&this._embedObj.poster.renditions&&this._embedObj.poster.renditions.find(t=>t.type=="custom_thumbnail")?this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"custom_thumbnail")):`https://image.mave.io/${this.embedController.spaceId}${this.embedController.embedId}.jpg?time=${this._poster}`:this._poster?this._poster:this.embedController.embedFile(chunkJHSFSCC2_cjs.g(this,C,xl).call(this,"thumbnail"))}set poster(t){t&&(this._poster=t,this.requestUpdate("poster"));}pop(){this.popped=true;}close(){this.popped=false;}set muted(t){let i=(t===""||t=="true"||t==true)??false;this._videoElement?this._videoElement.muted=i:this._queue.push(()=>this._videoElement.muted=i);}get muted(){return this._videoElement?.muted||false}set currentTime(t){this._videoElement?this._videoElement.currentTime=t:this._queue.push(()=>this._videoElement.currentTime=t);}get currentTime(){return this._videoElement?this._videoElement?.currentTime:0}get duration(){return new Promise((t,i)=>{if(this._videoElement&&!isNaN(this._videoElement.duration))return t(this._videoElement.duration);let r=()=>{this._videoElement?.addEventListener("loadedmetadata",()=>{this._videoElement&&t(this._videoElement.duration);}),this._videoElement?.addEventListener("error",()=>{i(new Error("Failed to load video metadata."));});};this._videoElement?r():this.addEventListener("mave:video_element_ready",()=>{r();});})}get paused(){return this._videoElement?this._videoElement.paused:true}play(){this._videoElement&&!this.embedController.loading?chunkJHSFSCC2_cjs.g(this,C,Rl).call(this):this._queue.push(()=>chunkJHSFSCC2_cjs.g(this,C,Rl).call(this));}restart(){this._videoElement&&(this.pause(),this._videoElement.currentTime=0,this.play());}pause(){this._videoElement?this._videoElement.pause():this._queue.push(()=>this._videoElement?.pause());}updateStylePoster(){this.poster&&this.style.setProperty("background",`center / contain no-repeat url(${this.poster})`);}connectedCallback(){super.connectedCallback(),this.languageController.locale=this.locale||"en",this.loadTheme(),typeof window<"u"&&window.matchMedia&&(this._contrastQuery=window.matchMedia("(prefers-contrast: more)"),this._contrastQueryHandler=()=>{this._controlColorsKey=void 0,this._controlColors=void 0,this.requestUpdate();},this._contrastQuery.addEventListener?this._contrastQuery.addEventListener("change",this._contrastQueryHandler):this._contrastQuery.addListener&&this._contrastQuery.addListener(this._contrastQueryHandler)),this.addEventListener("mave:video_element_ready",chunkJHSFSCC2_cjs.g(this,C,f0).bind(this));}requestUpdate(t,i){t==="locale"&&(this.languageController.locale=this.locale||"en"),super.requestUpdate(t,i);}disconnectedCallback(){super.disconnectedCallback(),this._contrastQuery&&this._contrastQueryHandler&&(this._contrastQuery.removeEventListener?this._contrastQuery.removeEventListener("change",this._contrastQueryHandler):this._contrastQuery.removeListener&&this._contrastQuery.removeListener(this._contrastQueryHandler)),this._contrastQuery=void 0,this._contrastQueryHandler=void 0,this._metricsInstance?.demonitor(),chunkJHSFSCC2_cjs.g(this,C,uh).call(this),this._cleanupHlsAudioTracks?.(),this._cleanupHlsAudioTracks=void 0,this._pendingAudioTrackSetup!=null&&(cancelAnimationFrame(this._pendingAudioTrackSetup),this._pendingAudioTrackSetup=void 0),this._hlsAudioTrackIdMap.clear(),this._hlsAudioTracks=[],this._currentAudioTrackMenu=void 0,this._themeMutationObserver?.disconnect(),this._themeMutationObserver=void 0,this._themeMutationObserverRoot=void 0;}loadTheme(){this.embed&&this._themeLoaded!=this.theme&&(this.theme&&this.theme.endsWith(".js")?chunk5QB22TB5_cjs.a.external(this.theme):chunk5QB22TB5_cjs.a.get(this.theme,`${this.embedController.cdnRoot}/themes/player`),this._themeLoaded=chunk5QB22TB5_cjs.a.getTheme());}updateEmbed(t){this._embedObj=t,this._audioTrackCount=t.audio_tracks?.length??0,this.updateStylePoster(),chunkJHSFSCC2_cjs.g(this,C,Ll).call(this),this.poster=this._embedObj.settings.poster,this.attributes.getNamedItem("color")||(this.color=this._embedObj.settings.color),this.attributes.getNamedItem("opacity")||(this.opacity=this._embedObj.settings.opacity?this._embedObj.settings.opacity:void 0),this.attributes.getNamedItem("aspect-ratio")||(this.aspect_ratio=this._embedObj.settings.aspect_ratio),this.attributes.getNamedItem("width")||(this.width=this._embedObj.settings.width),this.attributes.getNamedItem("height")||(this.height=this._embedObj.settings.height),this.attributes.getNamedItem("autoplay")||(this.autoplay=this._embedObj.settings.autoplay=="on_show"?"lazy":this._embedObj.settings.autoplay),this.attributes.getNamedItem("controls")||(this.controls=this._embedObj.settings.controls),this.attributes.getNamedItem("loop")||(this.loop=this._embedObj.settings.loop);}get styles(){let t={},i=!!this._embedObj?.subtitles?.length,r=this.subtitles==="none"||this.subtitles==="off"||!i,n=this.controls.includes("volume")||this.controls.includes("full"),a=this.color||this._embedObj?.settings.color,o=this.opacity||this._embedObj?.settings.opacity,d=a?`${a}${o||""}`:void 0;if(d){t["--primary-color"]=d;let f=chunkJHSFSCC2_cjs.g(this,C,L0).call(this,d);f&&(t["--mave-control-bg"]=f.bg,t["--mave-control-fg"]=f.fg,t["--mave-control-fg-muted"]=f.fgMuted,t["--mave-control-fg-weak"]=f.fgWeak,t["--media-control-background"]=f.bg,t["--media-menu-background"]=f.bg,t["--media-settings-menu-background"]=f.bg);}else chunkJHSFSCC2_cjs.g(this,C,yh).call(this)&&(t["--mave-control-bg"]="rgba(0, 0, 0, 0.85)",t["--mave-control-fg"]="rgb(255, 255, 255)",t["--mave-control-fg-muted"]="rgba(255, 255, 255, 0.85)",t["--mave-control-fg-weak"]="rgba(255, 255, 255, 0.6)");if(this.aspect_ratio=="auto"||this._embedObj?.settings.aspect_ratio=="auto"&&!this.aspect_ratio?t["--aspect-ratio"]=this._embedObj?.video.aspect_ratio:t["--aspect-ratio"]=this.aspect_ratio||this._embedObj?.settings.aspect_ratio,(this.width||this._embedObj?.settings.width)&&(t["--width"]=this.width||this._embedObj?.settings.width),(this.height||this._embedObj?.settings.height)&&(t["--height"]=this.height||this._embedObj?.settings.height),!this.controls.includes("full")&&!this.controls.includes("big")&&!this.controls.includes("none")){t["--play-display"]=this.controls.includes("play")?"flex":"none",t["--time-display"]=this.controls.includes("time")?"flex":"none",t["--seek-bar-visibility"]=this.controls.includes("seek")?"visible":"hidden",t["--volume-display"]=this.controls.includes("volume")?"flex":"none",t["--fullscreen-display"]=this.controls.includes("fullscreen")?"flex":"none";let f=this.controls.includes("subtitles")?"flex":"none";t["--media-captions-menu-button-display"]=f,t["--mave-captions-menu-button-display"]=f;}t["--playbackrate-display"]=this.controls.includes("rate")?"flex":"none",(r||this._embedObj?.created_at<1740674988&&!this.subtitles&&!this.active_subtitle)&&(t["--media-captions-menu-button-display"]="none",t["--mave-captions-menu-button-display"]="none"),this.controls.includes("full")||this._embedObj?.settings.controls=="full"&&!this.controls.includes("big")&&!this.controls.includes("none")?t["--media-control-bar-display"]="flex":t["--media-control-bar-display"]="none",this.controls.includes("big")||this._embedObj?.settings.controls=="big"&&!this.controls.includes("full")&&!this.controls.includes("none")?t["--big-button-display"]="flex":t["--big-button-display"]="none",this._embedObj?.video.audio===false?t["--media-mute-button-display"]="none":n?t["--media-mute-button-display"]="flex":t["--media-mute-button-display"]="none";let l=this._audioTrackCount??0,c=this.controls.includes("audiotracks")||this.controls.includes("full"),u=this.audioTracks??"auto",h=c&&l>1;return u==="off"?h=false:u==="on"&&(h=c&&l>0),t["--media-audio-track-menu-button-display"]=h?"flex":"none",chunkQQDH35OW_cjs.a(t)}render(){if(!this.embed)return;let t=this.querySelector('[slot="start-screen"], [data-slot="start-screen"]');return chunk2E5GLLOS_cjs.a`
|
|
1496
1496
|
<slot
|
|
1497
1497
|
name="video"
|
|
1498
1498
|
style=${chunkQQDH35OW_cjs.a({display:t&&!this._startedPlaying&&!this._isProcessing?"none":"block"})}
|