@mux/mux-player 3.4.2-canary.4 → 3.4.2-canary.5

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.
@@ -41,7 +41,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
41
41
  } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=Sl(this.config),n=e.map(vh).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Th(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof wt?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=vh(e.keyFormat),n=s?[s]:Sl(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Sl(this.config)),e.length===0)throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new im,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:v}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${v.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,v).catch(y=>{this.handleError(y),u.emit("error",y)}):g==="license-release"?e.keySystem===ke.FAIRPLAY&&(this.updateKeySession(e,Hh("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${bi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${bi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:pt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Hh(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==ke.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Pa.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};cd.CDMCleanupPromise=void 0;var wt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},At;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(At||(At={}));var Uf;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(Uf||(Uf={}));var fs;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(fs||(fs={}));var JR={[fs.OBJECT]:["br","d","ot","tb"],[fs.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[fs.SESSION]:["cid","pr","sf","sid","st","v"],[fs.STATUS]:["bs","rtp"]},Ka=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},hd=class{constructor(e){this.description=void 0,this.description=e}},eI="Dict";function tI(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function iI(i,e,t,r){return new Error(`failed to ${i} "${tI(e)}" as ${t}`,{cause:r})}var bv="Bare Item",rI="Boolean",sI="Byte Sequence",nI="Decimal",aI="Integer";function oI(i){return i<-999999999999999||999999999999999<i}var lI=/[\x00-\x1f\x7f]+/,dI="Token",uI="Key";function Si(i,e,t){return iI("serialize",i,e,t)}function cI(i){if(typeof i!="boolean")throw Si(i,rI);return i?"?1":"?0"}function hI(i){return btoa(String.fromCharCode(...i))}function fI(i){if(ArrayBuffer.isView(i)===!1)throw Si(i,sI);return`:${hI(i)}:`}function TE(i){if(oI(i))throw Si(i,aI);return i.toString()}function mI(i){return`@${TE(i.getTime()/1e3)}`}function bE(i,e){if(i<0)return-bE(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function pI(i){let e=bE(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Si(i,nI);let t=e.toString();return t.includes(".")?t:`${t}.0`}var gI="String";function vI(i){if(lI.test(i))throw Si(i,gI);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function EI(i){return i.description||i.toString().slice(7,-1)}function yv(i){let e=EI(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Si(e,dI);return e}function Ff(i){switch(typeof i){case"number":if(!j(i))throw Si(i,bv);return Number.isInteger(i)?TE(i):pI(i);case"string":return vI(i);case"symbol":return yv(i);case"boolean":return cI(i);case"object":if(i instanceof Date)return mI(i);if(i instanceof Uint8Array)return fI(i);if(i instanceof hd)return yv(i);default:throw Si(i,bv)}}function Bf(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Si(i,uI);return i}function nm(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${Bf(e)}`:`;${Bf(e)}=${Ff(t)}`).join("")}function yE(i){return i instanceof Ka?`${Ff(i.value)}${nm(i.params)}`:Ff(i)}function TI(i){return`(${i.value.map(yE).join(" ")})${nm(i.params)}`}function bI(i,e={whitespace:!0}){if(typeof i!="object")throw Si(i,eI);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Ka||(n=new Ka(n));let a=Bf(s);return n.value===!0?a+=nm(n.params):(a+="=",Array.isArray(n.value)?a+=TI(n):a+=yE(n)),a}).join(`,${r}`)}function yI(i,e){return bI(i,e)}var _I=i=>i==="ot"||i==="sf"||i==="st",AI=i=>typeof i=="number"?j(i):i!=null&&i!==""&&i!==!1;function SI(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function xI(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var $l=i=>Math.round(i),RI=(i,e)=>(e!=null&&e.baseUrl&&(i=SI(i,e.baseUrl)),encodeURIComponent(i)),Ol=i=>$l(i/100)*100,II={br:$l,d:$l,bl:Ol,dl:Ol,mtp:Ol,nor:RI,rtp:Ol,tb:$l};function LI(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=it({},II,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||AI(o)&&(_I(a)&&typeof o=="string"&&(o=new hd(o)),t[a]=o))}),t}function _E(i,e={}){return i?yI(LI(i,e),it({whitespace:!1},e)):""}function kI(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(JR).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||fs.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=_E(o,e),n),{})}function wI(i,e,t){return it(i,kI(e,t))}var DI="CMCD";function CI(i,e={}){if(!i)return"";let t=_E(i,e);return`${DI}=${encodeURIComponent(t)}`}var _v=/CMCD=[^&#]+/;function MI(i,e,t){let r=CI(e,t);if(!r)return i;if(_v.test(i))return i.replace(_v,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var $f=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:At.MANIFEST,su:!this.initialized})}catch(n){L.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===At.VIDEO||o===At.AUDIO||o==At.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){L.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||xI(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:Uf.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){it(t,this.createData());let r=t.ot===At.INIT||t.ot===At.VIDEO||t.ot===At.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),wI(e.headers,t)):e.url=MI(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return At.TIMED_TEXT;if(e.sn==="initSegment")return At.INIT;if(t==="audio")return At.AUDIO;if(t==="main")return this.hls.audioTracks.length?At.VIDEO:At.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===At.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===At.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ve.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},OI=3e5,Hf=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===ft.SendAlternateToPenaltyBox&&r.flags===ai.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>OI&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Wv(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===Ae.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===Ae.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new qe(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=AE(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new _r({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),Av(this.audioTracks,r,l,a),Av(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":v}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let y={steeringManifest:m,url:s.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,y),v&&this.updatePathwayPriority(v)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function Av(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=it({},a);return o.details=void 0,o.attrs=new qe(o.attrs),o.url=o.attrs.URI=AE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function AE(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var PI=/^age:\s*[\d.]+\s*$/im,fd=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 mn,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=!0,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,r){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=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[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),r.timeout=n&&j(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.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-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){let c=o!=null?o:t.response;if(c!=null){r.loading.end=Math.max(self.performance.now(),r.loading.first);let h=t.responseType==="arraybuffer"?c.byteLength:c.length;if(r.loaded=r.total=h,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let f=this.callbacks.onProgress;if(f&&f(r,e,c,t),!this.callbacks)return;let m={url:t.responseURL,data:c,code:a};this.callbacks.onSuccess(m,r,e,t);return}}let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Ql(l,d,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ql(e,t,!0))this.retry(e);else{var r;L.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Zf(e,r.retry),r.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.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&&PI.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}};function NI(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var UI=/(\d+)-(\d+)\/(\d+)/,md=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||HI,this.controller=new self.AbortController,this.stats=new mn}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=!0,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,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=FI(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&j(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new Gf(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=$I(c.headers)||s.total,a&&j(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!j(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}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,r,s=0,n){let a=new ed,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function FI(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(it({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function BI(i){let e=UI.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function $I(i){let e=i.get("Content-Range");if(e){let r=BI(e);if(j(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function HI(i,e){return new self.Request(i.url,e)}var Gf=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},GI=/\s/,KI={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)GI.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=mE(d.trim()),m=sm(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Hv(i,h))),s}},VI={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},SE=pt(pt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:fd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Jh,bufferController:Rf,capLevelController:Pf,errorController:Qh,fpsController:Nf,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Rv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:VI},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},WI()),{},{subtitleStreamController:_f,subtitleTrackController:Sf,timelineController:Of,audioStreamController:Tf,audioTrackController:yf,emeController:cd,cmcdController:$f,contentSteeringController:Hf});function WI(){return{cueHandler:KI,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function YI(i,e){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 t=Kf(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),pt(pt({},t),e)}function Kf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Kf):Object.keys(i).reduce((e,t)=>(e[t]=Kf(i[t]),e),{}):i}function qI(i){let e=i.loader;e!==md&&e!==fd?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):NI()&&(i.loader=md,i.progressive=!0,i.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Uh,Vf=class extends Ua{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.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 r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(Uh||(Uh=/chrome|firefox/i.test(navigator.userAgent)),Uh&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=ql(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=bx(p));let{width:g,height:v,unknownCodecs:y}=u;if(o||(o=!!(g&&v)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!Ah(m,"audio",r)||p&&!Ah(p,"video",r))return;let{CODECS:T,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":k,RESOLUTION:R,"VIDEO-RANGE":x}=f,w=`${`${k||"."}-`}${u.bitrate}-${R}-${_}-${T}-${x}-${A}`;if(n[w])if(n[w].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let C=a[w]+=1;u.attrs["PATHWAY-ID"]=new Array(C+1).join(".");let P=new _r(u);n[w]=P,s.push(P)}else n[w].addGroupId("audio",f.AUDIO),n[w].addGroupId("text",f.SUBTITLES);else{let C=new _r(u);n[w]=C,a[w]=1,s.push(C)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:v})=>(!!m||!!(g&&v))&&wx(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Ah(p.audioCodec,"audio",m)),Sv(a)}t.subtitles&&(o=t.subtitles,Sv(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return jl.indexOf(m.videoRange)-jl.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=B0(m.videoCodec),v=B0(p.videoCodec);if(g!==v)return v-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=Yl(m.codecSet),v=Yl(p.codecSet);if(g!==v)return v-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let v=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);v>g&&g===SE.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(E.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&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 ${r}${n?" with Pathway "+n:""}`);let l={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(E.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}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}onError(e,t){t.fatal||!t.context||t.context.type===Ae.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===se.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||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;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));Wv(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function Sv(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Wf=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=M.KEY_LOAD_ERROR,r,s,n){return new li({type:ne.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}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 r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:v,url:y}=m;if(!g.decryptdata||v!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));v.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,v.loader=null,a({frag:g,keyInfo:v})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,pt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function xE(){return self.SourceBuffer||self.WebKitSourceBuffer}function RE(){if(!gs())return!1;let e=xE();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function jI(){if(!RE())return!1;let i=gs();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(Na(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(Na(e,"audio"))))}function zI(){var i;let e=xE();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var XI=250,Hl=2,QI=.1,ZI=.05,Yf=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;L.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ve.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ve.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>Hl,v=!c||t&&t.start<=a||c-a>Hl&&!this.fragmentTracker.getPartialFragment(a);if(g||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let v=Math.max(c,u.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:Hl,A=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=_||A)){s.paused||this._trySkipBufferHole(A);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=XI&&(this._reportStall(u),!this.media))return;let p=Ve.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(n.message),t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ve.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,se.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,se.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let v=h.getPartialFragment(g);if(v)g+=v.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+ZI,n+QI);if(L.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);L.warn(o.message),r.currentTime=a,t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},JI=100,qf=class extends $a{constructor(e,t,r){super(e,t,r,"[stream-controller]",se.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(JI),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(E.BUFFER_EOS,p),this.state=N.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 d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==mt.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[g-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 g=this.audioOnly&&!this.altAudio?we.AUDIO:we.VIDEO,v=(g===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,g,se.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,se.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===mt.NOT_LOADED||s===mt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):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)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,se.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 r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.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,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,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 N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Yf(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;j(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!zI(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==N.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(E.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new od(this.hls,se.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new Fa(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),v=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,v)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){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();let n=this.hls;r&&(n.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==se.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(se.MAIN,t);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Ae.LEVEL&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ve.getBuffered(e).length){let r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==we.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,se.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ve.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_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=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(E.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){let T=l.initSegment||l;this._bufferInitSegment(u,m.tracks,T,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:m.tracks})}let v=m.initPTS,y=m.timescale;j(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:y},s.trigger(E.INIT_PTS_FOUND,{frag:l,id:r,initPTS:v,timescale:y}))}if(c&&p&&l.sn!=="initSegment"){let v=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,T=!v||l.cc>v.cc;if(n.independent!==!1){let{startPTS:_,endPTS:A,startDTS:k,endDTS:R}=c;if(d)d.elementaryStreams[c.type]={startPTS:_,endPTS:A,startDTS:k,endDTS:R};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){let x=this.getMainFwdBufferInfo(),O=(x?x.end:this.getLoadPosition())+this.config.maxBufferHole,w=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!y&&O<w-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,R,!0)}else y&&_>Hl&&(l.gap=!0);l.setElementaryStreamInfo(c.type,_,A,k,R),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,y||T)}else if(y||T)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:v,endPTS:y,startDTS:T,endDTS:_}=g;d&&(d.elementaryStreams[we.AUDIO]={startPTS:v,endPTS:y,startDTS:T,endDTS:_}),l.setElementaryStreamInfo(we.AUDIO,v,y,T,_),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let v={id:r,frag:l,details:p,samples:f.samples};s.trigger(E.FRAG_PARSING_METADATA,v)}if(p&&h){let v={id:r,frag:l,details:p,samples:h.samples};s.trigger(E.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(E.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,se.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ve.isBuffered(e,r)?t=this.getAppendedFrag(r):Ve.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(E.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(E.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&j(t)&&j(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}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}},Va=class i{static get version(){return"1.5.20"}static isMSESupported(){return RE()}static isSupported(){return jI()}static getMediaSource(){return gs()}static get Events(){return E}static get ErrorTypes(){return ne}static get ErrorDetails(){return M}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:SE}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new im,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,MS(e.debug||!1,"Hls instance");let t=this.config=YI(i.DefaultConfig,e);this.userConfig=e,t.progressive&&qI(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new Kh(this),m=new Yh(this),p=t.contentSteeringController,g=p?new p(this):null,v=this.levelController=new Vf(this,g),y=new tf(this),T=new Wf(this.config),_=this.streamController=new qf(this,y,T);c.setStreamController(_),h.setStreamController(_);let A=[f,v,_];g&&A.splice(1,0,g),this.networkControllers=A;let k=[d,u,c,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,A);let R=t.audioStreamController;R&&A.push(new R(this,y,T)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let x=t.subtitleStreamController;x&&A.push(new x(this,y,T)),this.createController(t.timelineController,k),T.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(qh,k),this.coreComponents=k,A.push(l);let O=l.onErrorOut;typeof O=="function"&&this.on(E.ERROR,O,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===E.ERROR;this.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(E.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){L.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=jf.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.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){L.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 ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){kx(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 r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}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()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||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:!1}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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};Va.defaultConfig=void 0;var ve=Va,Ne={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},J={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},qa=i=>i===Ne.VIDEO?"playback":i,Ar=class Wa extends Error{constructor(e,t=Wa.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Wa.MEDIA_ERR_NETWORK&&t<=Wa.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Wa.defaultMessages[this.code])!=null?n:"")}};Ar.MEDIA_ERR_ABORTED=1,Ar.MEDIA_ERR_NETWORK=2,Ar.MEDIA_ERR_DECODE=3,Ar.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ar.MEDIA_ERR_ENCRYPTED=5,Ar.MEDIA_ERR_CUSTOM=100,Ar.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var K=Ar,eL=i=>i==null,mm=(i,e)=>eL(e)?!1:i in e,lm={ANY:"any",MUTED:"muted"},Se={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},zt={MSE:"mse",NATIVE:"native"},Ya={HEADER:"header",QUERY:"query",NONE:"none"},vn=Object.values(Ya),Ji={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},dm={HLS:Ji.M3U8},SM=Object.keys(dm),xM=[...Object.values(Ji),"hls","HLS"];var tL="en",um={code:tL},rt=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function iL(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var bd=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},yd=i=>{let{type:e}=i;if(e){let t=e.toUpperCase();return mm(t,dm)?dm[t]:e}return rL(i)},NE=i=>i==="VOD"?Se.ON_DEMAND:Se.LIVE,UE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,rL=i=>{let{src:e}=i;if(!e)return"";let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return nL(i)?Ji.M3U8:"";let s=t.slice(r+1).toUpperCase();return mm(s,Ji)?Ji[s]:""},sL="mux.com",nL=({src:i,customDomain:e=sL})=>{let t;try{t=new URL(`${i}`)}catch{return!1}let r=t.protocol==="https:",s=t.hostname===`stream.${e}`.toLowerCase(),n=t.pathname.split("/"),a=n.length===2,o=!(n!=null&&n[1].includes("."));return r&&s&&a&&o},Sr=i=>{let e=(i!=null?i:"").split(".")[1];if(e)try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}catch{return}},aL=({exp:i},e=Date.now())=>!i||i*1e3<e,oL=({sub:i},e)=>i!==e,lL=({aud:i},e)=>!i,dL=({aud:i},e)=>i!==e,FE="en";function Q(i,e=!0){var t,r;let s=e&&(r=(t=um)==null?void 0:t[i])!=null?r:i,n=e?um.code:FE;return new uL(s,n)}var uL=class{constructor(i,e=(t=>(t=um)!=null?t:FE)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}},cL=Object.values(lm),IE=i=>typeof i=="boolean"||typeof i=="string"&&cL.includes(i),hL=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=IE(r)?r:!!r,o=()=>{s||rt(e,"playing",()=>{s=!0},{once:!0})};if(o(),rt(e,"loadstart",()=>{s=!1,o(),am(e,a)},{once:!0}),rt(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==Se.UNKNOWN?n=i.streamType===Se.LIVE:n=!Number.isFinite(e.duration)),am(e,a)},{once:!0}),t&&t.once(ve.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==Se.UNKNOWN?n=i.streamType===Se.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&rt(e,"play",()=>{e.preload==="metadata"?t.once(ve.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=IE(l)?l:!!l,am(e,a))}},am=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case lm.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case lm.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},fL=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return rt(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function mL(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(ve.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(ve.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(ve.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(ve.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(ve.Events.BUFFER_FLUSHING,h),c||e.trigger(ve.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(ve.Events.DESTROYING,l)}var om=i=>"time"in i?i.time:i.startTime;function pL(i,e){e.on(ve.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o,l;let d=(o=a.subtitleTrack)!=null?o:a.closedCaptions,u=e.subtitleTracks.findIndex(({lang:h,name:f,type:m})=>h==(d==null?void 0:d.lang)&&f===a.label&&m.toLowerCase()===a.kind),c=((l=a._id)!=null?l:a.default)?"default":`${a.kind}${u}`;_d(i,a.kind,a.label,d==null?void 0:d.lang,c,a.default)})});let t=()=>{if(!e.subtitleTracks.length)return;let s=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind));if(!s)return;let n=e.subtitleTracks[e.subtitleTrack],a=n?n.default?"default":`${e.subtitleTracks[e.subtitleTrack].type.toLowerCase()}${e.subtitleTrack}`:void 0;if(e.subtitleTrack<0||(s==null?void 0:s.id)!==a){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u,default:c})=>s.id==="default"&&c||l==s.language&&d===s.label&&u.toLowerCase()===s.kind);e.subtitleTrack=o}(s==null?void 0:s.id)===a&&s.cues&&Array.from(s.cues).forEach(o=>{s.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(ve.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(ve.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&(s.label==="thumbnails"||s.kind==="chapters")){if(!((n=s.cues)!=null&&n.length)){let o="track";s.kind&&(o+=`[kind="${s.kind}"]`),s.label&&(o+=`[label="${s.label}"]`);let l=i.querySelector(o),d=(a=l==null?void 0:l.getAttribute("src"))!=null?a:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",d)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(ve.Events.MANIFEST_LOADED,r),e.once(ve.Events.MEDIA_ATTACHED,r)}function _d(i,e,t,r,s,n){let a=document.createElement("track");return a.kind=e,a.label=t,r&&(a.srclang=r),s&&(a.id=s),n&&(a.default=!0),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),i.append(a),a.track}function BE(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function ja(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function $E(i,e,t,r){let s=ja(i,t,r);return s||(s=_d(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>om(a)-om(n)).forEach(n=>{var a,o;let l=n.value,d=om(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var pm="cuepoints",HE=Object.freeze({label:pm});async function gm(i,e,t=HE){return $E(i,e,t.label,"metadata")}var cm=i=>({time:i.startTime,value:JSON.parse(i.text)});function GE(i,e={label:pm}){let t=ja(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>cm(r)):[]}function vm(i,e={label:pm}){var t,r;let s=ja(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return cm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return cm(a||s.activeCues[0])}async function gL(i,e=HE){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await gm(i,[],e);rt(i,"cuechange",()=>{let s=vm(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var Em="chapters",KE=Object.freeze({label:Em}),hm=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function Tm(i,e,t=KE){return $E(i,e,t.label,"chapters")}function VE(i,e={label:Em}){var t;let r=ja(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>hm(s)):[]}function bm(i,e={label:Em}){var t,r;let s=ja(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return hm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return hm(a||s.activeCues[0])}async function vL(i,e=KE){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await Tm(i,[],e);rt(i,"cuechange",()=>{let s=bm(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function WE(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function YE(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var gn={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},EL=i=>{if(i===Ne.VIDEO)return gn.VIDEO;if(i===Ne.DRM)return gn.DRM},TL=(i,e)=>{var t,r;let s=qa(i),n=`${s}Token`;return(t=e.tokens)!=null&&t[s]?(r=e.tokens)==null?void 0:r[s]:mm(n,e)?e[n]:void 0},Ed=(i,e,t,r,s=!1,n=!(a=>(a=globalThis.navigator)==null?void 0:a.onLine)())=>{var a,o;if(n){let v=Q("Your device appears to be offline",s),y,T=K.MEDIA_ERR_NETWORK,_=new K(v,T,!1,y);return _.errorCategory=e,_.muxCode=J.NETWORK_OFFLINE,_.data=i,_}let l="status"in i?i.status:i.code,d=Date.now(),u=K.MEDIA_ERR_NETWORK;if(l===200)return;let c=qa(e),h=TL(e,t),f=EL(e),[m]=bd((a=t.playbackId)!=null?a:"");if(!l||!m)return;let p=Sr(h);if(h&&!p){let v=Q("The {tokenNamePrefix}-token provided is invalid or malformed.",s).format({tokenNamePrefix:c}),y=Q("Compact JWT string: {token}",s).format({token:h}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_MALFORMED,T.data=i,T}if(l>=500){let v=new K("",u,r!=null?r:!0);return v.errorCategory=e,v.muxCode=J.NETWORK_UNKNOWN_ERROR,v}if(l===403)if(p){if(aL(p,d)){let v={timeStyle:"medium",dateStyle:"medium"},y=Q("The video\u2019s secured {tokenNamePrefix}-token has expired.",s).format({tokenNamePrefix:c}),T=Q("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat("en",v).format((o=p.exp)!=null?o:0*1e3),currentDate:new Intl.DateTimeFormat("en",v).format(d)}),_=new K(y,u,!0,T);return _.errorCategory=e,_.muxCode=J.NETWORK_TOKEN_EXPIRED,_.data=i,_}if(oL(p,m)){let v=Q("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",s).format({tokenNamePrefix:c}),y=Q("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",s).format({tokenNamePrefix:c,playbackId:m,tokenPlaybackId:p.sub}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_SUB_MISMATCH,T.data=i,T}if(lL(p,f)){let v=Q("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:c}),y=Q("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",s).format({tokenNamePrefix:c,expectedAud:f}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_AUD_MISSING,T.data=i,T}if(dL(p,f)){let v=Q("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:c}),y=Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",s).format({tokenNamePrefix:c,expectedAud:f,aud:p.aud}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_AUD_MISMATCH,T.data=i,T}}else{let v=Q("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",s).format({tokenNamePrefix:c,category:e}),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_MISSING,T.data=i,T}if(l===412){let v=Q("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_NOT_READY,T.streamType=t.streamType===Se.LIVE?"live":t.streamType===Se.ON_DEMAND?"on-demand":"unknown",T.data=i,T}if(l===404){let v=Q("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_NOT_FOUND,T.data=i,T}if(l===400){let v=Q("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_INVALID_URL,T.data=i,T}let g=new K("",u,r!=null?r:!0);return g.errorCategory=e,g.muxCode=J.NETWORK_UNKNOWN_ERROR,g.data=i,g},LE=ve.DefaultConfig.capLevelController,qE=class jE extends LE{constructor(e){super(e)}get levels(){var e;return(e=this.hls.levels)!=null?e:[]}getValidLevels(e){return this.levels.filter((t,r)=>this.isLevelAllowed(t)&&r<=e)}getMaxLevel(e){let t=super.getMaxLevel(e),r=this.getValidLevels(e);if(!r[t])return t;let s=Math.min(r[t].width,r[t].height),n=jE.minMaxResolution;return s>=n?t:LE.getMaxLevelByMediaSize(r,n*(16/9),n)}};qE.minMaxResolution=720;var bL=qE,yL=bL,gd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},_L=i=>{if(i.includes("fps"))return gd.FAIRPLAY;if(i.includes("playready"))return gd.PLAYREADY;if(i.includes("widevine"))return gd.WIDEVINE},AL=i=>{let e=i.split(`
42
42
  `).find((t,r,s)=>r&&s[r-1].startsWith("#EXT-X-STREAM-INF"));return fetch(e).then(t=>t.status!==200?Promise.reject(t):t.text())},SL=i=>{let e=i.split(`
43
43
  `).filter(r=>r.startsWith("#EXT-X-SESSION-DATA"));if(!e.length)return{};let t={};for(let r of e){let s=RL(r),n=s["DATA-ID"];n&&(t[n]={...s})}return{sessionData:t}},xL=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g;function RL(i){let e=[...i.matchAll(xL)];return Object.fromEntries(e.map(([,t,r])=>[t,r]))}var IL=i=>{var e,t,r;let s=i.split(`
44
- `),n=(t=((e=s.find(d=>d.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),a=NE(n),o=UE(n),l;if(a===Se.LIVE){let d=s.find(u=>u.startsWith("#EXT-X-PART-INF"));if(d)l=+d.split(":")[1].split("=")[1]*2;else{let u=s.find(h=>h.startsWith("#EXT-X-TARGETDURATION")),c=(r=u==null?void 0:u.split(":"))==null?void 0:r[1];l=+(c!=null?c:6)*3}}return{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}},LL=async(i,e)=>{if(e===Ji.MP4)return{streamType:Se.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(e===Ji.M3U8){let t=await fetch(i);if(!t.ok)return Promise.reject(t);let r=await t.text(),s=await AL(r);return{...SL(r),...IL(s)}}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},kL=async(i,e,t=yd({src:i}))=>{var r,s,n,a;let{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:d,sessionData:u}=await LL(i,t),c=u==null?void 0:u["com.apple.hls.chapters"];(c!=null&&c.URI||c!=null&&c.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((r=c.URI)!=null?r:c.VALUE,e),((s=Xe.get(e))!=null?s:{}).liveEdgeStartOffset=d,((n=Xe.get(e))!=null?n:{}).targetLiveWindow=l,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((a=Xe.get(e))!=null?a:{}).streamType=o,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ym=async(i,e)=>{var t;try{let r=await fetch(i);if(!r.ok)throw new Error(`Failed to fetch Mux metadata: ${r.status} ${r.statusText}`);let s=await r.json(),n={};for(let o of s[0].metadata)o.key&&o.value&&(n[o.key]=o.value);((t=Xe.get(e))!=null?t:{}).metadata=n;let a=new CustomEvent("muxmetadata");e.dispatchEvent(a)}catch(r){console.error(r)}},wL=i=>{var e;let t=i.type,r=NE(t),s=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Se.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},DL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=wL(i);if(c===Se.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=Xe.get(e))!=null?o:{}).seekable=p}((l=Xe.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Xe.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Xe.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},kE,wE,CL=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgent)!=null?wE:"",DE,CE,ME,ML=(ME=(CE=(DE=globalThis==null?void 0:globalThis.navigator)==null?void 0:DE.userAgentData)==null?void 0:CE.platform)!=null?ME:"",OL=CL.toLowerCase().includes("android")||["x11","android"].some(i=>ML.toLowerCase().includes(i)),Xe=new WeakMap,er="mux.com",OE,PE,zE=(PE=(OE=ve).isSupported)==null?void 0:PE.call(OE),PL=OL,Ad=()=>_l.utils.now(),NL=_l.utils.generateUUID,za=({playbackId:i,customDomain:e=er,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=bd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},Sd=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},xd=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(/\.m3u8|\//);return e||void 0},UL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:sT(i)&&(r=(t=Sd(i.playbackId))!=null?t:xd(i.src))!=null?r:i.src},_m=i=>{var e;return(e=Xe.get(i))==null?void 0:e.error},XE=i=>{var e;return(e=Xe.get(i))==null?void 0:e.metadata},Td=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.streamType)!=null?t:Se.UNKNOWN},QE=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Rd=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},ZE=i=>{var e;let t=(e=Xe.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Rd(i);return r.length?r.end(r.length-1)-t:Number.NaN},Am=.034,FL=(i,e,t=Am)=>Math.abs(i-e)<=t,JE=(i,e,t=Am)=>i>e||FL(i,e,t),BL=(i,e=Am)=>i.paused&&JE(i.currentTime,i.duration,e),eT=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Sm=(i,e)=>i.ended||i.loop?i.ended:e&&eT(i,e)?!0:BL(i),tT=(i,e,t)=>{xm(e,t,i);let{metadata:r={}}=i,{view_session_id:s=NL()}=r,n=UL(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,Xe.set(e,{retryCount:0});let o=$L(i,e),l=fL(i,e,o);i!=null&&i.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?ve:void 0}):YL(i,e,o),qL(i,e,o),gL(e),vL(e);let d=hL(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},xm=(i,e,t)=>{let r=e==null?void 0:e.engine;i!=null&&i.mux&&!i.mux.deleted&&(t!=null&&t.muxDataKeepSession?r&&i.mux.removeHLSJS():(i.mux.destroy(),delete i.mux)),r&&(r.detachMedia(),r.destroy()),i&&(i.hasAttribute("src")&&(i.removeAttribute("src"),i.load()),i.removeEventListener("error",aT),i.removeEventListener("error",fm),i.removeEventListener("durationchange",nT),Xe.delete(i),i.dispatchEvent(new Event("teardown")))};function iT(i,e){var t;let r=yd(i);if(r!==Ji.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===zt.MSE,o=n===zt.NATIVE;return s&&(o||!(zE&&(a||PL)))}var $L=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yd(i)===Ji.M3U8,d=iT(i,e);if(l&&!d&&zE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=HL(r),h=GL(i),f=[Ya.QUERY,Ya.HEADER].includes(a)?{useHeaders:a===Ya.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0,m=new ve({debug:t,startPosition:s,cmcd:f,xhrSetup:(p,g)=>{var v,y;if(a&&a!==Ya.QUERY)return;let T=new URL(g);if(!T.searchParams.has("CMCD"))return;let _=((y=(v=T.searchParams.get("CMCD"))==null?void 0:v.split(","))!=null?y:[]).filter(A=>A.startsWith("sid")||A.startsWith("cid")).join(",");T.searchParams.set("CMCD",_),p.open("GET",T)},capLevelController:yL,...u,...c,...h,...o});return m.on(ve.Events.MANIFEST_PARSED,async function(p,g){var v;let y=(v=g.sessionData)==null?void 0:v["com.apple.hls.chapters"];y!=null&&y.VALUE&&ym(y.VALUE,e)}),m}},HL=i=>i===Se.LIVE?{backBufferLength:8}:{},GL=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=Sd(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:vd(i,"fairplay"),serverCertificateUrl:rT(i,"fairplay")},"com.widevine.alpha":{licenseUrl:vd(i,"widevine")},"com.microsoft.playready":{licenseUrl:vd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=_L(n);return r==null||r(l),o}))}},KL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},VL=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},WL=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,gd.FAIRPLAY),u}).catch(()=>{let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Ne.DRM,c.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,jt(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await KL(rT(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=Ed(c,Ne.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Ne.DRM,h.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){jt(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}d&&jt(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED,jt(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l),o=await VL(a,vd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=Ed(l,Ne.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=Q("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){jt(e,r);return}})},vd=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/license/${r}/${s}?token=${e}`},rT=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/appcert/${r}/${s}?token=${e}`},sT=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(er)||!!t&&s.includes(t.toLocaleLowerCase())},YL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=_l,muxDataSDKOptions:o={}}=i,l=sT(i);if(!n&&(s||l)){let{playerInitTime:d,playerSoftwareName:u,playerSoftwareVersion:c,beaconCollectionDomain:h,debug:f,disableCookies:m}=i,p={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},g=v=>typeof v.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(v):v;a.monitor(e,{debug:f,beaconCollectionDomain:h,hlsjs:t,Hls:t?ve:void 0,automaticErrorTracking:!1,errorTranslator:g,disableCookies:m,...o,data:{...s?{env_key:s}:{},player_software_name:u,player_software:u,player_software_version:c,player_init_time:d,...p}})}},qL=(i,e,t)=>{var r,s;let n=iT(i,e),{src:a,customDomain:o=er}=i,l=()=>{e.ended||!Sm(e,t)||(eT(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},d,u,c=()=>{let h=Rd(e),f,m;h.length>0&&(f=h.start(0),m=h.end(0)),(u!==m||d!==f)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),d=f,u=m};if(rt(e,"durationchange",c),e&&n){let h=yd(i);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=xd(a),g=new URL(`https://stream.${o}/${p}/metadata.json`);ym(g.toString(),e)}let f=()=>{if(Td(e)!==Se.LIVE||Number.isFinite(e.duration))return;let p=setInterval(c,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})},m=async()=>kL(a,e,h).then(f).catch(p=>{if(p instanceof Response){let g=Ed(p,Ne.VIDEO,i);if(g){jt(e,g);return}}else p instanceof Error});if(e.preload==="none"){let p=()=>{m(),e.removeEventListener("loadedmetadata",g)},g=()=>{m(),e.removeEventListener("play",p)};rt(e,"play",p,{once:!0}),rt(e,"loadedmetadata",g,{once:!0})}else m();(r=i.tokens)!=null&&r.drm?WL(i,e):rt(e,"encrypted",()=>{let p=Q("Attempting to play DRM-protected content without providing a DRM token."),g=new K(p,K.MEDIA_ERR_ENCRYPTED,!0);g.errorCategory=Ne.DRM,g.muxCode=J.ENCRYPTED_MISSING_TOKEN,jt(e,g)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=Xe.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",nT,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",aT),e.addEventListener("error",fm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(f=>{f.remove()})},{once:!0}),rt(e,"pause",l),rt(e,"seeked",l),rt(e,"play",()=>{e.ended||JE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ve.Events.LEVEL_LOADED,(h,f)=>{DL(f.details,e,t),c(),Td(e)===Se.LIVE&&!Number.isFinite(e.duration)&&(t.on(ve.Events.LEVEL_UPDATED,c),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ve.Events.LEVELS_UPDATED,c)}))}),t.on(ve.Events.ERROR,(h,f)=>{var m,p;let g=jL(f,i);if(g.muxCode===J.NETWORK_NOT_READY){let v=(m=Xe.get(e))!=null?m:{},y=(p=v.retryCount)!=null?p:0;if(y<6){let T=y===0?5e3:6e4,_=new K(`Retrying in ${T/1e3} seconds...`,g.code,g.fatal);Object.assign(_,g),jt(e,_),setTimeout(()=>{v.retryCount=y+1,f.details==="manifestLoadError"&&f.url&&t.loadSource(f.url)},T);return}else{v.retryCount=0;let T=new K('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',g.code,g.fatal);Object.assign(T,g),jt(e,T);return}}jt(e,g)}),t.on(ve.Events.MANIFEST_LOADED,()=>{let h=Xe.get(e);h&&h.error&&(h.error=null,h.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",fm),rt(e,"waiting",l),mL(i,t),pL(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function nT(i){var e;let t=i.target,r=(e=Xe.get(t))==null?void 0:e.startTime;if(r&&iL(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function aT(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=_m(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&jt(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}jt(e,s)}function jt(i,e){var t;e.fatal&&(((t=Xe.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function fm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Xe.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var jL=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ve.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ve.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ve.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ve.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ve.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===ve.ErrorTypes.NETWORK_ERROR)return Ne.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Ne.VIDEO;l=(r=Ed(i.response,u,e,i.fatal))!=null?r:new K("",d,i.fatal)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=Q("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_MISSING_TOKEN}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=Q("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_CDM_ERROR}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
44
+ `),n=(t=((e=s.find(d=>d.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),a=NE(n),o=UE(n),l;if(a===Se.LIVE){let d=s.find(u=>u.startsWith("#EXT-X-PART-INF"));if(d)l=+d.split(":")[1].split("=")[1]*2;else{let u=s.find(h=>h.startsWith("#EXT-X-TARGETDURATION")),c=(r=u==null?void 0:u.split(":"))==null?void 0:r[1];l=+(c!=null?c:6)*3}}return{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}},LL=async(i,e)=>{if(e===Ji.MP4)return{streamType:Se.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(e===Ji.M3U8){let t=await fetch(i);if(!t.ok)return Promise.reject(t);let r=await t.text(),s=await AL(r);return{...SL(r),...IL(s)}}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},kL=async(i,e,t=yd({src:i}))=>{var r,s,n,a;let{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:d,sessionData:u}=await LL(i,t),c=u==null?void 0:u["com.apple.hls.chapters"];(c!=null&&c.URI||c!=null&&c.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((r=c.URI)!=null?r:c.VALUE,e),((s=Xe.get(e))!=null?s:{}).liveEdgeStartOffset=d,((n=Xe.get(e))!=null?n:{}).targetLiveWindow=l,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((a=Xe.get(e))!=null?a:{}).streamType=o,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ym=async(i,e)=>{var t;try{let r=await fetch(i);if(!r.ok)throw new Error(`Failed to fetch Mux metadata: ${r.status} ${r.statusText}`);let s=await r.json(),n={};for(let o of s[0].metadata)o.key&&o.value&&(n[o.key]=o.value);((t=Xe.get(e))!=null?t:{}).metadata=n;let a=new CustomEvent("muxmetadata");e.dispatchEvent(a)}catch(r){console.error(r)}},wL=i=>{var e;let t=i.type,r=NE(t),s=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Se.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},DL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=wL(i);if(c===Se.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=Xe.get(e))!=null?o:{}).seekable=p}((l=Xe.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Xe.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Xe.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},kE,wE,CL=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgent)!=null?wE:"",DE,CE,ME,ML=(ME=(CE=(DE=globalThis==null?void 0:globalThis.navigator)==null?void 0:DE.userAgentData)==null?void 0:CE.platform)!=null?ME:"",OL=CL.toLowerCase().includes("android")||["x11","android"].some(i=>ML.toLowerCase().includes(i)),Xe=new WeakMap,er="mux.com",OE,PE,zE=(PE=(OE=ve).isSupported)==null?void 0:PE.call(OE),PL=OL,Ad=()=>_l.utils.now(),NL=_l.utils.generateUUID,za=({playbackId:i,customDomain:e=er,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=bd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},Sd=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},xd=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(/\.m3u8|\//);return e||void 0},UL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:sT(i)&&(r=(t=Sd(i.playbackId))!=null?t:xd(i.src))!=null?r:i.src},_m=i=>{var e;return(e=Xe.get(i))==null?void 0:e.error},XE=i=>{var e;return(e=Xe.get(i))==null?void 0:e.metadata},Td=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.streamType)!=null?t:Se.UNKNOWN},QE=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Rd=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},ZE=i=>{var e;let t=(e=Xe.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Rd(i);return r.length?r.end(r.length-1)-t:Number.NaN},Am=.034,FL=(i,e,t=Am)=>Math.abs(i-e)<=t,JE=(i,e,t=Am)=>i>e||FL(i,e,t),BL=(i,e=Am)=>i.paused&&JE(i.currentTime,i.duration,e),eT=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Sm=(i,e)=>i.ended||i.loop?i.ended:e&&eT(i,e)?!0:BL(i),tT=(i,e,t)=>{xm(e,t,i);let{metadata:r={}}=i,{view_session_id:s=NL()}=r,n=UL(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,Xe.set(e,{retryCount:0});let o=$L(i,e),l=fL(i,e,o);i!=null&&i.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?ve:void 0}):YL(i,e,o),qL(i,e,o),gL(e),vL(e);let d=hL(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},xm=(i,e,t)=>{let r=e==null?void 0:e.engine;i!=null&&i.mux&&!i.mux.deleted&&(t!=null&&t.muxDataKeepSession?r&&i.mux.removeHLSJS():(i.mux.destroy(),delete i.mux)),r&&(r.detachMedia(),r.destroy()),i&&(i.hasAttribute("src")&&(i.removeAttribute("src"),i.load()),i.removeEventListener("error",aT),i.removeEventListener("error",fm),i.removeEventListener("durationchange",nT),Xe.delete(i),i.dispatchEvent(new Event("teardown")))};function iT(i,e){var t;let r=yd(i);if(r!==Ji.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===zt.MSE,o=n===zt.NATIVE;return s&&(o||!(zE&&(a||PL)))}var $L=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yd(i)===Ji.M3U8,d=iT(i,e);if(l&&!d&&zE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=HL(r),h=GL(i),f=[Ya.QUERY,Ya.HEADER].includes(a)?{useHeaders:a===Ya.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0,m=new ve({debug:t,startPosition:s,cmcd:f,xhrSetup:(p,g)=>{var v,y;if(a&&a!==Ya.QUERY)return;let T=new URL(g);if(!T.searchParams.has("CMCD"))return;let _=((y=(v=T.searchParams.get("CMCD"))==null?void 0:v.split(","))!=null?y:[]).filter(A=>A.startsWith("sid")||A.startsWith("cid")).join(",");T.searchParams.set("CMCD",_),p.open("GET",T)},capLevelController:yL,...u,...c,...h,...o});return m.on(ve.Events.MANIFEST_PARSED,async function(p,g){var v,y;let T=(v=g.sessionData)==null?void 0:v["com.apple.hls.chapters"];(T!=null&&T.URI||T!=null&&T.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((y=T==null?void 0:T.URI)!=null?y:T==null?void 0:T.VALUE,e)}),m}},HL=i=>i===Se.LIVE?{backBufferLength:8}:{},GL=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=Sd(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:vd(i,"fairplay"),serverCertificateUrl:rT(i,"fairplay")},"com.widevine.alpha":{licenseUrl:vd(i,"widevine")},"com.microsoft.playready":{licenseUrl:vd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=_L(n);return r==null||r(l),o}))}},KL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},VL=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},WL=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,gd.FAIRPLAY),u}).catch(()=>{let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Ne.DRM,c.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,jt(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await KL(rT(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=Ed(c,Ne.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Ne.DRM,h.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){jt(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}d&&jt(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED,jt(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l),o=await VL(a,vd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=Ed(l,Ne.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=Q("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){jt(e,r);return}})},vd=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/license/${r}/${s}?token=${e}`},rT=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/appcert/${r}/${s}?token=${e}`},sT=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(er)||!!t&&s.includes(t.toLocaleLowerCase())},YL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=_l,muxDataSDKOptions:o={}}=i,l=sT(i);if(!n&&(s||l)){let{playerInitTime:d,playerSoftwareName:u,playerSoftwareVersion:c,beaconCollectionDomain:h,debug:f,disableCookies:m}=i,p={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},g=v=>typeof v.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(v):v;a.monitor(e,{debug:f,beaconCollectionDomain:h,hlsjs:t,Hls:t?ve:void 0,automaticErrorTracking:!1,errorTranslator:g,disableCookies:m,...o,data:{...s?{env_key:s}:{},player_software_name:u,player_software:u,player_software_version:c,player_init_time:d,...p}})}},qL=(i,e,t)=>{var r,s;let n=iT(i,e),{src:a,customDomain:o=er}=i,l=()=>{e.ended||!Sm(e,t)||(eT(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},d,u,c=()=>{let h=Rd(e),f,m;h.length>0&&(f=h.start(0),m=h.end(0)),(u!==m||d!==f)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),d=f,u=m};if(rt(e,"durationchange",c),e&&n){let h=yd(i);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=xd(a),g=new URL(`https://stream.${o}/${p}/metadata.json`);ym(g.toString(),e)}let f=()=>{if(Td(e)!==Se.LIVE||Number.isFinite(e.duration))return;let p=setInterval(c,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})},m=async()=>kL(a,e,h).then(f).catch(p=>{if(p instanceof Response){let g=Ed(p,Ne.VIDEO,i);if(g){jt(e,g);return}}else p instanceof Error});if(e.preload==="none"){let p=()=>{m(),e.removeEventListener("loadedmetadata",g)},g=()=>{m(),e.removeEventListener("play",p)};rt(e,"play",p,{once:!0}),rt(e,"loadedmetadata",g,{once:!0})}else m();(r=i.tokens)!=null&&r.drm?WL(i,e):rt(e,"encrypted",()=>{let p=Q("Attempting to play DRM-protected content without providing a DRM token."),g=new K(p,K.MEDIA_ERR_ENCRYPTED,!0);g.errorCategory=Ne.DRM,g.muxCode=J.ENCRYPTED_MISSING_TOKEN,jt(e,g)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=Xe.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",nT,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",aT),e.addEventListener("error",fm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(f=>{f.remove()})},{once:!0}),rt(e,"pause",l),rt(e,"seeked",l),rt(e,"play",()=>{e.ended||JE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ve.Events.LEVEL_LOADED,(h,f)=>{DL(f.details,e,t),c(),Td(e)===Se.LIVE&&!Number.isFinite(e.duration)&&(t.on(ve.Events.LEVEL_UPDATED,c),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ve.Events.LEVELS_UPDATED,c)}))}),t.on(ve.Events.ERROR,(h,f)=>{var m,p;let g=jL(f,i);if(g.muxCode===J.NETWORK_NOT_READY){let v=(m=Xe.get(e))!=null?m:{},y=(p=v.retryCount)!=null?p:0;if(y<6){let T=y===0?5e3:6e4,_=new K(`Retrying in ${T/1e3} seconds...`,g.code,g.fatal);Object.assign(_,g),jt(e,_),setTimeout(()=>{v.retryCount=y+1,f.details==="manifestLoadError"&&f.url&&t.loadSource(f.url)},T);return}else{v.retryCount=0;let T=new K('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',g.code,g.fatal);Object.assign(T,g),jt(e,T);return}}jt(e,g)}),t.on(ve.Events.MANIFEST_LOADED,()=>{let h=Xe.get(e);h&&h.error&&(h.error=null,h.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",fm),rt(e,"waiting",l),mL(i,t),pL(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function nT(i){var e;let t=i.target,r=(e=Xe.get(t))==null?void 0:e.startTime;if(r&&iL(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function aT(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=_m(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&jt(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}jt(e,s)}function jt(i,e){var t;e.fatal&&(((t=Xe.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function fm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Xe.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var jL=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ve.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ve.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ve.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ve.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ve.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===ve.ErrorTypes.NETWORK_ERROR)return Ne.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Ne.VIDEO;l=(r=Ed(i.response,u,e,i.fatal))!=null?r:new K("",d,i.fatal)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=Q("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_MISSING_TOKEN}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=Q("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_CDM_ERROR}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
45
45
  `:""}${i.response&&(i.response.code||i.response.text)?`response: ${i.response.code}, ${i.response.text}
46
46
  `:""}${i.reason?`failure reason: ${i.reason}
47
47
  `:""}${i.level?`level: ${i.level}
@@ -41,7 +41,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
41
41
  } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=Sl(this.config),n=e.map(vh).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Th(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof wt?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=vh(e.keyFormat),n=s?[s]:Sl(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Sl(this.config)),e.length===0)throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new im,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:v}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${v.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,v).catch(y=>{this.handleError(y),u.emit("error",y)}):g==="license-release"?e.keySystem===ke.FAIRPLAY&&(this.updateKeySession(e,Hh("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${bi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${bi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:pt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Hh(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==ke.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Pa.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};cd.CDMCleanupPromise=void 0;var wt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},At;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(At||(At={}));var Uf;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(Uf||(Uf={}));var fs;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(fs||(fs={}));var JR={[fs.OBJECT]:["br","d","ot","tb"],[fs.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[fs.SESSION]:["cid","pr","sf","sid","st","v"],[fs.STATUS]:["bs","rtp"]},Ka=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},hd=class{constructor(e){this.description=void 0,this.description=e}},eI="Dict";function tI(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function iI(i,e,t,r){return new Error(`failed to ${i} "${tI(e)}" as ${t}`,{cause:r})}var bv="Bare Item",rI="Boolean",sI="Byte Sequence",nI="Decimal",aI="Integer";function oI(i){return i<-999999999999999||999999999999999<i}var lI=/[\x00-\x1f\x7f]+/,dI="Token",uI="Key";function Si(i,e,t){return iI("serialize",i,e,t)}function cI(i){if(typeof i!="boolean")throw Si(i,rI);return i?"?1":"?0"}function hI(i){return btoa(String.fromCharCode(...i))}function fI(i){if(ArrayBuffer.isView(i)===!1)throw Si(i,sI);return`:${hI(i)}:`}function TE(i){if(oI(i))throw Si(i,aI);return i.toString()}function mI(i){return`@${TE(i.getTime()/1e3)}`}function bE(i,e){if(i<0)return-bE(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function pI(i){let e=bE(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Si(i,nI);let t=e.toString();return t.includes(".")?t:`${t}.0`}var gI="String";function vI(i){if(lI.test(i))throw Si(i,gI);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function EI(i){return i.description||i.toString().slice(7,-1)}function yv(i){let e=EI(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Si(e,dI);return e}function Ff(i){switch(typeof i){case"number":if(!j(i))throw Si(i,bv);return Number.isInteger(i)?TE(i):pI(i);case"string":return vI(i);case"symbol":return yv(i);case"boolean":return cI(i);case"object":if(i instanceof Date)return mI(i);if(i instanceof Uint8Array)return fI(i);if(i instanceof hd)return yv(i);default:throw Si(i,bv)}}function Bf(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Si(i,uI);return i}function nm(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${Bf(e)}`:`;${Bf(e)}=${Ff(t)}`).join("")}function yE(i){return i instanceof Ka?`${Ff(i.value)}${nm(i.params)}`:Ff(i)}function TI(i){return`(${i.value.map(yE).join(" ")})${nm(i.params)}`}function bI(i,e={whitespace:!0}){if(typeof i!="object")throw Si(i,eI);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Ka||(n=new Ka(n));let a=Bf(s);return n.value===!0?a+=nm(n.params):(a+="=",Array.isArray(n.value)?a+=TI(n):a+=yE(n)),a}).join(`,${r}`)}function yI(i,e){return bI(i,e)}var _I=i=>i==="ot"||i==="sf"||i==="st",AI=i=>typeof i=="number"?j(i):i!=null&&i!==""&&i!==!1;function SI(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function xI(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var $l=i=>Math.round(i),RI=(i,e)=>(e!=null&&e.baseUrl&&(i=SI(i,e.baseUrl)),encodeURIComponent(i)),Ol=i=>$l(i/100)*100,II={br:$l,d:$l,bl:Ol,dl:Ol,mtp:Ol,nor:RI,rtp:Ol,tb:$l};function LI(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=it({},II,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||AI(o)&&(_I(a)&&typeof o=="string"&&(o=new hd(o)),t[a]=o))}),t}function _E(i,e={}){return i?yI(LI(i,e),it({whitespace:!1},e)):""}function kI(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(JR).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||fs.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=_E(o,e),n),{})}function wI(i,e,t){return it(i,kI(e,t))}var DI="CMCD";function CI(i,e={}){if(!i)return"";let t=_E(i,e);return`${DI}=${encodeURIComponent(t)}`}var _v=/CMCD=[^&#]+/;function MI(i,e,t){let r=CI(e,t);if(!r)return i;if(_v.test(i))return i.replace(_v,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var $f=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:At.MANIFEST,su:!this.initialized})}catch(n){L.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===At.VIDEO||o===At.AUDIO||o==At.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){L.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||xI(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:Uf.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){it(t,this.createData());let r=t.ot===At.INIT||t.ot===At.VIDEO||t.ot===At.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),wI(e.headers,t)):e.url=MI(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return At.TIMED_TEXT;if(e.sn==="initSegment")return At.INIT;if(t==="audio")return At.AUDIO;if(t==="main")return this.hls.audioTracks.length?At.VIDEO:At.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===At.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===At.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ve.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},OI=3e5,Hf=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===ft.SendAlternateToPenaltyBox&&r.flags===ai.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>OI&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Wv(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===Ae.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===Ae.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new qe(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=AE(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new _r({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),Av(this.audioTracks,r,l,a),Av(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":v}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let y={steeringManifest:m,url:s.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,y),v&&this.updatePathwayPriority(v)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function Av(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=it({},a);return o.details=void 0,o.attrs=new qe(o.attrs),o.url=o.attrs.URI=AE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function AE(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var PI=/^age:\s*[\d.]+\s*$/im,fd=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 mn,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=!0,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,r){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=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[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),r.timeout=n&&j(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.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-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){let c=o!=null?o:t.response;if(c!=null){r.loading.end=Math.max(self.performance.now(),r.loading.first);let h=t.responseType==="arraybuffer"?c.byteLength:c.length;if(r.loaded=r.total=h,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let f=this.callbacks.onProgress;if(f&&f(r,e,c,t),!this.callbacks)return;let m={url:t.responseURL,data:c,code:a};this.callbacks.onSuccess(m,r,e,t);return}}let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Ql(l,d,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ql(e,t,!0))this.retry(e);else{var r;L.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Zf(e,r.retry),r.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.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&&PI.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}};function NI(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var UI=/(\d+)-(\d+)\/(\d+)/,md=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||HI,this.controller=new self.AbortController,this.stats=new mn}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=!0,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,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=FI(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&j(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new Gf(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=$I(c.headers)||s.total,a&&j(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!j(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}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,r,s=0,n){let a=new ed,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function FI(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(it({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function BI(i){let e=UI.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function $I(i){let e=i.get("Content-Range");if(e){let r=BI(e);if(j(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function HI(i,e){return new self.Request(i.url,e)}var Gf=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},GI=/\s/,KI={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)GI.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=mE(d.trim()),m=sm(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Hv(i,h))),s}},VI={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},SE=pt(pt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:fd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Jh,bufferController:Rf,capLevelController:Pf,errorController:Qh,fpsController:Nf,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Rv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:VI},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},WI()),{},{subtitleStreamController:_f,subtitleTrackController:Sf,timelineController:Of,audioStreamController:Tf,audioTrackController:yf,emeController:cd,cmcdController:$f,contentSteeringController:Hf});function WI(){return{cueHandler:KI,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function YI(i,e){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 t=Kf(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),pt(pt({},t),e)}function Kf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Kf):Object.keys(i).reduce((e,t)=>(e[t]=Kf(i[t]),e),{}):i}function qI(i){let e=i.loader;e!==md&&e!==fd?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):NI()&&(i.loader=md,i.progressive=!0,i.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Uh,Vf=class extends Ua{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.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 r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(Uh||(Uh=/chrome|firefox/i.test(navigator.userAgent)),Uh&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=ql(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=bx(p));let{width:g,height:v,unknownCodecs:y}=u;if(o||(o=!!(g&&v)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!Ah(m,"audio",r)||p&&!Ah(p,"video",r))return;let{CODECS:T,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":k,RESOLUTION:R,"VIDEO-RANGE":x}=f,w=`${`${k||"."}-`}${u.bitrate}-${R}-${_}-${T}-${x}-${A}`;if(n[w])if(n[w].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let C=a[w]+=1;u.attrs["PATHWAY-ID"]=new Array(C+1).join(".");let P=new _r(u);n[w]=P,s.push(P)}else n[w].addGroupId("audio",f.AUDIO),n[w].addGroupId("text",f.SUBTITLES);else{let C=new _r(u);n[w]=C,a[w]=1,s.push(C)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:v})=>(!!m||!!(g&&v))&&wx(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Ah(p.audioCodec,"audio",m)),Sv(a)}t.subtitles&&(o=t.subtitles,Sv(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return jl.indexOf(m.videoRange)-jl.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=B0(m.videoCodec),v=B0(p.videoCodec);if(g!==v)return v-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=Yl(m.codecSet),v=Yl(p.codecSet);if(g!==v)return v-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let v=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);v>g&&g===SE.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(E.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&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 ${r}${n?" with Pathway "+n:""}`);let l={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(E.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}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}onError(e,t){t.fatal||!t.context||t.context.type===Ae.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===se.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||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;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));Wv(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function Sv(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Wf=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=M.KEY_LOAD_ERROR,r,s,n){return new li({type:ne.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}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 r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:v,url:y}=m;if(!g.decryptdata||v!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));v.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,v.loader=null,a({frag:g,keyInfo:v})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,pt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function xE(){return self.SourceBuffer||self.WebKitSourceBuffer}function RE(){if(!gs())return!1;let e=xE();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function jI(){if(!RE())return!1;let i=gs();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(Na(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(Na(e,"audio"))))}function zI(){var i;let e=xE();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var XI=250,Hl=2,QI=.1,ZI=.05,Yf=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;L.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ve.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ve.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>Hl,v=!c||t&&t.start<=a||c-a>Hl&&!this.fragmentTracker.getPartialFragment(a);if(g||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let v=Math.max(c,u.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,_=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:Hl,A=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=_||A)){s.paused||this._trySkipBufferHole(A);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=XI&&(this._reportStall(u),!this.media))return;let p=Ve.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(n.message),t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ve.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,se.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,se.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let v=h.getPartialFragment(g);if(v)g+=v.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+ZI,n+QI);if(L.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);L.warn(o.message),r.currentTime=a,t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},JI=100,qf=class extends $a{constructor(e,t,r){super(e,t,r,"[stream-controller]",se.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(JI),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(E.BUFFER_EOS,p),this.state=N.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 d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==mt.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[g-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 g=this.audioOnly&&!this.altAudio?we.AUDIO:we.VIDEO,v=(g===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,g,se.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,se.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===mt.NOT_LOADED||s===mt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):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)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,se.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 r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.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,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,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 N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Yf(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;j(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!zI(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==N.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(E.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new od(this.hls,se.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new Fa(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),v=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,v)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){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();let n=this.hls;r&&(n.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==se.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(se.MAIN,t);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===Ae.LEVEL&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ve.getBuffered(e).length){let r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==we.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===we.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,se.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ve.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_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=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(E.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){let T=l.initSegment||l;this._bufferInitSegment(u,m.tracks,T,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:r,tracks:m.tracks})}let v=m.initPTS,y=m.timescale;j(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:y},s.trigger(E.INIT_PTS_FOUND,{frag:l,id:r,initPTS:v,timescale:y}))}if(c&&p&&l.sn!=="initSegment"){let v=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,T=!v||l.cc>v.cc;if(n.independent!==!1){let{startPTS:_,endPTS:A,startDTS:k,endDTS:R}=c;if(d)d.elementaryStreams[c.type]={startPTS:_,endPTS:A,startDTS:k,endDTS:R};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){let x=this.getMainFwdBufferInfo(),O=(x?x.end:this.getLoadPosition())+this.config.maxBufferHole,w=c.firstKeyFramePTS?c.firstKeyFramePTS:_;if(!y&&O<w-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,R,!0)}else y&&_>Hl&&(l.gap=!0);l.setElementaryStreamInfo(c.type,_,A,k,R),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,y||T)}else if(y||T)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:v,endPTS:y,startDTS:T,endDTS:_}=g;d&&(d.elementaryStreams[we.AUDIO]={startPTS:v,endPTS:y,startDTS:T,endDTS:_}),l.setElementaryStreamInfo(we.AUDIO,v,y,T,_),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let v={id:r,frag:l,details:p,samples:f.samples};s.trigger(E.FRAG_PARSING_METADATA,v)}if(p&&h){let v={id:r,frag:l,details:p,samples:h.samples};s.trigger(E.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(E.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,se.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ve.isBuffered(e,r)?t=this.getAppendedFrag(r):Ve.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(E.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(E.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&j(t)&&j(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}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}},Va=class i{static get version(){return"1.5.20"}static isMSESupported(){return RE()}static isSupported(){return jI()}static getMediaSource(){return gs()}static get Events(){return E}static get ErrorTypes(){return ne}static get ErrorDetails(){return M}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:SE}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new im,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,MS(e.debug||!1,"Hls instance");let t=this.config=YI(i.DefaultConfig,e);this.userConfig=e,t.progressive&&qI(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new Kh(this),m=new Yh(this),p=t.contentSteeringController,g=p?new p(this):null,v=this.levelController=new Vf(this,g),y=new tf(this),T=new Wf(this.config),_=this.streamController=new qf(this,y,T);c.setStreamController(_),h.setStreamController(_);let A=[f,v,_];g&&A.splice(1,0,g),this.networkControllers=A;let k=[d,u,c,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,A);let R=t.audioStreamController;R&&A.push(new R(this,y,T)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let x=t.subtitleStreamController;x&&A.push(new x(this,y,T)),this.createController(t.timelineController,k),T.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(qh,k),this.coreComponents=k,A.push(l);let O=l.onErrorOut;typeof O=="function"&&this.on(E.ERROR,O,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===E.ERROR;this.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(E.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){L.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=jf.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.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){L.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 ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){kx(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 r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}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()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||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:!1}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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};Va.defaultConfig=void 0;var ve=Va,Ne={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},J={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},qa=i=>i===Ne.VIDEO?"playback":i,Ar=class Wa extends Error{constructor(e,t=Wa.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Wa.MEDIA_ERR_NETWORK&&t<=Wa.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Wa.defaultMessages[this.code])!=null?n:"")}};Ar.MEDIA_ERR_ABORTED=1,Ar.MEDIA_ERR_NETWORK=2,Ar.MEDIA_ERR_DECODE=3,Ar.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Ar.MEDIA_ERR_ENCRYPTED=5,Ar.MEDIA_ERR_CUSTOM=100,Ar.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var K=Ar,eL=i=>i==null,mm=(i,e)=>eL(e)?!1:i in e,lm={ANY:"any",MUTED:"muted"},Se={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},zt={MSE:"mse",NATIVE:"native"},Ya={HEADER:"header",QUERY:"query",NONE:"none"},vn=Object.values(Ya),Ji={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},dm={HLS:Ji.M3U8},SM=Object.keys(dm),xM=[...Object.values(Ji),"hls","HLS"];var tL="en",um={code:tL},rt=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function iL(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var bd=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},yd=i=>{let{type:e}=i;if(e){let t=e.toUpperCase();return mm(t,dm)?dm[t]:e}return rL(i)},NE=i=>i==="VOD"?Se.ON_DEMAND:Se.LIVE,UE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,rL=i=>{let{src:e}=i;if(!e)return"";let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return nL(i)?Ji.M3U8:"";let s=t.slice(r+1).toUpperCase();return mm(s,Ji)?Ji[s]:""},sL="mux.com",nL=({src:i,customDomain:e=sL})=>{let t;try{t=new URL(`${i}`)}catch{return!1}let r=t.protocol==="https:",s=t.hostname===`stream.${e}`.toLowerCase(),n=t.pathname.split("/"),a=n.length===2,o=!(n!=null&&n[1].includes("."));return r&&s&&a&&o},Sr=i=>{let e=(i!=null?i:"").split(".")[1];if(e)try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}catch{return}},aL=({exp:i},e=Date.now())=>!i||i*1e3<e,oL=({sub:i},e)=>i!==e,lL=({aud:i},e)=>!i,dL=({aud:i},e)=>i!==e,FE="en";function Q(i,e=!0){var t,r;let s=e&&(r=(t=um)==null?void 0:t[i])!=null?r:i,n=e?um.code:FE;return new uL(s,n)}var uL=class{constructor(i,e=(t=>(t=um)!=null?t:FE)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}},cL=Object.values(lm),IE=i=>typeof i=="boolean"||typeof i=="string"&&cL.includes(i),hL=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=IE(r)?r:!!r,o=()=>{s||rt(e,"playing",()=>{s=!0},{once:!0})};if(o(),rt(e,"loadstart",()=>{s=!1,o(),am(e,a)},{once:!0}),rt(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==Se.UNKNOWN?n=i.streamType===Se.LIVE:n=!Number.isFinite(e.duration)),am(e,a)},{once:!0}),t&&t.once(ve.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==Se.UNKNOWN?n=i.streamType===Se.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&rt(e,"play",()=>{e.preload==="metadata"?t.once(ve.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=IE(l)?l:!!l,am(e,a))}},am=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case lm.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case lm.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},fL=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return rt(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function mL(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(ve.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(ve.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(ve.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(ve.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(ve.Events.BUFFER_FLUSHING,h),c||e.trigger(ve.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(ve.Events.DESTROYING,l)}var om=i=>"time"in i?i.time:i.startTime;function pL(i,e){e.on(ve.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o,l;let d=(o=a.subtitleTrack)!=null?o:a.closedCaptions,u=e.subtitleTracks.findIndex(({lang:h,name:f,type:m})=>h==(d==null?void 0:d.lang)&&f===a.label&&m.toLowerCase()===a.kind),c=((l=a._id)!=null?l:a.default)?"default":`${a.kind}${u}`;_d(i,a.kind,a.label,d==null?void 0:d.lang,c,a.default)})});let t=()=>{if(!e.subtitleTracks.length)return;let s=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind));if(!s)return;let n=e.subtitleTracks[e.subtitleTrack],a=n?n.default?"default":`${e.subtitleTracks[e.subtitleTrack].type.toLowerCase()}${e.subtitleTrack}`:void 0;if(e.subtitleTrack<0||(s==null?void 0:s.id)!==a){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u,default:c})=>s.id==="default"&&c||l==s.language&&d===s.label&&u.toLowerCase()===s.kind);e.subtitleTrack=o}(s==null?void 0:s.id)===a&&s.cues&&Array.from(s.cues).forEach(o=>{s.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(ve.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(ve.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&(s.label==="thumbnails"||s.kind==="chapters")){if(!((n=s.cues)!=null&&n.length)){let o="track";s.kind&&(o+=`[kind="${s.kind}"]`),s.label&&(o+=`[label="${s.label}"]`);let l=i.querySelector(o),d=(a=l==null?void 0:l.getAttribute("src"))!=null?a:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",d)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(ve.Events.MANIFEST_LOADED,r),e.once(ve.Events.MEDIA_ATTACHED,r)}function _d(i,e,t,r,s,n){let a=document.createElement("track");return a.kind=e,a.label=t,r&&(a.srclang=r),s&&(a.id=s),n&&(a.default=!0),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),i.append(a),a.track}function BE(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function ja(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function $E(i,e,t,r){let s=ja(i,t,r);return s||(s=_d(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>om(a)-om(n)).forEach(n=>{var a,o;let l=n.value,d=om(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var pm="cuepoints",HE=Object.freeze({label:pm});async function gm(i,e,t=HE){return $E(i,e,t.label,"metadata")}var cm=i=>({time:i.startTime,value:JSON.parse(i.text)});function GE(i,e={label:pm}){let t=ja(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>cm(r)):[]}function vm(i,e={label:pm}){var t,r;let s=ja(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return cm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return cm(a||s.activeCues[0])}async function gL(i,e=HE){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await gm(i,[],e);rt(i,"cuechange",()=>{let s=vm(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var Em="chapters",KE=Object.freeze({label:Em}),hm=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function Tm(i,e,t=KE){return $E(i,e,t.label,"chapters")}function VE(i,e={label:Em}){var t;let r=ja(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>hm(s)):[]}function bm(i,e={label:Em}){var t,r;let s=ja(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return hm(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return hm(a||s.activeCues[0])}async function vL(i,e=KE){return new Promise(t=>{rt(i,"loadstart",async()=>{let r=await Tm(i,[],e);rt(i,"cuechange",()=>{let s=bm(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function WE(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function YE(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var gn={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},EL=i=>{if(i===Ne.VIDEO)return gn.VIDEO;if(i===Ne.DRM)return gn.DRM},TL=(i,e)=>{var t,r;let s=qa(i),n=`${s}Token`;return(t=e.tokens)!=null&&t[s]?(r=e.tokens)==null?void 0:r[s]:mm(n,e)?e[n]:void 0},Ed=(i,e,t,r,s=!1,n=!(a=>(a=globalThis.navigator)==null?void 0:a.onLine)())=>{var a,o;if(n){let v=Q("Your device appears to be offline",s),y,T=K.MEDIA_ERR_NETWORK,_=new K(v,T,!1,y);return _.errorCategory=e,_.muxCode=J.NETWORK_OFFLINE,_.data=i,_}let l="status"in i?i.status:i.code,d=Date.now(),u=K.MEDIA_ERR_NETWORK;if(l===200)return;let c=qa(e),h=TL(e,t),f=EL(e),[m]=bd((a=t.playbackId)!=null?a:"");if(!l||!m)return;let p=Sr(h);if(h&&!p){let v=Q("The {tokenNamePrefix}-token provided is invalid or malformed.",s).format({tokenNamePrefix:c}),y=Q("Compact JWT string: {token}",s).format({token:h}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_MALFORMED,T.data=i,T}if(l>=500){let v=new K("",u,r!=null?r:!0);return v.errorCategory=e,v.muxCode=J.NETWORK_UNKNOWN_ERROR,v}if(l===403)if(p){if(aL(p,d)){let v={timeStyle:"medium",dateStyle:"medium"},y=Q("The video\u2019s secured {tokenNamePrefix}-token has expired.",s).format({tokenNamePrefix:c}),T=Q("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat("en",v).format((o=p.exp)!=null?o:0*1e3),currentDate:new Intl.DateTimeFormat("en",v).format(d)}),_=new K(y,u,!0,T);return _.errorCategory=e,_.muxCode=J.NETWORK_TOKEN_EXPIRED,_.data=i,_}if(oL(p,m)){let v=Q("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",s).format({tokenNamePrefix:c}),y=Q("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",s).format({tokenNamePrefix:c,playbackId:m,tokenPlaybackId:p.sub}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_SUB_MISMATCH,T.data=i,T}if(lL(p,f)){let v=Q("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:c}),y=Q("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",s).format({tokenNamePrefix:c,expectedAud:f}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_AUD_MISSING,T.data=i,T}if(dL(p,f)){let v=Q("The {tokenNamePrefix}-token is formatted with incorrect information.",s).format({tokenNamePrefix:c}),y=Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",s).format({tokenNamePrefix:c,expectedAud:f,aud:p.aud}),T=new K(v,u,!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_AUD_MISMATCH,T.data=i,T}}else{let v=Q("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",s).format({tokenNamePrefix:c,category:e}),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_TOKEN_MISSING,T.data=i,T}if(l===412){let v=Q("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_NOT_READY,T.streamType=t.streamType===Se.LIVE?"live":t.streamType===Se.ON_DEMAND?"on-demand":"unknown",T.data=i,T}if(l===404){let v=Q("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_NOT_FOUND,T.data=i,T}if(l===400){let v=Q("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),y=Q("Specified playback ID: {playbackId}",s).format({playbackId:m}),T=new K(v,u,r!=null?r:!0,y);return T.errorCategory=e,T.muxCode=J.NETWORK_INVALID_URL,T.data=i,T}let g=new K("",u,r!=null?r:!0);return g.errorCategory=e,g.muxCode=J.NETWORK_UNKNOWN_ERROR,g.data=i,g},LE=ve.DefaultConfig.capLevelController,qE=class jE extends LE{constructor(e){super(e)}get levels(){var e;return(e=this.hls.levels)!=null?e:[]}getValidLevels(e){return this.levels.filter((t,r)=>this.isLevelAllowed(t)&&r<=e)}getMaxLevel(e){let t=super.getMaxLevel(e),r=this.getValidLevels(e);if(!r[t])return t;let s=Math.min(r[t].width,r[t].height),n=jE.minMaxResolution;return s>=n?t:LE.getMaxLevelByMediaSize(r,n*(16/9),n)}};qE.minMaxResolution=720;var bL=qE,yL=bL,gd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},_L=i=>{if(i.includes("fps"))return gd.FAIRPLAY;if(i.includes("playready"))return gd.PLAYREADY;if(i.includes("widevine"))return gd.WIDEVINE},AL=i=>{let e=i.split(`
42
42
  `).find((t,r,s)=>r&&s[r-1].startsWith("#EXT-X-STREAM-INF"));return fetch(e).then(t=>t.status!==200?Promise.reject(t):t.text())},SL=i=>{let e=i.split(`
43
43
  `).filter(r=>r.startsWith("#EXT-X-SESSION-DATA"));if(!e.length)return{};let t={};for(let r of e){let s=RL(r),n=s["DATA-ID"];n&&(t[n]={...s})}return{sessionData:t}},xL=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g;function RL(i){let e=[...i.matchAll(xL)];return Object.fromEntries(e.map(([,t,r])=>[t,r]))}var IL=i=>{var e,t,r;let s=i.split(`
44
- `),n=(t=((e=s.find(d=>d.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),a=NE(n),o=UE(n),l;if(a===Se.LIVE){let d=s.find(u=>u.startsWith("#EXT-X-PART-INF"));if(d)l=+d.split(":")[1].split("=")[1]*2;else{let u=s.find(h=>h.startsWith("#EXT-X-TARGETDURATION")),c=(r=u==null?void 0:u.split(":"))==null?void 0:r[1];l=+(c!=null?c:6)*3}}return{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}},LL=async(i,e)=>{if(e===Ji.MP4)return{streamType:Se.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(e===Ji.M3U8){let t=await fetch(i);if(!t.ok)return Promise.reject(t);let r=await t.text(),s=await AL(r);return{...SL(r),...IL(s)}}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},kL=async(i,e,t=yd({src:i}))=>{var r,s,n,a;let{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:d,sessionData:u}=await LL(i,t),c=u==null?void 0:u["com.apple.hls.chapters"];(c!=null&&c.URI||c!=null&&c.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((r=c.URI)!=null?r:c.VALUE,e),((s=Xe.get(e))!=null?s:{}).liveEdgeStartOffset=d,((n=Xe.get(e))!=null?n:{}).targetLiveWindow=l,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((a=Xe.get(e))!=null?a:{}).streamType=o,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ym=async(i,e)=>{var t;try{let r=await fetch(i);if(!r.ok)throw new Error(`Failed to fetch Mux metadata: ${r.status} ${r.statusText}`);let s=await r.json(),n={};for(let o of s[0].metadata)o.key&&o.value&&(n[o.key]=o.value);((t=Xe.get(e))!=null?t:{}).metadata=n;let a=new CustomEvent("muxmetadata");e.dispatchEvent(a)}catch(r){console.error(r)}},wL=i=>{var e;let t=i.type,r=NE(t),s=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Se.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},DL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=wL(i);if(c===Se.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=Xe.get(e))!=null?o:{}).seekable=p}((l=Xe.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Xe.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Xe.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},kE,wE,CL=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgent)!=null?wE:"",DE,CE,ME,ML=(ME=(CE=(DE=globalThis==null?void 0:globalThis.navigator)==null?void 0:DE.userAgentData)==null?void 0:CE.platform)!=null?ME:"",OL=CL.toLowerCase().includes("android")||["x11","android"].some(i=>ML.toLowerCase().includes(i)),Xe=new WeakMap,er="mux.com",OE,PE,zE=(PE=(OE=ve).isSupported)==null?void 0:PE.call(OE),PL=OL,Ad=()=>_l.utils.now(),NL=_l.utils.generateUUID,za=({playbackId:i,customDomain:e=er,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=bd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},Sd=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},xd=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(/\.m3u8|\//);return e||void 0},UL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:sT(i)&&(r=(t=Sd(i.playbackId))!=null?t:xd(i.src))!=null?r:i.src},_m=i=>{var e;return(e=Xe.get(i))==null?void 0:e.error},XE=i=>{var e;return(e=Xe.get(i))==null?void 0:e.metadata},Td=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.streamType)!=null?t:Se.UNKNOWN},QE=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Rd=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},ZE=i=>{var e;let t=(e=Xe.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Rd(i);return r.length?r.end(r.length-1)-t:Number.NaN},Am=.034,FL=(i,e,t=Am)=>Math.abs(i-e)<=t,JE=(i,e,t=Am)=>i>e||FL(i,e,t),BL=(i,e=Am)=>i.paused&&JE(i.currentTime,i.duration,e),eT=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Sm=(i,e)=>i.ended||i.loop?i.ended:e&&eT(i,e)?!0:BL(i),tT=(i,e,t)=>{xm(e,t,i);let{metadata:r={}}=i,{view_session_id:s=NL()}=r,n=UL(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,Xe.set(e,{retryCount:0});let o=$L(i,e),l=fL(i,e,o);i!=null&&i.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?ve:void 0}):YL(i,e,o),qL(i,e,o),gL(e),vL(e);let d=hL(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},xm=(i,e,t)=>{let r=e==null?void 0:e.engine;i!=null&&i.mux&&!i.mux.deleted&&(t!=null&&t.muxDataKeepSession?r&&i.mux.removeHLSJS():(i.mux.destroy(),delete i.mux)),r&&(r.detachMedia(),r.destroy()),i&&(i.hasAttribute("src")&&(i.removeAttribute("src"),i.load()),i.removeEventListener("error",aT),i.removeEventListener("error",fm),i.removeEventListener("durationchange",nT),Xe.delete(i),i.dispatchEvent(new Event("teardown")))};function iT(i,e){var t;let r=yd(i);if(r!==Ji.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===zt.MSE,o=n===zt.NATIVE;return s&&(o||!(zE&&(a||PL)))}var $L=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yd(i)===Ji.M3U8,d=iT(i,e);if(l&&!d&&zE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=HL(r),h=GL(i),f=[Ya.QUERY,Ya.HEADER].includes(a)?{useHeaders:a===Ya.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0,m=new ve({debug:t,startPosition:s,cmcd:f,xhrSetup:(p,g)=>{var v,y;if(a&&a!==Ya.QUERY)return;let T=new URL(g);if(!T.searchParams.has("CMCD"))return;let _=((y=(v=T.searchParams.get("CMCD"))==null?void 0:v.split(","))!=null?y:[]).filter(A=>A.startsWith("sid")||A.startsWith("cid")).join(",");T.searchParams.set("CMCD",_),p.open("GET",T)},capLevelController:yL,...u,...c,...h,...o});return m.on(ve.Events.MANIFEST_PARSED,async function(p,g){var v;let y=(v=g.sessionData)==null?void 0:v["com.apple.hls.chapters"];y!=null&&y.VALUE&&ym(y.VALUE,e)}),m}},HL=i=>i===Se.LIVE?{backBufferLength:8}:{},GL=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=Sd(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:vd(i,"fairplay"),serverCertificateUrl:rT(i,"fairplay")},"com.widevine.alpha":{licenseUrl:vd(i,"widevine")},"com.microsoft.playready":{licenseUrl:vd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=_L(n);return r==null||r(l),o}))}},KL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},VL=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},WL=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,gd.FAIRPLAY),u}).catch(()=>{let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Ne.DRM,c.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,jt(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await KL(rT(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=Ed(c,Ne.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Ne.DRM,h.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){jt(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}d&&jt(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED,jt(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l),o=await VL(a,vd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=Ed(l,Ne.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=Q("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){jt(e,r);return}})},vd=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/license/${r}/${s}?token=${e}`},rT=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/appcert/${r}/${s}?token=${e}`},sT=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(er)||!!t&&s.includes(t.toLocaleLowerCase())},YL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=_l,muxDataSDKOptions:o={}}=i,l=sT(i);if(!n&&(s||l)){let{playerInitTime:d,playerSoftwareName:u,playerSoftwareVersion:c,beaconCollectionDomain:h,debug:f,disableCookies:m}=i,p={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},g=v=>typeof v.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(v):v;a.monitor(e,{debug:f,beaconCollectionDomain:h,hlsjs:t,Hls:t?ve:void 0,automaticErrorTracking:!1,errorTranslator:g,disableCookies:m,...o,data:{...s?{env_key:s}:{},player_software_name:u,player_software:u,player_software_version:c,player_init_time:d,...p}})}},qL=(i,e,t)=>{var r,s;let n=iT(i,e),{src:a,customDomain:o=er}=i,l=()=>{e.ended||!Sm(e,t)||(eT(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},d,u,c=()=>{let h=Rd(e),f,m;h.length>0&&(f=h.start(0),m=h.end(0)),(u!==m||d!==f)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),d=f,u=m};if(rt(e,"durationchange",c),e&&n){let h=yd(i);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=xd(a),g=new URL(`https://stream.${o}/${p}/metadata.json`);ym(g.toString(),e)}let f=()=>{if(Td(e)!==Se.LIVE||Number.isFinite(e.duration))return;let p=setInterval(c,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})},m=async()=>kL(a,e,h).then(f).catch(p=>{if(p instanceof Response){let g=Ed(p,Ne.VIDEO,i);if(g){jt(e,g);return}}else p instanceof Error});if(e.preload==="none"){let p=()=>{m(),e.removeEventListener("loadedmetadata",g)},g=()=>{m(),e.removeEventListener("play",p)};rt(e,"play",p,{once:!0}),rt(e,"loadedmetadata",g,{once:!0})}else m();(r=i.tokens)!=null&&r.drm?WL(i,e):rt(e,"encrypted",()=>{let p=Q("Attempting to play DRM-protected content without providing a DRM token."),g=new K(p,K.MEDIA_ERR_ENCRYPTED,!0);g.errorCategory=Ne.DRM,g.muxCode=J.ENCRYPTED_MISSING_TOKEN,jt(e,g)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=Xe.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",nT,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",aT),e.addEventListener("error",fm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(f=>{f.remove()})},{once:!0}),rt(e,"pause",l),rt(e,"seeked",l),rt(e,"play",()=>{e.ended||JE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ve.Events.LEVEL_LOADED,(h,f)=>{DL(f.details,e,t),c(),Td(e)===Se.LIVE&&!Number.isFinite(e.duration)&&(t.on(ve.Events.LEVEL_UPDATED,c),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ve.Events.LEVELS_UPDATED,c)}))}),t.on(ve.Events.ERROR,(h,f)=>{var m,p;let g=jL(f,i);if(g.muxCode===J.NETWORK_NOT_READY){let v=(m=Xe.get(e))!=null?m:{},y=(p=v.retryCount)!=null?p:0;if(y<6){let T=y===0?5e3:6e4,_=new K(`Retrying in ${T/1e3} seconds...`,g.code,g.fatal);Object.assign(_,g),jt(e,_),setTimeout(()=>{v.retryCount=y+1,f.details==="manifestLoadError"&&f.url&&t.loadSource(f.url)},T);return}else{v.retryCount=0;let T=new K('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',g.code,g.fatal);Object.assign(T,g),jt(e,T);return}}jt(e,g)}),t.on(ve.Events.MANIFEST_LOADED,()=>{let h=Xe.get(e);h&&h.error&&(h.error=null,h.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",fm),rt(e,"waiting",l),mL(i,t),pL(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function nT(i){var e;let t=i.target,r=(e=Xe.get(t))==null?void 0:e.startTime;if(r&&iL(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function aT(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=_m(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&jt(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}jt(e,s)}function jt(i,e){var t;e.fatal&&(((t=Xe.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function fm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Xe.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var jL=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ve.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ve.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ve.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ve.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ve.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===ve.ErrorTypes.NETWORK_ERROR)return Ne.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Ne.VIDEO;l=(r=Ed(i.response,u,e,i.fatal))!=null?r:new K("",d,i.fatal)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=Q("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_MISSING_TOKEN}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=Q("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_CDM_ERROR}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
44
+ `),n=(t=((e=s.find(d=>d.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),a=NE(n),o=UE(n),l;if(a===Se.LIVE){let d=s.find(u=>u.startsWith("#EXT-X-PART-INF"));if(d)l=+d.split(":")[1].split("=")[1]*2;else{let u=s.find(h=>h.startsWith("#EXT-X-TARGETDURATION")),c=(r=u==null?void 0:u.split(":"))==null?void 0:r[1];l=+(c!=null?c:6)*3}}return{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}},LL=async(i,e)=>{if(e===Ji.MP4)return{streamType:Se.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(e===Ji.M3U8){let t=await fetch(i);if(!t.ok)return Promise.reject(t);let r=await t.text(),s=await AL(r);return{...SL(r),...IL(s)}}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},kL=async(i,e,t=yd({src:i}))=>{var r,s,n,a;let{streamType:o,targetLiveWindow:l,liveEdgeStartOffset:d,sessionData:u}=await LL(i,t),c=u==null?void 0:u["com.apple.hls.chapters"];(c!=null&&c.URI||c!=null&&c.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((r=c.URI)!=null?r:c.VALUE,e),((s=Xe.get(e))!=null?s:{}).liveEdgeStartOffset=d,((n=Xe.get(e))!=null?n:{}).targetLiveWindow=l,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((a=Xe.get(e))!=null?a:{}).streamType=o,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ym=async(i,e)=>{var t;try{let r=await fetch(i);if(!r.ok)throw new Error(`Failed to fetch Mux metadata: ${r.status} ${r.statusText}`);let s=await r.json(),n={};for(let o of s[0].metadata)o.key&&o.value&&(n[o.key]=o.value);((t=Xe.get(e))!=null?t:{}).metadata=n;let a=new CustomEvent("muxmetadata");e.dispatchEvent(a)}catch(r){console.error(r)}},wL=i=>{var e;let t=i.type,r=NE(t),s=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return r===Se.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},DL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=wL(i);if(c===Se.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=Xe.get(e))!=null?o:{}).seekable=p}((l=Xe.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Xe.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Xe.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},kE,wE,CL=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgent)!=null?wE:"",DE,CE,ME,ML=(ME=(CE=(DE=globalThis==null?void 0:globalThis.navigator)==null?void 0:DE.userAgentData)==null?void 0:CE.platform)!=null?ME:"",OL=CL.toLowerCase().includes("android")||["x11","android"].some(i=>ML.toLowerCase().includes(i)),Xe=new WeakMap,er="mux.com",OE,PE,zE=(PE=(OE=ve).isSupported)==null?void 0:PE.call(OE),PL=OL,Ad=()=>_l.utils.now(),NL=_l.utils.generateUUID,za=({playbackId:i,customDomain:e=er,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:l,playbackToken:d,tokens:{playback:u=d}={},extraSourceParams:c={}}={})=>{if(!i)return;let[h,f=""]=bd(i),m=new URL(`https://stream.${e}/${h}.m3u8${f}`);return u||m.searchParams.has("token")?(m.searchParams.forEach((p,g)=>{g!="token"&&m.searchParams.delete(g)}),u&&m.searchParams.set("token",u)):(t&&m.searchParams.set("max_resolution",t),r&&(m.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&m.searchParams.set("rendition_order",s),n&&m.searchParams.set("program_start_time",`${n}`),a&&m.searchParams.set("program_end_time",`${a}`),o&&m.searchParams.set("asset_start_time",`${o}`),l&&m.searchParams.set("asset_end_time",`${l}`),Object.entries(c).forEach(([p,g])=>{g!=null&&m.searchParams.set(p,g)})),m.toString()},Sd=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},xd=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(/\.m3u8|\//);return e||void 0},UL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:sT(i)&&(r=(t=Sd(i.playbackId))!=null?t:xd(i.src))!=null?r:i.src},_m=i=>{var e;return(e=Xe.get(i))==null?void 0:e.error},XE=i=>{var e;return(e=Xe.get(i))==null?void 0:e.metadata},Td=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.streamType)!=null?t:Se.UNKNOWN},QE=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Rd=i=>{var e,t;return(t=(e=Xe.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},ZE=i=>{var e;let t=(e=Xe.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Rd(i);return r.length?r.end(r.length-1)-t:Number.NaN},Am=.034,FL=(i,e,t=Am)=>Math.abs(i-e)<=t,JE=(i,e,t=Am)=>i>e||FL(i,e,t),BL=(i,e=Am)=>i.paused&&JE(i.currentTime,i.duration,e),eT=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Sm=(i,e)=>i.ended||i.loop?i.ended:e&&eT(i,e)?!0:BL(i),tT=(i,e,t)=>{xm(e,t,i);let{metadata:r={}}=i,{view_session_id:s=NL()}=r,n=UL(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,Xe.set(e,{retryCount:0});let o=$L(i,e),l=fL(i,e,o);i!=null&&i.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?ve:void 0}):YL(i,e,o),qL(i,e,o),gL(e),vL(e);let d=hL(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},xm=(i,e,t)=>{let r=e==null?void 0:e.engine;i!=null&&i.mux&&!i.mux.deleted&&(t!=null&&t.muxDataKeepSession?r&&i.mux.removeHLSJS():(i.mux.destroy(),delete i.mux)),r&&(r.detachMedia(),r.destroy()),i&&(i.hasAttribute("src")&&(i.removeAttribute("src"),i.load()),i.removeEventListener("error",aT),i.removeEventListener("error",fm),i.removeEventListener("durationchange",nT),Xe.delete(i),i.dispatchEvent(new Event("teardown")))};function iT(i,e){var t;let r=yd(i);if(r!==Ji.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===zt.MSE,o=n===zt.NATIVE;return s&&(o||!(zE&&(a||PL)))}var $L=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yd(i)===Ji.M3U8,d=iT(i,e);if(l&&!d&&zE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=HL(r),h=GL(i),f=[Ya.QUERY,Ya.HEADER].includes(a)?{useHeaders:a===Ya.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0,m=new ve({debug:t,startPosition:s,cmcd:f,xhrSetup:(p,g)=>{var v,y;if(a&&a!==Ya.QUERY)return;let T=new URL(g);if(!T.searchParams.has("CMCD"))return;let _=((y=(v=T.searchParams.get("CMCD"))==null?void 0:v.split(","))!=null?y:[]).filter(A=>A.startsWith("sid")||A.startsWith("cid")).join(",");T.searchParams.set("CMCD",_),p.open("GET",T)},capLevelController:yL,...u,...c,...h,...o});return m.on(ve.Events.MANIFEST_PARSED,async function(p,g){var v,y;let T=(v=g.sessionData)==null?void 0:v["com.apple.hls.chapters"];(T!=null&&T.URI||T!=null&&T.VALUE.toLocaleLowerCase().startsWith("http"))&&ym((y=T==null?void 0:T.URI)!=null?y:T==null?void 0:T.VALUE,e)}),m}},HL=i=>i===Se.LIVE?{backBufferLength:8}:{},GL=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=Sd(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:vd(i,"fairplay"),serverCertificateUrl:rT(i,"fairplay")},"com.widevine.alpha":{licenseUrl:vd(i,"widevine")},"com.microsoft.playready":{licenseUrl:vd(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=_L(n);return r==null||r(l),o}))}},KL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},VL=async(i,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i});if(t.status!==200)return Promise.reject(t);let r=await t.arrayBuffer();return new Uint8Array(r)},WL=(i,e)=>{rt(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,gd.FAIRPLAY),u}).catch(()=>{let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new K(u,K.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=Ne.DRM,c.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,jt(e,c)});if(!l)return;let d=await l.createMediaKeys();try{let u=await KL(rT(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=Ed(c,Ne.DRM,i);return console.error("mediaError",h==null?void 0:h.message,h==null?void 0:h.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await d.setServerCertificate(u).catch(()=>{let c=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new K(c,K.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=Ne.DRM,h.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(u){jt(e,u);return}await e.setMediaKeys(d)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.addEventListener("keystatuseschange",()=>{n.keyStatuses.forEach(l=>{let d;if(l==="internal-error"){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_CDM_ERROR}else if(l==="output-restricted"||l==="output-downscaled"){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");d=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}d&&jt(e,d)})});let a=await Promise.all([n.generateRequest(r,s).catch(()=>{let l=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED,jt(e,d)}),new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})})]).then(([,l])=>l),o=await VL(a,vd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=Ed(l,Ne.DRM,i);return console.error("mediaError",d==null?void 0:d.message,d==null?void 0:d.context),d?Promise.reject(d):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(l)});await n.update(o).catch(()=>{let l=Q("Failed to update DRM license. This may be an issue with the player or your protected content."),d=new K(l,K.MEDIA_ERR_ENCRYPTED,!0);return d.errorCategory=Ne.DRM,d.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(d)})}catch(r){jt(e,r);return}})},vd=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/license/${r}/${s}?token=${e}`},rT=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=Sd(i);return`https://license.${t.toLocaleLowerCase().endsWith(er)?t:er}/appcert/${r}/${s}?token=${e}`},sT=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(er)||!!t&&s.includes(t.toLocaleLowerCase())},YL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=_l,muxDataSDKOptions:o={}}=i,l=sT(i);if(!n&&(s||l)){let{playerInitTime:d,playerSoftwareName:u,playerSoftwareVersion:c,beaconCollectionDomain:h,debug:f,disableCookies:m}=i,p={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},g=v=>typeof v.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(v):v;a.monitor(e,{debug:f,beaconCollectionDomain:h,hlsjs:t,Hls:t?ve:void 0,automaticErrorTracking:!1,errorTranslator:g,disableCookies:m,...o,data:{...s?{env_key:s}:{},player_software_name:u,player_software:u,player_software_version:c,player_init_time:d,...p}})}},qL=(i,e,t)=>{var r,s;let n=iT(i,e),{src:a,customDomain:o=er}=i,l=()=>{e.ended||!Sm(e,t)||(eT(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},d,u,c=()=>{let h=Rd(e),f,m;h.length>0&&(f=h.start(0),m=h.end(0)),(u!==m||d!==f)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),d=f,u=m};if(rt(e,"durationchange",c),e&&n){let h=yd(i);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=xd(a),g=new URL(`https://stream.${o}/${p}/metadata.json`);ym(g.toString(),e)}let f=()=>{if(Td(e)!==Se.LIVE||Number.isFinite(e.duration))return;let p=setInterval(c,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})},m=async()=>kL(a,e,h).then(f).catch(p=>{if(p instanceof Response){let g=Ed(p,Ne.VIDEO,i);if(g){jt(e,g);return}}else p instanceof Error});if(e.preload==="none"){let p=()=>{m(),e.removeEventListener("loadedmetadata",g)},g=()=>{m(),e.removeEventListener("play",p)};rt(e,"play",p,{once:!0}),rt(e,"loadedmetadata",g,{once:!0})}else m();(r=i.tokens)!=null&&r.drm?WL(i,e):rt(e,"encrypted",()=>{let p=Q("Attempting to play DRM-protected content without providing a DRM token."),g=new K(p,K.MEDIA_ERR_ENCRYPTED,!0);g.errorCategory=Ne.DRM,g.muxCode=J.ENCRYPTED_MISSING_TOKEN,jt(e,g)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=Xe.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",nT,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",aT),e.addEventListener("error",fm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(f=>{f.remove()})},{once:!0}),rt(e,"pause",l),rt(e,"seeked",l),rt(e,"play",()=>{e.ended||JE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(ve.Events.LEVEL_LOADED,(h,f)=>{DL(f.details,e,t),c(),Td(e)===Se.LIVE&&!Number.isFinite(e.duration)&&(t.on(ve.Events.LEVEL_UPDATED,c),rt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(ve.Events.LEVELS_UPDATED,c)}))}),t.on(ve.Events.ERROR,(h,f)=>{var m,p;let g=jL(f,i);if(g.muxCode===J.NETWORK_NOT_READY){let v=(m=Xe.get(e))!=null?m:{},y=(p=v.retryCount)!=null?p:0;if(y<6){let T=y===0?5e3:6e4,_=new K(`Retrying in ${T/1e3} seconds...`,g.code,g.fatal);Object.assign(_,g),jt(e,_),setTimeout(()=>{v.retryCount=y+1,f.details==="manifestLoadError"&&f.url&&t.loadSource(f.url)},T);return}else{v.retryCount=0;let T=new K('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',g.code,g.fatal);Object.assign(T,g),jt(e,T);return}}jt(e,g)}),t.on(ve.Events.MANIFEST_LOADED,()=>{let h=Xe.get(e);h&&h.error&&(h.error=null,h.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",fm),rt(e,"waiting",l),mL(i,t),pL(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function nT(i){var e;let t=i.target,r=(e=Xe.get(t))==null?void 0:e.startTime;if(r&&iL(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function aT(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new K(t,r);if(e.src&&r===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=_m(e))!=null?n:e.error;(a==null?void 0:a.code)===K.MEDIA_ERR_SRC_NOT_SUPPORTED&&jt(e,s)},500);return}if(e.src&&(r!==K.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}jt(e,s)}function jt(i,e){var t;e.fatal&&(((t=Xe.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function fm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Xe.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var jL=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[ve.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[ve.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[ve.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[ve.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===ve.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===ve.ErrorTypes.NETWORK_ERROR)return Ne.VIDEO},l,d=a(i);if(d===K.MEDIA_ERR_NETWORK&&i.response){let u=(t=o(i))!=null?t:Ne.VIDEO;l=(r=Ed(i.response,u,e,i.fatal))!=null?r:new K("",d,i.fatal)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let u=Q("Attempting to play DRM-protected content without providing a DRM token.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_MISSING_TOKEN}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let u=Q("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_NO_SESSION){let u=Q("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let u=Q("Failed to update DRM license. This may be an issue with the player or your protected content.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let u=Q("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let u=Q("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_CDM_ERROR}else if(i.details===ve.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let u=Q("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new K(u,K.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_OUTPUT_RESTRICTED}else l=new K(i.error.message,K.MEDIA_ERR_ENCRYPTED,i.fatal),l.errorCategory=Ne.DRM,l.muxCode=J.ENCRYPTED_ERROR;else l=new K("",d,i.fatal);return l.context||(l.context=`${i.url?`url: ${i.url}
45
45
  `:""}${i.response&&(i.response.code||i.response.text)?`response: ${i.response.code}, ${i.response.text}
46
46
  `:""}${i.reason?`failure reason: ${i.reason}
47
47
  `:""}${i.level?`level: ${i.level}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mux/mux-player",
3
- "version": "3.4.2-canary.4",
3
+ "version": "3.4.2-canary.5",
4
4
  "description": "An open source Mux player web component that Just Works™",
5
5
  "homepage": "https://mux.com/player",
6
6
  "keywords": [