@mux/mux-player 3.4.2-canary.4 → 3.4.2-canary.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mux-player.js +54 -54
- package/dist/mux-player.mjs +54 -54
- package/package.json +1 -1
package/dist/mux-player.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";(()=>{var nA=Object.defineProperty;var aA=Object.getPrototypeOf;var oA=Reflect.get;var Jg=i=>{throw TypeError(i)};var lA=(i,e,t)=>e in i?nA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Te=(i,e,t)=>lA(i,typeof e!="symbol"?e+"":e,t),ih=(i,e,t)=>e.has(i)||Jg("Cannot "+t);var I=(i,e,t)=>(ih(i,e,"read from private field"),t?t.call(i):e.get(i)),ie=(i,e,t)=>e.has(i)?Jg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Z=(i,e,t,r)=>(ih(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ce=(i,e,t)=>(ih(i,e,"access private method"),t);var fl=(i,e,t)=>oA(aA(i),t,e);var nn=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends nn{}globalThis.DocumentFragment=i}var _a=class extends nn{},rh=class extends nn{},dA={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(_a)}},Aa,sh=class{constructor(e,t={}){ie(this,Aa);Z(this,Aa,t==null?void 0:t.detail)}get detail(){return I(this,Aa)}initCustomEvent(){}};Aa=new WeakMap;function uA(i,e){return new _a}var e0={document:{createElement:uA},DocumentFragment,customElements:dA,CustomEvent:sh,EventTarget:nn,HTMLElement:_a,HTMLVideoElement:rh},t0=typeof window=="undefined"||typeof globalThis.customElements=="undefined",ml=t0?e0:globalThis,pM=t0?e0.document:globalThis.document;var cA=Object.create,u0=Object.defineProperty,hA=Object.getOwnPropertyDescriptor,fA=Object.getOwnPropertyNames,mA=Object.getPrototypeOf,pA=Object.prototype.hasOwnProperty,c0=function(i,e){return function(){return i&&(e=i(i=0)),e}},Lt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},gA=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=fA(e),n=0,a=s.length,o;n<a;n++)o=s[n],!pA.call(i,o)&&o!==t&&u0(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=hA(e,o))||r.enumerable});return i},Bt=function(i,e,t){return t=i!=null?cA(mA(i)):{},gA(e||!i||!i.__esModule?u0(t,"default",{value:i,enumerable:!0}):t,i)},ni=Lt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function os(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):os(i,e)}var ls=c0(function(){ls()});function h0(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var f0=c0(function(){}),m0=Lt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),vA=Lt(function(i,e){ls(),e.exports=t;function t(r,s){if(!os(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),EA=Lt(function(i,e){ls(),e.exports=t;function t(r,s){if(!os(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),p0=Lt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),g0=Lt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),v0=Lt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),TA=Lt(function(i,e){f0(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=h0(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var v=h._attributes[p][g],y=(v.prefix?v.prefix+":":"")+g;f.push({name:y,value:v.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function c(h){return u(h).replace(/"/g,""")}}),E0=Lt(function(i,e){ls();var t=m0(),r=p0(),s=g0(),n=v0(),a=TA(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!os(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),bA=Lt(function(i,e){ls();var t=E0();e.exports=r;function r(s){if(!os(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),yA=Lt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),_A=Lt(function(i,e){ls();var t=m0(),r=vA(),s=EA(),n=E0(),a=bA(),o=yA(),l=p0(),d=g0(),u=v0();e.exports=c;function c(){if(!os(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),AA=Lt(function(i,e){var t=_A();e.exports=new t}),T0=Lt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=AA(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function SA(i){if(Array.isArray(i))return i}function xA(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function RA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uh(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function b0(i,e){if(i){if(typeof i=="string")return uh(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return uh(i,e)}}function ji(i,e){return SA(i)||xA(i,e)||b0(i,e)||RA()}var Ra=Bt(ni()),i0=Bt(ni()),IA=Bt(ni()),LA={now:function(){var i=IA.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=LA,La=function(){var i,e,t;if(typeof((i=i0.default.crypto)===null||i===void 0?void 0:i.getRandomValues)=="function"){t=new Uint8Array(32),i0.default.crypto.getRandomValues(t);for(var r=0;r<32;r++)t[r]=t[r]%16}else{t=[];for(var s=0;s<32;s++)t[s]=Math.random()*16|0}var n=0;e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){var d=l==="x"?t[n]:t[n]&3|8;return n++,d.toString(16)});var a=tt.now(),o=a==null?void 0:a.toString(16).substring(3);return o?e.substring(0,28)+o:e},y0=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ii=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=y0()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ri(i){return kA(i)||wA(i)||b0(i)||DA()}var ns={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},CA=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=i?[console,i]:[console],l=(t=console.trace).bind.apply(t,ri(o)),d=(r=console.info).bind.apply(r,ri(o)),u=(s=console.debug).bind.apply(s,ri(o)),c=(n=console.warn).bind.apply(n,ri(o)),h=(a=console.error).bind.apply(a,ri(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.TRACE))return l.apply(void 0,ri(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.DEBUG))return u.apply(void 0,ri(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.INFO))return d.apply(void 0,ri(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.WARN))return c.apply(void 0,ri(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.ERROR))return h.apply(void 0,ri(p))},get level(){return f},set level(m){m!==this.level&&(f=m!=null?m:e)}}},Pe=CA("[mux]"),nh=Bt(ni());function ch(){var i=nh.default.doNotTrack||nh.default.navigator&&nh.default.navigator.doNotTrack;return i==="1"}function le(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}ls();function ct(i,e){if(!os(i,e))throw new TypeError("Cannot call a class as a function")}function r0(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ei(i,e,t){return e&&r0(i.prototype,e),t&&r0(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function on(i){return on=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},on(i)}function MA(i,e){for(;!Object.prototype.hasOwnProperty.call(i,e)&&(i=on(i),i!==null););return i}function gl(i,e,t){return typeof Reflect!="undefined"&&Reflect.get?gl=Reflect.get:gl=function(r,s,n){var a=MA(r,s);if(a){var o=Object.getOwnPropertyDescriptor(a,s);return o.get?o.get.call(n||r):o.value}},gl(i,e,t||i)}function hh(i,e){return hh=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},hh(i,e)}function OA(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&hh(i,e)}function PA(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}f0();function NA(i,e){return e&&(h0(e)==="object"||typeof e=="function")?e:le(i)}function UA(i){var e=PA();return function(){var t=on(i),r;if(e){var s=on(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return NA(this,r)}}var si=function(i){return ka(i)[0]},ka=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},ah=Bt(ni()),FA={exists:function(){var i=ah.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=ah.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=ah.default.performance,e=i&&i.timing;return e&&e.navigationStart}},El=FA;function et(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Tl(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function BA(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function mh(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):BA(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var $A=["x-cdn","content-type"],_0=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],HA=$A.concat(_0);function ph(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(HA.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function bl(i){if(i){var e=_0.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var GA=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},A0=GA,pl=function(i){if(!i)return{};var e=El.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},Sa=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return ph(i.getAllResponseHeaders())},KA=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(v){var y=parseInt(s.version),T;return y===1&&v.programDateTime!==null&&(T=v.programDateTime),y===0&&v.pdt!==null&&(T=v.pdt),T};if(!El.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(v,y){return i.emit(e,v,y)},d=function(v,y){var T=y.levels,_=y.audioTracks,A=y.url,k=y.stats,R=y.networkDetails,x=y.sessionData,O={},w={};T.forEach(function(q,ce){O[ce]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),_.forEach(function(q,ce){w[ce]={name:q.name,language:q.lang,bitrate:q.bitrate}});var C=pl(k),P=C.bytesLoaded,U=C.requestStart,X=C.responseStart,z=C.responseEnd;l("requestcompleted",mh(Tl({},A0(x)),{request_event_type:v,request_bytes_loaded:P,request_start:U,request_response_start:X,request_response_end:z,request_type:"manifest",request_hostname:si(A),request_response_headers:Sa(R),request_rendition_lists:{media:O,audio:w,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(v,y){var T=y.details,_=y.level,A=y.networkDetails,k=y.stats,R=pl(k),x=R.bytesLoaded,O=R.requestStart,w=R.responseStart,C=R.responseEnd,P=T.fragments[T.fragments.length-1],U=o(P)+a(P.duration);l("requestcompleted",{request_event_type:v,request_bytes_loaded:x,request_start:O,request_response_start:w,request_response_end:C,request_current_level:_,request_type:"manifest",request_hostname:si(T.url),request_response_headers:Sa(A),video_holdback:T.holdBack&&a(T.holdBack),video_part_holdback:T.partHoldBack&&a(T.partHoldBack),video_part_target_duration:T.partTarget&&a(T.partTarget),video_target_duration:T.targetduration&&a(T.targetduration),video_source_is_live:T.live,player_manifest_newest_program_time:isNaN(U)?void 0:U})};t.on(s.Events.LEVEL_LOADED,u);var c=function(v,y){var T=y.details,_=y.networkDetails,A=y.stats,k=pl(A),R=k.bytesLoaded,x=k.requestStart,O=k.responseStart,w=k.responseEnd;l("requestcompleted",{request_event_type:v,request_bytes_loaded:R,request_start:x,request_response_start:O,request_response_end:w,request_type:"manifest",request_hostname:si(T.url),request_response_headers:Sa(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(v,y){var T=y.stats,_=y.networkDetails,A=y.frag;T=T||A.stats;var k=pl(T),R=k.bytesLoaded,x=k.requestStart,O=k.responseStart,w=k.responseEnd,C=_?Sa(_):void 0,P={request_event_type:v,request_bytes_loaded:R,request_start:x,request_response_start:O,request_response_end:w,request_hostname:_?si(_.responseURL):void 0,request_id:C?bl(C):void 0,request_response_headers:C,request_media_duration:A.duration,request_url:_==null?void 0:_.responseURL};A.type==="main"?(P.request_type="media",P.request_current_level=A.level,P.request_video_width=(t.levels[A.level]||{}).width,P.request_video_height=(t.levels[A.level]||{}).height,P.request_labeled_bitrate=(t.levels[A.level]||{}).bitrate):P.request_type=A.type,l("requestcompleted",P)};t.on(s.Events.FRAG_LOADED,h);var f=function(v,y){var T=y.frag,_=T.start,A=o(T),k={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",k)};t.on(s.Events.FRAG_CHANGED,f);var m=function(v,y){var T=y.type,_=y.details,A=y.response,k=y.fatal,R=y.frag,x=y.networkDetails,O=(R==null?void 0:R.url)||y.url||"",w=x?Sa(x):void 0;if((_===s.ErrorDetails.MANIFEST_LOAD_ERROR||_===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT||_===s.ErrorDetails.LEVEL_LOAD_ERROR||_===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:_,request_url:O,request_hostname:si(O),request_id:w?bl(w):void 0,request_type:_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:A==null?void 0:A.code,request_error_text:A==null?void 0:A.text}),k){var C,P="".concat(O?"url: ".concat(O,`
|
|
1
|
+
"use strict";(()=>{var nA=Object.defineProperty;var aA=Object.getPrototypeOf;var oA=Reflect.get;var Jg=i=>{throw TypeError(i)};var lA=(i,e,t)=>e in i?nA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Te=(i,e,t)=>lA(i,typeof e!="symbol"?e+"":e,t),ih=(i,e,t)=>e.has(i)||Jg("Cannot "+t);var I=(i,e,t)=>(ih(i,e,"read from private field"),t?t.call(i):e.get(i)),ie=(i,e,t)=>e.has(i)?Jg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Z=(i,e,t,r)=>(ih(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ce=(i,e,t)=>(ih(i,e,"access private method"),t);var ml=(i,e,t)=>oA(aA(i),t,e);var nn=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends nn{}globalThis.DocumentFragment=i}var _a=class extends nn{},rh=class extends nn{},dA={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(_a)}},Aa,sh=class{constructor(e,t={}){ie(this,Aa);Z(this,Aa,t==null?void 0:t.detail)}get detail(){return I(this,Aa)}initCustomEvent(){}};Aa=new WeakMap;function uA(i,e){return new _a}var e0={document:{createElement:uA},DocumentFragment,customElements:dA,CustomEvent:sh,EventTarget:nn,HTMLElement:_a,HTMLVideoElement:rh},t0=typeof window=="undefined"||typeof globalThis.customElements=="undefined",pl=t0?e0:globalThis,pM=t0?e0.document:globalThis.document;var cA=Object.create,u0=Object.defineProperty,hA=Object.getOwnPropertyDescriptor,fA=Object.getOwnPropertyNames,mA=Object.getPrototypeOf,pA=Object.prototype.hasOwnProperty,c0=function(i,e){return function(){return i&&(e=i(i=0)),e}},Lt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},gA=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=fA(e),n=0,a=s.length,o;n<a;n++)o=s[n],!pA.call(i,o)&&o!==t&&u0(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=hA(e,o))||r.enumerable});return i},Bt=function(i,e,t){return t=i!=null?cA(mA(i)):{},gA(e||!i||!i.__esModule?u0(t,"default",{value:i,enumerable:!0}):t,i)},ni=Lt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function os(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):os(i,e)}var ls=c0(function(){ls()});function h0(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var f0=c0(function(){}),m0=Lt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),vA=Lt(function(i,e){ls(),e.exports=t;function t(r,s){if(!os(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),EA=Lt(function(i,e){ls(),e.exports=t;function t(r,s){if(!os(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),p0=Lt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),g0=Lt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),v0=Lt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),TA=Lt(function(i,e){f0(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=h0(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var v=h._attributes[p][g],y=(v.prefix?v.prefix+":":"")+g;f.push({name:y,value:v.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function c(h){return u(h).replace(/"/g,""")}}),E0=Lt(function(i,e){ls();var t=m0(),r=p0(),s=g0(),n=v0(),a=TA(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!os(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),bA=Lt(function(i,e){ls();var t=E0();e.exports=r;function r(s){if(!os(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),yA=Lt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),_A=Lt(function(i,e){ls();var t=m0(),r=vA(),s=EA(),n=E0(),a=bA(),o=yA(),l=p0(),d=g0(),u=v0();e.exports=c;function c(){if(!os(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),AA=Lt(function(i,e){var t=_A();e.exports=new t}),T0=Lt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=AA(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function SA(i){if(Array.isArray(i))return i}function xA(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function RA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uh(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function b0(i,e){if(i){if(typeof i=="string")return uh(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return uh(i,e)}}function ji(i,e){return SA(i)||xA(i,e)||b0(i,e)||RA()}var Ra=Bt(ni()),i0=Bt(ni()),IA=Bt(ni()),LA={now:function(){var i=IA.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=LA,La=function(){var i,e,t;if(typeof((i=i0.default.crypto)===null||i===void 0?void 0:i.getRandomValues)=="function"){t=new Uint8Array(32),i0.default.crypto.getRandomValues(t);for(var r=0;r<32;r++)t[r]=t[r]%16}else{t=[];for(var s=0;s<32;s++)t[s]=Math.random()*16|0}var n=0;e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){var d=l==="x"?t[n]:t[n]&3|8;return n++,d.toString(16)});var a=tt.now(),o=a==null?void 0:a.toString(16).substring(3);return o?e.substring(0,28)+o:e},y0=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ii=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=y0()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},El=function(i){var e;i&&typeof i.nodeName!="undefined"?(e=i,i=ii(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]};function kA(i){if(Array.isArray(i))return uh(i)}function wA(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function DA(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ri(i){return kA(i)||wA(i)||b0(i)||DA()}var ns={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},CA=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=i?[console,i]:[console],l=(t=console.trace).bind.apply(t,ri(o)),d=(r=console.info).bind.apply(r,ri(o)),u=(s=console.debug).bind.apply(s,ri(o)),c=(n=console.warn).bind.apply(n,ri(o)),h=(a=console.error).bind.apply(a,ri(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.TRACE))return l.apply(void 0,ri(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.DEBUG))return u.apply(void 0,ri(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.INFO))return d.apply(void 0,ri(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.WARN))return c.apply(void 0,ri(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>ns.ERROR))return h.apply(void 0,ri(p))},get level(){return f},set level(m){m!==this.level&&(f=m!=null?m:e)}}},Pe=CA("[mux]"),nh=Bt(ni());function ch(){var i=nh.default.doNotTrack||nh.default.navigator&&nh.default.navigator.doNotTrack;return i==="1"}function le(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}ls();function ct(i,e){if(!os(i,e))throw new TypeError("Cannot call a class as a function")}function r0(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ei(i,e,t){return e&&r0(i.prototype,e),t&&r0(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function on(i){return on=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},on(i)}function MA(i,e){for(;!Object.prototype.hasOwnProperty.call(i,e)&&(i=on(i),i!==null););return i}function vl(i,e,t){return typeof Reflect!="undefined"&&Reflect.get?vl=Reflect.get:vl=function(r,s,n){var a=MA(r,s);if(a){var o=Object.getOwnPropertyDescriptor(a,s);return o.get?o.get.call(n||r):o.value}},vl(i,e,t||i)}function hh(i,e){return hh=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},hh(i,e)}function OA(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&hh(i,e)}function PA(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}f0();function NA(i,e){return e&&(h0(e)==="object"||typeof e=="function")?e:le(i)}function UA(i){var e=PA();return function(){var t=on(i),r;if(e){var s=on(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return NA(this,r)}}var si=function(i){return ka(i)[0]},ka=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},ah=Bt(ni()),FA={exists:function(){var i=ah.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=ah.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=ah.default.performance,e=i&&i.timing;return e&&e.navigationStart}},Tl=FA;function et(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function bl(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function BA(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function mh(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):BA(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var $A=["x-cdn","content-type"],_0=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],HA=$A.concat(_0);function ph(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(HA.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function yl(i){if(i){var e=_0.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var GA=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},A0=GA,gl=function(i){if(!i)return{};var e=Tl.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},Sa=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return ph(i.getAllResponseHeaders())},KA=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(v){var y=parseInt(s.version),T;return y===1&&v.programDateTime!==null&&(T=v.programDateTime),y===0&&v.pdt!==null&&(T=v.pdt),T};if(!Tl.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(v,y){return i.emit(e,v,y)},d=function(v,y){var T=y.levels,_=y.audioTracks,A=y.url,k=y.stats,R=y.networkDetails,x=y.sessionData,O={},w={};T.forEach(function(q,ce){O[ce]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),_.forEach(function(q,ce){w[ce]={name:q.name,language:q.lang,bitrate:q.bitrate}});var C=gl(k),P=C.bytesLoaded,U=C.requestStart,X=C.responseStart,z=C.responseEnd;l("requestcompleted",mh(bl({},A0(x)),{request_event_type:v,request_bytes_loaded:P,request_start:U,request_response_start:X,request_response_end:z,request_type:"manifest",request_hostname:si(A),request_response_headers:Sa(R),request_rendition_lists:{media:O,audio:w,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(v,y){var T=y.details,_=y.level,A=y.networkDetails,k=y.stats,R=gl(k),x=R.bytesLoaded,O=R.requestStart,w=R.responseStart,C=R.responseEnd,P=T.fragments[T.fragments.length-1],U=o(P)+a(P.duration);l("requestcompleted",{request_event_type:v,request_bytes_loaded:x,request_start:O,request_response_start:w,request_response_end:C,request_current_level:_,request_type:"manifest",request_hostname:si(T.url),request_response_headers:Sa(A),video_holdback:T.holdBack&&a(T.holdBack),video_part_holdback:T.partHoldBack&&a(T.partHoldBack),video_part_target_duration:T.partTarget&&a(T.partTarget),video_target_duration:T.targetduration&&a(T.targetduration),video_source_is_live:T.live,player_manifest_newest_program_time:isNaN(U)?void 0:U})};t.on(s.Events.LEVEL_LOADED,u);var c=function(v,y){var T=y.details,_=y.networkDetails,A=y.stats,k=gl(A),R=k.bytesLoaded,x=k.requestStart,O=k.responseStart,w=k.responseEnd;l("requestcompleted",{request_event_type:v,request_bytes_loaded:R,request_start:x,request_response_start:O,request_response_end:w,request_type:"manifest",request_hostname:si(T.url),request_response_headers:Sa(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(v,y){var T=y.stats,_=y.networkDetails,A=y.frag;T=T||A.stats;var k=gl(T),R=k.bytesLoaded,x=k.requestStart,O=k.responseStart,w=k.responseEnd,C=_?Sa(_):void 0,P={request_event_type:v,request_bytes_loaded:R,request_start:x,request_response_start:O,request_response_end:w,request_hostname:_?si(_.responseURL):void 0,request_id:C?yl(C):void 0,request_response_headers:C,request_media_duration:A.duration,request_url:_==null?void 0:_.responseURL};A.type==="main"?(P.request_type="media",P.request_current_level=A.level,P.request_video_width=(t.levels[A.level]||{}).width,P.request_video_height=(t.levels[A.level]||{}).height,P.request_labeled_bitrate=(t.levels[A.level]||{}).bitrate):P.request_type=A.type,l("requestcompleted",P)};t.on(s.Events.FRAG_LOADED,h);var f=function(v,y){var T=y.frag,_=T.start,A=o(T),k={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",k)};t.on(s.Events.FRAG_CHANGED,f);var m=function(v,y){var T=y.type,_=y.details,A=y.response,k=y.fatal,R=y.frag,x=y.networkDetails,O=(R==null?void 0:R.url)||y.url||"",w=x?Sa(x):void 0;if((_===s.ErrorDetails.MANIFEST_LOAD_ERROR||_===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT||_===s.ErrorDetails.LEVEL_LOAD_ERROR||_===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:_,request_url:O,request_hostname:si(O),request_id:w?yl(w):void 0,request_type:_===s.ErrorDetails.FRAG_LOAD_ERROR||_===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":_===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||_===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":_===s.ErrorDetails.SUBTITLE_LOAD_ERROR||_===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":_===s.ErrorDetails.KEY_LOAD_ERROR||_===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:A==null?void 0:A.code,request_error_text:A==null?void 0:A.text}),k){var C,P="".concat(O?"url: ".concat(O,`
|
|
4
4
|
`):"")+"".concat(A&&(A.code||A.text)?"response: ".concat(A.code,", ").concat(A.text,`
|
|
5
5
|
`):"")+"".concat(y.reason?"failure reason: ".concat(y.reason,`
|
|
6
6
|
`):"")+"".concat(y.level?"level: ".concat(y.level,`
|
|
@@ -9,25 +9,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
9
9
|
`):"")+"".concat(y.error?"error: ".concat(y.error,`
|
|
10
10
|
`):"")+"".concat(y.event?"event: ".concat(y.event,`
|
|
11
11
|
`):"")+"".concat(y.err?"error message: ".concat((C=y.err)===null||C===void 0?void 0:C.message,`
|
|
12
|
-
`):"");l("error",{player_error_code:T,player_error_message:_,player_error_context:P})}};t.on(s.Events.ERROR,m);var p=function(v,y){var T=y.frag,_=T&&T._url||"";l("requestcanceled",{request_event_type:v,request_url:_,request_type:"media",request_hostname:si(_)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(v,y){var T=y.level,_=t.levels[T];if(_&&_.attrs&&_.attrs.BANDWIDTH){var A=_.attrs.BANDWIDTH,k,R=parseFloat(_.attrs["FRAME-RATE"]);isNaN(R)||(k=R),A?l("renditionchange",{video_source_fps:k,video_source_bitrate:A,video_source_width:_.width,video_source_height:_.height,video_source_rendition_name:_.name,video_source_codec:_==null?void 0:_.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},VA=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},s0=function(i,e){if(!i||!i.requestEndDate)return{};var t=si(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=ph(d[d.length-1]._responseHeaders||""));var c=u?
|
|
12
|
+
`):"");l("error",{player_error_code:T,player_error_message:_,player_error_context:P})}};t.on(s.Events.ERROR,m);var p=function(v,y){var T=y.frag,_=T&&T._url||"";l("requestcanceled",{request_event_type:v,request_url:_,request_type:"media",request_hostname:si(_)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(v,y){var T=y.level,_=t.levels[T];if(_&&_.attrs&&_.attrs.BANDWIDTH){var A=_.attrs.BANDWIDTH,k,R=parseFloat(_.attrs["FRAME-RATE"]);isNaN(R)||(k=R),A?l("renditionchange",{video_source_fps:k,video_source_bitrate:A,video_source_width:_.width,video_source_height:_.height,video_source_rendition_name:_.name,video_source_codec:_==null?void 0:_.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},VA=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},s0=function(i,e){if(!i||!i.requestEndDate)return{};var t=si(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=ph(d[d.length-1]._responseHeaders||""));var c=u?yl(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},WA=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},YA=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},qA=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},jA=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var n=qA(t),a=function(T,_){return i.emit(e,T,_)},o=function(T){var _=T.type,A=T.data,k=(A||{}).url;a("requestcompleted",{request_event_type:_,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:si(k),request_url:k})};t.on("manifestLoaded",o);var l={},d=function(T){if(typeof T.getRequests!="function")return null;var _=T.getRequests({state:"executed"});return _.length===0?null:_[_.length-1]},u=function(T){var _=T.type,A=T.fragmentModel,k=T.chunk,R=d(A);c({type:_,request:R,chunk:k})},c=function(T){var _=T.type,A=T.chunk,k=T.request,R=(A||{}).mediaInfo,x=R||{},O=x.type,w=x.bitrateList;w=w||[];var C={};w.forEach(function(pe,te){C[te]={},C[te].width=pe.width,C[te].height=pe.height,C[te].bitrate=pe.bandwidth,C[te].attrs={}}),O==="video"?l.video=C:O==="audio"?l.audio=C:l.media=C;var P=s0(k,t),U=P.requestStart,X=P.requestResponseStart,z=P.requestResponseEnd,q=P.requestResponseHeaders,ce=P.requestMediaDuration,fe=P.requestHostname,W=P.requestUrl,G=P.requestId;a("requestcompleted",{request_event_type:_,request_start:U,request_response_start:X,request_response_end:z,request_bytes_loaded:-1,request_type:O+"_init",request_response_headers:q,request_hostname:fe,request_id:G,request_url:W,request_media_duration:ce,request_rendition_lists:l})};n>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",u);var h=function(T){var _=T.type,A=T.fragmentModel,k=T.chunk,R=d(A);f({type:_,request:R,chunk:k})},f=function(T){var _=T.type,A=T.chunk,k=T.request,R=A||{},x=R.mediaInfo,O=R.start,w=x||{},C=w.type,P=s0(k,t),U=P.requestStart,X=P.requestResponseStart,z=P.requestResponseEnd,q=P.requestBytesLoaded,ce=P.requestResponseHeaders,fe=P.requestMediaDuration,W=P.requestHostname,G=P.requestUrl,pe=P.requestId,te=WA(C,t),_e=te.currentLevel,Ke=te.renditionWidth,Ye=te.renditionHeight,ze=te.renditionBitrate;a("requestcompleted",{request_event_type:_,request_start:U,request_response_start:X,request_response_end:z,request_bytes_loaded:q,request_type:C,request_response_headers:ce,request_hostname:W,request_id:pe,request_url:G,request_media_start_time:O,request_media_duration:fe,request_current_level:_e,request_labeled_bitrate:ze,request_video_width:Ke,request_video_height:Ye})};n>=4?t.on("mediaFragmentLoaded",f):t.on("mediaFragmentLoaded",h);var m={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(m.video&&typeof m.video.bitrate=="number"){if(!(m.video.width&&m.video.height)){s.warn("have bitrate info for video but missing width/height");return}var T=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(T+=m.audio.bitrate),T!==m.totalBitrate)return m.totalBitrate=T,{video_source_bitrate:T,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:YA(m.video.codec)}}},g=function(T,_,A){if(typeof T.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",T);return}var k=T.mediaType;if(k==="audio"||k==="video"){var R=t.getBitrateInfoListFor(k).find(function(O){var w=O.qualityIndex;return w===T.newQuality});if(!(R&&typeof R.bitrate=="number")){s.warn("missing bitrate info for ".concat(k));return}m[k]=mh(bl({},R),{codec:t.getCurrentTrackFor(k).codec});var x=p();x&&a("renditionchange",x)}};t.on("qualityChangeRendered",g);var v=function(T){var _=T.request,A=T.mediaType;_=_||{},a("requestcanceled",{request_event_type:_.type+"_"+_.action,request_url:_.url,request_type:A,request_hostname:si(_.url)})};t.on("fragmentLoadingAbandoned",v);var y=function(T){var _=T.error,A,k,R=(_==null||(A=_.data)===null||A===void 0?void 0:A.request)||{},x=(_==null||(k=_.data)===null||k===void 0?void 0:k.response)||{};(_==null?void 0:_.code)===27&&a("requestfailed",{request_error:R.type+"_"+R.action,request_url:R.url,request_hostname:si(R.url),request_type:R.mediaType,request_error_code:x.status,request_error_text:x.statusText});var O="".concat(R!=null&&R.url?"url: ".concat(R.url,`
|
|
13
13
|
`):"")+"".concat(x!=null&&x.status||x!=null&&x.statusText?"response: ".concat(x==null?void 0:x.status,", ").concat(x==null?void 0:x.statusText,`
|
|
14
|
-
`):"");a("error",{player_error_code:_==null?void 0:_.code,player_error_message:_==null?void 0:_.message,player_error_context:O})};t.on("error",y),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",y),t.off("fragmentLoadingAbandoned",v),delete t._stopMuxMonitor}},zA=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},n0=0,XA=function(){"use strict";function i(){ct(this,i),H(this,"_listeners",void 0)}return Ei(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++n0,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++n0;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),QA=XA,oh=Bt(ni()),ZA=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(oh.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ei(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=oh.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(oh.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),JA=ZA,e1=function i(e){"use strict";var t=this;ct(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},t1=e1,i1=function(){"use strict";function i(e){ct(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ei(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),et(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),r1=i1,s1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ei(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&et(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),n1=s1,a1=function(){"use strict";function i(e){ct(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ei(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),o1=a1,a0=5*60*1e3,l1=function i(e){"use strict";if(ct(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;et(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>a0&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(a0,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(et(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},d1=l1,u1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return Ei(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),c1=u1,h1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ei(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),f1=h1,m1=function i(e){"use strict";var t=this;ct(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb","renditionchange","orientationchange","viewend"],s=["playing","hb","renditionchange","orientationchange"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),et(e.data,"view_total_content_playback_time",a),et(e.data,"view_total_upscaling",l*a),et(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},p1=m1,g1=2e3,v1=function i(e){"use strict";var t=this;ct(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);et(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=g1){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,et(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},E1=v1,o0=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},T1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],b1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),T1.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),o0(t._adRequests,n),et(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||et(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),o0(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&et(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,et(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ei(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=ji(ka(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=ji(ka(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),y1=b1,l0=Bt(ni()),_1=function i(e){"use strict";ct(this,i);var t,r,s=function(){e.disableRebufferTracking||(et(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=l0.default.setInterval(function(){if(t){var d=tt.now();et(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(et(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,l0.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},A1=_1,S1=function i(e){"use strict";var t=this;ct(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},x1=S1,lh=Bt(ni()),S0=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document!="undefined"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),x0="muxData",R1=function(i){return Object.entries(i).map(function(e){var t=ji(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},I1=function(i){return i.split("&").reduce(function(e,t){var r=ji(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},R0=function(){var i;try{i=I1(S0.get(x0)||"")}catch{i={}}return i},I0=function(i){try{S0.set(x0,R1(i),{expires:365})}catch{}},L1=function(){var i=R0();return i.mux_viewer_id=i.mux_viewer_id||La(),i.msn=i.msn||Math.random(),I0(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},k1=function(){var i=R0(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=La(),i.sst=e),i.sex=e+25*60*1e3,I0(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function w1(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var D1=Bt(ni()),L0=function(){var i;switch(k0()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},k0=function(){var i=D1.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};L0.getConnectionFromAPI=k0;var C1=L0,M1={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},O1=w0(M1),P1={ad:"ad",af:"affiliate",ag:"aggregate",ap:"api",al:"application",ao:"audio",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",bn:"brand",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ci:"client",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cq:"creator",cr:"creative",cs:"captions",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",dy:"dynamic",eb:"enabled",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",or:"origin",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pp:"pip",pr:"preload",ps:"position",pt:"part",py:"property",px:"pop",pz:"plan",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rg:"range",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sh:"shift",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",ss:"status",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},d0=w0(P1);function w0(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function fh(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=O1[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),d0[l]?o+=d0[l]:Number.isInteger(Number(l))?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var as=Bt(ni()),N1=Bt(T0()),U1={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},F1=56*1024,B1=["hb","requestcompleted","requestfailed","requestcanceled"],$1="https://img.litix.io",zi=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||$1,this._eventQueue=[],this._postInFlight=!1,this._resendAfterPost=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},U1,e)};zi.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};zi.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};zi.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),as.default.clearTimeout(this._sendTimeout)};zi.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],fh({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);D0(this._beaconUrl,t,!0,function(){})};zi.prototype._sendBeaconQueue=function(){var i=this;if(this._postInFlight){this._resendAfterPost=!0;return}var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();D0(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1,i._resendAfterPost&&(i._resendAfterPost=!1,i._eventQueue.length>0&&i._sendBeaconQueue())})};zi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};zi.prototype._startBeaconSending=function(){var i=this;as.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=as.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};zi.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return B1.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var H1=typeof N1.default.exitPictureInPicture=="function"?function(i){return i.length<=F1}:function(i){return!1},D0=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(as.default.fetch){as.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:H1(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(as.default.XMLHttpRequest){var s=new as.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},G1=zi,K1=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],V1=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],W1=["ad_id","ad_creative_id","ad_universal_id"],Y1=["viewstart","error","ended","viewend"],q1=10*60*1e3,j1=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ct(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new G1(w1(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var v;this.disableCookies=(v=this.options.disableCookies)!==null&&v!==void 0?v:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:C1(),page_url:lh.default===null||lh.default===void 0||(p=lh.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:L1()}return Ei(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&ch())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:k1(),s=mh(Tl({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=fh(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Pe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):Y1.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=fh(s),this.eventQueue.queueEvent(s.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=q1)s=Tl({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=ji(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||K1.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||W1.includes(t)&&V1.includes(e))}}]),i}(),z1=function i(e){"use strict";ct(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,v=f.request_bytes_loaded;n++;var y,T;if(p?(y=p-(m!=null?m:0),T=(g!=null?g:0)-p):T=(g!=null?g:0)-(m!=null?m:0),T>0&&v&&v>0){var _=v/T*8e3;a++,r+=v,s+=T,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,_),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},X1=z1,Q1=60*60*1e3,Z1=function i(e){"use strict";var t=this;ct(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>Q1){var l=Object.keys(e.data).reduce(function(u,c){return c.indexOf("video_")===0?Object.assign(u,H({},c,e.data[c])):u},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view");var d=e.playbackHeartbeat._playheadShouldBeProgressing;e._resetView(Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing=d,e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},J1=Z1,eS=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],tS=new Set(["requestcompleted","requestfailed","requestcanceled"]),iS=function(i){"use strict";OA(t,i);var e=UA(t);function t(r,s,n){ct(this,t);var a;a=e.call(this),H(le(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(le(a),"NAVIGATION_START",void 0),H(le(a),"_destroyed",void 0),H(le(a),"_heartBeatTimeout",void 0),H(le(a),"adTracker",void 0),H(le(a),"dashjs",void 0),H(le(a),"data",void 0),H(le(a),"disablePlayheadRebufferTracking",void 0),H(le(a),"disableRebufferTracking",void 0),H(le(a),"errorTracker",void 0),H(le(a),"errorTranslator",void 0),H(le(a),"emitTranslator",void 0),H(le(a),"getAdData",void 0),H(le(a),"getPlayheadTime",void 0),H(le(a),"getStateData",void 0),H(le(a),"stateDataTranslator",void 0),H(le(a),"hlsjs",void 0),H(le(a),"id",void 0),H(le(a),"longResumeTracker",void 0),H(le(a),"minimumRebufferDuration",void 0),H(le(a),"mux",void 0),H(le(a),"playbackEventDispatcher",void 0),H(le(a),"playbackHeartbeat",void 0),H(le(a),"playbackHeartbeatTime",void 0),H(le(a),"playheadTime",void 0),H(le(a),"seekingTracker",void 0),H(le(a),"sustainedRebufferThreshold",void 0),H(le(a),"watchTimeTracker",void 0),H(le(a),"currentFragmentPDT",void 0),H(le(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=El.domContentLoadedEventEnd(),a.NAVIGATION_START=El.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(h){return h},emitTranslator:function(){for(var h=arguments.length,f=new Array(h),m=0;m<h;m++)f[m]=arguments[m];return f},stateDataTranslator:function(h){return h}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.level=n.debug?ns.DEBUG:ns.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.emitTranslator=n.emitTranslator,a.stateDataTranslator=n.stateDataTranslator,a.playbackEventDispatcher=new j1(r,n.data.env_key,n),a.data={player_instance_id:La(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(le(a));if(a.on("viewinit",function(h,f){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,f),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)}),a.on("videochange",function(h,f){this._resetView(f)}),a.on("programchange",function(h,f){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(f,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(h,f){this.currentFragmentPDT=f.currentFragmentPDT,this.currentFragmentStart=f.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var d=function(){var h=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",h&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",d,!1);var u=function(h){h.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",d),window.removeEventListener("pagehide",u)})}a.on("playerready",function(h,f){Object.assign(this.data,f)}),eS.forEach(function(h){a.on(h,function(f,m){h.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,m),this._sanitizeData()}),a.on("after"+h,function(){(h!=="error"||this.errorTracker.viewErrored)&&this.send(h)})}),a.on("viewend",function(h,f){Object.assign(a.data,f)});var c=function(h){var f=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=f-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",c),a.longResumeTracker=new J1(le(a)),a.errorTracker=new t1(le(a)),new x1(le(a)),a.seekingTracker=new E1(le(a)),a.playheadTime=new o1(le(a)),a.playbackHeartbeat=new JA(le(a)),new p1(le(a)),a.watchTimeTracker=new r1(le(a)),new n1(le(a)),a.adTracker=new y1(le(a)),new c1(le(a)),new d1(le(a)),new f1(le(a)),new A1(le(a)),new X1(le(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ei(t,[{key:"emit",value:function(r,s){var n,a=Object.assign({viewer_time:this.mux.utils.now()},s),o=[r,a];if(this.emitTranslator)try{o=this.emitTranslator(r,a)}catch(l){this.mux.log.warn("Exception in emit translator callback.",l)}o!=null&&o.length&&(n=gl(on(t.prototype),"emit",this)).call.apply(n,[this].concat(ri(o)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=ji(ka(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,tS.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_resetView",value:function(r){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",r)}},{key:"_updateStateData",value:function(){var r=this.getStateData();if(typeof this.stateDataTranslator=="function")try{r=this.stateDataTranslator(r)}catch(s){this.mux.log.warn("Exception in stateDataTranslator translator callback.",s)}Object.assign(this.data,r),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=La(),n=function(){s===r.data.view_id&&et(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,KA(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(VA(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,jA(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(zA(this.dashjs),this.dashjs=void 0)}}]),t}(QA),rS=iS,xa=Bt(T0());function sS(){return xa.default&&!!(xa.default.fullscreenElement||xa.default.webkitFullscreenElement||xa.default.mozFullScreenElement||xa.default.msFullscreenElement)}var nS=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],aS={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function oS(i,e,t){var r=ji(vl(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var c={getPlayheadTime:function(){return d(s.currentTime)},getStateData:function(){var f,m,p,g=((f=(m=this).getPlayheadTime)===null||f===void 0?void 0:f.call(m))||d(s.currentTime),v=this.hlsjs&&this.hlsjs.url,y=this.dashjs&&typeof this.dashjs.getSource=="function"&&this.dashjs.getSource(),T={player_is_paused:s.paused,player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:sS(),video_poster_url:s.poster,video_source_url:v||y||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(p=s.getVideoPlaybackQuality)===null||p===void 0?void 0:p.call(s).droppedVideoFrames};if(s.getStartDate&&g>0){var _=s.getStartDate();if(_&&typeof _.getTime=="function"&&_.getTime()){var A=_.getTime();if(T.player_program_time=A+g,s.seekable.length>0){var k=A+s.seekable.end(s.seekable.length-1);T.player_live_edge_program_time=k}}}return T}};t=Object.assign(u,t,c),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(f,m){i.emit(n,f,m)},s.mux.updateData=function(f){s.mux.emit("hb",f)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(f){s.removeEventListener(f,s.mux.listeners[f],!1)}),delete s.mux.listeners,s.mux.destroy=h,s.mux.swapElement=h,s.mux.emit=h,s.mux.addHLSJS=h,s.mux.addDashJS=h,s.mux.removeHLSJS=h,s.mux.removeDashJS=h,s.mux.updateData=h,s.mux.setEmitTranslator=h,s.mux.setStateDataTranslator=h,s.mux.setGetPlayheadTime=h,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(f){var m=ji(vl(f),3),p=m[0],g=m[1],v=m[2];if(p){if(v!=="video"&&v!=="audio")return i.log.error("The element of `"+g+"` was not a media element.")}else return i.log.error("No element was found with the `"+g+"` query selector.");p.muxId=s.muxId,delete s.muxId,p.mux=p.mux||{},p.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(p.mux.listeners).forEach(function(y){s.removeEventListener(y,p.mux.listeners[y],!1),p.addEventListener(y,p.mux.listeners[y],!1)}),p.mux.swapElement=s.mux.swapElement,p.mux.destroy=s.mux.destroy,delete s.mux,s=p},s.mux.addHLSJS=function(f){i.addHLSJS(n,f)},s.mux.addDashJS=function(f){i.addDashJS(n,f)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},s.mux.setEmitTranslator=function(f){i.setEmitTranslator(n,f)},s.mux.setStateDataTranslator=function(f){i.setStateDataTranslator(n,f)},s.mux.setGetPlayheadTime=function(f){f||(f=t.getPlayheadTime),i.setGetPlayheadTime(n,f)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},nS.forEach(function(f){f==="error"&&!t.automaticErrorTracking||(s.mux.listeners[f]=function(){var m={};if(f==="error"){if(!s.error||s.error.code===1)return;m.player_error_code=s.error.code,m.player_error_message=aS[s.error.code]||s.error.message}i.emit(n,f,m)},s.addEventListener(f,s.mux.listeners[f],!1))})}function lS(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return s}var Ia=Bt(ni()),an;Ia.default&&Ia.default.WeakMap&&(an=new WeakMap);function dS(i,e){if(!i||!e||!Ia.default||typeof Ia.default.getComputedStyle!="function")return"";var t;return an&&an.has(i)&&(t=an.get(i)),t||(t=Ia.default.getComputedStyle(i,null),an&&an.set(i,t)),t.getPropertyValue(e)}function uS(i){return Math.floor(i*1e3)}var ss={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},yl=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};yl.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
|
|
14
|
+
`):"");a("error",{player_error_code:_==null?void 0:_.code,player_error_message:_==null?void 0:_.message,player_error_context:O})};t.on("error",y),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",y),t.off("fragmentLoadingAbandoned",v),delete t._stopMuxMonitor}},zA=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},n0=0,XA=function(){"use strict";function i(){ct(this,i),H(this,"_listeners",void 0)}return Ei(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++n0,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++n0;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),QA=XA,oh=Bt(ni()),ZA=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(oh.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ei(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=oh.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(oh.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),JA=ZA,e1=function i(e){"use strict";var t=this;ct(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},t1=e1,i1=function(){"use strict";function i(e){ct(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ei(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),et(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),r1=i1,s1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ei(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&et(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),n1=s1,a1=function(){"use strict";function i(e){ct(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ei(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),o1=a1,a0=5*60*1e3,l1=function i(e){"use strict";if(ct(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;et(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>a0&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(a0,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(et(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},d1=l1,u1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return Ei(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),c1=u1,h1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ei(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),f1=h1,m1=function i(e){"use strict";var t=this;ct(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb","renditionchange","orientationchange","viewend"],s=["playing","hb","renditionchange","orientationchange"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),et(e.data,"view_total_content_playback_time",a),et(e.data,"view_total_upscaling",l*a),et(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},p1=m1,g1=2e3,v1=function i(e){"use strict";var t=this;ct(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);et(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=g1){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,et(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},E1=v1,o0=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},T1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],b1=function(){"use strict";function i(e){var t=this;ct(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),T1.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),o0(t._adRequests,n),et(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||et(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),o0(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&et(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,et(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||et(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ei(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=ji(ka(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=ji(ka(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),y1=b1,l0=Bt(ni()),_1=function i(e){"use strict";ct(this,i);var t,r,s=function(){e.disableRebufferTracking||(et(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=l0.default.setInterval(function(){if(t){var d=tt.now();et(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(et(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,l0.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},A1=_1,S1=function i(e){"use strict";var t=this;ct(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},x1=S1,lh=Bt(ni()),S0=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document!="undefined"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),x0="muxData",R1=function(i){return Object.entries(i).map(function(e){var t=ji(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},I1=function(i){return i.split("&").reduce(function(e,t){var r=ji(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},R0=function(){var i;try{i=I1(S0.get(x0)||"")}catch{i={}}return i},I0=function(i){try{S0.set(x0,R1(i),{expires:365})}catch{}},L1=function(){var i=R0();return i.mux_viewer_id=i.mux_viewer_id||La(),i.msn=i.msn||Math.random(),I0(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},k1=function(){var i=R0(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=La(),i.sst=e),i.sex=e+25*60*1e3,I0(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function w1(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var D1=Bt(ni()),L0=function(){var i;switch(k0()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},k0=function(){var i=D1.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};L0.getConnectionFromAPI=k0;var C1=L0,M1={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},O1=w0(M1),P1={ad:"ad",af:"affiliate",ag:"aggregate",ap:"api",al:"application",ao:"audio",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",bn:"brand",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ci:"client",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cq:"creator",cr:"creative",cs:"captions",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",dy:"dynamic",eb:"enabled",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",or:"origin",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pp:"pip",pr:"preload",ps:"position",pt:"part",py:"property",px:"pop",pz:"plan",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rg:"range",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sh:"shift",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",ss:"status",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},d0=w0(P1);function w0(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function fh(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=O1[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),d0[l]?o+=d0[l]:Number.isInteger(Number(l))?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var as=Bt(ni()),N1=Bt(T0()),U1={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},F1=56*1024,B1=["hb","requestcompleted","requestfailed","requestcanceled"],$1="https://img.litix.io",zi=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||$1,this._eventQueue=[],this._postInFlight=!1,this._resendAfterPost=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},U1,e)};zi.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};zi.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};zi.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),as.default.clearTimeout(this._sendTimeout)};zi.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],fh({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);D0(this._beaconUrl,t,!0,function(){})};zi.prototype._sendBeaconQueue=function(){var i=this;if(this._postInFlight){this._resendAfterPost=!0;return}var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();D0(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1,i._resendAfterPost&&(i._resendAfterPost=!1,i._eventQueue.length>0&&i._sendBeaconQueue())})};zi.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};zi.prototype._startBeaconSending=function(){var i=this;as.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=as.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};zi.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return B1.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var H1=typeof N1.default.exitPictureInPicture=="function"?function(i){return i.length<=F1}:function(i){return!1},D0=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(as.default.fetch){as.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:H1(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(as.default.XMLHttpRequest){var s=new as.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},G1=zi,K1=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],V1=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],W1=["ad_id","ad_creative_id","ad_universal_id"],Y1=["viewstart","error","ended","viewend"],q1=10*60*1e3,j1=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ct(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new G1(w1(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var v;this.disableCookies=(v=this.options.disableCookies)!==null&&v!==void 0?v:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:C1(),page_url:lh.default===null||lh.default===void 0||(p=lh.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:L1()}return Ei(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&ch())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:k1(),s=mh(bl({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=fh(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Pe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):Y1.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=fh(s),this.eventQueue.queueEvent(s.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=q1)s=bl({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=ji(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||K1.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||W1.includes(t)&&V1.includes(e))}}]),i}(),z1=function i(e){"use strict";ct(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,v=f.request_bytes_loaded;n++;var y,T;if(p?(y=p-(m!=null?m:0),T=(g!=null?g:0)-p):T=(g!=null?g:0)-(m!=null?m:0),T>0&&v&&v>0){var _=v/T*8e3;a++,r+=v,s+=T,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,_),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},X1=z1,Q1=60*60*1e3,Z1=function i(e){"use strict";var t=this;ct(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>Q1){var l=Object.keys(e.data).reduce(function(u,c){return c.indexOf("video_")===0?Object.assign(u,H({},c,e.data[c])):u},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view");var d=e.playbackHeartbeat._playheadShouldBeProgressing;e._resetView(Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing=d,e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},J1=Z1,eS=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],tS=new Set(["requestcompleted","requestfailed","requestcanceled"]),iS=function(i){"use strict";OA(t,i);var e=UA(t);function t(r,s,n){ct(this,t);var a;a=e.call(this),H(le(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(le(a),"NAVIGATION_START",void 0),H(le(a),"_destroyed",void 0),H(le(a),"_heartBeatTimeout",void 0),H(le(a),"adTracker",void 0),H(le(a),"dashjs",void 0),H(le(a),"data",void 0),H(le(a),"disablePlayheadRebufferTracking",void 0),H(le(a),"disableRebufferTracking",void 0),H(le(a),"errorTracker",void 0),H(le(a),"errorTranslator",void 0),H(le(a),"emitTranslator",void 0),H(le(a),"getAdData",void 0),H(le(a),"getPlayheadTime",void 0),H(le(a),"getStateData",void 0),H(le(a),"stateDataTranslator",void 0),H(le(a),"hlsjs",void 0),H(le(a),"id",void 0),H(le(a),"longResumeTracker",void 0),H(le(a),"minimumRebufferDuration",void 0),H(le(a),"mux",void 0),H(le(a),"playbackEventDispatcher",void 0),H(le(a),"playbackHeartbeat",void 0),H(le(a),"playbackHeartbeatTime",void 0),H(le(a),"playheadTime",void 0),H(le(a),"seekingTracker",void 0),H(le(a),"sustainedRebufferThreshold",void 0),H(le(a),"watchTimeTracker",void 0),H(le(a),"currentFragmentPDT",void 0),H(le(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=Tl.domContentLoadedEventEnd(),a.NAVIGATION_START=Tl.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(h){return h},emitTranslator:function(){for(var h=arguments.length,f=new Array(h),m=0;m<h;m++)f[m]=arguments[m];return f},stateDataTranslator:function(h){return h}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.level=n.debug?ns.DEBUG:ns.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.emitTranslator=n.emitTranslator,a.stateDataTranslator=n.stateDataTranslator,a.playbackEventDispatcher=new j1(r,n.data.env_key,n),a.data={player_instance_id:La(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(le(a));if(a.on("viewinit",function(h,f){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,f),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)}),a.on("videochange",function(h,f){this._resetView(f)}),a.on("programchange",function(h,f){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),this._resetView(Object.assign(f,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(h,f){this.currentFragmentPDT=f.currentFragmentPDT,this.currentFragmentStart=f.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var d=function(){var h=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",h&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",d,!1);var u=function(h){h.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",d),window.removeEventListener("pagehide",u)})}a.on("playerready",function(h,f){Object.assign(this.data,f)}),eS.forEach(function(h){a.on(h,function(f,m){h.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,m),this._sanitizeData()}),a.on("after"+h,function(){(h!=="error"||this.errorTracker.viewErrored)&&this.send(h)})}),a.on("viewend",function(h,f){Object.assign(a.data,f)});var c=function(h){var f=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=f-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",c),a.longResumeTracker=new J1(le(a)),a.errorTracker=new t1(le(a)),new x1(le(a)),a.seekingTracker=new E1(le(a)),a.playheadTime=new o1(le(a)),a.playbackHeartbeat=new JA(le(a)),new p1(le(a)),a.watchTimeTracker=new r1(le(a)),new n1(le(a)),a.adTracker=new y1(le(a)),new c1(le(a)),new d1(le(a)),new f1(le(a)),new A1(le(a)),new X1(le(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ei(t,[{key:"emit",value:function(r,s){var n,a=Object.assign({viewer_time:this.mux.utils.now()},s),o=[r,a];if(this.emitTranslator)try{o=this.emitTranslator(r,a)}catch(l){this.mux.log.warn("Exception in emit translator callback.",l)}o!=null&&o.length&&(n=vl(on(t.prototype),"emit",this)).call.apply(n,[this].concat(ri(o)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=ji(ka(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,tS.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_resetView",value:function(r){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",r)}},{key:"_updateStateData",value:function(){var r=this.getStateData();if(typeof this.stateDataTranslator=="function")try{r=this.stateDataTranslator(r)}catch(s){this.mux.log.warn("Exception in stateDataTranslator translator callback.",s)}Object.assign(this.data,r),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=La(),n=function(){s===r.data.view_id&&et(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,KA(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(VA(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,jA(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(zA(this.dashjs),this.dashjs=void 0)}}]),t}(QA),rS=iS,xa=Bt(T0());function sS(){return xa.default&&!!(xa.default.fullscreenElement||xa.default.webkitFullscreenElement||xa.default.mozFullScreenElement||xa.default.msFullscreenElement)}var nS=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],aS={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function oS(i,e,t){var r=ji(El(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var c={getPlayheadTime:function(){return d(s.currentTime)},getStateData:function(){var f,m,p,g=((f=(m=this).getPlayheadTime)===null||f===void 0?void 0:f.call(m))||d(s.currentTime),v=this.hlsjs&&this.hlsjs.url,y=this.dashjs&&typeof this.dashjs.getSource=="function"&&this.dashjs.getSource(),T={player_is_paused:s.paused,player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:sS(),video_poster_url:s.poster,video_source_url:v||y||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(p=s.getVideoPlaybackQuality)===null||p===void 0?void 0:p.call(s).droppedVideoFrames};if(s.getStartDate&&g>0){var _=s.getStartDate();if(_&&typeof _.getTime=="function"&&_.getTime()){var A=_.getTime();if(T.player_program_time=A+g,s.seekable.length>0){var k=A+s.seekable.end(s.seekable.length-1);T.player_live_edge_program_time=k}}}return T}};t=Object.assign(u,t,c),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(f,m){i.emit(n,f,m)},s.mux.updateData=function(f){s.mux.emit("hb",f)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(f){s.removeEventListener(f,s.mux.listeners[f],!1)}),delete s.mux.listeners,s.mux.destroy=h,s.mux.swapElement=h,s.mux.emit=h,s.mux.addHLSJS=h,s.mux.addDashJS=h,s.mux.removeHLSJS=h,s.mux.removeDashJS=h,s.mux.updateData=h,s.mux.setEmitTranslator=h,s.mux.setStateDataTranslator=h,s.mux.setGetPlayheadTime=h,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(f){var m=ji(El(f),3),p=m[0],g=m[1],v=m[2];if(p){if(v!=="video"&&v!=="audio")return i.log.error("The element of `"+g+"` was not a media element.")}else return i.log.error("No element was found with the `"+g+"` query selector.");p.muxId=s.muxId,delete s.muxId,p.mux=p.mux||{},p.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(p.mux.listeners).forEach(function(y){s.removeEventListener(y,p.mux.listeners[y],!1),p.addEventListener(y,p.mux.listeners[y],!1)}),p.mux.swapElement=s.mux.swapElement,p.mux.destroy=s.mux.destroy,delete s.mux,s=p},s.mux.addHLSJS=function(f){i.addHLSJS(n,f)},s.mux.addDashJS=function(f){i.addDashJS(n,f)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},s.mux.setEmitTranslator=function(f){i.setEmitTranslator(n,f)},s.mux.setStateDataTranslator=function(f){i.setStateDataTranslator(n,f)},s.mux.setGetPlayheadTime=function(f){f||(f=t.getPlayheadTime),i.setGetPlayheadTime(n,f)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},nS.forEach(function(f){f==="error"&&!t.automaticErrorTracking||(s.mux.listeners[f]=function(){var m={};if(f==="error"){if(!s.error||s.error.code===1)return;m.player_error_code=s.error.code,m.player_error_message=aS[s.error.code]||s.error.message}i.emit(n,f,m)},s.addEventListener(f,s.mux.listeners[f],!1))})}function lS(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return s}var Ia=Bt(ni()),an;Ia.default&&Ia.default.WeakMap&&(an=new WeakMap);function dS(i,e){if(!i||!e||!Ia.default||typeof Ia.default.getComputedStyle!="function")return"";var t;return an&&an.has(i)&&(t=an.get(i)),t||(t=Ia.default.getComputedStyle(i,null),an&&an.set(i,t)),t.getPropertyValue(e)}function uS(i){return Math.floor(i*1e3)}var ss={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},_l=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};_l.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
|
|
15
15
|
`);e>-1;e=this.buffer.indexOf(`
|
|
16
|
-
`))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};yl.prototype.processLine=function(i){var e=i.indexOf(":"),t=mS(i,e),r=t[0],s=t.length===2?gh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case ss.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case ss.PART_INF:{dh(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case ss.SERVER_CONTROL:{dh(this.manifest,t),this.setHoldBack();break}case ss.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case ss.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case ss.VERSION:{dh(this.manifest,t);break}case ss.SESSION_DATA:{var o=pS(t[1]),l=A0(o);Object.assign(this.manifest.sessionData,l)}}};yl.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var dh=function(i,e){var t=C0(e[0].replace("#EXT-X-","")),r;fS(e[1])?(r={},r=Object.assign(hS(e[1]),r)):r=gh(e[1]),i[t]=r},C0=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},gh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},cS=function(i){var e={},t=i.split("=");if(t.length>1){var r=C0(t[0]);e[r]=gh(t[1])}return e},hS=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=cS(s);t=Object.assign(n,t)}return t},fS=function(i){return i.indexOf("=")>-1},mS=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},pS=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},gS=yl,vS={safeCall:lS,safeIncrement:et,getComputedStyle:dS,secondsToMs:uS,assign:Object.assign,headersStringToObject:ph,cdnHeadersToRequestId:bl,extractHostnameAndDomain:ka,extractHostname:si,manifestParser:gS,generateShortID:y0,generateUUID:La,now:tt.now,findMediaElement:vl},ES=vS,TS={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled",HEARTBEAT:"hb",DESTROY:"destroy"},bS=TS,yS="mux-embed",_S="5.9.0",AS="2.1",Je={},Tr=function(i){var e=arguments;typeof i=="string"?Tr.hasOwnProperty(i)?Ra.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Tr[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ra.default.setTimeout(function(){i(Tr)},0):Pe.warn("`"+i+"` is invalid.")},SS={loaded:tt.now(),NAME:yS,VERSION:_S,API_VERSION:AS,PLAYER_TRACKED:!1,monitor:function(i,e){return oS(Tr,i,e)},destroyMonitor:function(i){var e=ji(vl(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=ii(i);Je[t]?Je[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=ii(i);Je[t]?Je[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=ii(i);Je[e]?Je[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=ii(i);Je[e]?Je[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){ch()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=ii(i);Je[t]=new rS(Tr,t,e)},emit:function(i,e,t){var r=ii(i);Je[r]?(Je[r].emit(e,t),e==="destroy"&&delete Je[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(i,e){var t=ii(i);Je[t]?Je[t].emit("hb",e):Pe.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(i,e){var t=ii(i);Je[t]?Je[t].emitTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(i,e){var t=ii(i);Je[t]?Je[t].stateDataTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(i,e){var t=ii(i);Je[t]?Je[t].getPlayheadTime=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:ch,log:Pe,utils:ES,events:bS,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Tr,SS);typeof Ra.default!="undefined"&&typeof Ra.default.addEventListener=="function"&&Ra.default.addEventListener("pagehide",function(i){i.persisted||(Tr.WINDOW_UNLOADING=!0)},!1);var _l=Tr;function xS(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var xv={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,v=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(v)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(xv);var jf=xv.exports;function M0(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function pt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?M0(Object(t),!0).forEach(function(r){LS(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):M0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function RS(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function IS(i){var e=RS(i,"string");return typeof e=="symbol"?e:String(e)}function LS(i,e,t){return e=IS(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function it(){return it=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},it.apply(this,arguments)}var j=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},kS=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=wS},wS=Number.MAX_SAFE_INTEGER||9007199254740991,E=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ne=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),M=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),us=function(){},Fh={trace:us,debug:us,log:us,warn:us,info:us,error:us},Da=Fh;function DS(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):us}function CS(i,...e){e.forEach(function(t){Da[t]=i[t]?i[t].bind(i):DS(t)})}function MS(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){CS(i,"debug","log","info","warn","error");try{Da.log(`Debug logs enabled for "${e}" in hls.js version 1.5.20`)}catch{Da=Fh}}else Da=Fh}var L=Da,OS=/^(\d+)x(\d+)$/,O0=/(.+?)=(".*?"|.*?)(?:,|$)/g,qe=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),it(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=OS.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(O0.lastIndex=0;(t=O0.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function PS(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function NS(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Gl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){L.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=it(new qe({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);j(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(j(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},mn=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},we={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Kl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[we.AUDIO]:null,[we.VIDEO]:null,[we.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=jf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Ca=class extends Kl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new mn,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!j(this.programDateTime))return null;let e=j(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[we.AUDIO]=null,e[we.VIDEO]=null,e[we.AUDIOVIDEO]=null}},Bh=class extends Kl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new mn,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},US=10,$h=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||US}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function zf(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function FS(i){let e=Hh(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function BS(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function $S(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=zf(a)):t=FS(a)}}return t}function Hh(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var pn=typeof self!="undefined"?self:void 0,ke={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Dt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function vh(i){switch(i){case Dt.FAIRPLAY:return ke.FAIRPLAY;case Dt.PLAYREADY:return ke.PLAYREADY;case Dt.WIDEVINE:return ke.WIDEVINE;case Dt.CLEARKEY:return ke.CLEARKEY}}var Al={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Eh(i){if(i===Al.WIDEVINE)return ke.WIDEVINE;if(i===Al.PLAYREADY)return ke.PLAYREADY;if(i===Al.CENC||i===Al.CLEARKEY)return ke.CLEARKEY}function Th(i){switch(i){case ke.FAIRPLAY:return Dt.FAIRPLAY;case ke.PLAYREADY:return Dt.PLAYREADY;case ke.WIDEVINE:return Dt.WIDEVINE;case ke.CLEARKEY:return Dt.CLEARKEY}}function Sl(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[ke.FAIRPLAY,ke.WIDEVINE,ke.PLAYREADY,ke.CLEARKEY].filter(s=>!!e[s]):[];return!r[ke.WIDEVINE]&&t&&r.push(ke.WIDEVINE),r}var Rv=function(i){return pn!=null&&(i=pn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function HS(i,e,t,r){let s;switch(i){case ke.FAIRPLAY:s=["cenc","sinf"];break;case ke.WIDEVINE:case ke.PLAYREADY:s=["cenc"];break;case ke.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return GS(s,e,t,r)}function GS(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Iv(i){let e=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),r=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let l=zf(o).subarray(0,16);return BS(l),l}}return null}function ms(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Xf=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Lv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Oa=(i,e)=>{let t=e,r=0;for(;Xf(i,e);){r+=10;let s=pd(i,e+6);r+=s,Lv(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},pd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},KS=(i,e)=>Xf(i,e)&&pd(i,e+6)+10<=i.length-e,Qf=i=>{let e=wv(i);for(let t=0;t<e.length;t++){let r=e[t];if(kv(r))return zS(r)}},kv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",VS=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=pd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},wv=i=>{let e=0,t=[];for(;Xf(i,e);){let r=pd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=VS(i.subarray(e)),a=WS(n);a&&t.push(a),e+=n.size+10}Lv(i,e)&&(e+=10)}return t},WS=i=>i.type==="PRIV"?YS(i):i.type[0]==="W"?jS(i):qS(i),YS=i=>{if(i.size<2)return;let e=Ai(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},qS=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Ai(i.data.subarray(t),!0);t+=r.length+1;let s=Ai(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Ai(i.data.subarray(1));return{key:i.type,data:e}},jS=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Ai(i.data.subarray(t),!0);t+=r.length+1;let s=Ai(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Ai(i.data);return{key:i.type,data:e}},zS=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Ai=(i,e=!1)=>{let t=XS();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},bh;function XS(){if(!navigator.userAgent.includes("PlayStation 4"))return!bh&&typeof self.TextDecoder!="undefined"&&(bh=new self.TextDecoder("utf-8")),bh}var bi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Vl=Math.pow(2,32)-1,QS=[].push,Dv={video:1,audio:2,id3:3,text:4};function at(i){return String.fromCharCode.apply(null,i)}function Cv(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function re(i,e){let t=Mv(i,e);return t<0?4294967296+t:t}function P0(i,e){let t=re(i,e);return t*=Math.pow(2,32),t+=re(i,e+4),t}function Mv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function yh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function ZS(i){let e=i.byteLength;for(let t=0;t<e;){let r=re(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function he(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=re(i,s),a=at(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=he(i.subarray(s+8,o),e.slice(1));l.length&&QS.apply(t,l)}s=o}return t}function JS(i){let e=[],t=i[0],r=8,s=re(i,r);r+=4;let n=0,a=0;t===0?(n=re(i,r),a=re(i,r+4),r+=8):(n=P0(i,r),a=P0(i,r+8),r+=16),r+=2;let o=i.length+a,l=Cv(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=re(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return L.warn("SIDX has hierarchical references (not supported)"),null;let m=re(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Ov(i){let e=[],t=he(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=he(n,["tkhd"])[0];if(a){let o=a[0],l=re(a,o===0?12:20),d=he(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=re(d,o===0?12:20),c=he(n,["mdia","hdlr"])[0];if(c){let h=at(c.subarray(8,12)),f={soun:we.AUDIO,vide:we.VIDEO}[h];if(f){let m=he(n,["mdia","minf","stbl","stsd"])[0],p=ex(m);e[l]={timescale:u,type:f},e[f]=pt({timescale:u,id:l},p)}}}}}return he(i,["moov","mvex","trex"]).forEach(s=>{let n=re(s,4),a=e[n];a&&(a.default={duration:re(s,12),flags:re(s,20)})}),e}function ex(i){let e=i.subarray(8),t=e.subarray(86),r=at(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=he(e,[r])[0].subarray(r==="enca"?28:78);he(o,["sinf"]).forEach(d=>{let u=he(d,["schm"])[0];if(u){let c=at(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=he(d,["frma"])[0];h&&(s=at(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=he(t,["avcC"])[0];s+="."+xl(a[1])+xl(a[2])+xl(a[3]);break}case"mp4a":{let a=he(e,[r])[0],o=he(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=_h(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=_h(o,l);let u=o[l++];if(u===64)s+="."+xl(u);else break;if(l+=12,o[l++]!==5)break;l=_h(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=he(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=re(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=he(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Ti(o)+"."+Ti(l);break}case"vp09":{let a=he(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Ti(o)+"."+Ti(l)+"."+Ti(d);break}case"av01":{let a=he(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Ti(l)+d+"."+Ti(h)+"."+f+"."+m+p+g+"."+Ti(1)+"."+Ti(1)+"."+Ti(1)+"."+0;break}}return{codec:s,encrypted:n}}function _h(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function xl(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Ti(i){return(i<10?"0":"")+i}function tx(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&he(i,["moov","trak"]).forEach(s=>{let a=he(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=he(a,["enca"]),l=o.length>0;l||(o=he(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);he(u,["sinf"]).forEach(h=>{let f=Pv(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(L.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${bi.hexDump(m)} -> ${bi.hexDump(t)}`),f.set(t,8))}})})}),i}function Pv(i){let e=he(i,["schm"])[0];if(e){let t=at(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return he(i,["schi","tenc"])[0]}return null}function ix(i,e){return he(e,["moof","traf"]).reduce((t,r)=>{let s=he(r,["tfdt"])[0],n=s[0],a=he(r,["tfhd"]).reduce((o,l)=>{let d=re(l,4),u=i[d];if(u){let c=re(s,4);if(n===1){if(c===Vl)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Vl+1,c+=re(s,8)}let h=u.timescale||9e4,f=c/h;if(j(f)&&(o===null||f<o))return f}return o},null);return a!==null&&j(a)&&(t===null||a<t)?a:t},null)}function rx(i,e){let t=0,r=0,s=0,n=he(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=he(o,["tfhd"])[0],d=re(l,4),u=e[d];if(!u)continue;let c=u.default,h=re(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=re(l,12):f=re(l,8));let m=u.timescale||9e4,p=he(o,["trun"]);for(let g=0;g<p.length;g++){if(t=sx(p[g]),!t&&f){let v=re(p[g],4);t=f*v}u.type===we.VIDEO?r+=t/m:u.type===we.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=he(i,["sidx"]);for(let u=0;u<d.length;u++){let c=JS(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&j(l))return l}return r||s}function sx(i){let e=re(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=re(i,4);for(let n=0;n<s;n++){if(e&256){let a=re(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function nx(i,e,t){he(e,["moof","traf"]).forEach(r=>{he(r,["tfhd"]).forEach(s=>{let n=re(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;he(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=re(l,4);if(d===0)c-=u,c=Math.max(c,0),yh(l,4,c);else{c*=Math.pow(2,32),c+=re(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(Vl+1)),f=Math.floor(c%(Vl+1));yh(l,4,h),yh(l,8,f)}}})})})}function ax(i){let e={valid:null,remainder:null},t=he(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=ms(i,0,r.byteOffset-8),e.remainder=ms(i,r.byteOffset-8),e}function qt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function N0(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return he(r,["moof"]).map(l=>{let d=l.byteOffset-8;he(l,["traf"]).map(c=>{let h=he(c,["tfdt"]).map(f=>{let m=f[0],p=re(f,4);return m===1&&(p*=Math.pow(2,32),p+=re(f,8)),p/s})[0];return h!==void 0&&(i=h),he(c,["tfhd"]).map(f=>{let m=re(f,4),p=re(f,0)&16777215,g=(p&1)!==0,v=(p&2)!==0,y=(p&8)!==0,T=0,_=(p&16)!==0,A=0,k=(p&32)!==0,R=8;m===n&&(g&&(R+=8),v&&(R+=4),y&&(T=re(f,R),R+=4),_&&(A=re(f,R),R+=4),k&&(R+=4),e.type==="video"&&(a=ox(e.codec)),he(c,["trun"]).map(x=>{let O=x[0],w=re(x,0)&16777215,C=(w&1)!==0,P=0,U=(w&4)!==0,X=(w&256)!==0,z=0,q=(w&512)!==0,ce=0,fe=(w&1024)!==0,W=(w&2048)!==0,G=0,pe=re(x,4),te=8;C&&(P=re(x,te),te+=4),U&&(te+=4);let _e=P+d;for(let Ke=0;Ke<pe;Ke++){if(X?(z=re(x,te),te+=4):z=T,q?(ce=re(x,te),te+=4):ce=A,fe&&(te+=4),W&&(O===0?G=re(x,te):G=Mv(x,te),te+=4),e.type===we.VIDEO){let Ye=0;for(;Ye<ce;){let ze=re(r,_e);if(_e+=4,lx(a,r[_e])){let xt=r.subarray(_e,_e+ze);Nv(xt,a?2:1,i+G/s,t)}_e+=ze,Ye+=ze+4}}i+=z/s}}))})})}),t}function ox(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function lx(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Nv(i,e,t,r){let s=Uv(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){L.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=Cv(s,u);if(u+=2,h===49){let f=re(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,v=64&p,y=v?2+g*3:0,T=new Uint8Array(y);if(v){T[0]=p;for(let _=1;_<y;_++)T[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:T})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Ai(f),userDataBytes:f})}}}function Uv(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function dx(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;at(i.subarray(d,d+1))!=="\0";)t+=at(i.subarray(d,d+1)),d+=1;for(t+=at(i.subarray(d,d+1)),d+=1;at(i.subarray(d,d+1))!=="\0";)r+=at(i.subarray(d,d+1)),d+=1;r+=at(i.subarray(d,d+1)),d+=1,s=re(i,12),n=re(i,16),o=re(i,20),l=re(i,24),d=28}else if(e===1){d+=4,s=re(i,d),d+=4;let c=re(i,d);d+=4;let h=re(i,d);for(d+=4,a=2**32*c+h,kS(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=re(i,d),d+=4,l=re(i,d),d+=4;at(i.subarray(d,d+1))!=="\0";)t+=at(i.subarray(d,d+1)),d+=1;for(t+=at(i.subarray(d,d+1)),d+=1;at(i.subarray(d,d+1))!=="\0";)r+=at(i.subarray(d,d+1)),d+=1;r+=at(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function ux(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function cx(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),ux([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function hx(i){let e=[];if(i instanceof ArrayBuffer){let t=i.byteLength,r=0;for(;r+32<t;){let s=new DataView(i,r),n=fx(s);e.push(n),r+=n.size}}return e}function fx(i){let e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};let n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};let a=i.buffer,o=bi.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28),d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}var Rl={},Pa=class i{static clearKeyUriToKeyIdMap(){Rl={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Dt.FAIRPLAY:case Dt.WIDEVINE:case Dt.PLAYREADY:case Dt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=mx(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=$S(this.uri);if(t)switch(this.keyFormat){case Dt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Dt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=cx(r,null,t),this.keyId=Iv(t);break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Rl[this.uri];if(!r){let s=Object.keys(Rl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Rl[this.uri]=r}this.keyId=r}return this}};function mx(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Fv=/\{\$([a-zA-Z0-9-_]+)\}/g;function U0(i){return Fv.test(i)}function kt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Gh(i,n))}}function Gh(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Fv,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function F0(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function px(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function gs(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function gx(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var Wl={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function vx(i,e){let t=Wl[e];return!!t&&!!t[i.slice(0,4)]}function Ah(i,e,t=!0){return!i.split(",").some(r=>!Bv(r,e,t))}function Bv(i,e,t=!0){var r;let s=gs(t);return(r=s==null?void 0:s.isTypeSupported(Na(i,e)))!=null?r:!1}function Na(i,e){return`${e}/mp4;codecs="${i}"`}function B0(i){if(i){let e=i.substring(0,4);return Wl.video[e]}return 2}function Yl(i){return i.split(",").reduce((e,t)=>{let r=Wl.video[t];return r?(r*2+e)/(e?3:2):(Wl.audio[t]+e)/(e?2:1)},0)}var Sh={};function Ex(i,e=!0){if(Sh[i])return Sh[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(Bv(t[r],"audio",e))return Sh[i]=t[r],t[r];return i}var Tx=/flac|opus/i;function ql(i,e=!0){return i.replace(Tx,t=>Ex(t.toLowerCase(),e))}function $0(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function bx(i){let e=i.split(",");for(let t=0;t<e.length;t++){let r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}var H0=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,G0=/#EXT-X-MEDIA:(.*)/g,yx=/^#EXT(?:INF|-X-TARGETDURATION):/m,K0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),_x=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),hs=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return jf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return yx.test(e)}static parseMasterPlaylist(e,t){let r=U0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];H0.lastIndex=0;let a;for(;(a=H0.exec(e))!=null;)if(a[1]){var o;let d=new qe(a[1]);kt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Gh(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),Ax(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new qe(u);kt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=V0(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new qe(u);kt(s,c,["NAME","VALUE","QUERYPARAM"]),F0(s,c,t)}break}case"CONTENT-STEERING":{let c=new qe(u);kt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=W0(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(G0.lastIndex=0;(s=G0.exec(e))!==null;){let d=new qe(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,kt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,v=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),v&&(y.instreamId=v),c!=null&&c.length){let T=i.findGroup(c,y.groupId)||c[0];Y0(y,T,"audioCodec"),Y0(y,T,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new $h(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new Ca(s,t),g,v,y,T=-1,_=!1,A=null;for(K0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=U0(e);(g=K0.exec(e))!==null;){_&&(_=!1,p=new Ca(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,A&&(p.setByteRange(A),A=null)));let O=g[1];if(O){p.duration=parseFloat(O);let w=(" "+g[2]).slice(1);p.title=w||null,p.tagList.push(w?["INF",O,w]:["INF",O])}else if(g[3]){if(j(p.duration)){p.start=h,y&&z0(p,y,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let w=(" "+g[3]).slice(1);p.relurl=Gh(o,w),q0(p,m),m=p,h+=p.duration,u++,c=0,_=!0}}else if(g[4]){let w=(" "+g[4]).slice(1);m?p.setByteRange(w,m):p.setByteRange(w)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),T===-1&&(T=l.length);else{if(g=g[0].match(_x),!g){L.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<g.length&&typeof g[v]=="undefined";v++);let w=(" "+g[v]).slice(1),C=(" "+g[v+1]).slice(1),P=g[v+2]?(" "+g[v+2]).slice(1):"";switch(w){case"PLAYLIST-TYPE":o.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(C);break;case"SKIP":{let U=new qe(C);kt(o,U,["RECENTLY-REMOVED-DATERANGES"]);let X=U.decimalInteger("SKIPPED-SEGMENTS");if(j(X)){o.skippedSegments=X;for(let q=X;q--;)l.unshift(null);u+=X}let z=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(o.recentlyRemovedDateranges=z.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(C),1);break;case"VERSION":o.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(C||P)&&p.tagList.push(P?[C,P]:[C]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([w]);break;case"BITRATE":p.tagList.push([w,C]);break;case"DATERANGE":{let U=new qe(C);kt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),kt(o,U,U.clientAttrs);let X=new Gl(U,o.dateRanges[U.ID]);X.isValid||o.skippedSegments?o.dateRanges[X.id]=X:L.warn(`Ignoring invalid DATERANGE tag: "${C}"`),p.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":{{let U=new qe(C);kt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?px(o,U,a):F0(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{let U=V0(C,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=it({},y)),y[U.keyFormat]=U}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=W0(C);break;case"MAP":{let U=new qe(C);if(kt(o,U,["BYTERANGE","URI"]),p.duration){let X=new Ca(s,t);j0(X,U,r,y),d=X,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let X=p.byteRangeEndOffset;if(X){let z=p.byteRangeStartOffset;A=`${X-z}@${z}`}else A=null;j0(p,U,r,y),d=p,_=!0}break}case"SERVER-CONTROL":{let U=new qe(C);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let U=new qe(C);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);let X=c>0?U[U.length-1]:void 0,z=c++,q=new qe(C);kt(o,q,["BYTERANGE","URI"]);let ce=new Bh(q,p,t,z,X);U.push(ce),p.duration+=ce.duration;break}case"PRELOAD-HINT":{let U=new qe(C);kt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{let U=new qe(C);kt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:L.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(q0(p,m),p.cc=f,o.fragmentHint=p,y&&z0(p,y,o));let k=l.length,R=l[0],x=l[k-1];if(h+=o.skippedSegments*o.targetduration,h>0&&k&&x){o.averagetargetduration=h/k;let O=x.sn;o.endSN=O!=="initSegment"?O:0,o.live||(x.endList=!0),R&&(o.startCC=R.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,T>0&&Sx(l,T),o}};function V0(i,e,t){var r,s;let n=new qe(i);kt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&L.error(`Invalid IV: ${n.IV}`);let c=o?hs.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Pa(a,c,u,h,l)}function W0(i){let t=new qe(i).decimalFloatingPoint("TIME-OFFSET");return j(t)?t:null}function Ax(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>vx(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function Y0(i,e,t){let r=e[t];r&&(i[t]=r)}function Sx(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function q0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),j(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function j0(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function z0(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Ae={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},se={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function X0(i){let{type:e}=i;switch(e){case Ae.AUDIO_TRACK:return se.AUDIO;case Ae.SUBTITLE_TRACK:return se.SUBTITLE;default:return se.MAIN}}function xh(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Kh=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ae.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:Ae.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ae.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ae.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){L.trace("[playlist-loader]: playlist request ongoing");return}L.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Ae.MANIFEST?n=r.manifestLoadPolicy.default:n=it({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Ae.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Ae.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Ae.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=it({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),hs.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=xh(e,r),l=hs.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=hs.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(T=>!T.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(L.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new qe({}),bitrate:0,url:""})),n.trigger(E.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:v,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=xh(e,r),c=0,h=j(l)?l:j(o)?o:0,f=X0(r),m=hs.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===Ae.MANIFEST){let p={attrs:new qe({}),bitrate:0,details:m,name:"",url:u};a.trigger(E.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===Ae.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Ae.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Ae.AUDIO_TRACK||e.type===Ae.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);L.warn(`[playlist-loader]: ${a}`);let l=M.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case Ae.MANIFEST:l=r?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,d=!0;break;case Ae.LEVEL:l=r?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,d=!1;break;case Ae.AUDIO_TRACK:l=r?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ae.SUBTITLE_TRACK:l=r?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:ne.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=pt({url:h,data:void 0},s)}this.hls.trigger(E.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=xh(t,s),m=X0(s),p=typeof s.level=="number"&&m===se.MAIN?d:void 0;if(!e.fragments.length){let v=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Ae.MANIFEST:case Ae.LEVEL:o.trigger(E.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Ae.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Ae.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function $v(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Hv(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){L.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function cn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Vh(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=Rx(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function xx(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function Rx(i,e,t){let r=[],s=xx(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Pl(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var di={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Ix=.25;function Wh(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function Q0(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?pt({type:s},r):r))}return n}var Il=(()=>{let i=Wh();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Rh(i,e){return i.getTime()/1e3-e}function Lx(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Yh=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(cn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return $v(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Wh();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===di.emsg&&!r||!s)continue;let d=wv(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>Il&&(c=Il),c-u<=0&&(c=u+Ix);for(let f=0;f<d.length;f++){let m=d[f];if(!kv(m)){this.updateId3CueEnds(u,l);let p=Q0(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Il&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===di.audioId3&&l:s==="video"?d=u=>u.type===di.emsg&&o:d=u=>u.type===di.audioId3&&l||u.type===di.emsg&&o,Vh(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!j(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Wh();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=Rh(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,v=Il,y=h.endDate;if(y)v=Rh(y,l),g=!0;else if(h.endOnNext&&!g){let _=a.reduce((A,k)=>{if(k!==h.id){let R=n[k];if(R.class===h.class&&R.startDate>h.startDate&&(!A||h.startDate<A.startDate))return R}return A},null);_&&(v=Rh(_.startDate,l),g=!0)}let T=Object.keys(h.attr);for(let _=0;_<T.length;_++){let A=T[_];if(!PS(A))continue;let k=p[A];if(k)g&&!m.durationKnown&&(k.endTime=v);else if(d){let R=h.attr[A];NS(A)&&(R=Lx(R));let x=Q0(d,f,v,{key:A,data:R},di.dateRange);x&&(x.id=c,this.id3Track.addCue(x),p[A]=x)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},qh=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&L.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},jh=["NONE","TYPE-0","TYPE-1",null];function kx(i){return jh.indexOf(i)>-1}var jl=["SDR","PQ","HLG"];function wx(i){return!!i&&jl.indexOf(i)>-1}var Nl={No:"",Yes:"YES",v2:"v2"};function Z0(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Nl.v2:Nl.Yes:Nl.No}var zl=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},_r=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return J0(this._audioGroups,e)}hasSubtitleGroup(e){return J0(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function J0(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function Ih(i,e){let t=e.startPTS;if(j(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Gv(i,e,t,r,s,n){r-t<=0&&(L.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(j(d)){let g=Math.abs(d-t);j(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)Ih(p[f],p[f-1]);for(f=m;f<p.length-1;f++)Ih(p[f],p[f+1]);return i.fragmentHint&&Ih(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function Dx(i,e){let t=null,r=i.fragments;for(let o=r.length-1;o>=0;o--){let l=r[o].initSegment;if(l){t=l;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s;Ox(i,e,(o,l,d,u)=>{if(e.skippedSegments&&l.cc!==o.cc){let c=o.cc-l.cc;for(let h=d;h<u.length;h++)u[h].cc+=c}j(o.startPTS)&&j(o.endPTS)&&(l.start=l.startPTS=o.startPTS,l.startDTS=o.startDTS,l.maxStartPTS=o.maxStartPTS,l.endPTS=o.endPTS,l.endDTS=o.endDTS,l.minEndPTS=o.minEndPTS,l.duration=o.endPTS-o.startPTS,l.duration&&(s=l),e.PTSKnown=e.alignedSliding=!0),l.elementaryStreams=o.elementaryStreams,l.loader=o.loader,l.stats=o.stats,o.initSegment&&(l.initSegment=o.initSegment,t=o.initSegment)});let n=e.fragments;if(t&&(e.fragmentHint?n.concat(e.fragmentHint):n).forEach(l=>{var d;l&&(!l.initSegment||l.initSegment.relurl===((d=t)==null?void 0:d.relurl))&&(l.initSegment=t)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(o=>!o),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let o=e.skippedSegments;o--;)n.shift();e.startSN=n[0].sn}else e.canSkipDateRanges&&(e.dateRanges=Cx(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));e.startCC=e.fragments[0].cc,e.endCC=n[n.length-1].cc}Mx(i.partList,e.partList,(o,l)=>{l.elementaryStreams=o.elementaryStreams,l.stats=o.stats}),s?Gv(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Kv(i,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let a=e.advancedDateTime;if(e.advanced&&a){let o=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=o),e.driftEndTime=a,e.driftEnd=o}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function Cx(i,e,t){let r=it({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Gl(e[s].attr,r[s]);n.isValid?r[s]=n:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function Mx(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function Ox(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c,d,o)}}function Kv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||zh(e,r[t].start)}function zh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function Px(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments;if(r.length&&t*4>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function Nx(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function ev(i,e,t){var r;return i!=null&&i.details?Vv((r=i.details)==null?void 0:r.partList,e,t):null}function Vv(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Wv(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Xl(i){switch(i.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tv(i,e){let t=Xl(e);return i.default[`${t?"timeout":"error"}Retry`]}function Zf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function iv(i){return pt(pt({},i),{errorRetry:null,timeoutRetry:null})}function Ql(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(Ux(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function Ux(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Yv={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function Fx(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!j(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if($x(e,t,a))return a}return null}function Zl(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;let o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&Xh(t,r,n)===0||Bx(n,i,Math.min(s,r))))return n;let a=Yv.search(e,Xh.bind(null,t,r));return a&&(a!==i||!n)?a:n}function Bx(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){let r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function Xh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function $x(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function Hx(i,e){return Yv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ai={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Qh=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===se.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case M.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ft.DoNothing,flags:ai.None};return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ft.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===se.MAIN?t.level:n.loadLevel;t.details===M.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Ae.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Ae.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ft.SendAlternateToPenaltyBox,t.errorAction.flags=ai.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ft.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ft.DoNothing,flags:ai.None};return}t.type===ne.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=tv(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Ql(s,n,Xl(e),e.response))return{action:ft.RetryRequest,flags:ai.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=tv(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==M.FRAG_GAP&&s.fragmentError++,Ql(o,l,Xl(e),e.response)))return{action:ft.RetryRequest,flags:ai.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===M.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,v=(p===se.AUDIO&&d===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:k})=>s.audioCodec!==k),T=e.sourceBufferName==="video"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR)&&c.some(({codecSet:k,audioCodec:R})=>s.codecSet!==k&&s.audioCodec===R),{type:_,groupId:A}=(a=e.context)!=null?a:{};for(let k=c.length;k--;){let R=(k+h)%c.length;if(R!==h&&R>=f&&R<=m&&c[R].loadError===0){var o,l;let x=c[R];if(d===M.FRAG_GAP&&p===se.MAIN&&e.frag){let O=c[R].details;if(O){let w=Zl(e.frag,O.fragments,e.frag.start);if(w!=null&&w.gap)continue}}else{if(_===Ae.AUDIO_TRACK&&x.hasAudioGroup(A)||_===Ae.SUBTITLE_TRACK&&x.hasSubtitleGroup(A))continue;if(p===se.AUDIO&&(o=s.audioGroups)!=null&&o.some(O=>x.hasAudioGroup(O))||p===se.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(O=>x.hasSubtitleGroup(O))||v&&s.audioCodec===x.audioCodec||!v&&s.audioCodec!==x.audioCodec||T&&s.codecSet===x.codecSet)continue}u=R;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ft.SendAlternateToPenaltyBox,flags:ai.None,nextAutoLevel:u}}return{action:ft.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ft.DoNothing:break;case ft.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==M.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case ft.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case ai.None:this.switchLevel(e,a);break;case ai.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=jh[jh.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},Ua=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=L.log.bind(L,`${t}:`),this.warn=L.warn.bind(L,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){L.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&Z0(r);return new zl(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&Dx(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,v=s.lastPartSn,y=s.endSN,T=s.lastPartIndex,_=T!==-1,A=v===y,k=g?0:T;_?(d=A?y+1:v,u=A?k:T+1):d=y+1;let R=s.age,x=R+s.ageHeader,O=Math.min(x-s.partTarget,s.targetduration*1.5);if(O>0){if(r&&O>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{let w=Math.floor(O/s.targetduration);if(d+=w,u!==void 0){let C=Math.round(O%s.targetduration/s.partTarget);u+=C}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${R.toFixed(2)}s goal: ${O} skip sn ${w} to part ${u}`)}s.tuneInGoal=O}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!A){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=Px(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=Z0(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Nl.No),new zl(r,s,n)}checkRetry(e){let t=e.details,r=Xl(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ft.RetryRequest||!s.resolved&&n===ft.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Zf(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},yr=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Zh=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new yr(e),this.fast_=new yr(t),this.defaultTTFB_=s,this.ttfb_=new yr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new yr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new yr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new yr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},qv={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},rv={};function Gx(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&j(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function Kx(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(qv);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:pt(pt({},n),{},{contentType:Na(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);j(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:Na(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=Vx(l);return rv[d]||(rv[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function Vx(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function Wx(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function Yx(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||jl.slice(0),t=e.preferHDR!==void 0?e.preferHDR:Wx(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function qx(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:v}=Yx(e,s);for(let A=n.length;A--;){let k=i[n[A]];d=k.channels[2]>0,c=Math.min(c,k.minHeight),h=Math.min(h,k.minFramerate),f=Math.min(f,k.minBitrate);let R=v.filter(x=>k.videoRanges[x]>0);R.length>0&&(u=!0,p=R)}c=j(c)?c:0,h=j(h)?h:0;let y=Math.max(1080,c),T=Math.max(30,h);return f=j(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((A,k)=>{let R=i[k];if(k===A)return A;if(R.minBitrate>t)return Xi(k,`min bitrate of ${R.minBitrate} > current estimate of ${t}`),A;if(!R.hasDefaultAudio)return Xi(k,"no renditions with default or auto-select sound found"),A;if(o&&k.indexOf(o.substring(0,4))%5!==0)return Xi(k,`audio codec preference "${o}" not found`),A;if(a&&!l){if(!R.channels[a])return Xi(k,`no renditions with ${a} channel sound found (channels options: ${Object.keys(R.channels)})`),A}else if((!o||l)&&d&&R.channels[2]===0)return Xi(k,"no renditions with stereo sound found"),A;return R.minHeight>y?(Xi(k,`min resolution of ${R.minHeight} > maximum of ${y}`),A):R.minFramerate>T?(Xi(k,`min framerate of ${R.minFramerate} > maximum of ${T}`),A):p.some(x=>R.videoRanges[x]>0)?R.maxScore<m?(Xi(k,`max score of ${R.maxScore} < selected max of ${m}`),A):A&&(Yl(k)>=Yl(A)||R.fragmentError>i[A].fragmentError)?A:(m=R.maxScore,k):(Xi(k,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),A)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Xi(i,e){L.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function jx(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function zx(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function _i(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(ps(i,s,t))return r}return-1}function ps(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,default:o}=i,l=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in i)||Xx(i.characteristics||"",e.characteristics))&&(t===void 0||t(i,e))}function Xx(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function cs(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function Qx(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=sv(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return _i(i,m,s)>-1});return c>-1?c:sv(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return _i(i,m,s)>-1})}function sv(i,e,t){for(let r=e;r>-1;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var Jh=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&g>-1,y=this.getBwEstimate(),T=s.levels,_=T[t.level],A=l.total||Math.max(l.loaded,Math.round(d*_.averageBitrate/8)),k=v?u-g:u;k<1&&v&&(k=Math.min(u,l.loaded*8/y));let R=v?l.loaded*1e3/k:0,x=R?(A-l.loaded)/R:A*8/y+f/1e3;if(x<=p)return;let O=R?R*8:y,w=Number.POSITIVE_INFINITY,C;for(C=t.level-1;C>c;C--){let U=T[C].maxBitrate;if(w=this.getTimeToLoadFrag(f/1e3,O,d*U,!T[C].details),w<p)break}if(w>=x||w>d*10)return;s.nextLoadLevel=s.nextAutoLevel=C,v?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let P=T[C].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>P&&this.resetEstimator(P),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
|
|
16
|
+
`))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};_l.prototype.processLine=function(i){var e=i.indexOf(":"),t=mS(i,e),r=t[0],s=t.length===2?gh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case ss.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case ss.PART_INF:{dh(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case ss.SERVER_CONTROL:{dh(this.manifest,t),this.setHoldBack();break}case ss.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case ss.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case ss.VERSION:{dh(this.manifest,t);break}case ss.SESSION_DATA:{var o=pS(t[1]),l=A0(o);Object.assign(this.manifest.sessionData,l)}}};_l.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var dh=function(i,e){var t=C0(e[0].replace("#EXT-X-","")),r;fS(e[1])?(r={},r=Object.assign(hS(e[1]),r)):r=gh(e[1]),i[t]=r},C0=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},gh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},cS=function(i){var e={},t=i.split("=");if(t.length>1){var r=C0(t[0]);e[r]=gh(t[1])}return e},hS=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=cS(s);t=Object.assign(n,t)}return t},fS=function(i){return i.indexOf("=")>-1},mS=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},pS=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},gS=_l,vS={safeCall:lS,safeIncrement:et,getComputedStyle:dS,secondsToMs:uS,assign:Object.assign,headersStringToObject:ph,cdnHeadersToRequestId:yl,extractHostnameAndDomain:ka,extractHostname:si,manifestParser:gS,generateShortID:y0,generateUUID:La,now:tt.now,findMediaElement:El},ES=vS,TS={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled",HEARTBEAT:"hb",DESTROY:"destroy"},bS=TS,yS="mux-embed",_S="5.9.0",AS="2.1",Je={},Tr=function(i){var e=arguments;typeof i=="string"?Tr.hasOwnProperty(i)?Ra.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Tr[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ra.default.setTimeout(function(){i(Tr)},0):Pe.warn("`"+i+"` is invalid.")},SS={loaded:tt.now(),NAME:yS,VERSION:_S,API_VERSION:AS,PLAYER_TRACKED:!1,monitor:function(i,e){return oS(Tr,i,e)},destroyMonitor:function(i){var e=ji(El(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=ii(i);Je[t]?Je[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=ii(i);Je[t]?Je[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=ii(i);Je[e]?Je[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=ii(i);Je[e]?Je[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){ch()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=ii(i);Je[t]=new rS(Tr,t,e)},emit:function(i,e,t){var r=ii(i);Je[r]?(Je[r].emit(e,t),e==="destroy"&&delete Je[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(i,e){var t=ii(i);Je[t]?Je[t].emit("hb",e):Pe.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(i,e){var t=ii(i);Je[t]?Je[t].emitTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(i,e){var t=ii(i);Je[t]?Je[t].stateDataTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(i,e){var t=ii(i);Je[t]?Je[t].getPlayheadTime=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:ch,log:Pe,utils:ES,events:bS,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Tr,SS);typeof Ra.default!="undefined"&&typeof Ra.default.addEventListener=="function"&&Ra.default.addEventListener("pagehide",function(i){i.persisted||(Tr.WINDOW_UNLOADING=!0)},!1);var Al=Tr;function xS(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var xv={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,v=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(v)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(xv);var jf=xv.exports;function M0(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function pt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?M0(Object(t),!0).forEach(function(r){LS(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):M0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function RS(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function IS(i){var e=RS(i,"string");return typeof e=="symbol"?e:String(e)}function LS(i,e,t){return e=IS(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function it(){return it=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},it.apply(this,arguments)}var j=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},kS=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=wS},wS=Number.MAX_SAFE_INTEGER||9007199254740991,E=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ne=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),M=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),us=function(){},Fh={trace:us,debug:us,log:us,warn:us,info:us,error:us},Da=Fh;function DS(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):us}function CS(i,...e){e.forEach(function(t){Da[t]=i[t]?i[t].bind(i):DS(t)})}function MS(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){CS(i,"debug","log","info","warn","error");try{Da.log(`Debug logs enabled for "${e}" in hls.js version 1.5.20`)}catch{Da=Fh}}else Da=Fh}var L=Da,OS=/^(\d+)x(\d+)$/,O0=/(.+?)=(".*?"|.*?)(?:,|$)/g,qe=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),it(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=OS.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(O0.lastIndex=0;(t=O0.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function PS(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function NS(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Kl=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){L.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=it(new qe({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);j(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(j(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},mn=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},we={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Vl=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[we.AUDIO]:null,[we.VIDEO]:null,[we.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=jf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Ca=class extends Vl{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new mn,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!j(this.programDateTime))return null;let e=j(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[we.AUDIO]=null,e[we.VIDEO]=null,e[we.AUDIOVIDEO]=null}},Bh=class extends Vl{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new mn,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},US=10,$h=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||US}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function zf(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function FS(i){let e=Hh(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function BS(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function $S(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=zf(a)):t=FS(a)}}return t}function Hh(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var pn=typeof self!="undefined"?self:void 0,ke={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Dt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function vh(i){switch(i){case Dt.FAIRPLAY:return ke.FAIRPLAY;case Dt.PLAYREADY:return ke.PLAYREADY;case Dt.WIDEVINE:return ke.WIDEVINE;case Dt.CLEARKEY:return ke.CLEARKEY}}var Sl={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Eh(i){if(i===Sl.WIDEVINE)return ke.WIDEVINE;if(i===Sl.PLAYREADY)return ke.PLAYREADY;if(i===Sl.CENC||i===Sl.CLEARKEY)return ke.CLEARKEY}function Th(i){switch(i){case ke.FAIRPLAY:return Dt.FAIRPLAY;case ke.PLAYREADY:return Dt.PLAYREADY;case ke.WIDEVINE:return Dt.WIDEVINE;case ke.CLEARKEY:return Dt.CLEARKEY}}function xl(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[ke.FAIRPLAY,ke.WIDEVINE,ke.PLAYREADY,ke.CLEARKEY].filter(s=>!!e[s]):[];return!r[ke.WIDEVINE]&&t&&r.push(ke.WIDEVINE),r}var Rv=function(i){return pn!=null&&(i=pn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function HS(i,e,t,r){let s;switch(i){case ke.FAIRPLAY:s=["cenc","sinf"];break;case ke.WIDEVINE:case ke.PLAYREADY:s=["cenc"];break;case ke.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return GS(s,e,t,r)}function GS(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Iv(i){let e=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),r=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(a){let o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){let l=zf(o).subarray(0,16);return BS(l),l}}return null}function ms(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Xf=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Lv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Oa=(i,e)=>{let t=e,r=0;for(;Xf(i,e);){r+=10;let s=gd(i,e+6);r+=s,Lv(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},gd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},KS=(i,e)=>Xf(i,e)&&gd(i,e+6)+10<=i.length-e,Qf=i=>{let e=wv(i);for(let t=0;t<e.length;t++){let r=e[t];if(kv(r))return zS(r)}},kv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",VS=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=gd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},wv=i=>{let e=0,t=[];for(;Xf(i,e);){let r=gd(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=VS(i.subarray(e)),a=WS(n);a&&t.push(a),e+=n.size+10}Lv(i,e)&&(e+=10)}return t},WS=i=>i.type==="PRIV"?YS(i):i.type[0]==="W"?jS(i):qS(i),YS=i=>{if(i.size<2)return;let e=Ai(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},qS=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Ai(i.data.subarray(t),!0);t+=r.length+1;let s=Ai(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Ai(i.data.subarray(1));return{key:i.type,data:e}},jS=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Ai(i.data.subarray(t),!0);t+=r.length+1;let s=Ai(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Ai(i.data);return{key:i.type,data:e}},zS=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Ai=(i,e=!1)=>{let t=XS();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},bh;function XS(){if(!navigator.userAgent.includes("PlayStation 4"))return!bh&&typeof self.TextDecoder!="undefined"&&(bh=new self.TextDecoder("utf-8")),bh}var bi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Wl=Math.pow(2,32)-1,QS=[].push,Dv={video:1,audio:2,id3:3,text:4};function at(i){return String.fromCharCode.apply(null,i)}function Cv(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function re(i,e){let t=Mv(i,e);return t<0?4294967296+t:t}function P0(i,e){let t=re(i,e);return t*=Math.pow(2,32),t+=re(i,e+4),t}function Mv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function yh(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function ZS(i){let e=i.byteLength;for(let t=0;t<e;){let r=re(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function he(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=re(i,s),a=at(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=he(i.subarray(s+8,o),e.slice(1));l.length&&QS.apply(t,l)}s=o}return t}function JS(i){let e=[],t=i[0],r=8,s=re(i,r);r+=4;let n=0,a=0;t===0?(n=re(i,r),a=re(i,r+4),r+=8):(n=P0(i,r),a=P0(i,r+8),r+=16),r+=2;let o=i.length+a,l=Cv(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=re(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return L.warn("SIDX has hierarchical references (not supported)"),null;let m=re(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function Ov(i){let e=[],t=he(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=he(n,["tkhd"])[0];if(a){let o=a[0],l=re(a,o===0?12:20),d=he(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=re(d,o===0?12:20),c=he(n,["mdia","hdlr"])[0];if(c){let h=at(c.subarray(8,12)),f={soun:we.AUDIO,vide:we.VIDEO}[h];if(f){let m=he(n,["mdia","minf","stbl","stsd"])[0],p=ex(m);e[l]={timescale:u,type:f},e[f]=pt({timescale:u,id:l},p)}}}}}return he(i,["moov","mvex","trex"]).forEach(s=>{let n=re(s,4),a=e[n];a&&(a.default={duration:re(s,12),flags:re(s,20)})}),e}function ex(i){let e=i.subarray(8),t=e.subarray(86),r=at(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=he(e,[r])[0].subarray(r==="enca"?28:78);he(o,["sinf"]).forEach(d=>{let u=he(d,["schm"])[0];if(u){let c=at(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=he(d,["frma"])[0];h&&(s=at(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=he(t,["avcC"])[0];s+="."+Rl(a[1])+Rl(a[2])+Rl(a[3]);break}case"mp4a":{let a=he(e,[r])[0],o=he(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=_h(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=_h(o,l);let u=o[l++];if(u===64)s+="."+Rl(u);else break;if(l+=12,o[l++]!==5)break;l=_h(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=he(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=re(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=he(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Ti(o)+"."+Ti(l);break}case"vp09":{let a=he(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Ti(o)+"."+Ti(l)+"."+Ti(d);break}case"av01":{let a=he(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Ti(l)+d+"."+Ti(h)+"."+f+"."+m+p+g+"."+Ti(1)+"."+Ti(1)+"."+Ti(1)+"."+0;break}}return{codec:s,encrypted:n}}function _h(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function Rl(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Ti(i){return(i<10?"0":"")+i}function tx(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&he(i,["moov","trak"]).forEach(s=>{let a=he(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=he(a,["enca"]),l=o.length>0;l||(o=he(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);he(u,["sinf"]).forEach(h=>{let f=Pv(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(L.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${bi.hexDump(m)} -> ${bi.hexDump(t)}`),f.set(t,8))}})})}),i}function Pv(i){let e=he(i,["schm"])[0];if(e){let t=at(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return he(i,["schi","tenc"])[0]}return null}function ix(i,e){return he(e,["moof","traf"]).reduce((t,r)=>{let s=he(r,["tfdt"])[0],n=s[0],a=he(r,["tfhd"]).reduce((o,l)=>{let d=re(l,4),u=i[d];if(u){let c=re(s,4);if(n===1){if(c===Wl)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Wl+1,c+=re(s,8)}let h=u.timescale||9e4,f=c/h;if(j(f)&&(o===null||f<o))return f}return o},null);return a!==null&&j(a)&&(t===null||a<t)?a:t},null)}function rx(i,e){let t=0,r=0,s=0,n=he(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=he(o,["tfhd"])[0],d=re(l,4),u=e[d];if(!u)continue;let c=u.default,h=re(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=re(l,12):f=re(l,8));let m=u.timescale||9e4,p=he(o,["trun"]);for(let g=0;g<p.length;g++){if(t=sx(p[g]),!t&&f){let v=re(p[g],4);t=f*v}u.type===we.VIDEO?r+=t/m:u.type===we.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=he(i,["sidx"]);for(let u=0;u<d.length;u++){let c=JS(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&j(l))return l}return r||s}function sx(i){let e=re(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=re(i,4);for(let n=0;n<s;n++){if(e&256){let a=re(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function nx(i,e,t){he(e,["moof","traf"]).forEach(r=>{he(r,["tfhd"]).forEach(s=>{let n=re(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;he(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=re(l,4);if(d===0)c-=u,c=Math.max(c,0),yh(l,4,c);else{c*=Math.pow(2,32),c+=re(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(Wl+1)),f=Math.floor(c%(Wl+1));yh(l,4,h),yh(l,8,f)}}})})})}function ax(i){let e={valid:null,remainder:null},t=he(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=ms(i,0,r.byteOffset-8),e.remainder=ms(i,r.byteOffset-8),e}function qt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function N0(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return he(r,["moof"]).map(l=>{let d=l.byteOffset-8;he(l,["traf"]).map(c=>{let h=he(c,["tfdt"]).map(f=>{let m=f[0],p=re(f,4);return m===1&&(p*=Math.pow(2,32),p+=re(f,8)),p/s})[0];return h!==void 0&&(i=h),he(c,["tfhd"]).map(f=>{let m=re(f,4),p=re(f,0)&16777215,g=(p&1)!==0,v=(p&2)!==0,y=(p&8)!==0,T=0,_=(p&16)!==0,A=0,k=(p&32)!==0,R=8;m===n&&(g&&(R+=8),v&&(R+=4),y&&(T=re(f,R),R+=4),_&&(A=re(f,R),R+=4),k&&(R+=4),e.type==="video"&&(a=ox(e.codec)),he(c,["trun"]).map(x=>{let O=x[0],w=re(x,0)&16777215,C=(w&1)!==0,P=0,U=(w&4)!==0,X=(w&256)!==0,z=0,q=(w&512)!==0,ce=0,fe=(w&1024)!==0,W=(w&2048)!==0,G=0,pe=re(x,4),te=8;C&&(P=re(x,te),te+=4),U&&(te+=4);let _e=P+d;for(let Ke=0;Ke<pe;Ke++){if(X?(z=re(x,te),te+=4):z=T,q?(ce=re(x,te),te+=4):ce=A,fe&&(te+=4),W&&(O===0?G=re(x,te):G=Mv(x,te),te+=4),e.type===we.VIDEO){let Ye=0;for(;Ye<ce;){let ze=re(r,_e);if(_e+=4,lx(a,r[_e])){let xt=r.subarray(_e,_e+ze);Nv(xt,a?2:1,i+G/s,t)}_e+=ze,Ye+=ze+4}}i+=z/s}}))})})}),t}function ox(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function lx(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Nv(i,e,t,r){let s=Uv(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){L.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=Cv(s,u);if(u+=2,h===49){let f=re(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,v=64&p,y=v?2+g*3:0,T=new Uint8Array(y);if(v){T[0]=p;for(let _=1;_<y;_++)T[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:T})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Ai(f),userDataBytes:f})}}}function Uv(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function dx(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;at(i.subarray(d,d+1))!=="\0";)t+=at(i.subarray(d,d+1)),d+=1;for(t+=at(i.subarray(d,d+1)),d+=1;at(i.subarray(d,d+1))!=="\0";)r+=at(i.subarray(d,d+1)),d+=1;r+=at(i.subarray(d,d+1)),d+=1,s=re(i,12),n=re(i,16),o=re(i,20),l=re(i,24),d=28}else if(e===1){d+=4,s=re(i,d),d+=4;let c=re(i,d);d+=4;let h=re(i,d);for(d+=4,a=2**32*c+h,kS(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=re(i,d),d+=4,l=re(i,d),d+=4;at(i.subarray(d,d+1))!=="\0";)t+=at(i.subarray(d,d+1)),d+=1;for(t+=at(i.subarray(d,d+1)),d+=1;at(i.subarray(d,d+1))!=="\0";)r+=at(i.subarray(d,d+1)),d+=1;r+=at(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function ux(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function cx(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),ux([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function hx(i){let e=[];if(i instanceof ArrayBuffer){let t=i.byteLength,r=0;for(;r+32<t;){let s=new DataView(i,r),n=fx(s);e.push(n),r+=n.size}}return e}function fx(i){let e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};let n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};let a=i.buffer,o=bi.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28),d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}var Il={},Pa=class i{static clearKeyUriToKeyIdMap(){Il={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Dt.FAIRPLAY:case Dt.WIDEVINE:case Dt.PLAYREADY:case Dt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=mx(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=$S(this.uri);if(t)switch(this.keyFormat){case Dt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Dt.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=cx(r,null,t),this.keyId=Iv(t);break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Il[this.uri];if(!r){let s=Object.keys(Il).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Il[this.uri]=r}this.keyId=r}return this}};function mx(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Fv=/\{\$([a-zA-Z0-9-_]+)\}/g;function U0(i){return Fv.test(i)}function kt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Gh(i,n))}}function Gh(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Fv,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function F0(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function px(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function gs(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function gx(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var Yl={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function vx(i,e){let t=Yl[e];return!!t&&!!t[i.slice(0,4)]}function Ah(i,e,t=!0){return!i.split(",").some(r=>!Bv(r,e,t))}function Bv(i,e,t=!0){var r;let s=gs(t);return(r=s==null?void 0:s.isTypeSupported(Na(i,e)))!=null?r:!1}function Na(i,e){return`${e}/mp4;codecs="${i}"`}function B0(i){if(i){let e=i.substring(0,4);return Yl.video[e]}return 2}function ql(i){return i.split(",").reduce((e,t)=>{let r=Yl.video[t];return r?(r*2+e)/(e?3:2):(Yl.audio[t]+e)/(e?2:1)},0)}var Sh={};function Ex(i,e=!0){if(Sh[i])return Sh[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(Bv(t[r],"audio",e))return Sh[i]=t[r],t[r];return i}var Tx=/flac|opus/i;function jl(i,e=!0){return i.replace(Tx,t=>Ex(t.toLowerCase(),e))}function $0(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function bx(i){let e=i.split(",");for(let t=0;t<e.length;t++){let r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}var H0=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,G0=/#EXT-X-MEDIA:(.*)/g,yx=/^#EXT(?:INF|-X-TARGETDURATION):/m,K0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),_x=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),hs=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return jf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return yx.test(e)}static parseMasterPlaylist(e,t){let r=U0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];H0.lastIndex=0;let a;for(;(a=H0.exec(e))!=null;)if(a[1]){var o;let d=new qe(a[1]);kt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Gh(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),Ax(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new qe(u);kt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=V0(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new qe(u);kt(s,c,["NAME","VALUE","QUERYPARAM"]),F0(s,c,t)}break}case"CONTENT-STEERING":{let c=new qe(u);kt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=W0(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(G0.lastIndex=0;(s=G0.exec(e))!==null;){let d=new qe(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,kt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,v=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),v&&(y.instreamId=v),c!=null&&c.length){let T=i.findGroup(c,y.groupId)||c[0];Y0(y,T,"audioCodec"),Y0(y,T,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new $h(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new Ca(s,t),g,v,y,T=-1,_=!1,A=null;for(K0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=U0(e);(g=K0.exec(e))!==null;){_&&(_=!1,p=new Ca(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,A&&(p.setByteRange(A),A=null)));let O=g[1];if(O){p.duration=parseFloat(O);let w=(" "+g[2]).slice(1);p.title=w||null,p.tagList.push(w?["INF",O,w]:["INF",O])}else if(g[3]){if(j(p.duration)){p.start=h,y&&z0(p,y,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let w=(" "+g[3]).slice(1);p.relurl=Gh(o,w),q0(p,m),m=p,h+=p.duration,u++,c=0,_=!0}}else if(g[4]){let w=(" "+g[4]).slice(1);m?p.setByteRange(w,m):p.setByteRange(w)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),T===-1&&(T=l.length);else{if(g=g[0].match(_x),!g){L.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<g.length&&typeof g[v]=="undefined";v++);let w=(" "+g[v]).slice(1),C=(" "+g[v+1]).slice(1),P=g[v+2]?(" "+g[v+2]).slice(1):"";switch(w){case"PLAYLIST-TYPE":o.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(C);break;case"SKIP":{let U=new qe(C);kt(o,U,["RECENTLY-REMOVED-DATERANGES"]);let X=U.decimalInteger("SKIPPED-SEGMENTS");if(j(X)){o.skippedSegments=X;for(let q=X;q--;)l.unshift(null);u+=X}let z=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(o.recentlyRemovedDateranges=z.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(C),1);break;case"VERSION":o.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(C||P)&&p.tagList.push(P?[C,P]:[C]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([w]);break;case"BITRATE":p.tagList.push([w,C]);break;case"DATERANGE":{let U=new qe(C);kt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),kt(o,U,U.clientAttrs);let X=new Kl(U,o.dateRanges[U.ID]);X.isValid||o.skippedSegments?o.dateRanges[X.id]=X:L.warn(`Ignoring invalid DATERANGE tag: "${C}"`),p.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":{{let U=new qe(C);kt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?px(o,U,a):F0(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{let U=V0(C,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=it({},y)),y[U.keyFormat]=U}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=W0(C);break;case"MAP":{let U=new qe(C);if(kt(o,U,["BYTERANGE","URI"]),p.duration){let X=new Ca(s,t);j0(X,U,r,y),d=X,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let X=p.byteRangeEndOffset;if(X){let z=p.byteRangeStartOffset;A=`${X-z}@${z}`}else A=null;j0(p,U,r,y),d=p,_=!0}break}case"SERVER-CONTROL":{let U=new qe(C);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let U=new qe(C);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);let X=c>0?U[U.length-1]:void 0,z=c++,q=new qe(C);kt(o,q,["BYTERANGE","URI"]);let ce=new Bh(q,p,t,z,X);U.push(ce),p.duration+=ce.duration;break}case"PRELOAD-HINT":{let U=new qe(C);kt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{let U=new qe(C);kt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:L.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(q0(p,m),p.cc=f,o.fragmentHint=p,y&&z0(p,y,o));let k=l.length,R=l[0],x=l[k-1];if(h+=o.skippedSegments*o.targetduration,h>0&&k&&x){o.averagetargetduration=h/k;let O=x.sn;o.endSN=O!=="initSegment"?O:0,o.live||(x.endList=!0),R&&(o.startCC=R.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,T>0&&Sx(l,T),o}};function V0(i,e,t){var r,s;let n=new qe(i);kt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&L.error(`Invalid IV: ${n.IV}`);let c=o?hs.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Pa(a,c,u,h,l)}function W0(i){let t=new qe(i).decimalFloatingPoint("TIME-OFFSET");return j(t)?t:null}function Ax(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>vx(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function Y0(i,e,t){let r=e[t];r&&(i[t]=r)}function Sx(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function q0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),j(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function j0(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function z0(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var Ae={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},se={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function X0(i){let{type:e}=i;switch(e){case Ae.AUDIO_TRACK:return se.AUDIO;case Ae.SUBTITLE_TRACK:return se.SUBTITLE;default:return se.MAIN}}function xh(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Kh=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ae.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:Ae.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ae.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:Ae.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){L.trace("[playlist-loader]: playlist request ongoing");return}L.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===Ae.MANIFEST?n=r.manifestLoadPolicy.default:n=it({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===Ae.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===Ae.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===Ae.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=it({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),hs.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=xh(e,r),l=hs.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=hs.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(T=>!T.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(L.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new qe({}),bitrate:0,url:""})),n.trigger(E.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:v,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=xh(e,r),c=0,h=j(l)?l:j(o)?o:0,f=X0(r),m=hs.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===Ae.MANIFEST){let p={attrs:new qe({}),bitrate:0,details:m,name:"",url:u};a.trigger(E.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===Ae.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===Ae.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===Ae.AUDIO_TRACK||e.type===Ae.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);L.warn(`[playlist-loader]: ${a}`);let l=M.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case Ae.MANIFEST:l=r?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,d=!0;break;case Ae.LEVEL:l=r?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,d=!1;break;case Ae.AUDIO_TRACK:l=r?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case Ae.SUBTITLE_TRACK:l=r?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:ne.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=pt({url:h,data:void 0},s)}this.hls.trigger(E.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=xh(t,s),m=X0(s),p=typeof s.level=="number"&&m===se.MAIN?d:void 0;if(!e.fragments.length){let v=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(E.ERROR,{type:ne.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case Ae.MANIFEST:case Ae.LEVEL:o.trigger(E.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case Ae.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Ae.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function $v(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Hv(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){L.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function cn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Vh(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=Rx(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function xx(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function Rx(i,e,t){let r=[],s=xx(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Nl(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var di={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Ix=.25;function Wh(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function Q0(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?pt({type:s},r):r))}return n}var Ll=(()=>{let i=Wh();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Rh(i,e){return i.getTime()/1e3-e}function Lx(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Yh=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(cn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return $v(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Wh();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===di.emsg&&!r||!s)continue;let d=wv(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>Ll&&(c=Ll),c-u<=0&&(c=u+Ix);for(let f=0;f<d.length;f++){let m=d[f];if(!kv(m)){this.updateId3CueEnds(u,l);let p=Q0(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Ll&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===di.audioId3&&l:s==="video"?d=u=>u.type===di.emsg&&o:d=u=>u.type===di.audioId3&&l||u.type===di.emsg&&o,Vh(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!j(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Wh();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=Rh(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,v=Ll,y=h.endDate;if(y)v=Rh(y,l),g=!0;else if(h.endOnNext&&!g){let _=a.reduce((A,k)=>{if(k!==h.id){let R=n[k];if(R.class===h.class&&R.startDate>h.startDate&&(!A||h.startDate<A.startDate))return R}return A},null);_&&(v=Rh(_.startDate,l),g=!0)}let T=Object.keys(h.attr);for(let _=0;_<T.length;_++){let A=T[_];if(!PS(A))continue;let k=p[A];if(k)g&&!m.durationKnown&&(k.endTime=v);else if(d){let R=h.attr[A];NS(A)&&(R=Lx(R));let x=Q0(d,f,v,{key:A,data:R},di.dateRange);x&&(x.id=c,this.id3Track.addCue(x),p[A]=x)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},qh=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&L.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},jh=["NONE","TYPE-0","TYPE-1",null];function kx(i){return jh.indexOf(i)>-1}var zl=["SDR","PQ","HLG"];function wx(i){return!!i&&zl.indexOf(i)>-1}var Ul={No:"",Yes:"YES",v2:"v2"};function Z0(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Ul.v2:Ul.Yes:Ul.No}var Xl=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},_r=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return J0(this._audioGroups,e)}hasSubtitleGroup(e){return J0(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function J0(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function Ih(i,e){let t=e.startPTS;if(j(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Gv(i,e,t,r,s,n){r-t<=0&&(L.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(j(d)){let g=Math.abs(d-t);j(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)Ih(p[f],p[f-1]);for(f=m;f<p.length-1;f++)Ih(p[f],p[f+1]);return i.fragmentHint&&Ih(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function Dx(i,e){let t=null,r=i.fragments;for(let o=r.length-1;o>=0;o--){let l=r[o].initSegment;if(l){t=l;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s;Ox(i,e,(o,l,d,u)=>{if(e.skippedSegments&&l.cc!==o.cc){let c=o.cc-l.cc;for(let h=d;h<u.length;h++)u[h].cc+=c}j(o.startPTS)&&j(o.endPTS)&&(l.start=l.startPTS=o.startPTS,l.startDTS=o.startDTS,l.maxStartPTS=o.maxStartPTS,l.endPTS=o.endPTS,l.endDTS=o.endDTS,l.minEndPTS=o.minEndPTS,l.duration=o.endPTS-o.startPTS,l.duration&&(s=l),e.PTSKnown=e.alignedSliding=!0),l.elementaryStreams=o.elementaryStreams,l.loader=o.loader,l.stats=o.stats,o.initSegment&&(l.initSegment=o.initSegment,t=o.initSegment)});let n=e.fragments;if(t&&(e.fragmentHint?n.concat(e.fragmentHint):n).forEach(l=>{var d;l&&(!l.initSegment||l.initSegment.relurl===((d=t)==null?void 0:d.relurl))&&(l.initSegment=t)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(o=>!o),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let o=e.skippedSegments;o--;)n.shift();e.startSN=n[0].sn}else e.canSkipDateRanges&&(e.dateRanges=Cx(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));e.startCC=e.fragments[0].cc,e.endCC=n[n.length-1].cc}Mx(i.partList,e.partList,(o,l)=>{l.elementaryStreams=o.elementaryStreams,l.stats=o.stats}),s?Gv(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Kv(i,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let a=e.advancedDateTime;if(e.advanced&&a){let o=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=o),e.driftEndTime=a,e.driftEnd=o}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function Cx(i,e,t){let r=it({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Kl(e[s].attr,r[s]);n.isValid?r[s]=n:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function Mx(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function Ox(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c,d,o)}}function Kv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||zh(e,r[t].start)}function zh(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function Px(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments;if(r.length&&t*4>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function Nx(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function ev(i,e,t){var r;return i!=null&&i.details?Vv((r=i.details)==null?void 0:r.partList,e,t):null}function Vv(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Wv(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Ql(i){switch(i.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tv(i,e){let t=Ql(e);return i.default[`${t?"timeout":"error"}Retry`]}function Zf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function iv(i){return pt(pt({},i),{errorRetry:null,timeoutRetry:null})}function Zl(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(Ux(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function Ux(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Yv={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function Fx(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!j(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if($x(e,t,a))return a}return null}function Jl(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;let o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&Xh(t,r,n)===0||Bx(n,i,Math.min(s,r))))return n;let a=Yv.search(e,Xh.bind(null,t,r));return a&&(a!==i||!n)?a:n}function Bx(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){let r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function Xh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function $x(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function Hx(i,e){return Yv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ft={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},ai={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Qh=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===se.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case M.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ft.DoNothing,flags:ai.None};return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ft.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===se.MAIN?t.level:n.loadLevel;t.details===M.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===Ae.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===Ae.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ft.SendAlternateToPenaltyBox,t.errorAction.flags=ai.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ft.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ft.DoNothing,flags:ai.None};return}t.type===ne.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=tv(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Zl(s,n,Ql(e),e.response))return{action:ft.RetryRequest,flags:ai.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=tv(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==M.FRAG_GAP&&s.fragmentError++,Zl(o,l,Ql(e),e.response)))return{action:ft.RetryRequest,flags:ai.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===M.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,v=(p===se.AUDIO&&d===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:k})=>s.audioCodec!==k),T=e.sourceBufferName==="video"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR)&&c.some(({codecSet:k,audioCodec:R})=>s.codecSet!==k&&s.audioCodec===R),{type:_,groupId:A}=(a=e.context)!=null?a:{};for(let k=c.length;k--;){let R=(k+h)%c.length;if(R!==h&&R>=f&&R<=m&&c[R].loadError===0){var o,l;let x=c[R];if(d===M.FRAG_GAP&&p===se.MAIN&&e.frag){let O=c[R].details;if(O){let w=Jl(e.frag,O.fragments,e.frag.start);if(w!=null&&w.gap)continue}}else{if(_===Ae.AUDIO_TRACK&&x.hasAudioGroup(A)||_===Ae.SUBTITLE_TRACK&&x.hasSubtitleGroup(A))continue;if(p===se.AUDIO&&(o=s.audioGroups)!=null&&o.some(O=>x.hasAudioGroup(O))||p===se.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(O=>x.hasSubtitleGroup(O))||v&&s.audioCodec===x.audioCodec||!v&&s.audioCodec!==x.audioCodec||T&&s.codecSet===x.codecSet)continue}u=R;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ft.SendAlternateToPenaltyBox,flags:ai.None,nextAutoLevel:u}}return{action:ft.SendAlternateToPenaltyBox,flags:ai.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ft.DoNothing:break;case ft.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==M.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case ft.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case ai.None:this.switchLevel(e,a);break;case ai.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=jh[jh.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},Ua=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=L.log.bind(L,`${t}:`),this.warn=L.warn.bind(L,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){L.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&Z0(r);return new Xl(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&Dx(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,v=s.lastPartSn,y=s.endSN,T=s.lastPartIndex,_=T!==-1,A=v===y,k=g?0:T;_?(d=A?y+1:v,u=A?k:T+1):d=y+1;let R=s.age,x=R+s.ageHeader,O=Math.min(x-s.partTarget,s.targetduration*1.5);if(O>0){if(r&&O>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{let w=Math.floor(O/s.targetduration);if(d+=w,u!==void 0){let C=Math.round(O%s.targetduration/s.partTarget);u+=C}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${R.toFixed(2)}s goal: ${O} skip sn ${w} to part ${u}`)}s.tuneInGoal=O}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!A){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=Px(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=Z0(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Ul.No),new Xl(r,s,n)}checkRetry(e){let t=e.details,r=Ql(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ft.RetryRequest||!s.resolved&&n===ft.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Zf(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},yr=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Zh=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new yr(e),this.fast_=new yr(t),this.defaultTTFB_=s,this.ttfb_=new yr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new yr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new yr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new yr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},qv={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},rv={};function Gx(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&j(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function Kx(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(qv);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:pt(pt({},n),{},{contentType:Na(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);j(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:Na(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=Vx(l);return rv[d]||(rv[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function Vx(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function Wx(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function Yx(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||zl.slice(0),t=e.preferHDR!==void 0?e.preferHDR:Wx(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function qx(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:v}=Yx(e,s);for(let A=n.length;A--;){let k=i[n[A]];d=k.channels[2]>0,c=Math.min(c,k.minHeight),h=Math.min(h,k.minFramerate),f=Math.min(f,k.minBitrate);let R=v.filter(x=>k.videoRanges[x]>0);R.length>0&&(u=!0,p=R)}c=j(c)?c:0,h=j(h)?h:0;let y=Math.max(1080,c),T=Math.max(30,h);return f=j(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((A,k)=>{let R=i[k];if(k===A)return A;if(R.minBitrate>t)return Xi(k,`min bitrate of ${R.minBitrate} > current estimate of ${t}`),A;if(!R.hasDefaultAudio)return Xi(k,"no renditions with default or auto-select sound found"),A;if(o&&k.indexOf(o.substring(0,4))%5!==0)return Xi(k,`audio codec preference "${o}" not found`),A;if(a&&!l){if(!R.channels[a])return Xi(k,`no renditions with ${a} channel sound found (channels options: ${Object.keys(R.channels)})`),A}else if((!o||l)&&d&&R.channels[2]===0)return Xi(k,"no renditions with stereo sound found"),A;return R.minHeight>y?(Xi(k,`min resolution of ${R.minHeight} > maximum of ${y}`),A):R.minFramerate>T?(Xi(k,`min framerate of ${R.minFramerate} > maximum of ${T}`),A):p.some(x=>R.videoRanges[x]>0)?R.maxScore<m?(Xi(k,`max score of ${R.maxScore} < selected max of ${m}`),A):A&&(ql(k)>=ql(A)||R.fragmentError>i[A].fragmentError)?A:(m=R.maxScore,k):(Xi(k,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),A)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Xi(i,e){L.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function jx(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function zx(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function _i(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(ps(i,s,t))return r}return-1}function ps(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,default:o}=i,l=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in i)||Xx(i.characteristics||"",e.characteristics))&&(t===void 0||t(i,e))}function Xx(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function cs(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function Qx(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=sv(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return _i(i,m,s)>-1});return c>-1?c:sv(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return _i(i,m,s)>-1})}function sv(i,e,t){for(let r=e;r>-1;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var Jh=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&g>-1,y=this.getBwEstimate(),T=s.levels,_=T[t.level],A=l.total||Math.max(l.loaded,Math.round(d*_.averageBitrate/8)),k=v?u-g:u;k<1&&v&&(k=Math.min(u,l.loaded*8/y));let R=v?l.loaded*1e3/k:0,x=R?(A-l.loaded)/R:A*8/y+f/1e3;if(x<=p)return;let O=R?R*8:y,w=Number.POSITIVE_INFINITY,C;for(C=t.level-1;C>c;C--){let U=T[C].maxBitrate;if(w=this.getTimeToLoadFrag(f/1e3,O,d*U,!T[C].details),w<p)break}if(w>=x||w>d*10)return;s.nextLoadLevel=s.nextAutoLevel=C,v?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let P=T[C].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>P&&this.resetEstimator(P),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
|
|
17
17
|
Time to underbuffer: ${p.toFixed(3)} s
|
|
18
18
|
Estimated load time for current fragment: ${x.toFixed(3)} s
|
|
19
19
|
Estimated load time for down switch fragment: ${w.toFixed(3)} s
|
|
20
20
|
TTFB estimate: ${g|0} ms
|
|
21
21
|
Current BW estimate: ${j(y)?y|0:"Unknown"} bps
|
|
22
22
|
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
23
|
-
Switching to level ${C} @ ${P|0} bps`),s.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new Zh(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{let r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){let a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;j(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===se.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(E.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==se.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){let g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,L.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}let f=this.findBestLevel(l,a,s,d,h,u,c);if(L.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;let d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:v}=this.hls;if(m.length===1)return 0;let y=m[c],T=!!(y!=null&&(l=y.details)!=null&&l.live),_=g===-1||u===-1,A,k="SDR",R=(y==null?void 0:y.frameRate)||0,{audioPreference:x,videoPreference:O}=v,w=this.audioTracksByGroup||(this.audioTracksByGroup=jx(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=zx(m,w,t,r)),q=qx(z,k,e,x,O),{codecSet:ce,videoRanges:fe,minFramerate:W,minBitrate:G,preferHDR:pe}=q;A=ce,k=pe?fe[fe.length-1]:fe[0],R=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(q)}`)}else A=y==null?void 0:y.codecSet,k=y==null?void 0:y.videoRange;let C=f?f.duration:h?h.duration:0,P=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let z=r;z>=t;z--){var X;let q=m[z],ce=z>c;if(!q)continue;if(v.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){let Ke=navigator.mediaCapabilities;typeof(Ke==null?void 0:Ke.decodingInfo)=="function"&&Gx(q,w,k,R,e,x)?(q.supportedPromise=Kx(q,w,Ke),q.supportedPromise.then(Ye=>{if(!this.hls)return;q.supportedResult=Ye;let ze=this.hls.levels,xt=ze.indexOf(q);Ye.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${Ye.error}" for level ${xt} ${JSON.stringify(Ye)}`):Ye.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${xt} ${JSON.stringify(Ye)}`),xt>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${xt}`),this.hls.removeLevel(xt)))})):q.supportedResult=qv}if(A&&q.codecSet!==A||k&&q.videoRange!==k||ce&&R>q.frameRate||!ce&&R>0&&R<q.frameRate||q.supportedResult&&!((X=q.supportedResult.decodingInfoResults)!=null&&X[0].smooth)){U.push(z);continue}let fe=q.details,W=(f?fe==null?void 0:fe.partTarget:fe==null?void 0:fe.averagetargetduration)||C,G;ce?G=o*e:G=a*e;let pe=C&&s>=C*2&&n===0?m[z].averageBitrate:m[z].maxBitrate,te=this.getTimeToLoadFrag(P,G,pe*W,fe===void 0);if(G>=pe&&(z===u||q.loadError===0&&q.fragmentError===0)&&(te<=P||!j(te)||T&&!this.bitrateTestDelay||te<d)){let Ke=this.forcedAutoLevel;return z!==g&&(Ke===-1||Ke!==g)&&(U.length&&L.trace(`[abr] Skipped level(s) ${U.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${k}`),L.info(`[abr] switch candidate:${c}->${z} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-pe)} ttfb:${P.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${te.toFixed(1)} firstSelection:${_} codecSet:${A} videoRange:${k} hls.loadLevel:${g}`)),_&&(this.firstSelection=z),z}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},ef=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},mt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},tf=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=ln(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Ll(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=ln(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&Ll(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Ll(t))}getState(e){let t=ln(e),r=this.fragments[t];return r?r.buffered?Ll(r)?mt.PARTIAL:mt.OK:mt.APPENDING:mt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=ln(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=ln(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=ln(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Ll(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function ln(i){return`${i.type}_${i.level}_${i.sn}`}var Zx={length:0,start:()=>0,end:()=>0},Ve=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),Zx}}},Fa=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=kl(),this.buffering={audio:kl(),video:kl(),audiovideo:kl()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function kl(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Ul(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function Jx(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function eR(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){L.log("No fragments to align");return}let s=Ul(t,r[0].cc);if(!s||s&&!s.startPTS){L.log("No frag in previous level to align on");return}return s}function nv(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function jv(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)nv(t[r],i);e.fragmentHint&&nv(e.fragmentHint,i),e.alignedSliding=!0}function tR(i,e,t){e&&(iR(i,t,e),!t.alignedSliding&&e&&Jl(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Kv(e,t))}function iR(i,e,t){if(Jx(i,t,e)){let r=eR(t,e);r&&j(r.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),jv(r.start,e))}}function Jl(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Ul(r,a),n=Ul(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Ul(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);jv(d,i)}var av=Math.pow(2,17),rf=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(lv(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=ov(e),c=iv(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:av};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let v=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:pt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(lv(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=ov(e,t),c=iv(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:av};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let v={frag:e,part:t,payload:f.data,networkDetails:g};r(v),o(v)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:pt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function ov(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(j(s)&&j(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function lv(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ne.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new li(r)}var li=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},sf=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},nf=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function rR(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ms(i,0,e-t):i}var af=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;let y=f[m],T=f[y],_=f[T],A=f[v]*257^v*16843008;s[m]=A<<24|A>>>8,n[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,o[m]=A,A=_*16843009^T*65537^y*257^m*16843008,d[v]=A<<24|A>>>8,u[v]=A<<16|A>>>16,c[v]=A<<8|A>>>24,h[v]=A,m?(m=y^f[f[f[_^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],v=f[3],y,T;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}T=y,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=h[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),d[o]=y=(d[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=d[o]:T=d[o-4],l<4||o<=4?u[l]=T:u[l]=m[c[T>>>24]]^p[c[T>>>16&255]]^g[c[T>>>8&255]]^v[c[T&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],v=new Int32Array(e),y=new Int32Array(v.length),T,_,A,k,R,x,O,w,C,P,U,X,z,q,ce=this.networkToHostOrderSwap;for(;t<v.length;){for(C=ce(v[t]),P=ce(v[t+1]),U=ce(v[t+2]),X=ce(v[t+3]),R=C^n[0],x=X^n[1],O=U^n[2],w=P^n[3],z=4,q=1;q<s;q++)T=l[R>>>24]^d[x>>16&255]^u[O>>8&255]^c[w&255]^n[z],_=l[x>>>24]^d[O>>16&255]^u[w>>8&255]^c[R&255]^n[z+1],A=l[O>>>24]^d[w>>16&255]^u[R>>8&255]^c[x&255]^n[z+2],k=l[w>>>24]^d[R>>16&255]^u[x>>8&255]^c[O&255]^n[z+3],R=T,x=_,O=A,w=k,z=z+4;T=a[R>>>24]<<24^a[x>>16&255]<<16^a[O>>8&255]<<8^a[w&255]^n[z],_=a[x>>>24]<<24^a[O>>16&255]<<16^a[w>>8&255]<<8^a[R&255]^n[z+1],A=a[O>>>24]<<24^a[w>>16&255]<<16^a[R>>8&255]<<8^a[x&255]^n[z+2],k=a[w>>>24]<<24^a[R>>16&255]<<16^a[x>>8&255]<<8^a[O&255]^n[z+3],y[t]=ce(T^f),y[t+1]=ce(k^m),y[t+2]=ce(A^p),y[t+3]=ce(_^g),f=C,m=P,p=U,g=X,t=t+4}return y.buffer}},sR=16,Ba=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?rR(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=qt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new af),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=ms(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new nf(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new sf(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%sR;return r!==e.length&&(t=ms(e,0,r),this.remainderData=ms(e,r)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},nR={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},$a=class extends ef{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=L.log.bind(L,`${s}:`),this.warn=L.warn.bind(L,`${s}:`),this.hls=e,this.fragmentLoader=new rf(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ba(e.config),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ve.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ve.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${j(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===mt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===mt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(E.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(E.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===se.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?nR.toString(Ve.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==se.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==se.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Fa(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(E.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),j(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(E.FRAG_LOADED,h);let m=ev(r,e.sn,c.index+1)||Vv(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?ev(o,n,a):null,d=l?l.fragment:Nx(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=qt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(E.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ve.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ve.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return j(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ve.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ve.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=se.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,se.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===mt.OK||r===mt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=Fx(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Hx(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Zl(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===mt.OK||m===mt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==mt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&j(n);if(a||!o&&!n){let{fragPrevious:l}=this;tR(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&j(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===M.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ft.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=Zf(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ft.RemoveAlternatePermanently&&(a.resolved=!0);else{L.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ft.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){let t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===se.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ve.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:Gv(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},ed=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=aR(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function aR(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function oR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function lR(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function dR(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function yi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Ha=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=qt(this.cachedData,e),this.cachedData=null);let r=Oa(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Qf(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&j(l))&&(this.basePTS=uR(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:di.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else KS(e,s)?(r=Oa(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:di.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=ms(e,n);this.cachedData?this.cachedData=qt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:yi(),id3Track:o,textTrack:yi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:yi(),id3Track:this._id3Track,textTrack:yi()}}destroy(){}},uR=(i,e,t)=>{if(j(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function cR(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,L.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function zv(i,e){return i[e]===255&&(i[e+1]&246)===240}function Xv(i,e){return i[e+1]&1?7:9}function Jf(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function hR(i,e){return e+5<i.length}function td(i,e){return e+1<i.length&&zv(i,e)}function fR(i,e){return hR(i,e)&&zv(i,e)&&Jf(i,e)<=i.length-e}function mR(i,e){if(td(i,e)){let t=Xv(i,e);if(e+t>=i.length)return!1;let r=Jf(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||td(i,s)}return!1}function Qv(i,e,t,r,s){if(!i.samplerate){let n=cR(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,L.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Zv(i){return 1024*9e4/i}function pR(i,e){let t=Xv(i,e);if(e+t<=i.length){let r=Jf(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Jv(i,e,t,r,s){let n=Zv(i.samplerate),a=r+s*n,o=pR(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var wl=null,gR=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],vR=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ER=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],TR=[0,1,1,4];function eE(i,e,t,r,s){if(t+24>e.length)return;let n=tE(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function tE(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=gR[l*14+s-1]*1e3,c=vR[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=ER[t][r],m=TR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(wl===null){let T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);wl=T?parseInt(T[1]):0}return!!wl&&wl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function em(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function iE(i,e){return e+1<i.length&&em(i,e)}function bR(i,e){return em(i,e)&&4<=i.length-e}function rE(i,e){if(e+1<i.length&&em(i,e)){let r=tE(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||iE(i,n)}return!1}var of=class extends Ha{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Oa(e,0),r=(t==null?void 0:t.length)||0;if(rE(e,r))return!1;for(let s=e.length;r<s;r++)if(mR(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return fR(e,t)}appendFrame(e,t,r){Qv(e,this.observer,t,r,e.manifestCodec);let s=Jv(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},yR=/\/emsg[-/]ID3/i,lf=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=yi("video",1),a=this.audioTrack=yi("audio",1),o=this.txtTrack=yi("text",1);if(this.id3Track=yi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Ov(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=Dv.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return ZS(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=qt(this.remainderData,e));let o=ax(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=N0(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=N0(e,t),{videoTrack:t,audioTrack:yi(),id3Track:s,textTrack:yi()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=he(e.samples,["emsg"]);s&&s.forEach(n=>{let a=dx(n);if(yR.test(a.schemeIdUri)){let o=j(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:di.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},sE=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},df=class extends Ha{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=nE(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=Oa(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&Qf(t)!==void 0&&sE(e,r)<16}};function nE(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,v=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|v>>2,(v&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),T=1536/o*9e4,_=r+s*T,A=e.subarray(t,t+u);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:_}),u}var uf=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&L.log(e.pts+"/"+e.dts+":"+e.debug)}},id=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let k=u();if(k===3&&h(1),m(),m(),h(1),c())for(a=k!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let v=u();if(v===0)u();else if(v===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let y=u(),T=u(),_=d(1);_===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let A=[1,1];if(c()&&c())switch(l()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-_)*(T+1)*16-(_?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},cf=class extends uf{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let v=new id(g).readSliceType();(v===2||v===4||v===7||v===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,Nv(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,v=new id(p).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[p],e.duration=n;let y=p.subarray(1,4),T="avc1.";for(let _=0;_<3;_++){let A=y[_].toString(16);A.length<2&&(A="0"+A),T+=A}e.codec=T}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=qt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=qt(f.data,t))}return e.naluState=s,a}},hf=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ba(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Uv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ht=188,ff=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new cf}static probe(e){let t=i.syncOffset(e);return t>0&&L.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ht*5,t-ht)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ht)if(e[l]===71&&(t-l===ht||e[l+ht]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ht*99,e.length-ht)+1)),n||(n=mf(e,l)===0),n&&o>1&&(a===0&&o>2||l+ht>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Dv[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,T=e.length;if(this.remainderData&&(e=qt(this.remainderData,e),T=e.length,this.remainderData=null),T<ht&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));T-=(T-_)%ht,T<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let A=0;for(let R=_;R<T;R+=ht)if(e[R]===71){let x=!!(e[R+1]&64),O=mf(e,R),w=(e[R+3]&48)>>4,C;if(w>1){if(C=R+5+e[R+4],C===R+ht)continue}else C=R+4;switch(O){case u:x&&(c&&(n=dn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,R+ht)),c.size+=R+ht-C);break;case h:if(x){if(m&&(n=dn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,R+ht)),m.size+=R+ht-C);break;case f:x&&(p&&(n=dn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,R+ht)),p.size+=R+ht-C);break;case 0:x&&(C+=e[C]+1),y=this._pmtId=_R(e,C);break;case y:{x&&(C+=e[C]+1);let P=AR(e,C,this.typeSupported,r,this.observer);u=P.videoPid,u>0&&(a.pid=u,a.segmentCodec=P.segmentVideoCodec),h=P.audioPid,h>0&&(o.pid=h,o.segmentCodec=P.segmentAudioCodec),f=P.id3Pid,f>0&&(l.pid=f),g!==null&&!v&&(L.warn(`MPEG-TS PMT found at ${R} after unknown PID '${g}'. Backtracking to sync byte @${_} to parse all TS packets.`),g=null,R=_-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else A++;A>0&&rd(this.observer,new Error(`Found ${A} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;let k={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(k),k}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=dn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=dn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=dn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new hf(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=qt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!td(n,a);a++);if(a!==r){let c,h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",rd(this.observer,new Error(c),h),!h)return}Qv(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Zv(e.samplerate);l=s.sample.pts+c}else{L.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Jv(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!td(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){L.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(iE(r,a)){let l=eE(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){L.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=nE(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){L.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=it({},t,{type:this._videoTrack?di.emsg:di.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function mf(i,e){return((i[e+1]&31)<<8)+i[e+2]}function _R(i,e){return(i[e+10]&31)<<8|i[e+11]}function AR(i,e,t,r,s){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){let d=mf(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){Lh("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){Lh("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?L.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){Lh("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?L.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return rd(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return rd(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function rd(i,e,t){L.warn(`parsing error: ${e.message}`),i.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Lh(i){L.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function dn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=qt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(L.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var pf=class extends Ha{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Oa(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Qf(t)!==void 0&&sE(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(rE(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return bR(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return eE(e,t,r,this.basePTS,this.frameIndex)}},sd=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},br=Math.pow(2,32)-1,ot=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(br+1)),s=Math.floor(t%(br+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(br+1)),s=Math.floor(t%(br+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(br+1)),o=Math.floor(r%(br+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(br+1)),a=Math.floor(t%(br+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e);return qt(i.FTYP,t)}};ot.types=void 0;ot.HDLR_TYPES=void 0;ot.STTS=void 0;ot.STSC=void 0;ot.STCO=void 0;ot.STSZ=void 0;ot.VMHD=void 0;ot.SMHD=void 0;ot.STSD=void 0;ot.FTYP=void 0;ot.DINF=void 0;var aE=9e4;function tm(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function SR(i,e,t=1,r=!1){return tm(i,e,1/t,r)}function wa(i,e=!1){return tm(i,1e3,1/aE,e)}function xR(i,e=1){return tm(i,aE,1/e)}var RR=10*1e3,dv=1024,IR=1152,LR=1536,un=null,kh=null,fn=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,un===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);un=a?parseInt(a[1]):0}if(kh===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);kh=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e[0].pts,s=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Yt(o,r),l=o-n),l>0?n:o},r);return t&&L.debug("PTS rollover detected"),s}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n,v=e.pid>-1,y=t.pid>-1,T=t.samples.length,_=e.samples.length>0,A=o&&T>0||T>1;if((!v||_)&&(!y||A)||this.ISGenerated||o){if(this.ISGenerated){var R,x,O,w;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((R=t.pixelRatio)==null?void 0:R[0])!==((x=X.pixelRatio)==null?void 0:x[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((w=X.pixelRatio)==null?void 0:w[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let C=this.isVideoContiguous,P=-1,U;if(A&&(P=kR(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,P>0){L.warn(`[mp4-remuxer]: Dropped ${P} out of ${T} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(P),t.dropped+=P,g+=(t.samples[0].pts-X)/t.inputTimeScale,U=g}else P===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),m=!1);if(this.ISGenerated){if(_&&A){let X=this.getVideoStartPts(t.samples),q=(Yt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,q),g+=Math.max(0,-q)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,y||A||l===se.AUDIO?g:void 0),A){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,C,X)}}else A&&(d=this.remuxVideo(t,g,C,0));d&&(d.firstKeyFrame=P,d.independent=P!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=oE(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=lE(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):ot.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ot.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){let p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Yt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||u===null){let W=t*n,G=a[0].pts-Yt(a[0].dts,a[0].pts);un&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let y=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Yt(G.pts-y,u),G.dts=Yt(G.dts-y,u),G.dts<a[W>0?W-1:W].dts&&(v=!0)}v&&a.sort(function(W,G){let pe=W.dts-G.dts,te=W.pts-G.pts;return pe||te}),f=a[0].dts,m=a[a.length-1].dts;let T=m-f,_=T?Math.round(T/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>_,pe=W<-1;if((G||pe)&&(G?L.warn(`AVC: ${wa(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${wa(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!pe||u>=a[0].pts||un)){f=u;let te=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=te;else for(let _e=0;_e<a.length&&!(a[_e].dts>te);_e++)a[_e].dts-=W,a[_e].pts-=W;L.log(`Video: Initial PTS/DTS adjusted: ${wa(te,!0)}/${wa(f,!0)}, delta: ${wa(W,!0)} ms`)}}f=Math.max(0,f);let A=0,k=0,R=f;for(let W=0;W<l;W++){let G=a[W],pe=G.units,te=pe.length,_e=0;for(let Ke=0;Ke<te;Ke++)_e+=pe[Ke].data.length;k+=_e,A+=te,G.length=_e,G.dts<R?(G.dts=R,R+=_/4|0||1):R=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let x=k+4*A+8,O;try{O=new Uint8Array(x)}catch(W){this.observer.emit(E.ERROR,E.ERROR,{type:ne.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:x,reason:`fail allocating video mdat ${x}`});return}let w=new DataView(O.buffer);w.setUint32(0,x),O.set(ot.types.mdat,4);let C=!1,P=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],pe=G.units,te=0;for(let Ye=0,ze=pe.length;Ye<ze;Ye++){let xt=pe[Ye],Er=xt.data,rn=xt.data.byteLength;w.setUint32(c,rn),c+=4,O.set(Er,c),c+=rn,te+=4+rn}let _e;if(W<l-1)h=a[W+1].dts-G.dts,_e=a[W+1].pts-G.pts;else{let Ye=this.config,ze=W>0?G.dts-a[W-1].dts:_;if(_e=W>0?G.pts-a[W-1].pts:_,Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){let xt=Math.floor(Ye.maxBufferHole*n),Er=(s?p+s*n:this.nextAudioPts)-G.pts;Er>xt?(h=Er-ze,h<0?h=ze:C=!0,L.log(`[mp4-remuxer]: It is approximately ${Er/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=ze}else h=ze}let Ke=Math.round(G.pts-G.dts);P=Math.min(P,h),X=Math.max(X,h),U=Math.min(U,_e),z=Math.max(z,_e),o.push(new nd(G.key,h,te,Ke))}if(o.length){if(un){if(un<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(kh&&z-U<X-P&&_/X<.025&&o[0].cts===0){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,pe=o.length;G<pe;G++){let te=W+o[G].duration,_e=W+o[G].cts;if(G<pe-1){let Ke=te+o[G+1].cts;o[G].duration=Ke-_e}else o[G].duration=G?o[G-1].duration:_;o[G].cts=0,W=te}}}h=C||!h?_:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let fe={data1:ot.moof(e.sequenceNumber++,f,it({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,fe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return IR;case"ac3":return LR;default:return dv}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,v=this.nextAudioPts||-1,y=t*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&v>0&&(s&&Math.abs(y-v)<9e3||Math.abs(Yt(p[0].pts-T,y)-v)<20*u),p.forEach(function(q){q.pts=Yt(q.pts-T,y)}),!r||v<0){if(p=p.filter(q=>q.pts>=0),!p.length)return;n===0?v=0:s&&!m?v=Math.max(0,y):v=p[0].pts}if(e.segmentCodec==="aac"){let q=this.config.maxAudioFramesDrift;for(let ce=0,fe=v;ce<p.length;ce++){let W=p[ce],G=W.pts,pe=G-fe,te=Math.abs(1e3*pe/a);if(pe<=-q*u&&m)ce===0&&(L.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*pe/a)} ms.`),this.nextAudioPts=v=fe=G);else if(pe>=q*u&&te<RR&&m){let _e=Math.round(pe/u);fe=G-_e*u,fe<0&&(_e--,fe+=u),ce===0&&(this.nextAudioPts=v=fe),L.warn(`[mp4-remuxer]: Injecting ${_e} audio frame @ ${(fe/a).toFixed(3)}s due to ${Math.round(1e3*pe/a)} ms gap.`);for(let Ke=0;Ke<_e;Ke++){let Ye=Math.max(fe,0),ze=sd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ze||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ze=W.unit.subarray()),p.splice(ce,0,{unit:ze,pts:Ye}),fe+=u,ce++}}W.pts=fe,fe+=u}}let _=null,A=null,k,R=0,x=p.length;for(;x--;)R+=p[x].unit.byteLength;for(let q=0,ce=p.length;q<ce;q++){let fe=p[q],W=fe.unit,G=fe.pts;if(A!==null){let te=f[q-1];te.duration=Math.round((G-A)/l)}else if(r&&e.segmentCodec==="aac"&&(G=v),_=G,R>0){R+=g;try{k=new Uint8Array(R)}catch(te){this.observer.emit(E.ERROR,E.ERROR,{type:ne.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:te,bytes:R,reason:`fail allocating audio mdat ${R}`});return}h||(new DataView(k.buffer).setUint32(0,R),k.set(ot.types.mdat,4))}else return;k.set(W,g);let pe=W.byteLength;g+=pe,f.push(new nd(!0,d,pe,0)),A=G}let O=f.length;if(!O)return;let w=f[f.length-1];this.nextAudioPts=v=A+l*w.duration;let C=h?new Uint8Array(0):ot.moof(e.sequenceNumber++,_/l,it({},e,{samples:f}));e.samples=[];let P=_/a,U=v/a,z={data1:C,data2:k,startPTS:P,endPTS:U,startDTS:P,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,z}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*dv,m=Math.ceil((h-c)/f),p=sd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!p){L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let v=0;v<m;v++){let y=c+v*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Yt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function kR(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function oE(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Yt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Yt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function lE(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Yt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var nd=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},gf=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(tx(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Ov(e);s.audio&&(t=uv(s.audio,we.AUDIO)),s.video&&(r=uv(s.video,we.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};j(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=rx(h,m),g=ix(m,h),v=g===null?n:g;(wR(d,v,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=v-n,d&&d.timescale===1&&L.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let y=e?v-d.baseTime/d.timescale:u,T=y+p;nx(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=T:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let _=!!m.audio,A=!!m.video,k="";_&&(k+="audio"),A&&(k+="video");let R={data1:h,startPTS:y,startDTS:y,endPTS:T,endDTS:T,type:k,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=R.type==="audio"?R:void 0,c.video=R.type!=="audio"?R:void 0,c.initSegment=f,c.id3=oE(r,n,d,d),s.samples.length&&(c.text=lE(s,n,d)),c}};function wR(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function uv(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===we.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return ql(t,!1);let r="mp4a.40.5";return L.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return L.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Zi;try{Zi=self.performance.now.bind(self.performance)}catch{L.debug("Unable to use Performance API on this environment"),Zi=pn==null?void 0:pn.Date.now}var Fl=[{demux:lf,remux:gf},{demux:ff,remux:fn},{demux:of,remux:fn},{demux:pf,remux:fn}];Fl.splice(2,0,{demux:df,remux:fn});var ad=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=Zi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:v,duration:y,initSegmentData:T}=l,_=DR(a,t);if(_&&_.method==="AES-128"){let x=this.getDecrypter();if(x.isSync()){let O=x.softwareDecrypt(a,_.key.buffer,_.iv.buffer);if(r.part>-1&&(O=x.flush()),!O)return n.executeEnd=Zi(),wh(r);a=new Uint8Array(O)}else return this.decryptionPromise=x.webCryptoDecrypt(a,_.key.buffer,_.iv.buffer).then(O=>{let w=this.push(O,null,r);return this.decryptionPromise=null,w}),this.decryptionPromise}let A=this.needsProbing(u,c);if(A){let x=this.configureTransmuxer(a);if(x)return L.warn(`[transmuxer] ${x.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message}),n.executeEnd=Zi(),wh(r)}(u||c||m||A)&&this.resetInitSegment(T,p,g,y,t),(u||m||A)&&this.resetInitialTimestamp(v),d||this.resetContiguity();let k=this.transmux(a,_,f,h,r),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,n.executeEnd=Zi(),k}flush(e){let t=e.transmuxing;t.executeStart=Zi();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Zi(),[wh(e)];let u=l.flush(o);return Bl(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=Zi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=Fl.length;h<f;h++){var o;if((o=Fl[h].demux)!=null&&o.probe(e)){a=Fl[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ba(this.config)),e}};function DR(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var wh=i=>({remuxResult:{},chunkMeta:i});function Bl(i){return"then"in i&&i.then instanceof Function}var vf=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},Ef=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},dE={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,y,T;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(T=1,y=new Array(v-1);T<v;T++)y[T-1]=arguments[T];g.fn.apply(g.context,y)}else{var _=g.length,A;for(T=0;T<_;T++)switch(g[T].once&&this.removeListener(d,g[T].fn,void 0,!0),v){case 1:g[T].fn.call(g[T].context);break;case 2:g[T].fn.call(g[T].context,u);break;case 3:g[T].fn.call(g[T].context,u,c);break;case 4:g[T].fn.call(g[T].context,u,c,h);break;default:if(!y)for(A=1,y=new Array(v-1);A<v;A++)y[A-1]=arguments[A];g[T].fn.apply(g[T].context,y)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],v=m.length;p<v;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(dE);var CR=dE.exports,im=xS(CR),od=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===E.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new im,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);let o=gs(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||oR())){try{n.workerPath?(L.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=dR(n.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=lR()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new ad(this.observer,l,n,"",t)}return}this.transmuxer=new ad(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),T=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=T===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),k=!y&&(T===1||T===0&&(_===1||A&&_<=0)),R=self.performance.now();(y||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=R),a&&(_||!k)&&(a.stats.parsing.start=R);let x=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),O=new Ef(v,k,l,y,m,x);if(!k||v||x){L.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
23
|
+
Switching to level ${C} @ ${P|0} bps`),s.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new Zh(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{let r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){let a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;j(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===se.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(E.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==se.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){let g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,L.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}let f=this.findBestLevel(l,a,s,d,h,u,c);if(L.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;let d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:v}=this.hls;if(m.length===1)return 0;let y=m[c],T=!!(y!=null&&(l=y.details)!=null&&l.live),_=g===-1||u===-1,A,k="SDR",R=(y==null?void 0:y.frameRate)||0,{audioPreference:x,videoPreference:O}=v,w=this.audioTracksByGroup||(this.audioTracksByGroup=jx(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=zx(m,w,t,r)),q=qx(z,k,e,x,O),{codecSet:ce,videoRanges:fe,minFramerate:W,minBitrate:G,preferHDR:pe}=q;A=ce,k=pe?fe[fe.length-1]:fe[0],R=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(q)}`)}else A=y==null?void 0:y.codecSet,k=y==null?void 0:y.videoRange;let C=f?f.duration:h?h.duration:0,P=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let z=r;z>=t;z--){var X;let q=m[z],ce=z>c;if(!q)continue;if(v.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){let Ke=navigator.mediaCapabilities;typeof(Ke==null?void 0:Ke.decodingInfo)=="function"&&Gx(q,w,k,R,e,x)?(q.supportedPromise=Kx(q,w,Ke),q.supportedPromise.then(Ye=>{if(!this.hls)return;q.supportedResult=Ye;let ze=this.hls.levels,xt=ze.indexOf(q);Ye.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${Ye.error}" for level ${xt} ${JSON.stringify(Ye)}`):Ye.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${xt} ${JSON.stringify(Ye)}`),xt>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${xt}`),this.hls.removeLevel(xt)))})):q.supportedResult=qv}if(A&&q.codecSet!==A||k&&q.videoRange!==k||ce&&R>q.frameRate||!ce&&R>0&&R<q.frameRate||q.supportedResult&&!((X=q.supportedResult.decodingInfoResults)!=null&&X[0].smooth)){U.push(z);continue}let fe=q.details,W=(f?fe==null?void 0:fe.partTarget:fe==null?void 0:fe.averagetargetduration)||C,G;ce?G=o*e:G=a*e;let pe=C&&s>=C*2&&n===0?m[z].averageBitrate:m[z].maxBitrate,te=this.getTimeToLoadFrag(P,G,pe*W,fe===void 0);if(G>=pe&&(z===u||q.loadError===0&&q.fragmentError===0)&&(te<=P||!j(te)||T&&!this.bitrateTestDelay||te<d)){let Ke=this.forcedAutoLevel;return z!==g&&(Ke===-1||Ke!==g)&&(U.length&&L.trace(`[abr] Skipped level(s) ${U.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${k}`),L.info(`[abr] switch candidate:${c}->${z} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-pe)} ttfb:${P.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${te.toFixed(1)} firstSelection:${_} codecSet:${A} videoRange:${k} hls.loadLevel:${g}`)),_&&(this.firstSelection=z),z}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},ef=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},mt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},tf=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=ln(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),kl(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=ln(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&kl(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||kl(t))}getState(e){let t=ln(e),r=this.fragments[t];return r?r.buffered?kl(r)?mt.PARTIAL:mt.OK:mt.APPENDING:mt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=ln(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=ln(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=ln(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function kl(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function ln(i){return`${i.type}_${i.level}_${i.sn}`}var Zx={length:0,start:()=>0,end:()=>0},Ve=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),Zx}}},Fa=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=wl(),this.buffering={audio:wl(),video:wl(),audiovideo:wl()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function wl(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Fl(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function Jx(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function eR(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){L.log("No fragments to align");return}let s=Fl(t,r[0].cc);if(!s||s&&!s.startPTS){L.log("No frag in previous level to align on");return}return s}function nv(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function jv(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)nv(t[r],i);e.fragmentHint&&nv(e.fragmentHint,i),e.alignedSliding=!0}function tR(i,e,t){e&&(iR(i,t,e),!t.alignedSliding&&e&&ed(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Kv(e,t))}function iR(i,e,t){if(Jx(i,t,e)){let r=eR(t,e);r&&j(r.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),jv(r.start,e))}}function ed(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Fl(r,a),n=Fl(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Fl(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);jv(d,i)}var av=Math.pow(2,17),rf=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(lv(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=ov(e),c=iv(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:av};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let v=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:pt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(lv(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=ov(e,t),c=iv(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:av};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let v={frag:e,part:t,payload:f.data,networkDetails:g};r(v),o(v)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:pt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new li({type:ne.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function ov(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(j(s)&&j(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function lv(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ne.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new li(r)}var li=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},sf=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},nf=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function rR(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ms(i,0,e-t):i}var af=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;let y=f[m],T=f[y],_=f[T],A=f[v]*257^v*16843008;s[m]=A<<24|A>>>8,n[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,o[m]=A,A=_*16843009^T*65537^y*257^m*16843008,d[v]=A<<24|A>>>8,u[v]=A<<16|A>>>16,c[v]=A<<8|A>>>24,h[v]=A,m?(m=y^f[f[f[_^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],v=f[3],y,T;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}T=y,o%n===0?(T=T<<8|T>>>24,T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255],T^=h[o/n|0]<<24):n>6&&o%n===4&&(T=c[T>>>24]<<24|c[T>>>16&255]<<16|c[T>>>8&255]<<8|c[T&255]),d[o]=y=(d[o-n]^T)>>>0}for(l=0;l<a;l++)o=a-l,l&3?T=d[o]:T=d[o-4],l<4||o<=4?u[l]=T:u[l]=m[c[T>>>24]]^p[c[T>>>16&255]]^g[c[T>>>8&255]]^v[c[T&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],v=new Int32Array(e),y=new Int32Array(v.length),T,_,A,k,R,x,O,w,C,P,U,X,z,q,ce=this.networkToHostOrderSwap;for(;t<v.length;){for(C=ce(v[t]),P=ce(v[t+1]),U=ce(v[t+2]),X=ce(v[t+3]),R=C^n[0],x=X^n[1],O=U^n[2],w=P^n[3],z=4,q=1;q<s;q++)T=l[R>>>24]^d[x>>16&255]^u[O>>8&255]^c[w&255]^n[z],_=l[x>>>24]^d[O>>16&255]^u[w>>8&255]^c[R&255]^n[z+1],A=l[O>>>24]^d[w>>16&255]^u[R>>8&255]^c[x&255]^n[z+2],k=l[w>>>24]^d[R>>16&255]^u[x>>8&255]^c[O&255]^n[z+3],R=T,x=_,O=A,w=k,z=z+4;T=a[R>>>24]<<24^a[x>>16&255]<<16^a[O>>8&255]<<8^a[w&255]^n[z],_=a[x>>>24]<<24^a[O>>16&255]<<16^a[w>>8&255]<<8^a[R&255]^n[z+1],A=a[O>>>24]<<24^a[w>>16&255]<<16^a[R>>8&255]<<8^a[x&255]^n[z+2],k=a[w>>>24]<<24^a[R>>16&255]<<16^a[x>>8&255]<<8^a[O&255]^n[z+3],y[t]=ce(T^f),y[t+1]=ce(k^m),y[t+2]=ce(A^p),y[t+3]=ce(_^g),f=C,m=P,p=U,g=X,t=t+4}return y.buffer}},sR=16,Ba=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?rR(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=qt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new af),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=ms(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new nf(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new sf(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%sR;return r!==e.length&&(t=ms(e,0,r),this.remainderData=ms(e,r)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},nR={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},$a=class extends ef{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=L.log.bind(L,`${s}:`),this.warn=L.warn.bind(L,`${s}:`),this.hls=e,this.fragmentLoader=new rf(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ba(e.config),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ve.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ve.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${j(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===mt.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===mt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(E.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(E.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===se.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?nR.toString(Ve.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==se.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==se.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Fa(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(E.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),j(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(E.FRAG_LOADED,h);let m=ev(r,e.sn,c.index+1)||Vv(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?ev(o,n,a):null,d=l?l.fragment:Nx(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=qt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(E.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ve.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ve.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return j(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ve.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ve.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){let r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=se.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,se.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===mt.OK||r===mt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=Fx(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Hx(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Jl(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===mt.OK||m===mt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==mt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&j(n);if(a||!o&&!n){let{fragPrevious:l}=this;tR(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&j(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===M.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ft.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=Zf(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ft.RemoveAlternatePermanently&&(a.resolved=!0);else{L.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ft.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){let t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);let a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===se.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ve.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:Gv(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},td=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=aR(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function aR(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function oR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function lR(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function dR(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function yi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var Ha=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=qt(this.cachedData,e),this.cachedData=null);let r=Oa(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Qf(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&j(l))&&(this.basePTS=uR(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:di.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else KS(e,s)?(r=Oa(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:di.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=ms(e,n);this.cachedData?this.cachedData=qt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:yi(),id3Track:o,textTrack:yi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:yi(),id3Track:this._id3Track,textTrack:yi()}}destroy(){}},uR=(i,e,t)=>{if(j(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function cR(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,L.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function zv(i,e){return i[e]===255&&(i[e+1]&246)===240}function Xv(i,e){return i[e+1]&1?7:9}function Jf(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function hR(i,e){return e+5<i.length}function id(i,e){return e+1<i.length&&zv(i,e)}function fR(i,e){return hR(i,e)&&zv(i,e)&&Jf(i,e)<=i.length-e}function mR(i,e){if(id(i,e)){let t=Xv(i,e);if(e+t>=i.length)return!1;let r=Jf(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||id(i,s)}return!1}function Qv(i,e,t,r,s){if(!i.samplerate){let n=cR(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,L.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Zv(i){return 1024*9e4/i}function pR(i,e){let t=Xv(i,e);if(e+t<=i.length){let r=Jf(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Jv(i,e,t,r,s){let n=Zv(i.samplerate),a=r+s*n,o=pR(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Dl=null,gR=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],vR=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ER=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],TR=[0,1,1,4];function eE(i,e,t,r,s){if(t+24>e.length)return;let n=tE(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function tE(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=gR[l*14+s-1]*1e3,c=vR[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=ER[t][r],m=TR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(Dl===null){let T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Dl=T?parseInt(T[1]):0}return!!Dl&&Dl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function em(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function iE(i,e){return e+1<i.length&&em(i,e)}function bR(i,e){return em(i,e)&&4<=i.length-e}function rE(i,e){if(e+1<i.length&&em(i,e)){let r=tE(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||iE(i,n)}return!1}var of=class extends Ha{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Oa(e,0),r=(t==null?void 0:t.length)||0;if(rE(e,r))return!1;for(let s=e.length;r<s;r++)if(mR(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return fR(e,t)}appendFrame(e,t,r){Qv(e,this.observer,t,r,e.manifestCodec);let s=Jv(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},yR=/\/emsg[-/]ID3/i,lf=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=yi("video",1),a=this.audioTrack=yi("audio",1),o=this.txtTrack=yi("text",1);if(this.id3Track=yi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Ov(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=Dv.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return ZS(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=qt(this.remainderData,e));let o=ax(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=N0(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=N0(e,t),{videoTrack:t,audioTrack:yi(),id3Track:s,textTrack:yi()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=he(e.samples,["emsg"]);s&&s.forEach(n=>{let a=dx(n);if(yR.test(a.schemeIdUri)){let o=j(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:di.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},sE=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},df=class extends Ha{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=nE(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=Oa(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&Qf(t)!==void 0&&sE(e,r)<16}};function nE(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,v=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|v>>2,(v&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),T=1536/o*9e4,_=r+s*T,A=e.subarray(t,t+u);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:_}),u}var uf=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&L.log(e.pts+"/"+e.dts+":"+e.debug)}},rd=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let k=u();if(k===3&&h(1),m(),m(),h(1),c())for(a=k!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let v=u();if(v===0)u();else if(v===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let y=u(),T=u(),_=d(1);_===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let A=[1,1];if(c()&&c())switch(l()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-_)*(T+1)*16-(_?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},cf=class extends uf{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let v=new rd(g).readSliceType();(v===2||v===4||v===7||v===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,Nv(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,v=new rd(p).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[p],e.duration=n;let y=p.subarray(1,4),T="avc1.";for(let _=0;_<3;_++){let A=y[_].toString(16);A.length<2&&(A="0"+A),T+=A}e.codec=T}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=qt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=qt(f.data,t))}return e.naluState=s,a}},hf=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ba(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=Uv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ht=188,ff=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new cf}static probe(e){let t=i.syncOffset(e);return t>0&&L.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ht*5,t-ht)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ht)if(e[l]===71&&(t-l===ht||e[l+ht]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ht*99,e.length-ht)+1)),n||(n=mf(e,l)===0),n&&o>1&&(a===0&&o>2||l+ht>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Dv[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,T=e.length;if(this.remainderData&&(e=qt(this.remainderData,e),T=e.length,this.remainderData=null),T<ht&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));T-=(T-_)%ht,T<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let A=0;for(let R=_;R<T;R+=ht)if(e[R]===71){let x=!!(e[R+1]&64),O=mf(e,R),w=(e[R+3]&48)>>4,C;if(w>1){if(C=R+5+e[R+4],C===R+ht)continue}else C=R+4;switch(O){case u:x&&(c&&(n=dn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(C,R+ht)),c.size+=R+ht-C);break;case h:if(x){if(m&&(n=dn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,R+ht)),m.size+=R+ht-C);break;case f:x&&(p&&(n=dn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,R+ht)),p.size+=R+ht-C);break;case 0:x&&(C+=e[C]+1),y=this._pmtId=_R(e,C);break;case y:{x&&(C+=e[C]+1);let P=AR(e,C,this.typeSupported,r,this.observer);u=P.videoPid,u>0&&(a.pid=u,a.segmentCodec=P.segmentVideoCodec),h=P.audioPid,h>0&&(o.pid=h,o.segmentCodec=P.segmentAudioCodec),f=P.id3Pid,f>0&&(l.pid=f),g!==null&&!v&&(L.warn(`MPEG-TS PMT found at ${R} after unknown PID '${g}'. Backtracking to sync byte @${_} to parse all TS packets.`),g=null,R=_-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else A++;A>0&&sd(this.observer,new Error(`Found ${A} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;let k={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(k),k}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=dn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=dn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=dn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new hf(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=qt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!id(n,a);a++);if(a!==r){let c,h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",sd(this.observer,new Error(c),h),!h)return}Qv(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Zv(e.samplerate);l=s.sample.pts+c}else{L.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Jv(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!id(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){L.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(iE(r,a)){let l=eE(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){L.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=nE(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){L.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=it({},t,{type:this._videoTrack?di.emsg:di.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function mf(i,e){return((i[e+1]&31)<<8)+i[e+2]}function _R(i,e){return(i[e+10]&31)<<8|i[e+11]}function AR(i,e,t,r,s){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){let d=mf(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){Lh("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){Lh("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?L.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){Lh("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?L.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return sd(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return sd(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function sd(i,e,t){L.warn(`parsing error: ${e.message}`),i.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Lh(i){L.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function dn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=qt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(L.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var pf=class extends Ha{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=Oa(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Qf(t)!==void 0&&sE(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(rE(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return bR(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return eE(e,t,r,this.basePTS,this.frameIndex)}},nd=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},br=Math.pow(2,32)-1,ot=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(br+1)),s=Math.floor(t%(br+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(br+1)),s=Math.floor(t%(br+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(br+1)),o=Math.floor(r%(br+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(br+1)),a=Math.floor(t%(br+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e);return qt(i.FTYP,t)}};ot.types=void 0;ot.HDLR_TYPES=void 0;ot.STTS=void 0;ot.STSC=void 0;ot.STCO=void 0;ot.STSZ=void 0;ot.VMHD=void 0;ot.SMHD=void 0;ot.STSD=void 0;ot.FTYP=void 0;ot.DINF=void 0;var aE=9e4;function tm(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function SR(i,e,t=1,r=!1){return tm(i,e,1/t,r)}function wa(i,e=!1){return tm(i,1e3,1/aE,e)}function xR(i,e=1){return tm(i,aE,1/e)}var RR=10*1e3,dv=1024,IR=1152,LR=1536,un=null,kh=null,fn=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,un===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);un=a?parseInt(a[1]):0}if(kh===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);kh=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e[0].pts,s=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Yt(o,r),l=o-n),l>0?n:o},r);return t&&L.debug("PTS rollover detected"),s}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n,v=e.pid>-1,y=t.pid>-1,T=t.samples.length,_=e.samples.length>0,A=o&&T>0||T>1;if((!v||_)&&(!y||A)||this.ISGenerated||o){if(this.ISGenerated){var R,x,O,w;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((R=t.pixelRatio)==null?void 0:R[0])!==((x=X.pixelRatio)==null?void 0:x[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((w=X.pixelRatio)==null?void 0:w[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let C=this.isVideoContiguous,P=-1,U;if(A&&(P=kR(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,P>0){L.warn(`[mp4-remuxer]: Dropped ${P} out of ${T} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(P),t.dropped+=P,g+=(t.samples[0].pts-X)/t.inputTimeScale,U=g}else P===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),m=!1);if(this.ISGenerated){if(_&&A){let X=this.getVideoStartPts(t.samples),q=(Yt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,q),g+=Math.max(0,-q)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,y||A||l===se.AUDIO?g:void 0),A){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,C,X)}}else A&&(d=this.remuxVideo(t,g,C,0));d&&(d.firstKeyFrame=P,d.independent=P!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=oE(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=lE(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):ot.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ot.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){let p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Yt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||u===null){let W=t*n,G=a[0].pts-Yt(a[0].dts,a[0].pts);un&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let y=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Yt(G.pts-y,u),G.dts=Yt(G.dts-y,u),G.dts<a[W>0?W-1:W].dts&&(v=!0)}v&&a.sort(function(W,G){let pe=W.dts-G.dts,te=W.pts-G.pts;return pe||te}),f=a[0].dts,m=a[a.length-1].dts;let T=m-f,_=T?Math.round(T/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>_,pe=W<-1;if((G||pe)&&(G?L.warn(`AVC: ${wa(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${wa(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!pe||u>=a[0].pts||un)){f=u;let te=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=te;else for(let _e=0;_e<a.length&&!(a[_e].dts>te);_e++)a[_e].dts-=W,a[_e].pts-=W;L.log(`Video: Initial PTS/DTS adjusted: ${wa(te,!0)}/${wa(f,!0)}, delta: ${wa(W,!0)} ms`)}}f=Math.max(0,f);let A=0,k=0,R=f;for(let W=0;W<l;W++){let G=a[W],pe=G.units,te=pe.length,_e=0;for(let Ke=0;Ke<te;Ke++)_e+=pe[Ke].data.length;k+=_e,A+=te,G.length=_e,G.dts<R?(G.dts=R,R+=_/4|0||1):R=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let x=k+4*A+8,O;try{O=new Uint8Array(x)}catch(W){this.observer.emit(E.ERROR,E.ERROR,{type:ne.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:x,reason:`fail allocating video mdat ${x}`});return}let w=new DataView(O.buffer);w.setUint32(0,x),O.set(ot.types.mdat,4);let C=!1,P=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],pe=G.units,te=0;for(let Ye=0,ze=pe.length;Ye<ze;Ye++){let xt=pe[Ye],Er=xt.data,rn=xt.data.byteLength;w.setUint32(c,rn),c+=4,O.set(Er,c),c+=rn,te+=4+rn}let _e;if(W<l-1)h=a[W+1].dts-G.dts,_e=a[W+1].pts-G.pts;else{let Ye=this.config,ze=W>0?G.dts-a[W-1].dts:_;if(_e=W>0?G.pts-a[W-1].pts:_,Ye.stretchShortVideoTrack&&this.nextAudioPts!==null){let xt=Math.floor(Ye.maxBufferHole*n),Er=(s?p+s*n:this.nextAudioPts)-G.pts;Er>xt?(h=Er-ze,h<0?h=ze:C=!0,L.log(`[mp4-remuxer]: It is approximately ${Er/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=ze}else h=ze}let Ke=Math.round(G.pts-G.dts);P=Math.min(P,h),X=Math.max(X,h),U=Math.min(U,_e),z=Math.max(z,_e),o.push(new ad(G.key,h,te,Ke))}if(o.length){if(un){if(un<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(kh&&z-U<X-P&&_/X<.025&&o[0].cts===0){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,pe=o.length;G<pe;G++){let te=W+o[G].duration,_e=W+o[G].cts;if(G<pe-1){let Ke=te+o[G+1].cts;o[G].duration=Ke-_e}else o[G].duration=G?o[G-1].duration:_;o[G].cts=0,W=te}}}h=C||!h?_:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let fe={data1:ot.moof(e.sequenceNumber++,f,it({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,fe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return IR;case"ac3":return LR;default:return dv}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,v=this.nextAudioPts||-1,y=t*a,T=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&v>0&&(s&&Math.abs(y-v)<9e3||Math.abs(Yt(p[0].pts-T,y)-v)<20*u),p.forEach(function(q){q.pts=Yt(q.pts-T,y)}),!r||v<0){if(p=p.filter(q=>q.pts>=0),!p.length)return;n===0?v=0:s&&!m?v=Math.max(0,y):v=p[0].pts}if(e.segmentCodec==="aac"){let q=this.config.maxAudioFramesDrift;for(let ce=0,fe=v;ce<p.length;ce++){let W=p[ce],G=W.pts,pe=G-fe,te=Math.abs(1e3*pe/a);if(pe<=-q*u&&m)ce===0&&(L.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*pe/a)} ms.`),this.nextAudioPts=v=fe=G);else if(pe>=q*u&&te<RR&&m){let _e=Math.round(pe/u);fe=G-_e*u,fe<0&&(_e--,fe+=u),ce===0&&(this.nextAudioPts=v=fe),L.warn(`[mp4-remuxer]: Injecting ${_e} audio frame @ ${(fe/a).toFixed(3)}s due to ${Math.round(1e3*pe/a)} ms gap.`);for(let Ke=0;Ke<_e;Ke++){let Ye=Math.max(fe,0),ze=nd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ze||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ze=W.unit.subarray()),p.splice(ce,0,{unit:ze,pts:Ye}),fe+=u,ce++}}W.pts=fe,fe+=u}}let _=null,A=null,k,R=0,x=p.length;for(;x--;)R+=p[x].unit.byteLength;for(let q=0,ce=p.length;q<ce;q++){let fe=p[q],W=fe.unit,G=fe.pts;if(A!==null){let te=f[q-1];te.duration=Math.round((G-A)/l)}else if(r&&e.segmentCodec==="aac"&&(G=v),_=G,R>0){R+=g;try{k=new Uint8Array(R)}catch(te){this.observer.emit(E.ERROR,E.ERROR,{type:ne.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:te,bytes:R,reason:`fail allocating audio mdat ${R}`});return}h||(new DataView(k.buffer).setUint32(0,R),k.set(ot.types.mdat,4))}else return;k.set(W,g);let pe=W.byteLength;g+=pe,f.push(new ad(!0,d,pe,0)),A=G}let O=f.length;if(!O)return;let w=f[f.length-1];this.nextAudioPts=v=A+l*w.duration;let C=h?new Uint8Array(0):ot.moof(e.sequenceNumber++,_/l,it({},e,{samples:f}));e.samples=[];let P=_/a,U=v/a,z={data1:C,data2:k,startPTS:P,endPTS:U,startDTS:P,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,z}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*dv,m=Math.ceil((h-c)/f),p=nd.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!p){L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let v=0;v<m;v++){let y=c+v*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Yt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function kR(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function oE(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Yt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Yt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function lE(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Yt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var ad=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},gf=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(tx(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=Ov(e);s.audio&&(t=uv(s.audio,we.AUDIO)),s.video&&(r=uv(s.video,we.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};j(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=rx(h,m),g=ix(m,h),v=g===null?n:g;(wR(d,v,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=v-n,d&&d.timescale===1&&L.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let y=e?v-d.baseTime/d.timescale:u,T=y+p;nx(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=T:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let _=!!m.audio,A=!!m.video,k="";_&&(k+="audio"),A&&(k+="video");let R={data1:h,startPTS:y,startDTS:y,endPTS:T,endDTS:T,type:k,hasAudio:_,hasVideo:A,nb:1,dropped:0};return c.audio=R.type==="audio"?R:void 0,c.video=R.type!=="audio"?R:void 0,c.initSegment=f,c.id3=oE(r,n,d,d),s.samples.length&&(c.text=lE(s,n,d)),c}};function wR(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function uv(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===we.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return jl(t,!1);let r="mp4a.40.5";return L.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return L.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var Zi;try{Zi=self.performance.now.bind(self.performance)}catch{L.debug("Unable to use Performance API on this environment"),Zi=pn==null?void 0:pn.Date.now}var Bl=[{demux:lf,remux:gf},{demux:ff,remux:fn},{demux:of,remux:fn},{demux:pf,remux:fn}];Bl.splice(2,0,{demux:df,remux:fn});var od=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=Zi();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:v,duration:y,initSegmentData:T}=l,_=DR(a,t);if(_&&_.method==="AES-128"){let x=this.getDecrypter();if(x.isSync()){let O=x.softwareDecrypt(a,_.key.buffer,_.iv.buffer);if(r.part>-1&&(O=x.flush()),!O)return n.executeEnd=Zi(),wh(r);a=new Uint8Array(O)}else return this.decryptionPromise=x.webCryptoDecrypt(a,_.key.buffer,_.iv.buffer).then(O=>{let w=this.push(O,null,r);return this.decryptionPromise=null,w}),this.decryptionPromise}let A=this.needsProbing(u,c);if(A){let x=this.configureTransmuxer(a);if(x)return L.warn(`[transmuxer] ${x.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message}),n.executeEnd=Zi(),wh(r)}(u||c||m||A)&&this.resetInitSegment(T,p,g,y,t),(u||m||A)&&this.resetInitialTimestamp(v),d||this.resetContiguity();let k=this.transmux(a,_,f,h,r),R=this.currentTransmuxState;return R.contiguous=!0,R.discontinuity=!1,R.trackSwitch=!1,n.executeEnd=Zi(),k}flush(e){let t=e.transmuxing;t.executeStart=Zi();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Zi(),[wh(e)];let u=l.flush(o);return $l(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=Zi()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=Bl.length;h<f;h++){var o;if((o=Bl[h].demux)!=null&&o.probe(e)){a=Bl[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ba(this.config)),e}};function DR(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var wh=i=>({remuxResult:{},chunkMeta:i});function $l(i){return"then"in i&&i.then instanceof Function}var vf=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},Ef=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},dE={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,y,T;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(T=1,y=new Array(v-1);T<v;T++)y[T-1]=arguments[T];g.fn.apply(g.context,y)}else{var _=g.length,A;for(T=0;T<_;T++)switch(g[T].once&&this.removeListener(d,g[T].fn,void 0,!0),v){case 1:g[T].fn.call(g[T].context);break;case 2:g[T].fn.call(g[T].context,u);break;case 3:g[T].fn.call(g[T].context,u,c);break;case 4:g[T].fn.call(g[T].context,u,c,h);break;default:if(!y)for(A=1,y=new Array(v-1);A<v;A++)y[A-1]=arguments[A];g[T].fn.apply(g[T].context,y)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],v=m.length;p<v;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(dE);var CR=dE.exports,im=xS(CR),ld=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===E.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new im,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);let o=gs(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||oR())){try{n.workerPath?(L.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=dR(n.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=lR()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:ne.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new od(this.observer,l,n,"",t)}return}this.transmuxer=new od(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),T=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=T===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),k=!y&&(T===1||T===0&&(_===1||A&&_<=0)),R=self.performance.now();(y||T||n.stats.parsing.start===0)&&(n.stats.parsing.start=R),a&&(_||!k)&&(a.stats.parsing.start=R);let x=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),O=new Ef(v,k,l,y,m,x);if(!k||v||x){L.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
|
|
24
24
|
discontinuity: ${v}
|
|
25
25
|
trackSwitch: ${y}
|
|
26
26
|
contiguous: ${k}
|
|
27
27
|
accurateTimeOffset: ${l}
|
|
28
28
|
timeOffset: ${m}
|
|
29
|
-
initSegmentChange: ${x}`);let w=new vf(r,s,t,o,u);this.configureTransmuxer(w)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){let w=f.push(e,p,d,O);Bl(w)?(f.async=!0,w.then(C=>{this.handleTransmuxComplete(C)}).catch(C=>{this.transmuxerError(C,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(w))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Bl(r)||t.async?(Bl(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){L.warn(`worker message received with no ${t?"event name":"data"}`);return}let r=this.hls;if(this.hls)switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":L[t.data.logType]&&L[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},cv=100,Tf=class extends $a{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",se.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(cv),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ve.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Xh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!this.buffering||!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,we.AUDIO,se.AUDIO));let d=this.getFwdBufferInfo(l,se.AUDIO);if(d===null)return;if(!this.switchingTrack&&this._streamEnded(d,o)){e.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}let u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,se.MAIN),c=d.len,h=this.getMaxBufferLength(u==null?void 0:u.len),f=o.fragments,m=f[0].start,p=this.getLoadPosition(),g=this.flushing?p:d.end;if(this.switchingTrack&&r){let _=p;o.PTSKnown&&_<m&&(d.end>m||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05)}if(c>=h&&!this.switchingTrack&&g<f[f.length-1].start)return;let v=this.getNextFragment(g,o),y=!1;if(v&&this.isLoopLoading(v,g)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,o,d,se.MAIN,h)),!v){this.bufferFlushed=!0;return}let T=u&&v.start>u.end+o.targetduration;if(T||!(u!=null&&u.len)&&d.len){let _=this.getAppendedFrag(v.start,se.MAIN);if(_===null||(y||(y=!!_.gap||!!T&&u.len===0),T&&!y||y&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(v,a,g)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new _r(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(cv):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)Jl(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new od(this.hls,se.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,v=g!==-1,y=new Fa(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,v);h.push(n,m,c,"",r,s,u.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new ed,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==se.AUDIO){if(!this.loadedmetadata&&r.type===se.MAIN){let n=this.videoBuffer||this.media;n&&Ve.getBuffered(n).length&&(this.loadedmetadata=!0)}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}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,pt({},n)))}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.AUDIO,t);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Ae.AUDIO_TRACK&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==we.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==we.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,se.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{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,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:v,startDTS:y,endDTS:T}=h;d&&(d.elementaryStreams[we.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:T}),l.setElementaryStreamInfo(we.AUDIO,g,v,y,T),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=it({id:r,frag:l,details:c},m);s.trigger(E.FRAG_PARSING_METADATA,g)}if(f){let g=it({id:r,frag:l,details:c},f);s.trigger(E.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===mt.NOT_LOADED||s===mt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Jl(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:r,assocLang:s,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;ps({name:t,lang:r,assocLang:s,characteristics:n,audioCodec:a,channels:o},e,cs)||(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,pt({},e))}};function uE(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Ga(i[t].attrs,e[t].attrs))return!1;return!0}function Ga(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function bf(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var yf=class extends Ua{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=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_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,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_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=_i(l,o,cs);if(h>-1)n=o[h];else{let f=_i(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Ae.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&ps(e,s,cs))return s;let n=_i(e,this.tracksInGroup,cs);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=Qx(e,t.levels,r,a,cs);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=_i(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,pt({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||ps(e,s,cs)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(ps({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,cs))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Ga(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Ga(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},hv=500,_f=class extends $a{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",se.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(hv),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,se.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===se.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===se.SUBTITLE&&(t.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&uE(this.levels,t)){this.levels=t.map(r=>new _r(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new _r(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,se.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(hv)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(Jl(a,c),d=a.fragments[0].start):h&&(d=h.start,zh(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,zh(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Zl(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(E.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,se.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let v=s.maxFragLookUpTolerance,y=o>m-v?0:v;p=Zl(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let v=p.sn-u.startSN,y=h[v-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===mt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===mt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Af(this.tracksBuffered[this.currentTrackId]||[])}},Af=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Sf=class extends Ua{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=Pl(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}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_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,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_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Pl(this.media.textTracks).forEach(t=>{cn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=_i(o,a);if(u>-1)n=a[u];else{let c=_i(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||ps(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(Ga(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(Ga(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(bf(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ae.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&ps(e,r))return r;let s=_i(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=_i(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=Pl(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>bf(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!j(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},xf=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},fv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Rf=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&L.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=gx(gs(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,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.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,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.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new xf(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=gs(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,mv(r),MR(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&mv(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer(),this.hls.resumeBuffering()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=$0(l.codec,l.levelCodec),p=m==null?void 0:m.replace(fv,"$1"),g=$0(u,c),v=(o=g)==null?void 0:o.replace(fv,"$1");if(g&&p!==v){a.slice(0,5)==="audio"&&(g=ql(g,this.appendSource));let y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let v=l.start,y={execute:()=>{if(c.executeStart=self.performance.now(),g){let T=this.sourceBuffer[o];if(T){let _=v-T.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${_}) sn: ${l.sn})`),T.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),m&&m.first===0&&(m.first=T);let{sourceBuffer:_}=this,A={};for(let k in _)A[k]=Ve.getBuffered(_[k]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:A})},onError:T=>{let _={type:ne.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:T,err:T,fatal:!1};if(T.code===DOMException.QUOTA_EXCEEDED_ERR)_.details=M.BUFFER_FULL_ERROR;else{let A=++this.appendErrors[o];_.details=M.BUFFER_APPEND_ERROR,this.warn(`Failed ${A}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),A>=r.config.appendErrorMaxRetry&&(_.fatal=!0)}r.trigger(E.ERROR,_)}};s.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(E.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[we.AUDIOVIDEO]?n.push("audiovideo"):(a[we.AUDIO]&&n.push("audio"),a[we.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(E.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(j(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(j(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ve.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ve.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=j(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!j(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=ql(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(E.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;let r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=j(s.duration)?s.duration:1/0,u=j(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function mv(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function MR(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var OR={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},cE=i=>String.fromCharCode(OR[i]||i),oi=15,Qi=100,PR={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},NR={17:2,18:4,21:6,22:8,23:10,19:13,20:15},UR={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},FR={25:2,26:4,29:6,30:8,31:10,27:13,28:15},BR=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],If=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;L.log(`${this.time} [${e}] ${r}`)}}},ds=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},ld=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Lf=class{constructor(){this.uchar=" ",this.penState=new ld}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},kf=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new ld,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Qi;t++)this.chars.push(new Lf);this.logger=e}equals(e){for(let t=0;t<Qi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Qi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Qi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Qi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Qi)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=cE(e);if(this.pos>=Qi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Qi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Qi;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Ma=class{constructor(e){this.rows=[],this.currRow=oi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<oi;t++)this.rows.push(new kf(e));this.logger=e}reset(){for(let e=0;e<oi;e++)this.rows[e].clear();this.currRow=oi-1}equals(e){let t=!0;for(let r=0;r<oi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<oi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<oi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<oi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<oi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
|
|
30
|
-
`)),r}getTextAndFormat(){return this.rows}},dd=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ma(r),this.nonDisplayedMemory=new Ma(r),this.lastOutputScreen=new Ma(r),this.currRollUpRow=this.displayedMemory.rows[oi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[oi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},ud=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=HR(),this.logger=void 0;let s=this.logger=new If;this.channels=[null,new dd(e,t,s),new dd(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){let s=t[r]&127,n=t[r+1]&127,a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+ds([t[r],t[r+1]])+"] -> ("+ds([s,n])+")");let l=this.cmdHistory;if(s>=16&&s<=31){if($R(s,n,l)){Dl(null,null,l),this.logger.log(3,()=>"Repeated command ("+ds([s,n])+") is dropped");continue}Dl(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else Dl(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){let u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ds([s,n])+" orig: "+ds([t[r],t[r+1]]))}}parseCmd(e,t){let r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+ds([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;let a=e<=23?1:2;t>=64&&t<=95?r=a===1?PR[e]:UR[e]:r=a===1?NR[e]:FR[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+cE(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+ds(s).join(",")),s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=BR[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}Dl(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function Dl(i,e,t){t.a=i,t.b=e}function $R(i,e,t){return t.a===i&&t.b===e}function HR(){return{a:null,b:null}}var hn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},rm=function(){if(pn!=null&&pn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,v=null,y="",T=!0,_="auto",A="start",k=50,R="middle",x=50,O="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(w){h=""+w}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(w){f=!!w}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(w){if(typeof w!="number")throw new TypeError("Start time must be set to a number.");m=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(w){if(typeof w!="number")throw new TypeError("End time must be set to a number.");p=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(w){g=""+w,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return v},set:function(w){v=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return y},set:function(w){let C=r(w);if(C===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return T},set:function(w){T=!!w,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return _},set:function(w){if(typeof w!="number"&&w!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return A},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");A=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return k},set:function(w){if(w<0||w>100)throw new Error("Position must be between 0 and 100.");k=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return R},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");R=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return x},set:function(w){if(w<0||w>100)throw new Error("Size must be between 0 and 100.");x=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return O},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");O=C,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),wf=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function hE(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var Df=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function fE(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var Cf=new rm(0,0,""),Cl=Cf.align==="middle"?"middle":"center";function GR(i,e,t){let r=i;function s(){let o=hE(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Df;fE(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Cl,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Cl,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Cl,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&Cf.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Cl);let c=d.get("position","auto");c==="auto"&&Cf.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function mE(i){return i.replace(/<br(?: \/)?>/gi,`
|
|
29
|
+
initSegmentChange: ${x}`);let w=new vf(r,s,t,o,u);this.configureTransmuxer(w)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){let w=f.push(e,p,d,O);$l(w)?(f.async=!0,w.then(C=>{this.handleTransmuxComplete(C)}).catch(C=>{this.transmuxerError(C,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(w))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);$l(r)||t.async?($l(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){L.warn(`worker message received with no ${t?"event name":"data"}`);return}let r=this.hls;if(this.hls)switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":L[t.data.logType]&&L[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}},cv=100,Tf=class extends $a{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",se.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(cv),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ve.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Xh(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!this.buffering||!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,we.AUDIO,se.AUDIO));let d=this.getFwdBufferInfo(l,se.AUDIO);if(d===null)return;if(!this.switchingTrack&&this._streamEnded(d,o)){e.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}let u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,se.MAIN),c=d.len,h=this.getMaxBufferLength(u==null?void 0:u.len),f=o.fragments,m=f[0].start,p=this.getLoadPosition(),g=this.flushing?p:d.end;if(this.switchingTrack&&r){let _=p;o.PTSKnown&&_<m&&(d.end>m||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=m+.05)}if(c>=h&&!this.switchingTrack&&g<f[f.length-1].start)return;let v=this.getNextFragment(g,o),y=!1;if(v&&this.isLoopLoading(v,g)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,o,d,se.MAIN,h)),!v){this.bufferFlushed=!0;return}let T=u&&v.start>u.end+o.targetduration;if(T||!(u!=null&&u.len)&&d.len){let _=this.getAppendedFrag(v.start,se.MAIN);if(_===null||(y||(y=!!_.gap||!!T&&u.len===0),T&&!y||y&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(v,a,g)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new _r(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(cv):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)ed(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new ld(this.hls,se.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,v=g!==-1,y=new Fa(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,v);h.push(n,m,c,"",r,s,u.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new td,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==se.AUDIO){if(!this.loadedmetadata&&r.type===se.MAIN){let n=this.videoBuffer||this.media;n&&Ve.getBuffered(n).length&&(this.loadedmetadata=!0)}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}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,pt({},n)))}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.AUDIO,t);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===Ae.AUDIO_TRACK&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==we.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==we.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,se.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{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,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:v,startDTS:y,endDTS:T}=h;d&&(d.elementaryStreams[we.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:T}),l.setElementaryStreamInfo(we.AUDIO,g,v,y,T),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=it({id:r,frag:l,details:c},m);s.trigger(E.FRAG_PARSING_METADATA,g)}if(f){let g=it({id:r,frag:l,details:c},f);s.trigger(E.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===mt.NOT_LOADED||s===mt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&ed(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){let{name:t,lang:r,assocLang:s,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;ps({name:t,lang:r,assocLang:s,characteristics:n,audioCodec:a,channels:o},e,cs)||(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,pt({},e))}};function uE(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Ga(i[t].attrs,e[t].attrs))return!1;return!0}function Ga(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function bf(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var yf=class extends Ua{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=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_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,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_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=_i(l,o,cs);if(h>-1)n=o[h];else{let f=_i(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Ae.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&ps(e,s,cs))return s;let n=_i(e,this.tracksInGroup,cs);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=Qx(e,t.levels,r,a,cs);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=_i(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,pt({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||ps(e,s,cs)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(ps({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,cs))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Ga(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Ga(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},hv=500,_f=class extends $a{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",se.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_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.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,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.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(hv),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,se.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===se.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===se.SUBTITLE&&(t.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&uE(this.levels,t)){this.levels=t.map(r=>new _r(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new _r(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,se.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(hv)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(ed(a,c),d=a.fragments[0].start):h&&(d=h.start,zh(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,zh(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Jl(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(E.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ve.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,se.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let v=s.maxFragLookUpTolerance,y=o>m-v?0:v;p=Jl(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let v=p.sn-u.startSN,y=h[v-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===mt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===mt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new Af(this.tracksBuffered[this.currentTrackId]||[])}},Af=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Sf=class extends Ua{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=Nl(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}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_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,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_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Nl(this.media.textTracks).forEach(t=>{cn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=_i(o,a);if(u>-1)n=a[u];else{let c=_i(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||ps(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(Ga(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(Ga(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(bf(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Ae.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&ps(e,r))return r;let s=_i(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=_i(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=Nl(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>bf(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!j(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},xf=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},fv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Rf=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&L.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=gx(gs(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,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.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,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.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new xf(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=gs(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,mv(r),MR(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&mv(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer(),this.hls.resumeBuffering()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=$0(l.codec,l.levelCodec),p=m==null?void 0:m.replace(fv,"$1"),g=$0(u,c),v=(o=g)==null?void 0:o.replace(fv,"$1");if(g&&p!==v){a.slice(0,5)==="audio"&&(g=jl(g,this.appendSource));let y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let v=l.start,y={execute:()=>{if(c.executeStart=self.performance.now(),g){let T=this.sourceBuffer[o];if(T){let _=v-T.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${_}) sn: ${l.sn})`),T.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let T=self.performance.now();c.executeEnd=c.end=T,f.first===0&&(f.first=T),m&&m.first===0&&(m.first=T);let{sourceBuffer:_}=this,A={};for(let k in _)A[k]=Ve.getBuffered(_[k]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:A})},onError:T=>{let _={type:ne.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:T,err:T,fatal:!1};if(T.code===DOMException.QUOTA_EXCEEDED_ERR)_.details=M.BUFFER_FULL_ERROR;else{let A=++this.appendErrors[o];_.details=M.BUFFER_APPEND_ERROR,this.warn(`Failed ${A}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),A>=r.config.appendErrorMaxRetry&&(_.fatal=!0)}r.trigger(E.ERROR,_)}};s.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(E.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[we.AUDIOVIDEO]?n.push("audiovideo"):(a[we.AUDIO]&&n.push("audio"),a[we.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(E.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(j(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(j(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ve.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ve.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=j(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!j(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=jl(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(E.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;let r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(E.ERROR,{type:ne.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=j(s.duration)?s.duration:1/0,u=j(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function mv(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function MR(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var OR={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},cE=i=>String.fromCharCode(OR[i]||i),oi=15,Qi=100,PR={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},NR={17:2,18:4,21:6,22:8,23:10,19:13,20:15},UR={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},FR={25:2,26:4,29:6,30:8,31:10,27:13,28:15},BR=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],If=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;L.log(`${this.time} [${e}] ${r}`)}}},ds=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},dd=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Lf=class{constructor(){this.uchar=" ",this.penState=new dd}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},kf=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new dd,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Qi;t++)this.chars.push(new Lf);this.logger=e}equals(e){for(let t=0;t<Qi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Qi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Qi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Qi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Qi)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=cE(e);if(this.pos>=Qi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Qi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<Qi;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},Ma=class{constructor(e){this.rows=[],this.currRow=oi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<oi;t++)this.rows.push(new kf(e));this.logger=e}reset(){for(let e=0;e<oi;e++)this.rows[e].clear();this.currRow=oi-1}equals(e){let t=!0;for(let r=0;r<oi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<oi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<oi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<oi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<oi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
|
|
30
|
+
`)),r}getTextAndFormat(){return this.rows}},ud=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ma(r),this.nonDisplayedMemory=new Ma(r),this.lastOutputScreen=new Ma(r),this.currRollUpRow=this.displayedMemory.rows[oi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[oi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},cd=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=HR(),this.logger=void 0;let s=this.logger=new If;this.channels=[null,new ud(e,t,s),new ud(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){let s=t[r]&127,n=t[r+1]&127,a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+ds([t[r],t[r+1]])+"] -> ("+ds([s,n])+")");let l=this.cmdHistory;if(s>=16&&s<=31){if($R(s,n,l)){Cl(null,null,l),this.logger.log(3,()=>"Repeated command ("+ds([s,n])+") is dropped");continue}Cl(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else Cl(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){let u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+ds([s,n])+" orig: "+ds([t[r],t[r+1]]))}}parseCmd(e,t){let r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+ds([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;let a=e<=23?1:2;t>=64&&t<=95?r=a===1?PR[e]:UR[e]:r=a===1?NR[e]:FR[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+cE(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+ds(s).join(",")),s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=BR[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}Cl(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function Cl(i,e,t){t.a=i,t.b=e}function $R(i,e,t){return t.a===i&&t.b===e}function HR(){return{a:null,b:null}}var hn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},rm=function(){if(pn!=null&&pn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,v=null,y="",T=!0,_="auto",A="start",k=50,R="middle",x=50,O="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(w){h=""+w}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(w){f=!!w}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(w){if(typeof w!="number")throw new TypeError("Start time must be set to a number.");m=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(w){if(typeof w!="number")throw new TypeError("End time must be set to a number.");p=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(w){g=""+w,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return v},set:function(w){v=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return y},set:function(w){let C=r(w);if(C===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return T},set:function(w){T=!!w,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return _},set:function(w){if(typeof w!="number"&&w!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return A},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");A=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return k},set:function(w){if(w<0||w>100)throw new Error("Position must be between 0 and 100.");k=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return R},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");R=C,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return x},set:function(w){if(w<0||w>100)throw new Error("Size must be between 0 and 100.");x=w,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return O},set:function(w){let C=s(w);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");O=C,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),wf=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function hE(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var Df=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function fE(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var Cf=new rm(0,0,""),Ml=Cf.align==="middle"?"middle":"center";function GR(i,e,t){let r=i;function s(){let o=hE(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Df;fE(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Ml,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Ml,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Ml,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&Cf.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Ml);let c=d.get("position","auto");c==="auto"&&Cf.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function mE(i){return i.replace(/<br(?: \/)?>/gi,`
|
|
31
31
|
`)}var Mf=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new wf,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=mE(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
|
|
32
32
|
`;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
|
|
33
33
|
`&&++a,t.buffer=n.slice(a),o}function s(n){fE(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new rm(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{GR(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
@@ -37,11 +37,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
37
37
|
`).split(`
|
|
38
38
|
`),d=[],u=e?xR(e.baseTime,e.timescale):0,c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){let v=t[r],y=t.ccOffset,T=(h-u)/9e4;if(v!=null&&v.new&&(f!==void 0?y=t.ccOffset=v.start:WR(t,r,T)),T){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=T-t.presentationOffset}let _=g.endTime-g.startTime,A=Yt((g.startTime+y-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(A,0),g.endTime=Math.max(A+_,0);let k=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(k)),g.id||(g.id=sm(g.startTime,g.endTime,k)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(Dh(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(v=>{Dh(v,"LOCAL:")?c=v.slice(6):Dh(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{f=VR(c)/1e3}catch(v){m=v}return}else g===""&&(p=!1);o.parse(g+`
|
|
39
39
|
`)}),o.flush()}var Mh="stpp.ttml.im1t",pE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,gE=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,qR={left:"start",center:"center",right:"end",start:"start",end:"end"};function pv(i,e,t,r){let s=he(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Ai(o)),a=SR(e.baseTime,1,e.timescale);try{n.forEach(o=>t(jR(o,a)))}catch(o){r(o)}}function jR(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=gv(Oh(s,"styling","style")),d=gv(Oh(s,"layout","region")),u=Oh(s,"body","[begin]");return[].map.call(u,c=>{let h=vE(c,o);if(!h||!c.hasAttribute("begin"))return null;let f=Nh(c.getAttribute("begin"),a),m=Nh(c.getAttribute("dur"),a),p=Nh(c.getAttribute("end"),a);if(f===null)throw vv(c);if(p===null){if(m===null)throw vv(c);p=f+m}let g=new rm(f-e,p-e,h);g.id=sm(g.startTime,g.endTime,g.text);let v=d[c.getAttribute("region")],y=l[c.getAttribute("style")],T=zR(v,y,l),{textAlign:_}=T;if(_){let A=qR[_];A&&(g.lineAlign=A),g.align=_}return it(g,T),g}).filter(c=>c!==null)}function Oh(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function gv(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function vE(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
|
|
40
|
-
`:(n=r.childNodes)!=null&&n.length?vE(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function zR(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=Ph(e,r,l)||Ph(i,r,l)||Ph(s,r,l);return d&&(o[l]=d),o},{})}function Ph(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function vv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Nh(i,e){if(!i)return null;let t=hE(i);return t===null&&(pE.test(i)?t=XR(i,e):gE.test(i)&&(t=QR(i,e))),t}function XR(i,e){let t=pE.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function QR(i,e){let t=gE.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var Of=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Tv(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new hn(this,"textTrack1"),t=new hn(this,"textTrack2"),r=new hn(this,"textTrack3"),s=new hn(this,"textTrack4");this.cea608Parser1=new ud(1,e,t),this.cea608Parser2=new ud(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=ZR(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(E.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(Ev(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,cn(r[e]),$v(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{cn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Tv(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)cn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===Mh);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(uE(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?Pl(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&Ev(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)cn(u);else{let c=EE(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===se.MAIN){var r,s;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===se.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===Mh?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;pv(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{L.log(`Failed to parse IMSC1: ${s}`),r.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?qt(r.initSegment.data,new Uint8Array(s)):s;YR(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),L.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||pv(t,this.initPTS[e.cc],()=>{r.textCodec=Mh,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Hv(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===se.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===se.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Vh(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Vh(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function EE(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function Ev(i,e){return!!i&&i.kind===EE(e)&&bf(e,i)}function ZR(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function Tv(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Pf=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&j(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},Nf=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Ml="[eme]",cd=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.debug=L.debug.bind(L,Ml),this.log=L.log.bind(L,Ml),this.warn=L.warn.bind(L,Ml),this.error=L.error.bind(L,Ml),this.onMediaEncrypted=t=>{let{initDataType:r,initData:s}=t,n=`"${t.type}" event: init data type: "${r}"`;if(this.debug(n),s!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=Sl(this.config));let o=a.map(Th).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o=vh(a),l,d;if(r==="sinf"){if(o!==ke.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=at(new Uint8Array(s));try{let p=zf(JSON.parse(m).sinf),g=Pv(p);if(!g)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=g.subarray(8,24),d=ke.FAIRPLAY}catch(p){this.warn(`${n} Failed to parse sinf: ${p}`);return}}else{if(o!==ke.WIDEVINE&&o!==ke.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=hx(s),p=m.filter(v=>!!v.systemId&&Eh(v.systemId)===o);p.length>1&&this.warn(`${n} Using first of ${p.length} pssh found for selected key-system ${o}`);let g=p[0];if(!g){m.length===0||m.some(v=>!v.systemId)?this.warn(`${n} contains incomplete or invalid pssh data`):this.log(`ignoring ${n} for ${m.map(v=>Eh(v.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(d=Eh(g.systemId),g.version===0&&g.data)if(d===ke.WIDEVINE){let v=g.data.length-22;l=g.data.subarray(v,v+16)}else d===ke.PLAYREADY&&(l=Iv(g.data))}if(!d||!l){this.log(`Unable to handle ${n} with key-system ${o}`);return}let u=bi.hexDump(l),{keyIdToKeySessionPromise:c,mediaKeySessions:h}=this,f=c[u];for(let m=0;m<h.length;m++){let p=h[m],g=p.decryptdata;if(!g.keyId)continue;let v=bi.hexDump(g.keyId);if(u===v||g.uri.replace(/-/g,"").indexOf(u)!==-1){if(f=c[v],g.pssh)break;delete c[v],g.pssh=new Uint8Array(s),g.keyId=l,f=c[u]=f.then(()=>this.generateRequestWithPreferredKeySession(p,r,s,"encrypted-event-key-match")),f.catch(y=>this.handleError(y));break}}if(!f){if(d!==o){this.log(`Ignoring "${n}" with ${d} init data for selected key-system ${o}`);return}f=c[u]=this.getKeySystemSelectionPromise([d]).then(({keySystem:m,mediaKeys:p})=>{var g;this.throwIfDestroyed();let v=new Pa("ISO-23001-7",u,(g=Th(m))!=null?g:"");return v.pssh=new Uint8Array(s),v.keyId=l,this.attemptSetMediaKeys(m,p).then(()=>{this.throwIfDestroyed();let y=this.createMediaKeySessionContext({decryptdata:v,keySystem:m,mediaKeys:p});return this.generateRequestWithPreferredKeySession(y,r,s,"encrypted-event-no-match")})}),f.catch(m=>this.handleError(m))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===ke.WIDEVINE&&r)return r}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof wt?o(c):o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return Rv===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=HS(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${bi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return bi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${bi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
|
|
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(`
|
|
40
|
+
`:(n=r.childNodes)!=null&&n.length?vE(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function zR(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=Ph(e,r,l)||Ph(i,r,l)||Ph(s,r,l);return d&&(o[l]=d),o},{})}function Ph(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function vv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Nh(i,e){if(!i)return null;let t=hE(i);return t===null&&(pE.test(i)?t=XR(i,e):gE.test(i)&&(t=QR(i,e))),t}function XR(i,e){let t=pE.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function QR(i,e){let t=gE.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var Of=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Tv(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new hn(this,"textTrack1"),t=new hn(this,"textTrack2"),r=new hn(this,"textTrack3"),s=new hn(this,"textTrack4");this.cea608Parser1=new cd(1,e,t),this.cea608Parser2=new cd(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=ZR(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(E.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(Ev(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,cn(r[e]),$v(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{cn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Tv(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)cn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===Mh);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(uE(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?Nl(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&Ev(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)cn(u);else{let c=EE(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===se.MAIN){var r,s;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===se.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===Mh?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;pv(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{L.log(`Failed to parse IMSC1: ${s}`),r.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?qt(r.initSegment.data,new Uint8Array(s)):s;YR(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),L.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||pv(t,this.initPTS[e.cc],()=>{r.textCodec=Mh,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Hv(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===se.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===se.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Vh(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Vh(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function EE(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function Ev(i,e){return!!i&&i.kind===EE(e)&&bf(e,i)}function ZR(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function Tv(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Pf=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&j(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},Nf=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Ol="[eme]",hd=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.debug=L.debug.bind(L,Ol),this.log=L.log.bind(L,Ol),this.warn=L.warn.bind(L,Ol),this.error=L.error.bind(L,Ol),this.onMediaEncrypted=t=>{let{initDataType:r,initData:s}=t,n=`"${t.type}" event: init data type: "${r}"`;if(this.debug(n),s!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=xl(this.config));let o=a.map(Th).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o=vh(a),l,d;if(r==="sinf"){if(o!==ke.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=at(new Uint8Array(s));try{let p=zf(JSON.parse(m).sinf),g=Pv(p);if(!g)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=g.subarray(8,24),d=ke.FAIRPLAY}catch(p){this.warn(`${n} Failed to parse sinf: ${p}`);return}}else{if(o!==ke.WIDEVINE&&o!==ke.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${r}" for selected key-system ${o}`);return}let m=hx(s),p=m.filter(v=>!!v.systemId&&Eh(v.systemId)===o);p.length>1&&this.warn(`${n} Using first of ${p.length} pssh found for selected key-system ${o}`);let g=p[0];if(!g){m.length===0||m.some(v=>!v.systemId)?this.warn(`${n} contains incomplete or invalid pssh data`):this.log(`ignoring ${n} for ${m.map(v=>Eh(v.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(d=Eh(g.systemId),g.version===0&&g.data)if(d===ke.WIDEVINE){let v=g.data.length-22;l=g.data.subarray(v,v+16)}else d===ke.PLAYREADY&&(l=Iv(g.data))}if(!d||!l){this.log(`Unable to handle ${n} with key-system ${o}`);return}let u=bi.hexDump(l),{keyIdToKeySessionPromise:c,mediaKeySessions:h}=this,f=c[u];for(let m=0;m<h.length;m++){let p=h[m],g=p.decryptdata;if(!g.keyId)continue;let v=bi.hexDump(g.keyId);if(u===v||g.uri.replace(/-/g,"").indexOf(u)!==-1){if(f=c[v],g.pssh)break;delete c[v],g.pssh=new Uint8Array(s),g.keyId=l,f=c[u]=f.then(()=>this.generateRequestWithPreferredKeySession(p,r,s,"encrypted-event-key-match")),f.catch(y=>this.handleError(y));break}}if(!f){if(d!==o){this.log(`Ignoring "${n}" with ${d} init data for selected key-system ${o}`);return}f=c[u]=this.getKeySystemSelectionPromise([d]).then(({keySystem:m,mediaKeys:p})=>{var g;this.throwIfDestroyed();let v=new Pa("ISO-23001-7",u,(g=Th(m))!=null?g:"");return v.pssh=new Uint8Array(s),v.keyId=l,this.attemptSetMediaKeys(m,p).then(()=>{this.throwIfDestroyed();let y=this.createMediaKeySessionContext({decryptdata:v,keySystem:m,mediaKeys:p});return this.generateRequestWithPreferredKeySession(y,r,s,"encrypted-event-no-match")})}),f.catch(m=>this.handleError(m))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===ke.WIDEVINE&&r)return r}getLicenseServerUrlOrThrow(e){let t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof wt?o(c):o(new wt({type:ne.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return Rv===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=HS(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${bi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return bi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${bi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
|
|
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=xl(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]:xl(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=xl(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}`)})}}};hd.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}},fd=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 fd)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 Hl=i=>Math.round(i),RI=(i,e)=>(e!=null&&e.baseUrl&&(i=SI(i,e.baseUrl)),encodeURIComponent(i)),Pl=i=>Hl(i/100)*100,II={br:Hl,d:Hl,bl:Pl,dl:Pl,mtp:Pl,nor:RI,rtp:Pl,tb:Hl};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 fd(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,md=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};Zl(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(Zl(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+)/,pd=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 td,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:md,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:hd,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!==pd&&e!==md?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):NI()&&(i.loader=pd,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=jl(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 zl.indexOf(m.videoRange)-zl.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=ql(m.codecSet),v=ql(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,Gl=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>Gl,v=!c||t&&t.start<=a||c-a>Gl&&!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:Gl,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 ld(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&&_>Gl&&(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 yd=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},_d=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}`;Ad(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 Ad(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=Ad(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},Td=(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]=yd((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,vd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},_L=i=>{if(i.includes("fps"))return vd.FAIRPLAY;if(i.includes("playready"))return vd.PLAYREADY;if(i.includes("widevine"))return vd.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=_d({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,Sd=()=>Al.utils.now(),NL=Al.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=""]=yd(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()},xd=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},Rd=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=xd(i.playbackId))!=null?t:Rd(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},bd=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},Id=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=Id(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=_d(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=_d(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=xd(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Ed(i,"fairplay"),serverCertificateUrl:rT(i,"fairplay")},"com.widevine.alpha":{licenseUrl:Ed(i,"widevine")},"com.microsoft.playready":{licenseUrl:Ed(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,vd.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=Td(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,Ed(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=Td(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}})},Ed=({playbackId:i,tokens:{drm:e}={},customDomain:t=er},r)=>{let s=xd(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=xd(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=Al,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=Id(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=_d(i);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=Rd(a),g=new URL(`https://stream.${o}/${p}/metadata.json`);ym(g.toString(),e)}let f=()=>{if(bd(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=Td(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(),bd(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=Td(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}
|
|
@@ -92,9 +92,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
92
92
|
<video${gT(i)}></video>
|
|
93
93
|
</slot>
|
|
94
94
|
<slot></slot>
|
|
95
|
-
`}function pT(i,{tag:e,is:t}){var n,a,o,l,d,cT,c,h,f,m,p,vs,Rm,hT,Im,fT,mT;let r=(a=(n=globalThis.document)==null?void 0:n.createElement)==null?void 0:a.call(n,e,{is:t}),s=r?QL(r):[];return o=class extends i{constructor(){super(...arguments);ie(this,p);ie(this,c,!1);ie(this,h,null);ie(this,f,new Map);ie(this,m);Te(this,"get");Te(this,"set");Te(this,"call")}static get observedAttributes(){var O,w,C;return Ce(O=o,d,cT).call(O),[...(C=(w=r==null?void 0:r.constructor)==null?void 0:w.observedAttributes)!=null?C:[],...uT]}get nativeEl(){var x,O,w,C,P;return Ce(this,p,vs).call(this),(P=(C=(O=(x=I(this,h))!=null?x:this.querySelector(":scope > [slot=media]"))!=null?O:this.querySelector(e))!=null?C:(w=this.shadowRoot)==null?void 0:w.querySelector(e))!=null?P:null}set nativeEl(x){Z(this,h,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,O;return(O=this.getAttribute("preload"))!=null?O:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});let x=ZL(this.attributes);t&&(x.is=t),e&&(x.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(x)}this.nativeEl.muted=this.hasAttribute("muted");for(let x of s)Ce(this,p,fT).call(this,x);Z(this,m,new MutationObserver(Ce(this,p,hT).bind(this))),this.shadowRoot.addEventListener("slotchange",()=>Ce(this,p,Rm).call(this)),Ce(this,p,Rm).call(this);for(let x of this.constructor.Events)this.shadowRoot.addEventListener(x,this,!0)}handleEvent(x){x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,O,w){Ce(this,p,vs).call(this),Ce(this,p,mT).call(this,x,O,w)}connectedCallback(){Ce(this,p,vs).call(this)}},l=new WeakMap,d=new WeakSet,cT=function(){if(I(this,l))return;Z(this,l,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let O of s)if(!(O in this.prototype))if(typeof r[O]=="function")this.prototype[O]=function(...w){return Ce(this,p,vs).call(this),(()=>{var U;if(this.call)return this.call(O,...w);let P=(U=this.nativeEl)==null?void 0:U[O];return P==null?void 0:P.apply(this.nativeEl,w)})()};else{let w={get(){var P,U,X;Ce(this,p,vs).call(this);let C=O.toLowerCase();if(x.has(C)){let z=this.getAttribute(C);return z===null?!1:z===""?!0:z}return(X=(P=this.get)==null?void 0:P.call(this,O))!=null?X:(U=this.nativeEl)==null?void 0:U[O]}};O!==O.toUpperCase()&&(w.set=function(C){Ce(this,p,vs).call(this);let P=O.toLowerCase();if(x.has(P)){C===!0||C===!1||C==null?this.toggleAttribute(P,!!C):this.setAttribute(P,C);return}if(this.set){this.set(O,C);return}this.nativeEl&&(this.nativeEl[O]=C)}),Object.defineProperty(this.prototype,O,w)}},c=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakSet,vs=function(){I(this,c)||(Z(this,c,!0),this.init())},Rm=function(){var C;let x=new Map(I(this,f)),O=(C=this.shadowRoot)==null?void 0:C.querySelector("slot:not([name])");(O==null?void 0:O.assignedElements({flatten:!0}).filter(P=>["track","source"].includes(P.localName))).forEach(P=>{var X,z;x.delete(P);let U=I(this,f).get(P);U||(U=P.cloneNode(),I(this,f).set(P,U),(X=I(this,m))==null||X.observe(P,{attributes:!0})),(z=this.nativeEl)==null||z.append(U),Ce(this,p,Im).call(this,U)}),x.forEach((P,U)=>{P.remove(),I(this,f).delete(U)})},hT=function(x){var O;for(let w of x)if(w.type==="attributes"){let{target:C,attributeName:P}=w,U=I(this,f).get(C);U&&P&&(U.setAttribute(P,(O=C.getAttribute(P))!=null?O:""),Ce(this,p,Im).call(this,U))}},Im=function(x){x&&x.localName==="track"&&x.default&&(x.kind==="chapters"||x.kind==="metadata")&&x.track.mode==="disabled"&&(x.track.mode="hidden")},fT=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let O=this[x];delete this[x],this[x]=O}},mT=function(x,O,w){var C,P,U;["id","class"].includes(x)||!o.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(w===null?(C=this.nativeEl)==null||C.removeAttribute(x):((P=this.nativeEl)==null?void 0:P.getAttribute(x))!==w&&((U=this.nativeEl)==null||U.setAttribute(x,w)))},ie(o,d),Te(o,"getTemplateHTML",e.endsWith("audio")?zL:XL),Te(o,"shadowRootOptions",{mode:"open"}),Te(o,"Events",dT),ie(o,l,!1),o}function QL(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){let r=Object.getOwnPropertyNames(t);e.push(...r)}return e}function gT(i){let e="";for(let t in i){if(!uT.includes(t))continue;let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function ZL(i){let e={};for(let t of i)e[t.name]=t.value;return e}var oT,
|
|
96
|
-
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" part="logo" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" viewBox="0 0 1600 500"><g fill="#fff"><path d="M994.287 93.486c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m0-93.486c-34.509 0-62.484 27.976-62.484 62.486v187.511c0 68.943-56.09 125.033-125.032 125.033s-125.03-56.09-125.03-125.033V62.486C681.741 27.976 653.765 0 619.256 0s-62.484 27.976-62.484 62.486v187.511C556.772 387.85 668.921 500 806.771 500c137.851 0 250.001-112.15 250.001-250.003V62.486c0-34.51-27.976-62.486-62.485-62.486M1537.51 468.511c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m-275.883-218.509-143.33 143.329c-24.402 24.402-24.402 63.966 0 88.368 24.402 24.402 63.967 24.402 88.369 0l143.33-143.329 143.328 143.329c24.402 24.4 63.967 24.402 88.369 0 24.403-24.402 24.403-63.966.001-88.368l-143.33-143.329.001-.004 143.329-143.329c24.402-24.402 24.402-63.965 0-88.367s-63.967-24.402-88.369 0L1349.996 161.63 1206.667 18.302c-24.402-24.401-63.967-24.402-88.369 0s-24.402 63.965 0 88.367l143.329 143.329v.004ZM437.511 468.521c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31M461.426 4.759C438.078-4.913 411.2.432 393.33 18.303L249.999 161.632 106.669 18.303C88.798.432 61.922-4.913 38.573 4.759 15.224 14.43-.001 37.214-.001 62.488v375.026c0 34.51 27.977 62.486 62.487 62.486 34.51 0 62.486-27.976 62.486-62.486V213.341l80.843 80.844c24.404 24.402 63.965 24.402 88.369 0l80.843-80.844v224.173c0 34.51 27.976 62.486 62.486 62.486s62.486-27.976 62.486-62.486V62.488c0-25.274-15.224-48.058-38.573-57.729" style="fill-rule:nonzero"/></g></svg>`,D={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",PLAYBACK_TOKEN:"playback-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",ASSET_START_TIME:"asset-start-time",ASSET_END_TIME:"asset-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_INIT_TIME:"player-init-time",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type",LOGO:"logo"},rk=Object.values(D),vT=tk(),ET="mux-video",xi,
|
|
97
|
-
${
|
|
95
|
+
`}function pT(i,{tag:e,is:t}){var n,a,o,l,d,cT,c,h,f,m,p,vs,Rm,hT,Im,fT,mT;let r=(a=(n=globalThis.document)==null?void 0:n.createElement)==null?void 0:a.call(n,e,{is:t}),s=r?QL(r):[];return o=class extends i{constructor(){super(...arguments);ie(this,p);ie(this,c,!1);ie(this,h,null);ie(this,f,new Map);ie(this,m);Te(this,"get");Te(this,"set");Te(this,"call")}static get observedAttributes(){var O,w,C;return Ce(O=o,d,cT).call(O),[...(C=(w=r==null?void 0:r.constructor)==null?void 0:w.observedAttributes)!=null?C:[],...uT]}get nativeEl(){var x,O,w,C,P;return Ce(this,p,vs).call(this),(P=(C=(O=(x=I(this,h))!=null?x:this.querySelector(":scope > [slot=media]"))!=null?O:this.querySelector(e))!=null?C:(w=this.shadowRoot)==null?void 0:w.querySelector(e))!=null?P:null}set nativeEl(x){Z(this,h,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,O;return(O=this.getAttribute("preload"))!=null?O:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});let x=ZL(this.attributes);t&&(x.is=t),e&&(x.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(x)}this.nativeEl.muted=this.hasAttribute("muted");for(let x of s)Ce(this,p,fT).call(this,x);Z(this,m,new MutationObserver(Ce(this,p,hT).bind(this))),this.shadowRoot.addEventListener("slotchange",()=>Ce(this,p,Rm).call(this)),Ce(this,p,Rm).call(this);for(let x of this.constructor.Events)this.shadowRoot.addEventListener(x,this,!0)}handleEvent(x){x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,O,w){Ce(this,p,vs).call(this),Ce(this,p,mT).call(this,x,O,w)}connectedCallback(){Ce(this,p,vs).call(this)}},l=new WeakMap,d=new WeakSet,cT=function(){if(I(this,l))return;Z(this,l,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let O of s)if(!(O in this.prototype))if(typeof r[O]=="function")this.prototype[O]=function(...w){return Ce(this,p,vs).call(this),(()=>{var U;if(this.call)return this.call(O,...w);let P=(U=this.nativeEl)==null?void 0:U[O];return P==null?void 0:P.apply(this.nativeEl,w)})()};else{let w={get(){var P,U,X;Ce(this,p,vs).call(this);let C=O.toLowerCase();if(x.has(C)){let z=this.getAttribute(C);return z===null?!1:z===""?!0:z}return(X=(P=this.get)==null?void 0:P.call(this,O))!=null?X:(U=this.nativeEl)==null?void 0:U[O]}};O!==O.toUpperCase()&&(w.set=function(C){Ce(this,p,vs).call(this);let P=O.toLowerCase();if(x.has(P)){C===!0||C===!1||C==null?this.toggleAttribute(P,!!C):this.setAttribute(P,C);return}if(this.set){this.set(O,C);return}this.nativeEl&&(this.nativeEl[O]=C)}),Object.defineProperty(this.prototype,O,w)}},c=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakSet,vs=function(){I(this,c)||(Z(this,c,!0),this.init())},Rm=function(){var C;let x=new Map(I(this,f)),O=(C=this.shadowRoot)==null?void 0:C.querySelector("slot:not([name])");(O==null?void 0:O.assignedElements({flatten:!0}).filter(P=>["track","source"].includes(P.localName))).forEach(P=>{var X,z;x.delete(P);let U=I(this,f).get(P);U||(U=P.cloneNode(),I(this,f).set(P,U),(X=I(this,m))==null||X.observe(P,{attributes:!0})),(z=this.nativeEl)==null||z.append(U),Ce(this,p,Im).call(this,U)}),x.forEach((P,U)=>{P.remove(),I(this,f).delete(U)})},hT=function(x){var O;for(let w of x)if(w.type==="attributes"){let{target:C,attributeName:P}=w,U=I(this,f).get(C);U&&P&&(U.setAttribute(P,(O=C.getAttribute(P))!=null?O:""),Ce(this,p,Im).call(this,U))}},Im=function(x){x&&x.localName==="track"&&x.default&&(x.kind==="chapters"||x.kind==="metadata")&&x.track.mode==="disabled"&&(x.track.mode="hidden")},fT=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let O=this[x];delete this[x],this[x]=O}},mT=function(x,O,w){var C,P,U;["id","class"].includes(x)||!o.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(w===null?(C=this.nativeEl)==null||C.removeAttribute(x):((P=this.nativeEl)==null?void 0:P.getAttribute(x))!==w&&((U=this.nativeEl)==null||U.setAttribute(x,w)))},ie(o,d),Te(o,"getTemplateHTML",e.endsWith("audio")?zL:XL),Te(o,"shadowRootOptions",{mode:"open"}),Te(o,"Events",dT),ie(o,l,!1),o}function QL(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){let r=Object.getOwnPropertyNames(t);e.push(...r)}return e}function gT(i){let e="";for(let t in i){if(!uT.includes(t))continue;let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function ZL(i){let e={};for(let t of i)e[t.name]=t.value;return e}var oT,Xa=pT((oT=globalThis.HTMLElement)!=null?oT:class{},{tag:"video"}),lT,LM=pT((lT=globalThis.HTMLElement)!=null?lT:class{},{tag:"audio"});var TT=i=>{throw TypeError(i)},km=(i,e,t)=>e.has(i)||TT("Cannot "+t),bt=(i,e,t)=>(km(i,e,"read from private field"),t?t.call(i):e.get(i)),ui=(i,e,t)=>e.has(i)?TT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Xt=(i,e,t,r)=>(km(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Lm=(i,e,t)=>(km(i,e,"access private method"),t),JL=()=>{try{return"0.25.3"}catch{}return"UNKNOWN"},ek=JL(),tk=()=>ek,ik=`
|
|
96
|
+
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" part="logo" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" viewBox="0 0 1600 500"><g fill="#fff"><path d="M994.287 93.486c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m0-93.486c-34.509 0-62.484 27.976-62.484 62.486v187.511c0 68.943-56.09 125.033-125.032 125.033s-125.03-56.09-125.03-125.033V62.486C681.741 27.976 653.765 0 619.256 0s-62.484 27.976-62.484 62.486v187.511C556.772 387.85 668.921 500 806.771 500c137.851 0 250.001-112.15 250.001-250.003V62.486c0-34.51-27.976-62.486-62.485-62.486M1537.51 468.511c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31m-275.883-218.509-143.33 143.329c-24.402 24.402-24.402 63.966 0 88.368 24.402 24.402 63.967 24.402 88.369 0l143.33-143.329 143.328 143.329c24.402 24.4 63.967 24.402 88.369 0 24.403-24.402 24.403-63.966.001-88.368l-143.33-143.329.001-.004 143.329-143.329c24.402-24.402 24.402-63.965 0-88.367s-63.967-24.402-88.369 0L1349.996 161.63 1206.667 18.302c-24.402-24.401-63.967-24.402-88.369 0s-24.402 63.965 0 88.367l143.329 143.329v.004ZM437.511 468.521c-17.121 0-31-13.879-31-31 0-17.121 13.879-31 31-31 17.121 0 31 13.879 31 31 0 17.121-13.879 31-31 31M461.426 4.759C438.078-4.913 411.2.432 393.33 18.303L249.999 161.632 106.669 18.303C88.798.432 61.922-4.913 38.573 4.759 15.224 14.43-.001 37.214-.001 62.488v375.026c0 34.51 27.977 62.486 62.487 62.486 34.51 0 62.486-27.976 62.486-62.486V213.341l80.843 80.844c24.404 24.402 63.965 24.402 88.369 0l80.843-80.844v224.173c0 34.51 27.976 62.486 62.486 62.486s62.486-27.976 62.486-62.486V62.488c0-25.274-15.224-48.058-38.573-57.729" style="fill-rule:nonzero"/></g></svg>`,D={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",PLAYBACK_TOKEN:"playback-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",ASSET_START_TIME:"asset-start-time",ASSET_END_TIME:"asset-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_INIT_TIME:"player-init-time",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type",LOGO:"logo"},rk=Object.values(D),vT=tk(),ET="mux-video",xi,Qa,Ld,Za,kd,wd,Dd,Cd,Md,Ja,eo,Od,bT=class extends Xa{constructor(){super(),ui(this,eo),ui(this,xi),ui(this,Qa),ui(this,Ld),ui(this,Za,{}),ui(this,kd,{}),ui(this,wd),ui(this,Dd),ui(this,Cd),ui(this,Md),ui(this,Ja,""),Xt(this,Ld,Sd()),this.nativeEl.addEventListener("muxmetadata",i=>{var e;let t=XE(this.nativeEl),r=(e=this.metadata)!=null?e:{};this.metadata={...t,...r},(t==null?void 0:t["com.mux.video.branding"])==="mux-free-plan"&&(Xt(this,Ja,"default"),this.updateLogo())})}static get NAME(){return ET}static get VERSION(){return vT}static get observedAttributes(){var i;return[...rk,...(i=Xa.observedAttributes)!=null?i:[]]}static getLogoHTML(i){return!i||i==="false"?"":i==="default"?ik:`<img part="logo" src="${i}" />`}static getTemplateHTML(i={}){var e;return`
|
|
97
|
+
${Xa.getTemplateHTML(i)}
|
|
98
98
|
<style>
|
|
99
99
|
:host {
|
|
100
100
|
position: relative;
|
|
@@ -121,16 +121,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
121
121
|
<slot name="logo">
|
|
122
122
|
${this.getLogoHTML((e=i[D.LOGO])!=null?e:"")}
|
|
123
123
|
</slot>
|
|
124
|
-
`}get preferCmcd(){var i;return(i=this.getAttribute(D.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?vn.includes(i)?this.setAttribute(D.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${vn.join()}`):this.removeAttribute(D.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(D.PLAYER_INIT_TIME)?+this.getAttribute(D.PLAYER_INIT_TIME):bt(this,Ld)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(D.PLAYER_INIT_TIME):this.setAttribute(D.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=bt(this,Cd))!=null?i:ET}set playerSoftwareName(i){Xt(this,Cd,i)}get playerSoftwareVersion(){var i;return(i=bt(this,Dd))!=null?i:vT}set playerSoftwareVersion(i){Xt(this,Dd,i)}get _hls(){var i;return(i=bt(this,xi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=_m(this.nativeEl))!=null?i:null}get errorTranslator(){return bt(this,Md)}set errorTranslator(i){Xt(this,Md,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(D.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(D.TYPE,i):this.removeAttribute(D.TYPE))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(D.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(D.DEBUG,""):this.removeAttribute(D.DEBUG))}get disableTracking(){return this.hasAttribute(D.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(D.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(D.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(D.DISABLE_COOKIES,""):this.removeAttribute(D.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(D.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(D.START_TIME):this.setAttribute(D.START_TIME,`${i}`))}get playbackId(){var i;return this.hasAttribute(D.PLAYBACK_ID)?this.getAttribute(D.PLAYBACK_ID):(i=xd(this.src))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(D.PLAYBACK_ID,i):this.removeAttribute(D.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(D.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(D.MAX_RESOLUTION,i):this.removeAttribute(D.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(D.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(D.MIN_RESOLUTION,i):this.removeAttribute(D.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(D.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(D.RENDITION_ORDER,i):this.removeAttribute(D.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(D.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(D.PROGRAM_START_TIME):this.setAttribute(D.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(D.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(D.PROGRAM_END_TIME):this.setAttribute(D.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){let i=this.getAttribute(D.ASSET_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetStartTime(i){i==null?this.removeAttribute(D.ASSET_START_TIME):this.setAttribute(D.ASSET_START_TIME,`${i}`)}get assetEndTime(){let i=this.getAttribute(D.ASSET_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetEndTime(i){i==null?this.removeAttribute(D.ASSET_END_TIME):this.setAttribute(D.ASSET_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(D.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(D.CUSTOM_DOMAIN,i):this.removeAttribute(D.CUSTOM_DOMAIN))}get drmToken(){var i;return(i=this.getAttribute(D.DRM_TOKEN))!=null?i:void 0}set drmToken(i){i!==this.drmToken&&(i?this.setAttribute(D.DRM_TOKEN,i):this.removeAttribute(D.DRM_TOKEN))}get playbackToken(){var i,e,t,r;if(this.hasAttribute(D.PLAYBACK_TOKEN))return(i=this.getAttribute(D.PLAYBACK_TOKEN))!=null?i:void 0;if(this.hasAttribute(D.PLAYBACK_ID)){let[,s]=bd((e=this.playbackId)!=null?e:"");return(t=new URLSearchParams(s).get("token"))!=null?t:void 0}if(this.src)return(r=new URLSearchParams(this.src).get("token"))!=null?r:void 0}set playbackToken(i){i!==this.playbackToken&&(i?this.setAttribute(D.PLAYBACK_TOKEN,i):this.removeAttribute(D.PLAYBACK_TOKEN))}get tokens(){let i=this.getAttribute(D.PLAYBACK_TOKEN),e=this.getAttribute(D.DRM_TOKEN);return{...bt(this,kd),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{}}}set tokens(i){Xt(this,kd,i!=null?i:{})}get ended(){return Sm(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(D.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(D.ENV_KEY,i):this.removeAttribute(D.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(D.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(D.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(D.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(D.STREAM_TYPE))!=null?i:Td(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(D.STREAM_TYPE,i):this.removeAttribute(D.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(D.TARGET_LIVE_WINDOW)?+this.getAttribute(D.TARGET_LIVE_WINDOW):QE(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(D.TARGET_LIVE_WINDOW):this.setAttribute(D.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(D.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return ZE(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(D.LIVE_EDGE_OFFSET))return+this.getAttribute(D.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.liveEdgeOffset&&(i==null?this.removeAttribute(D.LIVE_EDGE_OFFSET):this.setAttribute(D.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return Rd(this.nativeEl)}async addCuePoints(i){return gm(this.nativeEl,i)}get activeCuePoint(){return vm(this.nativeEl)}get cuePoints(){return GE(this.nativeEl)}async addChapters(i){return Tm(this.nativeEl,i)}get activeChapter(){return bm(this.nativeEl)}get chapters(){return VE(this.nativeEl)}getStartDate(){return WE(this.nativeEl,this._hls)}get currentPdt(){return YE(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(D.PREFER_PLAYBACK);if(i===zt.MSE||i===zt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===zt.MSE||i===zt.NATIVE?this.setAttribute(D.PREFER_PLAYBACK,i):this.removeAttribute(D.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![D.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...bt(this,Qa)}}set metadata(i){Xt(this,Qa,i!=null?i:{}),this.mux&&this.mux.emit("hb",bt(this,Qa))}get _hlsConfig(){return bt(this,wd)}set _hlsConfig(i){Xt(this,wd,i)}get logo(){var i;return(i=this.getAttribute(D.LOGO))!=null?i:bt(this,Za)}set logo(i){i?this.setAttribute(D.LOGO,i):this.removeAttribute(D.LOGO)}load(){Xt(this,xi,tT(this,this.nativeEl,bt(this,xi)))}unload(){xm(this.nativeEl,bt(this,xi),this),Xt(this,xi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(Id.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case D.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case D.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Lm(this,Ja,Od).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Lm(this,Ja,Od).call(this));break}case"autoplay":if(t===e)break;(r=bt(this,xi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=bt(this,xi))==null||s.setPreload(t);break;case D.PLAYBACK_ID:this.src=za(this);break;case D.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case D.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case D.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case D.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;case D.LOGO:(t==null||t!==e)&&this.updateLogo();break}}updateLogo(){if(!this.shadowRoot)return;let i=this.shadowRoot.querySelector('slot[name="logo"]');if(!i)return;let e=this.constructor.getLogoHTML(bt(this,Za)||this.logo);i.innerHTML=e}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!bt(this,xi)&&Lm(this,Ja,Od).call(this)}disconnectedCallback(){this.unload()}handleEvent(i){i.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(i.type,{composed:!0,detail:i.detail}))}};xi=new WeakMap,Xa=new WeakMap,Ld=new WeakMap,Qa=new WeakMap,kd=new WeakMap,wd=new WeakMap,Dd=new WeakMap,Cd=new WeakMap,Md=new WeakMap,Za=new WeakMap,Ja=new WeakSet,Od=async function(){bt(this,Xa)||(await Xt(this,Xa,Promise.resolve()),Xt(this,Xa,null),this.load())};var tr=new WeakMap,En=class extends Error{},Pd=class extends Error{};var sk=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],yT=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function _T(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function AT(){return globalThis.chrome}function ST(){var t;let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((t=globalThis.chrome)!=null&&t.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function ir(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function eo(){var i;return(i=ir())==null?void 0:i.getCurrentSession()}function Nd(){var i;return(i=eo())==null?void 0:i.getSessionObj().media[0]}function xT(i){return new Promise((e,t)=>{Nd().editTracksInfo(i,e,t)})}function RT(i){return new Promise((e,t)=>{Nd().getStatus(i,e,t)})}function wm(i){return ir().setOptions({...Dm(),...i})}function Dm(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}function nk(i){if(!i)return;let e=/\.([a-zA-Z0-9]+)(?:\?.*)?$/,t=i.match(e);return t?t[1]:null}function ak(i){let e=i.split(`
|
|
124
|
+
`}get preferCmcd(){var i;return(i=this.getAttribute(D.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?vn.includes(i)?this.setAttribute(D.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${vn.join()}`):this.removeAttribute(D.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(D.PLAYER_INIT_TIME)?+this.getAttribute(D.PLAYER_INIT_TIME):bt(this,Ld)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(D.PLAYER_INIT_TIME):this.setAttribute(D.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=bt(this,Cd))!=null?i:ET}set playerSoftwareName(i){Xt(this,Cd,i)}get playerSoftwareVersion(){var i;return(i=bt(this,Dd))!=null?i:vT}set playerSoftwareVersion(i){Xt(this,Dd,i)}get _hls(){var i;return(i=bt(this,xi))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=_m(this.nativeEl))!=null?i:null}get errorTranslator(){return bt(this,Md)}set errorTranslator(i){Xt(this,Md,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(D.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(D.TYPE,i):this.removeAttribute(D.TYPE))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(D.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(D.DEBUG,""):this.removeAttribute(D.DEBUG))}get disableTracking(){return this.hasAttribute(D.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(D.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(D.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(D.DISABLE_COOKIES,""):this.removeAttribute(D.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(D.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(D.START_TIME):this.setAttribute(D.START_TIME,`${i}`))}get playbackId(){var i;return this.hasAttribute(D.PLAYBACK_ID)?this.getAttribute(D.PLAYBACK_ID):(i=Rd(this.src))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(D.PLAYBACK_ID,i):this.removeAttribute(D.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(D.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(D.MAX_RESOLUTION,i):this.removeAttribute(D.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(D.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(D.MIN_RESOLUTION,i):this.removeAttribute(D.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(D.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(D.RENDITION_ORDER,i):this.removeAttribute(D.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(D.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(D.PROGRAM_START_TIME):this.setAttribute(D.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(D.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(D.PROGRAM_END_TIME):this.setAttribute(D.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){let i=this.getAttribute(D.ASSET_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetStartTime(i){i==null?this.removeAttribute(D.ASSET_START_TIME):this.setAttribute(D.ASSET_START_TIME,`${i}`)}get assetEndTime(){let i=this.getAttribute(D.ASSET_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set assetEndTime(i){i==null?this.removeAttribute(D.ASSET_END_TIME):this.setAttribute(D.ASSET_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(D.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(D.CUSTOM_DOMAIN,i):this.removeAttribute(D.CUSTOM_DOMAIN))}get drmToken(){var i;return(i=this.getAttribute(D.DRM_TOKEN))!=null?i:void 0}set drmToken(i){i!==this.drmToken&&(i?this.setAttribute(D.DRM_TOKEN,i):this.removeAttribute(D.DRM_TOKEN))}get playbackToken(){var i,e,t,r;if(this.hasAttribute(D.PLAYBACK_TOKEN))return(i=this.getAttribute(D.PLAYBACK_TOKEN))!=null?i:void 0;if(this.hasAttribute(D.PLAYBACK_ID)){let[,s]=yd((e=this.playbackId)!=null?e:"");return(t=new URLSearchParams(s).get("token"))!=null?t:void 0}if(this.src)return(r=new URLSearchParams(this.src).get("token"))!=null?r:void 0}set playbackToken(i){i!==this.playbackToken&&(i?this.setAttribute(D.PLAYBACK_TOKEN,i):this.removeAttribute(D.PLAYBACK_TOKEN))}get tokens(){let i=this.getAttribute(D.PLAYBACK_TOKEN),e=this.getAttribute(D.DRM_TOKEN);return{...bt(this,kd),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{}}}set tokens(i){Xt(this,kd,i!=null?i:{})}get ended(){return Sm(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(D.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(D.ENV_KEY,i):this.removeAttribute(D.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(D.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(D.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(D.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(D.STREAM_TYPE))!=null?i:bd(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(D.STREAM_TYPE,i):this.removeAttribute(D.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(D.TARGET_LIVE_WINDOW)?+this.getAttribute(D.TARGET_LIVE_WINDOW):QE(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(D.TARGET_LIVE_WINDOW):this.setAttribute(D.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(D.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return ZE(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(D.LIVE_EDGE_OFFSET))return+this.getAttribute(D.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.liveEdgeOffset&&(i==null?this.removeAttribute(D.LIVE_EDGE_OFFSET):this.setAttribute(D.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return Id(this.nativeEl)}async addCuePoints(i){return gm(this.nativeEl,i)}get activeCuePoint(){return vm(this.nativeEl)}get cuePoints(){return GE(this.nativeEl)}async addChapters(i){return Tm(this.nativeEl,i)}get activeChapter(){return bm(this.nativeEl)}get chapters(){return VE(this.nativeEl)}getStartDate(){return WE(this.nativeEl,this._hls)}get currentPdt(){return YE(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(D.PREFER_PLAYBACK);if(i===zt.MSE||i===zt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===zt.MSE||i===zt.NATIVE?this.setAttribute(D.PREFER_PLAYBACK,i):this.removeAttribute(D.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![D.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...bt(this,Za)}}set metadata(i){Xt(this,Za,i!=null?i:{}),this.mux&&this.mux.emit("hb",bt(this,Za))}get _hlsConfig(){return bt(this,wd)}set _hlsConfig(i){Xt(this,wd,i)}get logo(){var i;return(i=this.getAttribute(D.LOGO))!=null?i:bt(this,Ja)}set logo(i){i?this.setAttribute(D.LOGO,i):this.removeAttribute(D.LOGO)}load(){Xt(this,xi,tT(this,this.nativeEl,bt(this,xi)))}unload(){xm(this.nativeEl,bt(this,xi),this),Xt(this,xi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(Xa.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case D.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case D.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Lm(this,eo,Od).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Lm(this,eo,Od).call(this));break}case"autoplay":if(t===e)break;(r=bt(this,xi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=bt(this,xi))==null||s.setPreload(t);break;case D.PLAYBACK_ID:this.src=za(this);break;case D.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case D.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case D.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case D.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;case D.LOGO:(t==null||t!==e)&&this.updateLogo();break}}updateLogo(){if(!this.shadowRoot)return;let i=this.shadowRoot.querySelector('slot[name="logo"]');if(!i)return;let e=this.constructor.getLogoHTML(bt(this,Ja)||this.logo);i.innerHTML=e}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!bt(this,xi)&&Lm(this,eo,Od).call(this)}disconnectedCallback(){this.unload()}handleEvent(i){i.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(i.type,{composed:!0,detail:i.detail}))}};xi=new WeakMap,Qa=new WeakMap,Ld=new WeakMap,Za=new WeakMap,kd=new WeakMap,wd=new WeakMap,Dd=new WeakMap,Cd=new WeakMap,Md=new WeakMap,Ja=new WeakMap,eo=new WeakSet,Od=async function(){bt(this,Qa)||(await Xt(this,Qa,Promise.resolve()),Xt(this,Qa,null),this.load())};var tr=new WeakMap,En=class extends Error{},Pd=class extends Error{};var sk=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],yT=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function _T(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function AT(){return globalThis.chrome}function ST(){var t;let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((t=globalThis.chrome)!=null&&t.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function ir(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function to(){var i;return(i=ir())==null?void 0:i.getCurrentSession()}function Nd(){var i;return(i=to())==null?void 0:i.getSessionObj().media[0]}function xT(i){return new Promise((e,t)=>{Nd().editTracksInfo(i,e,t)})}function RT(i){return new Promise((e,t)=>{Nd().getStatus(i,e,t)})}function wm(i){return ir().setOptions({...Dm(),...i})}function Dm(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}function nk(i){if(!i)return;let e=/\.([a-zA-Z0-9]+)(?:\?.*)?$/,t=i.match(e);return t?t[1]:null}function ak(i){let e=i.split(`
|
|
125
125
|
`),t=[];for(let r=0;r<e.length;r++)if(e[r].trim().startsWith("#EXT-X-STREAM-INF")){let n=e[r+1]?e[r+1].trim():"";n&&!n.startsWith("#")&&t.push(n)}return t}function ok(i){return i.split(`
|
|
126
|
-
`).find(r=>!r.trim().startsWith("#")&&r.trim()!=="")}async function IT(i){try{let t=(await fetch(i,{method:"HEAD"})).headers.get("Content-Type");return sk.some(r=>t===r)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function LT(i){try{let e=await(await fetch(i)).text(),t=e,r=ak(e);if(r.length>0){let a=new URL(r[0],i).toString();t=await(await fetch(a)).text()}let s=ok(t);return nk(s)}catch(e){console.error("Error while trying to parse the manifest playlist",e);return}}var Ud=new yT,xr=new WeakSet,lt;_T(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}lt||(lt=cast.framework,ir().addEventListener(lt.CastContextEventType.CAST_STATE_CHANGED,s=>{Ud.forEach(n=>{var a,o;return(o=(a=tr.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),ir().addEventListener(lt.CastContextEventType.SESSION_STATE_CHANGED,s=>{Ud.forEach(n=>{var a,o;return(o=(a=tr.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),Ud.forEach(s=>{var n,a;return(a=(n=tr.get(s)).init)==null?void 0:a.call(n)}))});var kT=0,Ie,to,$t,rr,Ts,bs,Rr,Bd,$e,Es,wT,DT,Cm,CT,Mm,MT,Om,Fd=class extends EventTarget{constructor(t){super();ie(this,$e);ie(this,Ie);ie(this,to);ie(this,$t);ie(this,rr);ie(this,Ts,"disconnected");ie(this,bs,!1);ie(this,Rr,new Set);ie(this,Bd,new WeakMap);Z(this,Ie,t),Ud.add(this),tr.set(this,{init:()=>Ce(this,$e,Mm).call(this),onCastStateChanged:()=>Ce(this,$e,Cm).call(this),onSessionStateChanged:()=>Ce(this,$e,CT).call(this),getCastPlayer:()=>I(this,$e,Es)}),Ce(this,$e,Mm).call(this)}get state(){return I(this,Ts)}async watchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");return I(this,Bd).set(t,++kT),I(this,Rr).add(t),queueMicrotask(()=>t(Ce(this,$e,DT).call(this))),kT}async cancelWatchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");t?I(this,Rr).delete(t):I(this,Rr).clear()}async prompt(){var r,s,n,a;if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");if(!((s=(r=globalThis.chrome)==null?void 0:r.cast)!=null&&s.isAvailable))throw new Pd("The RemotePlayback API is disabled on this platform.");let t=xr.has(I(this,Ie));xr.add(I(this,Ie)),wm(I(this,Ie).castOptions),Object.entries(I(this,rr)).forEach(([o,l])=>{I(this,$t).controller.addEventListener(o,l)});try{await ir().requestSession()}catch(o){if(t||xr.delete(I(this,Ie)),o==="cancel")return;throw new Error(o)}(a=(n=tr.get(I(this,Ie)))==null?void 0:n.loadOnPrompt)==null||a.call(n)}};Ie=new WeakMap,to=new WeakMap,$t=new WeakMap,rr=new WeakMap,Ts=new WeakMap,bs=new WeakMap,Rr=new WeakMap,Bd=new WeakMap,$e=new WeakSet,Es=function(){if(xr.has(I(this,Ie)))return I(this,$t)},wT=function(){xr.has(I(this,Ie))&&(Object.entries(I(this,rr)).forEach(([t,r])=>{I(this,$t).controller.removeEventListener(t,r)}),xr.delete(I(this,Ie)),I(this,Ie).muted=I(this,$t).isMuted,I(this,Ie).currentTime=I(this,$t).savedPlayerState.currentTime,I(this,$t).savedPlayerState.isPaused===!1&&I(this,Ie).play())},DT=function(){var r;let t=(r=ir())==null?void 0:r.getCastState();return t&&t!=="NO_DEVICES_AVAILABLE"},Cm=function(){let t=ir().getCastState();if(xr.has(I(this,Ie))&&t==="CONNECTING"&&(Z(this,Ts,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,bs)&&(t!=null&&t.includes("CONNECT"))){Z(this,bs,!0);for(let r of I(this,Rr))r(!0)}else if(I(this,bs)&&(!t||t==="NO_DEVICES_AVAILABLE")){Z(this,bs,!1);for(let r of I(this,Rr))r(!1)}},CT=async function(){var r;let{SESSION_RESUMED:t}=lt.SessionState;if(ir().getSessionState()===t&&I(this,Ie).castSrc===((r=Nd())==null?void 0:r.media.contentId)){xr.add(I(this,Ie)),Object.entries(I(this,rr)).forEach(([s,n])=>{I(this,$t).controller.addEventListener(s,n)});try{await RT(new chrome.cast.media.GetStatusRequest)}catch(s){console.error(s)}I(this,rr)[lt.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,rr)[lt.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Mm=function(){!lt||I(this,to)||(Z(this,to,!0),wm(I(this,Ie).castOptions),I(this,Ie).textTracks.addEventListener("change",()=>Ce(this,$e,Om).call(this)),Ce(this,$e,Cm).call(this),Z(this,$t,new lt.RemotePlayer),new lt.RemotePlayerController(I(this,$t)),Z(this,rr,{[lt.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:t})=>{t===!0?(Z(this,Ts,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,$e,wT).call(this),Z(this,Ts,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[lt.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("durationchange"))},[lt.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[lt.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[lt.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var t;(t=I(this,$e,Es))!=null&&t.isMediaLoaded&&I(this,Ie).dispatchEvent(new Event("timeupdate"))},[lt.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("resize"))},[lt.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event(this.paused?"pause":"play"))},[lt.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var t,r;((t=I(this,$e,Es))==null?void 0:t.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,Ie).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(r=I(this,$e,Es))==null?void 0:r.playerState]))},[lt.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var t;(t=I(this,$e,Es))!=null&&t.isMediaLoaded&&(await Promise.resolve(),Ce(this,$e,MT).call(this))}}))},MT=function(){Ce(this,$e,Om).call(this)},Om=async function(){var h,f,m,p,g;if(!I(this,$e,Es))return;let r=((f=(h=I(this,$t).mediaInfo)==null?void 0:h.tracks)!=null?f:[]).filter(({type:v})=>v===chrome.cast.media.TrackType.TEXT),s=[...I(this,Ie).textTracks].filter(({kind:v})=>v==="subtitles"||v==="captions"),n=r.map(({language:v,name:y,trackId:T})=>{var A;let{mode:_}=(A=s.find(k=>k.language===v&&k.label===y))!=null?A:{};return _?{mode:_,trackId:T}:!1}).filter(Boolean),o=n.filter(({mode:v})=>v!=="showing").map(({trackId:v})=>v),l=n.find(({mode:v})=>v==="showing"),d=(g=(p=(m=eo())==null?void 0:m.getSessionObj().media[0])==null?void 0:p.activeTrackIds)!=null?g:[],u=d;if(d.length&&(u=u.filter(v=>!o.includes(v))),l!=null&&l.trackId&&(u=[...u,l.trackId]),u=[...new Set(u)],!((v,y)=>v.length===y.length&&v.every(T=>y.includes(T)))(d,u))try{let v=new chrome.cast.media.EditTracksInfoRequest(u);await xT(v)}catch(v){console.error(v)}};var OT=i=>{var e,t,r,s,n,a,o,xe,PT;return t=class extends i{constructor(){super(...arguments);ie(this,o);ie(this,r,{paused:!1});ie(this,s,Dm());ie(this,n);ie(this,a)}get remote(){return I(this,a)?I(this,a):AT()?(this.disableRemotePlayback||ST(),tr.set(this,{loadOnPrompt:()=>Ce(this,o,PT).call(this)}),Z(this,a,new Fd(this))):super.remote}attributeChangedCallback(h,f,m){if(super.attributeChangedCallback(h,f,m),h==="cast-receiver"&&m){I(this,s).receiverApplicationId=m;return}if(I(this,o,xe))switch(h){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var v,y;if(!I(this,o,xe))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);h.customData=this.castCustomData;let f=[...this.querySelectorAll("track")].filter(({kind:T,src:_})=>_&&(T==="subtitles"||T==="captions")),m=[],p=0;if(f.length&&(h.tracks=f.map(T=>{let _=++p;m.length===0&&T.track.mode==="showing"&&m.push(_);let A=new chrome.cast.media.Track(_,chrome.cast.media.TrackType.TEXT);return A.trackContentId=T.src,A.trackContentType="text/vtt",A.subtype=T.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,A.name=T.label,A.language=T.srclang,A})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}],IT(this.castSrc)){let T=await LT(this.castSrc);((T==null?void 0:T.includes("m4s"))||(T==null?void 0:T.includes("mp4")))&&(h.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.FMP4,h.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.FMP4)}let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(v=super.currentTime)!=null?v:0,g.autoplay=!I(this,r).paused,g.activeTrackIds=m,await((y=eo())==null?void 0:y.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var h;if(I(this,o,xe)){I(this,o,xe).isPaused&&((h=I(this,o,xe).controller)==null||h.playOrPause());return}return super.play()}pause(){var h;if(I(this,o,xe)){I(this,o,xe).isPaused||(h=I(this,o,xe).controller)==null||h.playOrPause();return}super.pause()}get castOptions(){return I(this,s)}get castReceiver(){var h;return(h=this.getAttribute("cast-receiver"))!=null?h:void 0}set castReceiver(h){this.castReceiver!=h&&this.setAttribute("cast-receiver",`${h}`)}get castSrc(){var h,f,m;return(m=(f=this.getAttribute("cast-src"))!=null?f:(h=this.querySelector("source"))==null?void 0:h.src)!=null?m:this.currentSrc}set castSrc(h){this.castSrc!=h&&this.setAttribute("cast-src",`${h}`)}get castContentType(){var h;return(h=this.getAttribute("cast-content-type"))!=null?h:void 0}set castContentType(h){this.setAttribute("cast-content-type",`${h}`)}get castStreamType(){var h,f;return(f=(h=this.getAttribute("cast-stream-type"))!=null?h:this.streamType)!=null?f:void 0}set castStreamType(h){this.setAttribute("cast-stream-type",`${h}`)}get castCustomData(){return I(this,n)}set castCustomData(h){let f=typeof h;if(!["object","undefined"].includes(f)){console.error(`castCustomData must be nullish or an object but value was of type ${f}`);return}Z(this,n,h)}get readyState(){if(I(this,o,xe))switch(I(this,o,xe).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return I(this,o,xe)?I(this,o,xe).isPaused:super.paused}get muted(){var h;return I(this,o,xe)?(h=I(this,o,xe))==null?void 0:h.isMuted:super.muted}set muted(h){var f;if(I(this,o,xe)){(h&&!I(this,o,xe).isMuted||!h&&I(this,o,xe).isMuted)&&((f=I(this,o,xe).controller)==null||f.muteOrUnmute());return}super.muted=h}get volume(){var h,f;return I(this,o,xe)?(f=(h=I(this,o,xe))==null?void 0:h.volumeLevel)!=null?f:1:super.volume}set volume(h){var f;if(I(this,o,xe)){I(this,o,xe).volumeLevel=+h,(f=I(this,o,xe).controller)==null||f.setVolumeLevel();return}super.volume=h}get duration(){var h,f,m;return I(this,o,xe)&&((h=I(this,o,xe))!=null&&h.isMediaLoaded)?(m=(f=I(this,o,xe))==null?void 0:f.duration)!=null?m:NaN:super.duration}get currentTime(){var h,f,m;return I(this,o,xe)&&((h=I(this,o,xe))!=null&&h.isMediaLoaded)?(m=(f=I(this,o,xe))==null?void 0:f.currentTime)!=null?m:0:super.currentTime}set currentTime(h){var f;if(I(this,o,xe)){I(this,o,xe).currentTime=h,(f=I(this,o,xe).controller)==null||f.seek();return}super.currentTime=h}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,xe=function(){var h,f;return(f=(h=tr.get(this.remote))==null?void 0:h.getCastPlayer)==null?void 0:f.call(h)},PT=async function(){I(this,r).paused=fl(t.prototype,this,"paused"),fl(t.prototype,this,"pause").call(this),this.muted=fl(t.prototype,this,"muted");try{await this.load()}catch(h){console.error(h)}},Te(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t};var sr=class extends Event{constructor(t,r){super(t);Te(this,"track");this.track=r.track}};var Pm=new WeakMap;function V(i){var e;return(e=Pm.get(i))!=null?e:lk(i,{})}function lk(i,e){let t=Pm.get(i);return t||Pm.set(i,t={}),Object.assign(t,e)}function $d(i,e){let t=i.videoTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in _s.prototype||Object.defineProperty(_s.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new sr("addtrack",{track:e}))})}function Hd(i){var r;let e=(r=V(i).media)==null?void 0:r.videoTracks;if(!e)return;V(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new sr("removetrack",{track:i}))})}function NT(i){var r;let e=(r=V(i).media.videoTracks)!=null?r:[],t=!1;for(let s of e)s!==i&&(s.selected=!1,t=!0);if(t){if(V(e).changeRequested)return;V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))})}}var Ir,Lr,kr,ys,io,_s=class extends EventTarget{constructor(){super();ie(this,ys);ie(this,Ir);ie(this,Lr);ie(this,kr);V(this).trackSet=new Set}[Symbol.iterator](){return I(this,ys,io).values()}get length(){return I(this,ys,io).size}getTrackById(t){var r;return(r=[...I(this,ys,io)].find(s=>s.id===t))!=null?r:null}get selectedIndex(){return[...I(this,ys,io)].findIndex(t=>t.selected)}get onaddtrack(){return I(this,Ir)}set onaddtrack(t){I(this,Ir)&&(this.removeEventListener("addtrack",I(this,Ir)),Z(this,Ir,void 0)),typeof t=="function"&&(Z(this,Ir,t),this.addEventListener("addtrack",t))}get onremovetrack(){return I(this,Lr)}set onremovetrack(t){I(this,Lr)&&(this.removeEventListener("removetrack",I(this,Lr)),Z(this,Lr,void 0)),typeof t=="function"&&(Z(this,Lr,t),this.addEventListener("removetrack",t))}get onchange(){return I(this,kr)}set onchange(t){I(this,kr)&&(this.removeEventListener("change",I(this,kr)),Z(this,kr,void 0)),typeof t=="function"&&(Z(this,kr,t),this.addEventListener("change",t))}};Ir=new WeakMap,Lr=new WeakMap,kr=new WeakMap,ys=new WeakSet,io=function(){return V(this).trackSet};var nr=class extends Event{constructor(t,r){super(t);Te(this,"rendition");this.rendition=r.rendition}};function UT(i,e){let t=V(i).media.videoRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in As.prototype||Object.defineProperty(As.prototype,s,{get(){return Tn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new nr("addrendition",{rendition:e}))})}function FT(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new nr("removerendition",{rendition:i}))})}function BT(i){let e=V(i).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Tn(i){return[...V(i).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...V(t).renditionSet])}var wr,Dr,Cr,As=class extends EventTarget{constructor(){super(...arguments);ie(this,wr);ie(this,Dr);ie(this,Cr)}[Symbol.iterator](){return Tn(this).values()}get length(){return Tn(this).length}getRenditionById(t){var r;return(r=Tn(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return Tn(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of Tn(this).entries())s.selected=r===t}get onaddrendition(){return I(this,wr)}set onaddrendition(t){I(this,wr)&&(this.removeEventListener("addrendition",I(this,wr)),Z(this,wr,void 0)),typeof t=="function"&&(Z(this,wr,t),this.addEventListener("addrendition",t))}get onremoverendition(){return I(this,Dr)}set onremoverendition(t){I(this,Dr)&&(this.removeEventListener("removerendition",I(this,Dr)),Z(this,Dr,void 0)),typeof t=="function"&&(Z(this,Dr,t),this.addEventListener("removerendition",t))}get onchange(){return I(this,Cr)}set onchange(t){I(this,Cr)&&(this.removeEventListener("change",I(this,Cr)),Z(this,Cr,void 0)),typeof t=="function"&&(Z(this,Cr,t),this.addEventListener("change",t))}};wr=new WeakMap,Dr=new WeakMap,Cr=new WeakMap;var bn,ro=class{constructor(){Te(this,"src");Te(this,"id");Te(this,"width");Te(this,"height");Te(this,"bitrate");Te(this,"frameRate");Te(this,"codec");ie(this,bn,!1)}get selected(){return I(this,bn)}set selected(e){I(this,bn)!==e&&(Z(this,bn,e),BT(this))}};bn=new WeakMap;var yn,_n=class{constructor(){Te(this,"id");Te(this,"kind");Te(this,"label","");Te(this,"language","");Te(this,"sourceBuffer");ie(this,yn,!1)}addRendition(e,t,r,s,n,a){let o=new ro;return o.src=e,o.width=t,o.height=r,o.frameRate=a,o.bitrate=n,o.codec=s,UT(this,o),o}removeRendition(e){FT(e)}get selected(){return I(this,yn)}set selected(e){I(this,yn)!==e&&(Z(this,yn,e),e===!0&&NT(this))}};yn=new WeakMap;function $T(i,e){let t=V(i).media.audioRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in Ss.prototype||Object.defineProperty(Ss.prototype,s,{get(){return An(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new nr("addrendition",{rendition:e}))})}function HT(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new nr("removerendition",{rendition:i}))})}function GT(i){let e=V(i).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function An(i){return[...V(i).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...V(t).renditionSet])}var Mr,Or,Pr,Ss=class extends EventTarget{constructor(){super(...arguments);ie(this,Mr);ie(this,Or);ie(this,Pr)}[Symbol.iterator](){return An(this).values()}get length(){return An(this).length}getRenditionById(t){var r;return(r=An(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return An(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of An(this).entries())s.selected=r===t}get onaddrendition(){return I(this,Mr)}set onaddrendition(t){I(this,Mr)&&(this.removeEventListener("addrendition",I(this,Mr)),Z(this,Mr,void 0)),typeof t=="function"&&(Z(this,Mr,t),this.addEventListener("addrendition",t))}get onremoverendition(){return I(this,Or)}set onremoverendition(t){I(this,Or)&&(this.removeEventListener("removerendition",I(this,Or)),Z(this,Or,void 0)),typeof t=="function"&&(Z(this,Or,t),this.addEventListener("removerendition",t))}get onchange(){return I(this,Pr)}set onchange(t){I(this,Pr)&&(this.removeEventListener("change",I(this,Pr)),Z(this,Pr,void 0)),typeof t=="function"&&(Z(this,Pr,t),this.addEventListener("change",t))}};Mr=new WeakMap,Or=new WeakMap,Pr=new WeakMap;var Sn,so=class{constructor(){Te(this,"src");Te(this,"id");Te(this,"bitrate");Te(this,"codec");ie(this,Sn,!1)}get selected(){return I(this,Sn)}set selected(e){I(this,Sn)!==e&&(Z(this,Sn,e),GT(this))}};Sn=new WeakMap;function Kd(i,e){let t=i.audioTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in xs.prototype||Object.defineProperty(xs.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new sr("addtrack",{track:e}))})}function Vd(i){var r;let e=(r=V(i).media)==null?void 0:r.audioTracks;if(!e)return;V(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new sr("removetrack",{track:i}))})}function KT(i){let e=V(i).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Nr,Ur,Fr,xn,Gd,xs=class extends EventTarget{constructor(){super();ie(this,xn);ie(this,Nr);ie(this,Ur);ie(this,Fr);V(this).trackSet=new Set}[Symbol.iterator](){return I(this,xn,Gd).values()}get length(){return I(this,xn,Gd).size}getTrackById(t){var r;return(r=[...I(this,xn,Gd)].find(s=>s.id===t))!=null?r:null}get onaddtrack(){return I(this,Nr)}set onaddtrack(t){I(this,Nr)&&(this.removeEventListener("addtrack",I(this,Nr)),Z(this,Nr,void 0)),typeof t=="function"&&(Z(this,Nr,t),this.addEventListener("addtrack",t))}get onremovetrack(){return I(this,Ur)}set onremovetrack(t){I(this,Ur)&&(this.removeEventListener("removetrack",I(this,Ur)),Z(this,Ur,void 0)),typeof t=="function"&&(Z(this,Ur,t),this.addEventListener("removetrack",t))}get onchange(){return I(this,Fr)}set onchange(t){I(this,Fr)&&(this.removeEventListener("change",I(this,Fr)),Z(this,Fr,void 0)),typeof t=="function"&&(Z(this,Fr,t),this.addEventListener("change",t))}};Nr=new WeakMap,Ur=new WeakMap,Fr=new WeakMap,xn=new WeakSet,Gd=function(){return V(this).trackSet};var Rn,In=class{constructor(){Te(this,"id");Te(this,"kind");Te(this,"label","");Te(this,"language","");Te(this,"sourceBuffer");ie(this,Rn,!1)}addRendition(e,t,r){let s=new so;return s.src=e,s.codec=t,s.bitrate=r,$T(this,s),s}removeRendition(e){HT(e)}get enabled(){return I(this,Rn)}set enabled(e){I(this,Rn)!==e&&(Z(this,Rn,e),KT(this))}};Rn=new WeakMap;var VT=Wd(globalThis.HTMLMediaElement,"video"),WT=Wd(globalThis.HTMLMediaElement,"audio");function YT(i){if(!(i!=null&&i.prototype))return i;let e=Wd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return dk(this)}});let t=Wd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return uk(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new _n;return l.kind=n,l.label=a,l.language=o,$d(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Hd),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new In;return l.kind=n,l.label=a,l.language=o,Kd(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=Vd),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=V(n).videoRenditions;return a||(a=new As,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=V(n).audioRenditions;return a||(a=new Ss,V(a).media=n,V(n).audioRenditions=a),a};return i}function Wd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function dk(i){var t;let e=V(i).videoTracks;if(!e&&(e=new _s,V(i).videoTracks=e,VT)){let r=VT.call((t=i.nativeEl)!=null?t:i);for(let s of r)$d(i,s);r.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...e].some(n=>n instanceof _n)){for(let n of r)Hd(n);return}$d(i,s.track)}),r.addEventListener("removetrack",s=>{Hd(s.track)})}return e}function uk(i){var t;let e=V(i).audioTracks;if(!e&&(e=new xs,V(i).audioTracks=e,WT)){let r=WT.call((t=i.nativeEl)!=null?t:i);for(let s of r)Kd(i,s);r.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...e].some(n=>n instanceof In)){for(let n of r)Vd(n);return}Kd(i,s.track)}),r.addEventListener("removetrack",s=>{Vd(s.track)})}return e}var jT=i=>{throw TypeError(i)},zT=(i,e,t)=>e.has(i)||jT("Cannot "+t),XT=(i,e,t)=>(zT(i,e,"read from private field"),t?t.call(i):e.get(i)),QT=(i,e,t)=>e.has(i)?jT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),ZT=(i,e,t,r)=>(zT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),jd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends jd{}globalThis.DocumentFragment=i}var Um=class extends jd{},ck=class extends jd{},hk={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Um)}},Yd,fk=class{constructor(i,e={}){QT(this,Yd),ZT(this,Yd,e==null?void 0:e.detail)}get detail(){return XT(this,Yd)}initCustomEvent(){}};Yd=new WeakMap;function mk(i,e){return new Um}var JT={document:{createElement:mk},DocumentFragment,customElements:hk,CustomEvent:fk,EventTarget:jd,HTMLElement:Um,HTMLVideoElement:ck},eb=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Nm=eb?JT:globalThis,zO=eb?JT.document:globalThis.document,qd,qT=class extends OT(YT(bT)){constructor(){super(...arguments),QT(this,qd)}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var i;return(i=XT(this,qd))!=null?i:this.muxCastCustomData}set castCustomData(i){ZT(this,qd,i)}};qd=new WeakMap;Nm.customElements.get("mux-video")||(Nm.customElements.define("mux-video",qT),Nm.MuxVideoElement=qT);var $={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},me={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Fm={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_WIDTH:"mediaWidth"},tb=Object.entries(Fm),b=tb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),pk={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Qt=tb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...pk}),aP=Object.entries(Qt).reduce((i,[e,t])=>{let r=b[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),ib=Object.entries(b).reduce((i,[e,t])=>{let r=Qt[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),Ct={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Br={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Bm={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ht={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ci={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var rb={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function sb(i){return i==null?void 0:i.map(vk).join(" ")}function nb(i){return i==null?void 0:i.split(/\s+/).map(Ek)}function vk(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function Ek(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function ab(i){return i==null?void 0:i.map(Tk).join(" ")}function ob(i){return i==null?void 0:i.split(/\s+/).map(bk)}function Tk(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function bk(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function lb(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Ln(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function zd(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Xd=i=>new Promise(e=>setTimeout(e,i));var db=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],yk=(i,e)=>{let t=i===1?db[e].singular:db[e].plural;return`${i} ${t}`},Rs=i=>{if(!Ln(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&yk(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function hi(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var dP=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var ub={"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","Source Not Supported":"Source Not Supported","Encryption Error":"Encryption Error","A network error caused the media download to fail.":"A network error caused the media download to fail.","A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.":"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.","An unsupported error occurred. The server or network failed, or your browser does not support this format.":"An unsupported error occurred. The server or network failed, or your browser does not support this format.","The media is encrypted and there are no keys to decrypt it.":"The media is encrypted and there are no keys to decrypt it."};var cb,$m={en:ub},Hm=((cb=globalThis.navigator)==null?void 0:cb.language)||"en",hb=i=>{Hm=i};var Ak=i=>{var e,t,r;let[s]=Hm.split("-");return((e=$m[Hm])==null?void 0:e[i])||((t=$m[s])==null?void 0:t[i])||((r=$m.en)==null?void 0:r[i])||i},B=(i,e={})=>Ak(i).replace(/\{(\w+)\}/g,(t,r)=>r in e?String(e[r]):`{${r}}`);var Qd=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Zd=class extends Qd{},Jd=class extends Zd{constructor(){super(...arguments),this.role=null}},Gm=class{observe(){}unobserve(){}disconnect(){}},fb={createElement:function(){return new no.HTMLElement},createElementNS:function(){return new no.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},no={ResizeObserver:Gm,document:fb,Node:Zd,Element:Jd,HTMLElement:class extends Jd{constructor(){super(...arguments),this.innerHTML=""}get content(){return new no.DocumentFragment}},DocumentFragment:class extends Qd{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}},DOMParser:class{parseFromString(e,t){return{body:{textContent:e}}}}},mb=typeof window=="undefined"||typeof window.customElements=="undefined",pb=Object.keys(no).every(i=>i in globalThis),S=mb&&!pb?no:globalThis,Ue=mb&&!pb?fb:globalThis.document;var gb=new WeakMap,Km=i=>{let e=gb.get(i);return e||gb.set(i,e=new Set),e},vb=new S.ResizeObserver(i=>{for(let e of i)for(let t of Km(e.target))t(e)});function ar(i,e){Km(i).add(e),vb.observe(i)}function or(i,e){let t=Km(i);t.delete(e),t.size||vb.unobserve(i)}function He(i){let e={};for(let t of i)e[t.name]=t.value;return e}function We(i){var e;return(e=eu(i))!=null?e:Ri(i,"media-controller")}function eu(i){var e;let{MEDIA_CONTROLLER:t}=me,r=i.getAttribute(t);if(r)return(e=Is(i))==null?void 0:e.getElementById(r)}var tu=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},Sk=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},iu=(i,e)=>Sk(i,e)[0],Rt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Rt(i,e.getRootNode().host),Ri=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||Ri(i.getRootNode().host,e)};function ao(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=ao(t.shadowRoot))!=null?e:t:null}function Is(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function ru(i,{depth:e=3,checkOpacity:t=!0,checkVisibilityCSS:r=!0}={}){if(i.checkVisibility)return i.checkVisibility({checkOpacity:t,checkVisibilityCSS:r});let s=i;for(;s&&e>0;){let n=getComputedStyle(s);if(t&&n.opacity==="0"||r&&n.visibility==="hidden"||n.display==="none")return!1;s=s.parentElement,e--}return!0}function Eb(i,e,t,r){let s=r.x-t.x,n=r.y-t.y,a=s*s+n*n;if(a===0)return 0;let o=((i-t.x)*s+(e-t.y)*n)/a;return Math.max(0,Math.min(1,o))}function Me(i,e){let t=xk(i,r=>r===e);return t||Vm(i,e)}function xk(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(let a of n!=null?n:[])if(e(a.selectorText))return a}}function Vm(i,e){var t,r;let s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function ge(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function ye(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}ge(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function ae(i,e){return i.hasAttribute(e)}function oe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}ae(i,e)!=t&&i.toggleAttribute(e,t)}function de(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function ue(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;de(i,e,void 0)!==r&&i.setAttribute(e,r)}var Tb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$r=(i,e,t)=>(Tb(i,e,"read from private field"),t?t.call(i):e.get(i)),Rk=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},su=(i,e,t,r)=>(Tb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mt;function Ik(i){return`
|
|
126
|
+
`).find(r=>!r.trim().startsWith("#")&&r.trim()!=="")}async function IT(i){try{let t=(await fetch(i,{method:"HEAD"})).headers.get("Content-Type");return sk.some(r=>t===r)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function LT(i){try{let e=await(await fetch(i)).text(),t=e,r=ak(e);if(r.length>0){let a=new URL(r[0],i).toString();t=await(await fetch(a)).text()}let s=ok(t);return nk(s)}catch(e){console.error("Error while trying to parse the manifest playlist",e);return}}var Ud=new yT,xr=new WeakSet,lt;_T(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}lt||(lt=cast.framework,ir().addEventListener(lt.CastContextEventType.CAST_STATE_CHANGED,s=>{Ud.forEach(n=>{var a,o;return(o=(a=tr.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),ir().addEventListener(lt.CastContextEventType.SESSION_STATE_CHANGED,s=>{Ud.forEach(n=>{var a,o;return(o=(a=tr.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),Ud.forEach(s=>{var n,a;return(a=(n=tr.get(s)).init)==null?void 0:a.call(n)}))});var kT=0,Ie,io,$t,rr,Ts,bs,Rr,Bd,$e,Es,wT,DT,Cm,CT,Mm,MT,Om,Fd=class extends EventTarget{constructor(t){super();ie(this,$e);ie(this,Ie);ie(this,io);ie(this,$t);ie(this,rr);ie(this,Ts,"disconnected");ie(this,bs,!1);ie(this,Rr,new Set);ie(this,Bd,new WeakMap);Z(this,Ie,t),Ud.add(this),tr.set(this,{init:()=>Ce(this,$e,Mm).call(this),onCastStateChanged:()=>Ce(this,$e,Cm).call(this),onSessionStateChanged:()=>Ce(this,$e,CT).call(this),getCastPlayer:()=>I(this,$e,Es)}),Ce(this,$e,Mm).call(this)}get state(){return I(this,Ts)}async watchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");return I(this,Bd).set(t,++kT),I(this,Rr).add(t),queueMicrotask(()=>t(Ce(this,$e,DT).call(this))),kT}async cancelWatchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");t?I(this,Rr).delete(t):I(this,Rr).clear()}async prompt(){var r,s,n,a;if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");if(!((s=(r=globalThis.chrome)==null?void 0:r.cast)!=null&&s.isAvailable))throw new Pd("The RemotePlayback API is disabled on this platform.");let t=xr.has(I(this,Ie));xr.add(I(this,Ie)),wm(I(this,Ie).castOptions),Object.entries(I(this,rr)).forEach(([o,l])=>{I(this,$t).controller.addEventListener(o,l)});try{await ir().requestSession()}catch(o){if(t||xr.delete(I(this,Ie)),o==="cancel")return;throw new Error(o)}(a=(n=tr.get(I(this,Ie)))==null?void 0:n.loadOnPrompt)==null||a.call(n)}};Ie=new WeakMap,io=new WeakMap,$t=new WeakMap,rr=new WeakMap,Ts=new WeakMap,bs=new WeakMap,Rr=new WeakMap,Bd=new WeakMap,$e=new WeakSet,Es=function(){if(xr.has(I(this,Ie)))return I(this,$t)},wT=function(){xr.has(I(this,Ie))&&(Object.entries(I(this,rr)).forEach(([t,r])=>{I(this,$t).controller.removeEventListener(t,r)}),xr.delete(I(this,Ie)),I(this,Ie).muted=I(this,$t).isMuted,I(this,Ie).currentTime=I(this,$t).savedPlayerState.currentTime,I(this,$t).savedPlayerState.isPaused===!1&&I(this,Ie).play())},DT=function(){var r;let t=(r=ir())==null?void 0:r.getCastState();return t&&t!=="NO_DEVICES_AVAILABLE"},Cm=function(){let t=ir().getCastState();if(xr.has(I(this,Ie))&&t==="CONNECTING"&&(Z(this,Ts,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,bs)&&(t!=null&&t.includes("CONNECT"))){Z(this,bs,!0);for(let r of I(this,Rr))r(!0)}else if(I(this,bs)&&(!t||t==="NO_DEVICES_AVAILABLE")){Z(this,bs,!1);for(let r of I(this,Rr))r(!1)}},CT=async function(){var r;let{SESSION_RESUMED:t}=lt.SessionState;if(ir().getSessionState()===t&&I(this,Ie).castSrc===((r=Nd())==null?void 0:r.media.contentId)){xr.add(I(this,Ie)),Object.entries(I(this,rr)).forEach(([s,n])=>{I(this,$t).controller.addEventListener(s,n)});try{await RT(new chrome.cast.media.GetStatusRequest)}catch(s){console.error(s)}I(this,rr)[lt.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,rr)[lt.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Mm=function(){!lt||I(this,io)||(Z(this,io,!0),wm(I(this,Ie).castOptions),I(this,Ie).textTracks.addEventListener("change",()=>Ce(this,$e,Om).call(this)),Ce(this,$e,Cm).call(this),Z(this,$t,new lt.RemotePlayer),new lt.RemotePlayerController(I(this,$t)),Z(this,rr,{[lt.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:t})=>{t===!0?(Z(this,Ts,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,$e,wT).call(this),Z(this,Ts,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[lt.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("durationchange"))},[lt.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[lt.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("volumechange"))},[lt.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var t;(t=I(this,$e,Es))!=null&&t.isMediaLoaded&&I(this,Ie).dispatchEvent(new Event("timeupdate"))},[lt.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event("resize"))},[lt.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,Ie).dispatchEvent(new Event(this.paused?"pause":"play"))},[lt.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var t,r;((t=I(this,$e,Es))==null?void 0:t.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,Ie).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(r=I(this,$e,Es))==null?void 0:r.playerState]))},[lt.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var t;(t=I(this,$e,Es))!=null&&t.isMediaLoaded&&(await Promise.resolve(),Ce(this,$e,MT).call(this))}}))},MT=function(){Ce(this,$e,Om).call(this)},Om=async function(){var h,f,m,p,g;if(!I(this,$e,Es))return;let r=((f=(h=I(this,$t).mediaInfo)==null?void 0:h.tracks)!=null?f:[]).filter(({type:v})=>v===chrome.cast.media.TrackType.TEXT),s=[...I(this,Ie).textTracks].filter(({kind:v})=>v==="subtitles"||v==="captions"),n=r.map(({language:v,name:y,trackId:T})=>{var A;let{mode:_}=(A=s.find(k=>k.language===v&&k.label===y))!=null?A:{};return _?{mode:_,trackId:T}:!1}).filter(Boolean),o=n.filter(({mode:v})=>v!=="showing").map(({trackId:v})=>v),l=n.find(({mode:v})=>v==="showing"),d=(g=(p=(m=to())==null?void 0:m.getSessionObj().media[0])==null?void 0:p.activeTrackIds)!=null?g:[],u=d;if(d.length&&(u=u.filter(v=>!o.includes(v))),l!=null&&l.trackId&&(u=[...u,l.trackId]),u=[...new Set(u)],!((v,y)=>v.length===y.length&&v.every(T=>y.includes(T)))(d,u))try{let v=new chrome.cast.media.EditTracksInfoRequest(u);await xT(v)}catch(v){console.error(v)}};var OT=i=>{var e,t,r,s,n,a,o,xe,PT;return t=class extends i{constructor(){super(...arguments);ie(this,o);ie(this,r,{paused:!1});ie(this,s,Dm());ie(this,n);ie(this,a)}get remote(){return I(this,a)?I(this,a):AT()?(this.disableRemotePlayback||ST(),tr.set(this,{loadOnPrompt:()=>Ce(this,o,PT).call(this)}),Z(this,a,new Fd(this))):super.remote}attributeChangedCallback(h,f,m){if(super.attributeChangedCallback(h,f,m),h==="cast-receiver"&&m){I(this,s).receiverApplicationId=m;return}if(I(this,o,xe))switch(h){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var v,y;if(!I(this,o,xe))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);h.customData=this.castCustomData;let f=[...this.querySelectorAll("track")].filter(({kind:T,src:_})=>_&&(T==="subtitles"||T==="captions")),m=[],p=0;if(f.length&&(h.tracks=f.map(T=>{let _=++p;m.length===0&&T.track.mode==="showing"&&m.push(_);let A=new chrome.cast.media.Track(_,chrome.cast.media.TrackType.TEXT);return A.trackContentId=T.src,A.trackContentType="text/vtt",A.subtype=T.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,A.name=T.label,A.language=T.srclang,A})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}],IT(this.castSrc)){let T=await LT(this.castSrc);((T==null?void 0:T.includes("m4s"))||(T==null?void 0:T.includes("mp4")))&&(h.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.FMP4,h.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.FMP4)}let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(v=super.currentTime)!=null?v:0,g.autoplay=!I(this,r).paused,g.activeTrackIds=m,await((y=to())==null?void 0:y.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var h;if(I(this,o,xe)){I(this,o,xe).isPaused&&((h=I(this,o,xe).controller)==null||h.playOrPause());return}return super.play()}pause(){var h;if(I(this,o,xe)){I(this,o,xe).isPaused||(h=I(this,o,xe).controller)==null||h.playOrPause();return}super.pause()}get castOptions(){return I(this,s)}get castReceiver(){var h;return(h=this.getAttribute("cast-receiver"))!=null?h:void 0}set castReceiver(h){this.castReceiver!=h&&this.setAttribute("cast-receiver",`${h}`)}get castSrc(){var h,f,m;return(m=(f=this.getAttribute("cast-src"))!=null?f:(h=this.querySelector("source"))==null?void 0:h.src)!=null?m:this.currentSrc}set castSrc(h){this.castSrc!=h&&this.setAttribute("cast-src",`${h}`)}get castContentType(){var h;return(h=this.getAttribute("cast-content-type"))!=null?h:void 0}set castContentType(h){this.setAttribute("cast-content-type",`${h}`)}get castStreamType(){var h,f;return(f=(h=this.getAttribute("cast-stream-type"))!=null?h:this.streamType)!=null?f:void 0}set castStreamType(h){this.setAttribute("cast-stream-type",`${h}`)}get castCustomData(){return I(this,n)}set castCustomData(h){let f=typeof h;if(!["object","undefined"].includes(f)){console.error(`castCustomData must be nullish or an object but value was of type ${f}`);return}Z(this,n,h)}get readyState(){if(I(this,o,xe))switch(I(this,o,xe).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return I(this,o,xe)?I(this,o,xe).isPaused:super.paused}get muted(){var h;return I(this,o,xe)?(h=I(this,o,xe))==null?void 0:h.isMuted:super.muted}set muted(h){var f;if(I(this,o,xe)){(h&&!I(this,o,xe).isMuted||!h&&I(this,o,xe).isMuted)&&((f=I(this,o,xe).controller)==null||f.muteOrUnmute());return}super.muted=h}get volume(){var h,f;return I(this,o,xe)?(f=(h=I(this,o,xe))==null?void 0:h.volumeLevel)!=null?f:1:super.volume}set volume(h){var f;if(I(this,o,xe)){I(this,o,xe).volumeLevel=+h,(f=I(this,o,xe).controller)==null||f.setVolumeLevel();return}super.volume=h}get duration(){var h,f,m;return I(this,o,xe)&&((h=I(this,o,xe))!=null&&h.isMediaLoaded)?(m=(f=I(this,o,xe))==null?void 0:f.duration)!=null?m:NaN:super.duration}get currentTime(){var h,f,m;return I(this,o,xe)&&((h=I(this,o,xe))!=null&&h.isMediaLoaded)?(m=(f=I(this,o,xe))==null?void 0:f.currentTime)!=null?m:0:super.currentTime}set currentTime(h){var f;if(I(this,o,xe)){I(this,o,xe).currentTime=h,(f=I(this,o,xe).controller)==null||f.seek();return}super.currentTime=h}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,xe=function(){var h,f;return(f=(h=tr.get(this.remote))==null?void 0:h.getCastPlayer)==null?void 0:f.call(h)},PT=async function(){I(this,r).paused=ml(t.prototype,this,"paused"),ml(t.prototype,this,"pause").call(this),this.muted=ml(t.prototype,this,"muted");try{await this.load()}catch(h){console.error(h)}},Te(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t};var sr=class extends Event{constructor(t,r){super(t);Te(this,"track");this.track=r.track}};var Pm=new WeakMap;function V(i){var e;return(e=Pm.get(i))!=null?e:lk(i,{})}function lk(i,e){let t=Pm.get(i);return t||Pm.set(i,t={}),Object.assign(t,e)}function $d(i,e){let t=i.videoTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in _s.prototype||Object.defineProperty(_s.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new sr("addtrack",{track:e}))})}function Hd(i){var r;let e=(r=V(i).media)==null?void 0:r.videoTracks;if(!e)return;V(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new sr("removetrack",{track:i}))})}function NT(i){var r;let e=(r=V(i).media.videoTracks)!=null?r:[],t=!1;for(let s of e)s!==i&&(s.selected=!1,t=!0);if(t){if(V(e).changeRequested)return;V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))})}}var Ir,Lr,kr,ys,ro,_s=class extends EventTarget{constructor(){super();ie(this,ys);ie(this,Ir);ie(this,Lr);ie(this,kr);V(this).trackSet=new Set}[Symbol.iterator](){return I(this,ys,ro).values()}get length(){return I(this,ys,ro).size}getTrackById(t){var r;return(r=[...I(this,ys,ro)].find(s=>s.id===t))!=null?r:null}get selectedIndex(){return[...I(this,ys,ro)].findIndex(t=>t.selected)}get onaddtrack(){return I(this,Ir)}set onaddtrack(t){I(this,Ir)&&(this.removeEventListener("addtrack",I(this,Ir)),Z(this,Ir,void 0)),typeof t=="function"&&(Z(this,Ir,t),this.addEventListener("addtrack",t))}get onremovetrack(){return I(this,Lr)}set onremovetrack(t){I(this,Lr)&&(this.removeEventListener("removetrack",I(this,Lr)),Z(this,Lr,void 0)),typeof t=="function"&&(Z(this,Lr,t),this.addEventListener("removetrack",t))}get onchange(){return I(this,kr)}set onchange(t){I(this,kr)&&(this.removeEventListener("change",I(this,kr)),Z(this,kr,void 0)),typeof t=="function"&&(Z(this,kr,t),this.addEventListener("change",t))}};Ir=new WeakMap,Lr=new WeakMap,kr=new WeakMap,ys=new WeakSet,ro=function(){return V(this).trackSet};var nr=class extends Event{constructor(t,r){super(t);Te(this,"rendition");this.rendition=r.rendition}};function UT(i,e){let t=V(i).media.videoRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in As.prototype||Object.defineProperty(As.prototype,s,{get(){return Tn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new nr("addrendition",{rendition:e}))})}function FT(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new nr("removerendition",{rendition:i}))})}function BT(i){let e=V(i).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Tn(i){return[...V(i).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...V(t).renditionSet])}var wr,Dr,Cr,As=class extends EventTarget{constructor(){super(...arguments);ie(this,wr);ie(this,Dr);ie(this,Cr)}[Symbol.iterator](){return Tn(this).values()}get length(){return Tn(this).length}getRenditionById(t){var r;return(r=Tn(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return Tn(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of Tn(this).entries())s.selected=r===t}get onaddrendition(){return I(this,wr)}set onaddrendition(t){I(this,wr)&&(this.removeEventListener("addrendition",I(this,wr)),Z(this,wr,void 0)),typeof t=="function"&&(Z(this,wr,t),this.addEventListener("addrendition",t))}get onremoverendition(){return I(this,Dr)}set onremoverendition(t){I(this,Dr)&&(this.removeEventListener("removerendition",I(this,Dr)),Z(this,Dr,void 0)),typeof t=="function"&&(Z(this,Dr,t),this.addEventListener("removerendition",t))}get onchange(){return I(this,Cr)}set onchange(t){I(this,Cr)&&(this.removeEventListener("change",I(this,Cr)),Z(this,Cr,void 0)),typeof t=="function"&&(Z(this,Cr,t),this.addEventListener("change",t))}};wr=new WeakMap,Dr=new WeakMap,Cr=new WeakMap;var bn,so=class{constructor(){Te(this,"src");Te(this,"id");Te(this,"width");Te(this,"height");Te(this,"bitrate");Te(this,"frameRate");Te(this,"codec");ie(this,bn,!1)}get selected(){return I(this,bn)}set selected(e){I(this,bn)!==e&&(Z(this,bn,e),BT(this))}};bn=new WeakMap;var yn,_n=class{constructor(){Te(this,"id");Te(this,"kind");Te(this,"label","");Te(this,"language","");Te(this,"sourceBuffer");ie(this,yn,!1)}addRendition(e,t,r,s,n,a){let o=new so;return o.src=e,o.width=t,o.height=r,o.frameRate=a,o.bitrate=n,o.codec=s,UT(this,o),o}removeRendition(e){FT(e)}get selected(){return I(this,yn)}set selected(e){I(this,yn)!==e&&(Z(this,yn,e),e===!0&&NT(this))}};yn=new WeakMap;function $T(i,e){let t=V(i).media.audioRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in Ss.prototype||Object.defineProperty(Ss.prototype,s,{get(){return An(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new nr("addrendition",{rendition:e}))})}function HT(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new nr("removerendition",{rendition:i}))})}function GT(i){let e=V(i).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function An(i){return[...V(i).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...V(t).renditionSet])}var Mr,Or,Pr,Ss=class extends EventTarget{constructor(){super(...arguments);ie(this,Mr);ie(this,Or);ie(this,Pr)}[Symbol.iterator](){return An(this).values()}get length(){return An(this).length}getRenditionById(t){var r;return(r=An(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return An(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of An(this).entries())s.selected=r===t}get onaddrendition(){return I(this,Mr)}set onaddrendition(t){I(this,Mr)&&(this.removeEventListener("addrendition",I(this,Mr)),Z(this,Mr,void 0)),typeof t=="function"&&(Z(this,Mr,t),this.addEventListener("addrendition",t))}get onremoverendition(){return I(this,Or)}set onremoverendition(t){I(this,Or)&&(this.removeEventListener("removerendition",I(this,Or)),Z(this,Or,void 0)),typeof t=="function"&&(Z(this,Or,t),this.addEventListener("removerendition",t))}get onchange(){return I(this,Pr)}set onchange(t){I(this,Pr)&&(this.removeEventListener("change",I(this,Pr)),Z(this,Pr,void 0)),typeof t=="function"&&(Z(this,Pr,t),this.addEventListener("change",t))}};Mr=new WeakMap,Or=new WeakMap,Pr=new WeakMap;var Sn,no=class{constructor(){Te(this,"src");Te(this,"id");Te(this,"bitrate");Te(this,"codec");ie(this,Sn,!1)}get selected(){return I(this,Sn)}set selected(e){I(this,Sn)!==e&&(Z(this,Sn,e),GT(this))}};Sn=new WeakMap;function Kd(i,e){let t=i.audioTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in xs.prototype||Object.defineProperty(xs.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new sr("addtrack",{track:e}))})}function Vd(i){var r;let e=(r=V(i).media)==null?void 0:r.audioTracks;if(!e)return;V(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new sr("removetrack",{track:i}))})}function KT(i){let e=V(i).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Nr,Ur,Fr,xn,Gd,xs=class extends EventTarget{constructor(){super();ie(this,xn);ie(this,Nr);ie(this,Ur);ie(this,Fr);V(this).trackSet=new Set}[Symbol.iterator](){return I(this,xn,Gd).values()}get length(){return I(this,xn,Gd).size}getTrackById(t){var r;return(r=[...I(this,xn,Gd)].find(s=>s.id===t))!=null?r:null}get onaddtrack(){return I(this,Nr)}set onaddtrack(t){I(this,Nr)&&(this.removeEventListener("addtrack",I(this,Nr)),Z(this,Nr,void 0)),typeof t=="function"&&(Z(this,Nr,t),this.addEventListener("addtrack",t))}get onremovetrack(){return I(this,Ur)}set onremovetrack(t){I(this,Ur)&&(this.removeEventListener("removetrack",I(this,Ur)),Z(this,Ur,void 0)),typeof t=="function"&&(Z(this,Ur,t),this.addEventListener("removetrack",t))}get onchange(){return I(this,Fr)}set onchange(t){I(this,Fr)&&(this.removeEventListener("change",I(this,Fr)),Z(this,Fr,void 0)),typeof t=="function"&&(Z(this,Fr,t),this.addEventListener("change",t))}};Nr=new WeakMap,Ur=new WeakMap,Fr=new WeakMap,xn=new WeakSet,Gd=function(){return V(this).trackSet};var Rn,In=class{constructor(){Te(this,"id");Te(this,"kind");Te(this,"label","");Te(this,"language","");Te(this,"sourceBuffer");ie(this,Rn,!1)}addRendition(e,t,r){let s=new no;return s.src=e,s.codec=t,s.bitrate=r,$T(this,s),s}removeRendition(e){HT(e)}get enabled(){return I(this,Rn)}set enabled(e){I(this,Rn)!==e&&(Z(this,Rn,e),KT(this))}};Rn=new WeakMap;var VT=Wd(globalThis.HTMLMediaElement,"video"),WT=Wd(globalThis.HTMLMediaElement,"audio");function YT(i){if(!(i!=null&&i.prototype))return i;let e=Wd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return dk(this)}});let t=Wd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return uk(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new _n;return l.kind=n,l.label=a,l.language=o,$d(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Hd),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new In;return l.kind=n,l.label=a,l.language=o,Kd(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=Vd),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=V(n).videoRenditions;return a||(a=new As,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=V(n).audioRenditions;return a||(a=new Ss,V(a).media=n,V(n).audioRenditions=a),a};return i}function Wd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function dk(i){var t;let e=V(i).videoTracks;if(!e&&(e=new _s,V(i).videoTracks=e,VT)){let r=VT.call((t=i.nativeEl)!=null?t:i);for(let s of r)$d(i,s);r.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...e].some(n=>n instanceof _n)){for(let n of r)Hd(n);return}$d(i,s.track)}),r.addEventListener("removetrack",s=>{Hd(s.track)})}return e}function uk(i){var t;let e=V(i).audioTracks;if(!e&&(e=new xs,V(i).audioTracks=e,WT)){let r=WT.call((t=i.nativeEl)!=null?t:i);for(let s of r)Kd(i,s);r.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...e].some(n=>n instanceof In)){for(let n of r)Vd(n);return}Kd(i,s.track)}),r.addEventListener("removetrack",s=>{Vd(s.track)})}return e}var jT=i=>{throw TypeError(i)},zT=(i,e,t)=>e.has(i)||jT("Cannot "+t),XT=(i,e,t)=>(zT(i,e,"read from private field"),t?t.call(i):e.get(i)),QT=(i,e,t)=>e.has(i)?jT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),ZT=(i,e,t,r)=>(zT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),jd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends jd{}globalThis.DocumentFragment=i}var Um=class extends jd{},ck=class extends jd{},hk={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Um)}},Yd,fk=class{constructor(i,e={}){QT(this,Yd),ZT(this,Yd,e==null?void 0:e.detail)}get detail(){return XT(this,Yd)}initCustomEvent(){}};Yd=new WeakMap;function mk(i,e){return new Um}var JT={document:{createElement:mk},DocumentFragment,customElements:hk,CustomEvent:fk,EventTarget:jd,HTMLElement:Um,HTMLVideoElement:ck},eb=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Nm=eb?JT:globalThis,zO=eb?JT.document:globalThis.document,qd,qT=class extends OT(YT(bT)){constructor(){super(...arguments),QT(this,qd)}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var i;return(i=XT(this,qd))!=null?i:this.muxCastCustomData}set castCustomData(i){ZT(this,qd,i)}};qd=new WeakMap;Nm.customElements.get("mux-video")||(Nm.customElements.define("mux-video",qT),Nm.MuxVideoElement=qT);var $={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},me={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Fm={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_WIDTH:"mediaWidth"},tb=Object.entries(Fm),b=tb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),pk={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Qt=tb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...pk}),aP=Object.entries(Qt).reduce((i,[e,t])=>{let r=b[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),ib=Object.entries(b).reduce((i,[e,t])=>{let r=Qt[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),Ct={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Br={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Bm={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ht={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ci={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var rb={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function sb(i){return i==null?void 0:i.map(vk).join(" ")}function nb(i){return i==null?void 0:i.split(/\s+/).map(Ek)}function vk(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function Ek(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function ab(i){return i==null?void 0:i.map(Tk).join(" ")}function ob(i){return i==null?void 0:i.split(/\s+/).map(bk)}function Tk(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function bk(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function lb(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Ln(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function zd(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Xd=i=>new Promise(e=>setTimeout(e,i));var db=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],yk=(i,e)=>{let t=i===1?db[e].singular:db[e].plural;return`${i} ${t}`},Rs=i=>{if(!Ln(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&yk(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function hi(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var dP=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var ub={"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","Source Not Supported":"Source Not Supported","Encryption Error":"Encryption Error","A network error caused the media download to fail.":"A network error caused the media download to fail.","A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.":"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.","An unsupported error occurred. The server or network failed, or your browser does not support this format.":"An unsupported error occurred. The server or network failed, or your browser does not support this format.","The media is encrypted and there are no keys to decrypt it.":"The media is encrypted and there are no keys to decrypt it."};var cb,$m={en:ub},Hm=((cb=globalThis.navigator)==null?void 0:cb.language)||"en",hb=i=>{Hm=i};var Ak=i=>{var e,t,r;let[s]=Hm.split("-");return((e=$m[Hm])==null?void 0:e[i])||((t=$m[s])==null?void 0:t[i])||((r=$m.en)==null?void 0:r[i])||i},B=(i,e={})=>Ak(i).replace(/\{(\w+)\}/g,(t,r)=>r in e?String(e[r]):`{${r}}`);var Qd=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Zd=class extends Qd{},Jd=class extends Zd{constructor(){super(...arguments),this.role=null}},Gm=class{observe(){}unobserve(){}disconnect(){}},fb={createElement:function(){return new ao.HTMLElement},createElementNS:function(){return new ao.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},ao={ResizeObserver:Gm,document:fb,Node:Zd,Element:Jd,HTMLElement:class extends Jd{constructor(){super(...arguments),this.innerHTML=""}get content(){return new ao.DocumentFragment}},DocumentFragment:class extends Qd{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}},DOMParser:class{parseFromString(e,t){return{body:{textContent:e}}}}},mb=typeof window=="undefined"||typeof window.customElements=="undefined",pb=Object.keys(ao).every(i=>i in globalThis),S=mb&&!pb?ao:globalThis,Ue=mb&&!pb?fb:globalThis.document;var gb=new WeakMap,Km=i=>{let e=gb.get(i);return e||gb.set(i,e=new Set),e},vb=new S.ResizeObserver(i=>{for(let e of i)for(let t of Km(e.target))t(e)});function ar(i,e){Km(i).add(e),vb.observe(i)}function or(i,e){let t=Km(i);t.delete(e),t.size||vb.unobserve(i)}function He(i){let e={};for(let t of i)e[t.name]=t.value;return e}function We(i){var e;return(e=eu(i))!=null?e:Ri(i,"media-controller")}function eu(i){var e;let{MEDIA_CONTROLLER:t}=me,r=i.getAttribute(t);if(r)return(e=Is(i))==null?void 0:e.getElementById(r)}var tu=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},Sk=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},iu=(i,e)=>Sk(i,e)[0],Rt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Rt(i,e.getRootNode().host),Ri=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||Ri(i.getRootNode().host,e)};function oo(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=oo(t.shadowRoot))!=null?e:t:null}function Is(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function ru(i,{depth:e=3,checkOpacity:t=!0,checkVisibilityCSS:r=!0}={}){if(i.checkVisibility)return i.checkVisibility({checkOpacity:t,checkVisibilityCSS:r});let s=i;for(;s&&e>0;){let n=getComputedStyle(s);if(t&&n.opacity==="0"||r&&n.visibility==="hidden"||n.display==="none")return!1;s=s.parentElement,e--}return!0}function Eb(i,e,t,r){let s=r.x-t.x,n=r.y-t.y,a=s*s+n*n;if(a===0)return 0;let o=((i-t.x)*s+(e-t.y)*n)/a;return Math.max(0,Math.min(1,o))}function Me(i,e){let t=xk(i,r=>r===e);return t||Vm(i,e)}function xk(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(let a of n!=null?n:[])if(e(a.selectorText))return a}}function Vm(i,e){var t,r;let s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function ge(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function ye(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}ge(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function ae(i,e){return i.hasAttribute(e)}function oe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}ae(i,e)!=t&&i.toggleAttribute(e,t)}function de(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function ue(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;de(i,e,void 0)!==r&&i.setAttribute(e,r)}var Tb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$r=(i,e,t)=>(Tb(i,e,"read from private field"),t?t.call(i):e.get(i)),Rk=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},su=(i,e,t,r)=>(Tb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mt;function Ik(i){return`
|
|
127
127
|
<style>
|
|
128
128
|
:host {
|
|
129
129
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
130
130
|
box-sizing: border-box;
|
|
131
131
|
}
|
|
132
132
|
</style>
|
|
133
|
-
`}var kn=class extends S.HTMLElement{constructor(){if(super(),Rk(this,Mt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,b.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=$r(this,Mt))==null?void 0:s.unassociateElement)==null||n.call(s,this),su(this,Mt,null)),r&&this.isConnected&&(su(this,Mt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=$r(this,Mt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),su(this,Mt,Lk(this)),this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=$r(this,Mt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=$r(this,Mt))==null||r.addEventListener("pointerdown",this),(s=$r(this,Mt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=$r(this,Mt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=$r(this,Mt))==null||r.removeEventListener("pointerdown",this),(s=$r(this,Mt))==null||s.removeEventListener("click",this),su(this,Mt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Bm.TOUCH){this.handleTap(e);return}else if(f===Bm.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new S.CustomEvent(t,{composed:!0,bubbles:!0}))}};Mt=new WeakMap;kn.shadowRootOptions={mode:"open"};kn.getTemplateHTML=Ik;function Lk(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Ri(i,"media-controller")}S.customElements.get("media-gesture-receiver")||S.customElements.define("media-gesture-receiver",kn);var nu=kn;var jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kt=(i,e,t)=>(jm(i,e,"read from private field"),t?t.call(i):e.get(i)),Gt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ls=(i,e,t,r)=>(jm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Zt=(i,e,t)=>(jm(i,e,"access private method"),t),lu,wn,
|
|
133
|
+
`}var kn=class extends S.HTMLElement{constructor(){if(super(),Rk(this,Mt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,b.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=$r(this,Mt))==null?void 0:s.unassociateElement)==null||n.call(s,this),su(this,Mt,null)),r&&this.isConnected&&(su(this,Mt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=$r(this,Mt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),su(this,Mt,Lk(this)),this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=$r(this,Mt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=$r(this,Mt))==null||r.addEventListener("pointerdown",this),(s=$r(this,Mt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(me.MEDIA_CONTROLLER)&&((t=(e=$r(this,Mt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=$r(this,Mt))==null||r.removeEventListener("pointerdown",this),(s=$r(this,Mt))==null||s.removeEventListener("click",this),su(this,Mt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Bm.TOUCH){this.handleTap(e);return}else if(f===Bm.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new S.CustomEvent(t,{composed:!0,bubbles:!0}))}};Mt=new WeakMap;kn.shadowRootOptions={mode:"open"};kn.getTemplateHTML=Ik;function Lk(i){var e;let t=i.getAttribute(me.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Ri(i,"media-controller")}S.customElements.get("media-gesture-receiver")||S.customElements.define("media-gesture-receiver",kn);var nu=kn;var jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Kt=(i,e,t)=>(jm(i,e,"read from private field"),t?t.call(i):e.get(i)),Gt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ls=(i,e,t,r)=>(jm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Zt=(i,e,t)=>(jm(i,e,"access private method"),t),lu,wn,uo,Dn,au,Wm,bb,lo,ou,Ym,yb,qm,_b,co,du,uu,zm,Cn,ho,ee={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};function kk(i){return`
|
|
134
134
|
<style>
|
|
135
135
|
|
|
136
136
|
:host([${b.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
@@ -280,7 +280,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
280
280
|
<slot part="bottom chrome"></slot>
|
|
281
281
|
</span>
|
|
282
282
|
<slot name="dialog" part="layer dialog-layer"></slot>
|
|
283
|
-
`}var wk=Object.values(b),Dk="sm:384 md:576 lg:768 xl:960";function Ck(i){Ab(i.target,i.contentRect.width)}function Ab(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ee.BREAKPOINTS))!=null?t:Dk,s=Mk(r),n=Ok(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Qt.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}i.breakpointsComputed||(i.breakpointsComputed=!0,i.dispatchEvent(new CustomEvent(Qt.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}function Mk(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Ok(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}var ks=class extends S.HTMLElement{constructor(){if(super(),Gt(this,Wm),Gt(this,Ym),Gt(this,qm),Gt(this,uo),Gt(this,uu),Gt(this,Cn),Gt(this,lu,0),Gt(this,wn,null),Gt(this,lo,null),Gt(this,Dn,void 0),this.breakpointsComputed=!1,Gt(this,au,new MutationObserver(Zt(this,Wm,bb).bind(this))),Gt(this,oo,!1),Gt(this,ou,t=>{Kt(this,oo)||(setTimeout(()=>{Ck(t),Ls(this,oo,!1)},0),Ls(this,oo,!0))}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let t=He(this.attributes),r=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(r):this.shadowRoot.innerHTML=r}let e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:!0}).length){Kt(this,wn)&&this.mediaUnsetCallback(Kt(this,wn));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ee.AUTOHIDE,ee.GESTURES_DISABLED].concat(wk).filter(e=>![b.MEDIA_RENDITION_LIST,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_CHAPTERS_CUES,b.MEDIA_WIDTH,b.MEDIA_HEIGHT,b.MEDIA_ERROR,b.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ee.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Ls(this,wn,e),e.localName.includes("-")&&await S.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;Kt(this,au).observe(this,{childList:!0,subtree:!0}),ar(this,Kt(this,ou));let r=this.getAttribute(ee.AUDIO)!=null?B("audio player"):B("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(ee.USER_INACTIVE,""),Ab(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=S.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;Kt(this,au).disconnect(),or(this,Kt(this,ou)),this.media&&this.mediaUnsetCallback(this.media),(e=S.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Ls(this,wn,null)}handleEvent(e){switch(e.type){case"pointerdown":Ls(this,lu,e.timeStamp);break;case"pointermove":Zt(this,Ym,yb).call(this,e);break;case"pointerup":Zt(this,qm,_b).call(this,e);break;case"mouseleave":Zt(this,uo,du).call(this);break;case"mouseup":this.removeAttribute(ee.KEYBOARD_CONTROL);break;case"keyup":Zt(this,Cn,co).call(this),this.setAttribute(ee.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);Ls(this,Dn,isNaN(t)?0:t)}get autohide(){return(Kt(this,Dn)===void 0?2:Kt(this,Dn)).toString()}get breakpoints(){return de(this,ee.BREAKPOINTS)}set breakpoints(e){ue(this,ee.BREAKPOINTS,e)}get audio(){return ae(this,ee.AUDIO)}set audio(e){oe(this,ee.AUDIO,e)}get gesturesDisabled(){return ae(this,ee.GESTURES_DISABLED)}set gesturesDisabled(e){oe(this,ee.GESTURES_DISABLED,e)}get keyboardControl(){return ae(this,ee.KEYBOARD_CONTROL)}set keyboardControl(e){oe(this,ee.KEYBOARD_CONTROL,e)}get noAutohide(){return ae(this,ee.NO_AUTOHIDE)}set noAutohide(e){oe(this,ee.NO_AUTOHIDE,e)}get autohideOverControls(){return ae(this,ee.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){oe(this,ee.AUTOHIDE_OVER_CONTROLS,e)}get userInteractive(){return ae(this,ee.USER_INACTIVE)}set userInteractive(e){oe(this,ee.USER_INACTIVE,e)}};lu=new WeakMap;wn=new WeakMap;lo=new WeakMap;Dn=new WeakMap;au=new WeakMap;Wm=new WeakSet;bb=function(i){let e=this.media;for(let t of i){if(t.type!=="childList")continue;let r=t.removedNodes;for(let s of r){if(s.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(s);else{let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=!1);a&&this.mediaUnsetCallback(s)}}if(e)for(let s of t.addedNodes)s===e&&this.handleMediaUpdated(e)}};oo=new WeakMap;ou=new WeakMap;Ym=new WeakSet;yb=function(i){if(i.pointerType!=="mouse"&&i.timeStamp-Kt(this,lu)<250)return;Zt(this,uu,zm).call(this),clearTimeout(Kt(this,lo));let e=this.hasAttribute(ee.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(i.target)||e)&&Zt(this,Cn,co).call(this)};qm=new WeakSet;_b=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ee.USER_INACTIVE);[this,this.media].includes(i.target)&&e?Zt(this,uo,du).call(this):Zt(this,Cn,co).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&Zt(this,Cn,co).call(this)};uo=new WeakSet;du=function(){if(Kt(this,Dn)<0||this.hasAttribute(ee.USER_INACTIVE))return;this.setAttribute(ee.USER_INACTIVE,"");let i=new S.CustomEvent(Qt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};uu=new WeakSet;zm=function(){if(!this.hasAttribute(ee.USER_INACTIVE))return;this.removeAttribute(ee.USER_INACTIVE);let i=new S.CustomEvent(Qt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Cn=new WeakSet;co=function(){Zt(this,uu,zm).call(this),clearTimeout(Kt(this,lo));let i=parseInt(this.autohide);i<0||Ls(this,lo,setTimeout(()=>{Zt(this,uo,du).call(this)},i*1e3))};ks.shadowRootOptions={mode:"open"};ks.getTemplateHTML=kk;S.customElements.get("media-container")||S.customElements.define("media-container",ks);var Sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(Sb(i,e,"read from private field"),t?t.call(i):e.get(i)),ho=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cu=(i,e,t,r)=>(Sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,On,hu,ws,lr,Hr,Gr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){ho(this,lr),ho(this,Mn,void 0),ho(this,On,void 0),ho(this,hu,void 0),ho(this,ws,new Set),cu(this,Mn,e),cu(this,On,t),cu(this,hu,new Set(r))}[Symbol.iterator](){return gt(this,lr,Hr).values()}get length(){return gt(this,lr,Hr).size}get value(){var e;return(e=[...gt(this,lr,Hr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(cu(this,ws,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...gt(this,lr,Hr)][e]}values(){return gt(this,lr,Hr).values()}forEach(e,t){gt(this,lr,Hr).forEach(e,t)}add(...e){var t,r;e.forEach(s=>gt(this,ws).add(s)),!(this.value===""&&!((t=gt(this,Mn))!=null&&t.hasAttribute(`${gt(this,On)}`)))&&((r=gt(this,Mn))==null||r.setAttribute(`${gt(this,On)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>gt(this,ws).delete(r)),(t=gt(this,Mn))==null||t.setAttribute(`${gt(this,On)}`,`${this.value}`)}contains(e){return gt(this,lr,Hr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Mn=new WeakMap;On=new WeakMap;hu=new WeakMap;ws=new WeakMap;lr=new WeakSet;Hr=function(){return gt(this,ws).size?gt(this,ws):gt(this,hu)};var Pk=(i="")=>i.split(/\s+/),xb=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?Ct.CAPTIONS:Ct.SUBTITLES,language:t,label:s}},Ds=(i="",e={})=>Pk(i).map(t=>{let r=xb(t);return{...e,...r}}),Xm=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?xb(e):e):typeof i=="string"?Ds(i):[i]:[],fu=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,dr=(i=[])=>Array.prototype.map.call(i,fu).join(" "),Nk=(i,e)=>t=>t[i]===e,Rb=i=>{let e=Object.entries(i).map(([t,r])=>Nk(t,r));return t=>e.every(r=>r(t))},Cs=(i,e=[],t=[])=>{let r=Xm(t).map(Rb),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},Ms=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:Rb(e);return Array.from(i.textTracks).filter(t)},mu=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(b.MEDIA_SUBTITLES_SHOWING)};var Lb=i=>{var e;let{media:t,fullscreenElement:r}=i;try{let s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){let n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()}catch(s){console.error(s)}},Ib="exitFullscreen"in Ue?"exitFullscreen":"webkitExitFullscreen"in Ue?"webkitExitFullscreen":"webkitCancelFullScreen"in Ue?"webkitCancelFullScreen":void 0,kb=i=>{var e;let{documentElement:t}=i;if(Ib){let r=(e=t==null?void 0:t[Ib])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},fo="fullscreenElement"in Ue?"fullscreenElement":"webkitFullscreenElement"in Ue?"webkitFullscreenElement":void 0,Uk=i=>{let{documentElement:e,media:t}=i,r=e==null?void 0:e[fo];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===rb.FULLSCREEN?t:r},wb=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=Uk(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(fo in a))return Rt(n,s);for(;a!=null&&a[fo];){if(a[fo]===s)return!0;a=(e=a[fo])==null?void 0:e.shadowRoot}}return!1},Fk="fullscreenEnabled"in Ue?"fullscreenEnabled":"webkitFullscreenEnabled"in Ue?"webkitFullscreenEnabled":void 0,Db=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[Fk])||t&&"webkitSupportsFullscreen"in t};var pu,Qm=()=>{var i,e;return pu||(pu=(e=(i=Ue)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),pu)},Cb=async(i=Qm())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([Bk(i,t.signal),$k(i,e)]);return t.abort(),r},Bk=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),$k=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await Xd(10)}return i.volume!==e},Hk=/.*Version\/.*Safari\/.*/.test(S.navigator.userAgent),Zm=(i=Qm())=>S.matchMedia("(display-mode: standalone)").matches&&Hk?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Jm=(i=Qm())=>Db({documentElement:Ue,media:i}),Mb=Jm(),Ob=Zm(),Pb=!!S.WebKitPlaybackTargetAvailabilityEvent,Nb=!!S.chrome;var Pn=i=>Ms(i.media,e=>[Ct.SUBTITLES,Ct.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),ep=i=>Ms(i.media,e=>e.mode===Br.SHOWING&&[Ct.SUBTITLES,Ct.CAPTIONS].includes(e.kind)),gu=(i,e)=>{let t=Pn(i),r=ep(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)Cs(Br.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),g=c.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;Cs(Br.DISABLED,t,r),Cs(Br.SHOWING,t,[{language:o,label:l,kind:d}])}}},vu=(i,e)=>i===e?!0:i==null||e==null||typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?Gk(i,e):Object.entries(i).every(([t,r])=>t in e&&vu(r,e[t])),Gk=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>vu(s,e[n])):!0};var Kk=Object.values(ci),Eu,Vk=Cb().then(i=>(Eu=i,Eu)),Ub=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof S.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=S.customElements.get(t);r&&e instanceof r||(await S.customElements.whenDefined(t),S.customElements.upgrade(e))}))},Wk=new S.DOMParser,Yk=i=>i&&(Wk.parseFromString(i,"text/html").body.textContent||i),Nn={mediaError:{get(i,e){let{media:t}=i;if((e==null?void 0:e.type)!=="playing")return t==null?void 0:t.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(i,e){var t;let{media:r}=i;if((e==null?void 0:e.type)!=="playing")return(t=r==null?void 0:r.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(i,e){var t,r;let{media:s}=i;if((e==null?void 0:e.type)!=="playing")return(r=(t=s==null?void 0:s.error)==null?void 0:t.message)!=null?r:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;if(t){try{S.localStorage.setItem("media-chrome-pref-muted",i?"true":"false")}catch(r){console.debug("Error setting muted pref",r)}t.muted=i}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noMutedPref:t}}=e,{media:r}=e;if(!(!r||r.muted||t))try{let s=S.localStorage.getItem("media-chrome-pref-muted")==="true";Nn.mediaMuted.set(s,e),i(s)}catch(s){console.debug("Error getting muted pref",s)}}]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?S.localStorage.removeItem("media-chrome-pref-volume"):S.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch(r){console.debug("Error setting volume pref",r)}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let{media:r}=e;if(!r)return;let s=S.localStorage.getItem("media-chrome-pref-volume");if(s==null)return;Nn.mediaVolume.set(+s,e),i(+s)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||!Ln(i)||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[ci.LIVE,ci.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(Kk.includes(s))return s===ci.UNKNOWN?r:s;let n=e.duration;return n===1/0?ci.LIVE:Number.isFinite(n)?ci.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=Nn.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===ci.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Nn.mediaStreamType.get(i)===ci.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return Pn(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return ep(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![Ct.CAPTIONS,Ct.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||gu(e,!0)};return s.addEventListener("loadstart",a),(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),()=>{var o,l;s.removeEventListener("loadstart",a),(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=Ms(t,{kind:Ct.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:Yk(s),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;if(!r)return;let s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?Rt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!Ue.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else Ue.pictureInPictureElement&&Ue.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return wb(i)},set(i,e){i?Lb(e):kb(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&S.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!Mb||!Jm(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!Ob||!Zm(e))return Ht.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(Eu===!1||(e==null?void 0:e.volume)==null)return Ht.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{Eu==null&&Vk.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!Nb||!((t=r==null?void 0:r.remote)!=null&&t.state))return Ht.UNSUPPORTED;if(!(e==null||e==="available"))return Ht.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!Pb)return Ht.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Ht.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Ht.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Ht.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var Fb={[$.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=Ms(a,{kind:Ct.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,v)=>g===0?p.endTime>o:g===v.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[$.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[$.MEDIA_PLAY_REQUEST](i,e){var t,r,s,n;let a="mediaPaused",l=i.mediaStreamType.get(e)===ci.LIVE,d=!((t=e.options)!=null&&t.noAutoSeekToLive),u=i.mediaTargetLiveWindow.get(e)>0;if(l&&d&&!u){let c=(r=i.mediaSeekable.get(e))==null?void 0:r[1];if(c){let h=(n=(s=e.options)==null?void 0:s.seekToLiveOffset)!=null?n:0,f=c-h;i.mediaCurrentTime.set(f,e)}}i[a].set(!1,e)},[$.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[$.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[$.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[$.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[$.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[$.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t,r,s;let n="mediaCurrentTime",a=(t=i.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;let o=(s=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?s:0,l=a-o;i[n].set(l,e)},[$.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=Pn(e),a=Xm(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&S.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Cs(Br.SHOWING,n,a)},[$.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=Pn(e),s=t!=null?t:[];Cs(Br.DISABLED,r,s)},[$.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){gu(e,t)},[$.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[$.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[$.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[$.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[$.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[$.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var Bb=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Nn,requestMap:s=Fb,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(vu(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[v,{get:y}])=>(g[v]=y(l),g),{});u(p)},h={},f,m=async(p,g)=>{var v,y,T,_,A,k,R,x,O,w,C,P,U,X,z,q;let ce=!!f;if(f={...l,...f!=null?f:{},...p},ce)return;await Ub(...Object.values(p));let fe=o.length>0&&g===0&&a,W=l.media!==f.media,G=((v=l.media)==null?void 0:v.textTracks)!==((y=f.media)==null?void 0:y.textTracks),pe=((T=l.media)==null?void 0:T.videoRenditions)!==((_=f.media)==null?void 0:_.videoRenditions),te=((A=l.media)==null?void 0:A.audioTracks)!==((k=f.media)==null?void 0:k.audioTracks),_e=((R=l.media)==null?void 0:R.remote)!==((x=f.media)==null?void 0:x.remote),Ke=l.documentElement!==f.documentElement,Ye=!!l.media&&(W||fe),ze=!!((O=l.media)!=null&&O.textTracks)&&(G||fe),xt=!!((w=l.media)!=null&&w.videoRenditions)&&(pe||fe),Er=!!((C=l.media)!=null&&C.audioTracks)&&(te||fe),rn=!!((P=l.media)!=null&&P.remote)&&(_e||fe),Kg=!!l.documentElement&&(Ke||fe),Vg=Ye||ze||xt||Er||rn||Kg,sn=o.length===0&&g===1&&a,Wg=!!f.media&&(W||sn),Yg=!!((U=f.media)!=null&&U.textTracks)&&(G||sn),qg=!!((X=f.media)!=null&&X.videoRenditions)&&(pe||sn),jg=!!((z=f.media)!=null&&z.audioTracks)&&(te||sn),zg=!!((q=f.media)!=null&&q.remote)&&(_e||sn),Xg=!!f.documentElement&&(Ke||sn),Qg=Wg||Yg||qg||jg||zg||Xg;if(!(Vg||Qg)){Object.entries(f).forEach(([Oe,ya])=>{l[Oe]=ya}),c(),f=void 0;return}Object.entries(r).forEach(([Oe,{get:ya,mediaEvents:Z_=[],textTracksEvents:J_=[],videoRenditionsEvents:eA=[],audioTracksEvents:tA=[],remoteEvents:iA=[],rootEvents:rA=[],stateOwnersUpdateHandlers:sA=[]}])=>{h[Oe]||(h[Oe]={});let Ut=Ze=>{let Ft=ya(l,Ze);u({[Oe]:Ft})},ut;ut=h[Oe].mediaEvents,Z_.forEach(Ze=>{ut&&Ye&&(l.media.removeEventListener(Ze,ut),h[Oe].mediaEvents=void 0),Wg&&(f.media.addEventListener(Ze,Ut),h[Oe].mediaEvents=Ut)}),ut=h[Oe].textTracksEvents,J_.forEach(Ze=>{var Ft,ti;ut&&ze&&((Ft=l.media.textTracks)==null||Ft.removeEventListener(Ze,ut),h[Oe].textTracksEvents=void 0),Yg&&((ti=f.media.textTracks)==null||ti.addEventListener(Ze,Ut),h[Oe].textTracksEvents=Ut)}),ut=h[Oe].videoRenditionsEvents,eA.forEach(Ze=>{var Ft,ti;ut&&xt&&((Ft=l.media.videoRenditions)==null||Ft.removeEventListener(Ze,ut),h[Oe].videoRenditionsEvents=void 0),qg&&((ti=f.media.videoRenditions)==null||ti.addEventListener(Ze,Ut),h[Oe].videoRenditionsEvents=Ut)}),ut=h[Oe].audioTracksEvents,tA.forEach(Ze=>{var Ft,ti;ut&&Er&&((Ft=l.media.audioTracks)==null||Ft.removeEventListener(Ze,ut),h[Oe].audioTracksEvents=void 0),jg&&((ti=f.media.audioTracks)==null||ti.addEventListener(Ze,Ut),h[Oe].audioTracksEvents=Ut)}),ut=h[Oe].remoteEvents,iA.forEach(Ze=>{var Ft,ti;ut&&rn&&((Ft=l.media.remote)==null||Ft.removeEventListener(Ze,ut),h[Oe].remoteEvents=void 0),zg&&((ti=f.media.remote)==null||ti.addEventListener(Ze,Ut),h[Oe].remoteEvents=Ut)}),ut=h[Oe].rootEvents,rA.forEach(Ze=>{ut&&Kg&&(l.documentElement.removeEventListener(Ze,ut),h[Oe].rootEvents=void 0),Xg&&(f.documentElement.addEventListener(Ze,Ut),h[Oe].rootEvents=Ut)});let Zg=h[Oe].stateOwnersUpdateHandlers;sA.forEach(Ze=>{Zg&&Vg&&Zg(),Qg&&(h[Oe].stateOwnersUpdateHandlers=Ze(Ut,f))})}),Object.entries(f).forEach(([Oe,ya])=>{l[Oe]=ya}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:v}=p;if(s[g]&&d.mediaErrorCode==null){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:v}):g==="fullscreenelementchangerequest"?m({fullscreenElement:v}):g==="documentelementchangerequest"?m({documentElement:v}):g==="optionschangerequest"&&Object.entries(v!=null?v:{}).forEach(([y,T])=>{l.options[y]=T})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var sp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},be=(i,e,t)=>(sp(i,e,"read from private field"),t?t.call(i):e.get(i)),ur=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kr=(i,e,t,r)=>(sp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Vr=(i,e,t)=>(sp(i,e,"access private method"),t),Ps,mo,Fe,po,Ii,Tu,bu,tp,Un,go,yu,ip,Vb=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],$b=10,Y={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",SEEK_TO_LIVE_OFFSET:"seektoliveoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset",LANG:"lang"},_u=class extends ks{constructor(){super(),ur(this,bu),ur(this,Un),ur(this,yu),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,ur(this,Ps,new Gr(this,Y.HOTKEYS)),ur(this,mo,void 0),ur(this,Fe,void 0),ur(this,po,void 0),ur(this,Ii,void 0),ur(this,Tu,t=>{var r;(r=be(this,Fe))==null||r.dispatch(t)}),this.associateElement(this);let e={};Kr(this,po,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new S.CustomEvent(ib[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Y.NO_HOTKEYS,Y.HOTKEYS,Y.DEFAULT_STREAM_TYPE,Y.DEFAULT_SUBTITLES,Y.DEFAULT_DURATION,Y.LANG)}get mediaStore(){return be(this,Fe)}set mediaStore(e){var t,r;if(be(this,Fe)&&((t=be(this,Ii))==null||t.call(this),Kr(this,Ii,void 0)),Kr(this,Fe,e),!be(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)){Vr(this,bu,tp).call(this);return}Kr(this,Ii,(r=be(this,Fe))==null?void 0:r.subscribe(be(this,po)))}get fullscreenElement(){var e;return(e=be(this,mo))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(Y.FULLSCREEN_ELEMENT)&&this.removeAttribute(Y.FULLSCREEN_ELEMENT),Kr(this,mo,e),(t=be(this,Fe))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return ae(this,Y.DEFAULT_SUBTITLES)}set defaultSubtitles(e){oe(this,Y.DEFAULT_SUBTITLES,e)}get defaultStreamType(){return de(this,Y.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){ue(this,Y.DEFAULT_STREAM_TYPE,e)}get defaultDuration(){return ge(this,Y.DEFAULT_DURATION)}set defaultDuration(e){ye(this,Y.DEFAULT_DURATION,e)}get noHotkeys(){return ae(this,Y.NO_HOTKEYS)}set noHotkeys(e){oe(this,Y.NO_HOTKEYS,e)}get keysUsed(){return de(this,Y.KEYS_USED)}set keysUsed(e){ue(this,Y.KEYS_USED,e)}get liveEdgeOffset(){return ge(this,Y.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){ye(this,Y.LIVE_EDGE_OFFSET,e)}get noAutoSeekToLive(){return ae(this,Y.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){oe(this,Y.NO_AUTO_SEEK_TO_LIVE,e)}get noVolumePref(){return ae(this,Y.NO_VOLUME_PREF)}set noVolumePref(e){oe(this,Y.NO_VOLUME_PREF,e)}get noSubtitlesLangPref(){return ae(this,Y.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){oe(this,Y.NO_SUBTITLES_LANG_PREF,e)}get noDefaultStore(){return ae(this,Y.NO_DEFAULT_STORE)}set noDefaultStore(e){oe(this,Y.NO_DEFAULT_STORE,e)}attributeChangedCallback(e,t,r){var s,n,a,o,l,d,u,c;if(super.attributeChangedCallback(e,t,r),e===Y.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Y.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Y.HOTKEYS)be(this,Ps).value=r;else if(e===Y.DEFAULT_SUBTITLES&&r!==t)(s=be(this,Fe))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES)}});else if(e===Y.DEFAULT_STREAM_TYPE)(a=be(this,Fe))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(Y.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===Y.LIVE_EDGE_OFFSET)(o=be(this,Fe))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(Y.LIVE_EDGE_OFFSET)}});else if(e===Y.SEEK_TO_LIVE_OFFSET)(l=be(this,Fe))==null||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(Y.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===Y.NO_AUTO_SEEK_TO_LIVE)(d=be(this,Fe))==null||d.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(Y.NO_AUTO_SEEK_TO_LIVE)}});else if(e===Y.FULLSCREEN_ELEMENT){let h=r?(u=this.getRootNode())==null?void 0:u.getElementById(r):void 0;Kr(this,mo,h),(c=be(this,Fe))==null||c.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===Y.LANG&&r!==t&&hb(r)}connectedCallback(){var e,t;!be(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)&&Vr(this,bu,tp).call(this),(e=be(this,Fe))==null||e.dispatch({type:"documentelementchangerequest",detail:Ue}),super.connectedCallback(),be(this,Fe)&&!be(this,Ii)&&Kr(this,Ii,(t=be(this,Fe))==null?void 0:t.subscribe(be(this,po))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),be(this,Fe)&&((t=be(this,Fe))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=be(this,Fe))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),be(this,Ii)&&((s=be(this,Ii))==null||s.call(this),Kr(this,Ii,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=be(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=be(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Kb(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=Zk(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,be(this,Tu))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values($).forEach(s=>{e.removeEventListener(s,be(this,Tu))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),be(this,Fe)&&Object.entries(be(this,Fe).getState()).forEach(([s,n])=>{Kb([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",Vr(this,yu,ip))}disableHotkeys(){this.removeEventListener("keydown",Vr(this,yu,ip)),this.removeEventListener("keyup",Vr(this,Un,go))}get hotkeys(){return de(this,Y.HOTKEYS)}set hotkeys(e){ue(this,Y.HOTKEYS,e)}keyboardShortcutHandler(e){var t,r,s,n,a;let o=e.target;if(((s=(r=(t=o.getAttribute(Y.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!be(this,Ps).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&be(this,Ps).contains("nospace")))switch(e.key){case" ":case"k":d=be(this,Fe).getState().mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new S.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(Y.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(Y.KEYBOARD_BACKWARD_SEEK_OFFSET):$b;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(Y.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(Y.KEYBOARD_FORWARD_SEEK_OFFSET):$b;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};Ps=new WeakMap;mo=new WeakMap;Fe=new WeakMap;po=new WeakMap;Ii=new WeakMap;Tu=new WeakMap;bu=new WeakSet;tp=function(){var i;this.mediaStore=Bb({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(Y.DEFAULT_DURATION)?+this.getAttribute(Y.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(Y.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(Y.SEEK_TO_LIVE_OFFSET):this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(Y.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(Y.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(Y.NO_SUBTITLES_LANG_PREF)}})};Un=new WeakSet;go=function(i){let{key:e}=i;if(!Vb.includes(e)){this.removeEventListener("keyup",Vr(this,Un,go));return}this.keyboardShortcutHandler(i)};yu=new WeakSet;ip=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!Vb.includes(r)){this.removeEventListener("keyup",Vr(this,Un,go));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(be(this,Ps).contains(`no${r.toLowerCase()}`)||r===" "&&be(this,Ps).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Vr(this,Un,go),{once:!0})};var qk=Object.values(b),jk=Object.values(Fm),Wb=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(S.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,me.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>qk.includes(o)):[]},zk=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&S.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof S.customElements.get(i.nodeName.toLowerCase()))&&S.customElements.upgrade(i),jk.some(r=>r in i)},rp=i=>zk(i)||!!Wb(i).length,Hb=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Gb={[b.MEDIA_SUBTITLES_LIST]:dr,[b.MEDIA_SUBTITLES_SHOWING]:dr,[b.MEDIA_SEEKABLE]:Hb,[b.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Hb).join(" "),[b.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[b.MEDIA_RENDITION_LIST]:sb,[b.MEDIA_AUDIO_TRACK_LIST]:ab},Xk=async(i,e,t)=>{var r,s;if(i.isConnected||await Xd(0),typeof t=="boolean"||t==null)return oe(i,e,t);if(typeof t=="number")return ye(i,e,t);if(typeof t=="string")return ue(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=Gb[e])==null?void 0:r.call(Gb,t))!=null?s:t;return i.setAttribute(e,n)},Qk=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Os=(i,e)=>{if(Qk(i))return;let t=(s,n)=>{var a,o;rp(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Os(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!rp(i)){S.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},Kb=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=Wb(r),n=e.toLowerCase();s.includes(n)&&Xk(r,n,t)})},Zk=(i,e,t)=>{Os(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,v=>Os(v,e)),Array.prototype.forEach.call(f,v=>Os(v,t))):m==="attributes"&&g===me.MEDIA_CHROME_ATTRIBUTES&&(rp(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>Os(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Os(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Os(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};S.customElements.get("media-controller")||S.customElements.define("media-controller",_u);var np=_u;var Fn={PLACEMENT:"placement",BOUNDS:"bounds"};function Jk(i){return`
|
|
283
|
+
`}var wk=Object.values(b),Dk="sm:384 md:576 lg:768 xl:960";function Ck(i){Ab(i.target,i.contentRect.width)}function Ab(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ee.BREAKPOINTS))!=null?t:Dk,s=Mk(r),n=Ok(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(Qt.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}i.breakpointsComputed||(i.breakpointsComputed=!0,i.dispatchEvent(new CustomEvent(Qt.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}function Mk(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Ok(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}var ks=class extends S.HTMLElement{constructor(){if(super(),Gt(this,Wm),Gt(this,Ym),Gt(this,qm),Gt(this,co),Gt(this,uu),Gt(this,Cn),Gt(this,lu,0),Gt(this,wn,null),Gt(this,uo,null),Gt(this,Dn,void 0),this.breakpointsComputed=!1,Gt(this,au,new MutationObserver(Zt(this,Wm,bb).bind(this))),Gt(this,lo,!1),Gt(this,ou,t=>{Kt(this,lo)||(setTimeout(()=>{Ck(t),Ls(this,lo,!1)},0),Ls(this,lo,!0))}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let t=He(this.attributes),r=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(r):this.shadowRoot.innerHTML=r}let e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:!0}).length){Kt(this,wn)&&this.mediaUnsetCallback(Kt(this,wn));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ee.AUTOHIDE,ee.GESTURES_DISABLED].concat(wk).filter(e=>![b.MEDIA_RENDITION_LIST,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_CHAPTERS_CUES,b.MEDIA_WIDTH,b.MEDIA_HEIGHT,b.MEDIA_ERROR,b.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==ee.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Ls(this,wn,e),e.localName.includes("-")&&await S.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;Kt(this,au).observe(this,{childList:!0,subtree:!0}),ar(this,Kt(this,ou));let r=this.getAttribute(ee.AUDIO)!=null?B("audio player"):B("video player");this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(ee.USER_INACTIVE,""),Ab(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=S.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;Kt(this,au).disconnect(),or(this,Kt(this,ou)),this.media&&this.mediaUnsetCallback(this.media),(e=S.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Ls(this,wn,null)}handleEvent(e){switch(e.type){case"pointerdown":Ls(this,lu,e.timeStamp);break;case"pointermove":Zt(this,Ym,yb).call(this,e);break;case"pointerup":Zt(this,qm,_b).call(this,e);break;case"mouseleave":Zt(this,co,du).call(this);break;case"mouseup":this.removeAttribute(ee.KEYBOARD_CONTROL);break;case"keyup":Zt(this,Cn,ho).call(this),this.setAttribute(ee.KEYBOARD_CONTROL,"");break}}set autohide(e){let t=Number(e);Ls(this,Dn,isNaN(t)?0:t)}get autohide(){return(Kt(this,Dn)===void 0?2:Kt(this,Dn)).toString()}get breakpoints(){return de(this,ee.BREAKPOINTS)}set breakpoints(e){ue(this,ee.BREAKPOINTS,e)}get audio(){return ae(this,ee.AUDIO)}set audio(e){oe(this,ee.AUDIO,e)}get gesturesDisabled(){return ae(this,ee.GESTURES_DISABLED)}set gesturesDisabled(e){oe(this,ee.GESTURES_DISABLED,e)}get keyboardControl(){return ae(this,ee.KEYBOARD_CONTROL)}set keyboardControl(e){oe(this,ee.KEYBOARD_CONTROL,e)}get noAutohide(){return ae(this,ee.NO_AUTOHIDE)}set noAutohide(e){oe(this,ee.NO_AUTOHIDE,e)}get autohideOverControls(){return ae(this,ee.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){oe(this,ee.AUTOHIDE_OVER_CONTROLS,e)}get userInteractive(){return ae(this,ee.USER_INACTIVE)}set userInteractive(e){oe(this,ee.USER_INACTIVE,e)}};lu=new WeakMap;wn=new WeakMap;uo=new WeakMap;Dn=new WeakMap;au=new WeakMap;Wm=new WeakSet;bb=function(i){let e=this.media;for(let t of i){if(t.type!=="childList")continue;let r=t.removedNodes;for(let s of r){if(s.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(s);else{let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=!1);a&&this.mediaUnsetCallback(s)}}if(e)for(let s of t.addedNodes)s===e&&this.handleMediaUpdated(e)}};lo=new WeakMap;ou=new WeakMap;Ym=new WeakSet;yb=function(i){if(i.pointerType!=="mouse"&&i.timeStamp-Kt(this,lu)<250)return;Zt(this,uu,zm).call(this),clearTimeout(Kt(this,uo));let e=this.hasAttribute(ee.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(i.target)||e)&&Zt(this,Cn,ho).call(this)};qm=new WeakSet;_b=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ee.USER_INACTIVE);[this,this.media].includes(i.target)&&e?Zt(this,co,du).call(this):Zt(this,Cn,ho).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&Zt(this,Cn,ho).call(this)};co=new WeakSet;du=function(){if(Kt(this,Dn)<0||this.hasAttribute(ee.USER_INACTIVE))return;this.setAttribute(ee.USER_INACTIVE,"");let i=new S.CustomEvent(Qt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};uu=new WeakSet;zm=function(){if(!this.hasAttribute(ee.USER_INACTIVE))return;this.removeAttribute(ee.USER_INACTIVE);let i=new S.CustomEvent(Qt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Cn=new WeakSet;ho=function(){Zt(this,uu,zm).call(this),clearTimeout(Kt(this,uo));let i=parseInt(this.autohide);i<0||Ls(this,uo,setTimeout(()=>{Zt(this,co,du).call(this)},i*1e3))};ks.shadowRootOptions={mode:"open"};ks.getTemplateHTML=kk;S.customElements.get("media-container")||S.customElements.define("media-container",ks);var Sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(Sb(i,e,"read from private field"),t?t.call(i):e.get(i)),fo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cu=(i,e,t,r)=>(Sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,On,hu,ws,lr,Hr,Gr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){fo(this,lr),fo(this,Mn,void 0),fo(this,On,void 0),fo(this,hu,void 0),fo(this,ws,new Set),cu(this,Mn,e),cu(this,On,t),cu(this,hu,new Set(r))}[Symbol.iterator](){return gt(this,lr,Hr).values()}get length(){return gt(this,lr,Hr).size}get value(){var e;return(e=[...gt(this,lr,Hr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(cu(this,ws,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...gt(this,lr,Hr)][e]}values(){return gt(this,lr,Hr).values()}forEach(e,t){gt(this,lr,Hr).forEach(e,t)}add(...e){var t,r;e.forEach(s=>gt(this,ws).add(s)),!(this.value===""&&!((t=gt(this,Mn))!=null&&t.hasAttribute(`${gt(this,On)}`)))&&((r=gt(this,Mn))==null||r.setAttribute(`${gt(this,On)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>gt(this,ws).delete(r)),(t=gt(this,Mn))==null||t.setAttribute(`${gt(this,On)}`,`${this.value}`)}contains(e){return gt(this,lr,Hr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};Mn=new WeakMap;On=new WeakMap;hu=new WeakMap;ws=new WeakMap;lr=new WeakSet;Hr=function(){return gt(this,ws).size?gt(this,ws):gt(this,hu)};var Pk=(i="")=>i.split(/\s+/),xb=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?Ct.CAPTIONS:Ct.SUBTITLES,language:t,label:s}},Ds=(i="",e={})=>Pk(i).map(t=>{let r=xb(t);return{...e,...r}}),Xm=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?xb(e):e):typeof i=="string"?Ds(i):[i]:[],fu=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,dr=(i=[])=>Array.prototype.map.call(i,fu).join(" "),Nk=(i,e)=>t=>t[i]===e,Rb=i=>{let e=Object.entries(i).map(([t,r])=>Nk(t,r));return t=>e.every(r=>r(t))},Cs=(i,e=[],t=[])=>{let r=Xm(t).map(Rb),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},Ms=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:Rb(e);return Array.from(i.textTracks).filter(t)},mu=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(b.MEDIA_SUBTITLES_SHOWING)};var Lb=i=>{var e;let{media:t,fullscreenElement:r}=i;try{let s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){let n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()}catch(s){console.error(s)}},Ib="exitFullscreen"in Ue?"exitFullscreen":"webkitExitFullscreen"in Ue?"webkitExitFullscreen":"webkitCancelFullScreen"in Ue?"webkitCancelFullScreen":void 0,kb=i=>{var e;let{documentElement:t}=i;if(Ib){let r=(e=t==null?void 0:t[Ib])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},mo="fullscreenElement"in Ue?"fullscreenElement":"webkitFullscreenElement"in Ue?"webkitFullscreenElement":void 0,Uk=i=>{let{documentElement:e,media:t}=i,r=e==null?void 0:e[mo];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===rb.FULLSCREEN?t:r},wb=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=Uk(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(mo in a))return Rt(n,s);for(;a!=null&&a[mo];){if(a[mo]===s)return!0;a=(e=a[mo])==null?void 0:e.shadowRoot}}return!1},Fk="fullscreenEnabled"in Ue?"fullscreenEnabled":"webkitFullscreenEnabled"in Ue?"webkitFullscreenEnabled":void 0,Db=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[Fk])||t&&"webkitSupportsFullscreen"in t};var pu,Qm=()=>{var i,e;return pu||(pu=(e=(i=Ue)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),pu)},Cb=async(i=Qm())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([Bk(i,t.signal),$k(i,e)]);return t.abort(),r},Bk=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),$k=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await Xd(10)}return i.volume!==e},Hk=/.*Version\/.*Safari\/.*/.test(S.navigator.userAgent),Zm=(i=Qm())=>S.matchMedia("(display-mode: standalone)").matches&&Hk?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Jm=(i=Qm())=>Db({documentElement:Ue,media:i}),Mb=Jm(),Ob=Zm(),Pb=!!S.WebKitPlaybackTargetAvailabilityEvent,Nb=!!S.chrome;var Pn=i=>Ms(i.media,e=>[Ct.SUBTITLES,Ct.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),ep=i=>Ms(i.media,e=>e.mode===Br.SHOWING&&[Ct.SUBTITLES,Ct.CAPTIONS].includes(e.kind)),gu=(i,e)=>{let t=Pn(i),r=ep(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)Cs(Br.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),g=c.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;Cs(Br.DISABLED,t,r),Cs(Br.SHOWING,t,[{language:o,label:l,kind:d}])}}},vu=(i,e)=>i===e?!0:i==null||e==null||typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?Gk(i,e):Object.entries(i).every(([t,r])=>t in e&&vu(r,e[t])),Gk=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>vu(s,e[n])):!0};var Kk=Object.values(ci),Eu,Vk=Cb().then(i=>(Eu=i,Eu)),Ub=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof S.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=S.customElements.get(t);r&&e instanceof r||(await S.customElements.whenDefined(t),S.customElements.upgrade(e))}))},Wk=new S.DOMParser,Yk=i=>i&&(Wk.parseFromString(i,"text/html").body.textContent||i),Nn={mediaError:{get(i,e){let{media:t}=i;if((e==null?void 0:e.type)!=="playing")return t==null?void 0:t.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(i,e){var t;let{media:r}=i;if((e==null?void 0:e.type)!=="playing")return(t=r==null?void 0:r.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(i,e){var t,r;let{media:s}=i;if((e==null?void 0:e.type)!=="playing")return(r=(t=s==null?void 0:s.error)==null?void 0:t.message)!=null?r:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;if(t){try{S.localStorage.setItem("media-chrome-pref-muted",i?"true":"false")}catch(r){console.debug("Error setting muted pref",r)}t.muted=i}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noMutedPref:t}}=e,{media:r}=e;if(!(!r||r.muted||t))try{let s=S.localStorage.getItem("media-chrome-pref-muted")==="true";Nn.mediaMuted.set(s,e),i(s)}catch(s){console.debug("Error getting muted pref",s)}}]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?S.localStorage.removeItem("media-chrome-pref-volume"):S.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch(r){console.debug("Error setting volume pref",r)}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let{media:r}=e;if(!r)return;let s=S.localStorage.getItem("media-chrome-pref-volume");if(s==null)return;Nn.mediaVolume.set(+s,e),i(+s)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||!Ln(i)||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[ci.LIVE,ci.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(Kk.includes(s))return s===ci.UNKNOWN?r:s;let n=e.duration;return n===1/0?ci.LIVE:Number.isFinite(n)?ci.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=Nn.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===ci.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Nn.mediaStreamType.get(i)===ci.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return Pn(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return ep(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![Ct.CAPTIONS,Ct.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||gu(e,!0)};return s.addEventListener("loadstart",a),(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),()=>{var o,l;s.removeEventListener("loadstart",a),(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=Ms(t,{kind:Ct.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:Yk(s),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;if(!r)return;let s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?Rt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!Ue.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else Ue.pictureInPictureElement&&Ue.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return wb(i)},set(i,e){i?Lb(e):kb(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&S.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!Mb||!Jm(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!Ob||!Zm(e))return Ht.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(Eu===!1||(e==null?void 0:e.volume)==null)return Ht.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{Eu==null&&Vk.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!Nb||!((t=r==null?void 0:r.remote)!=null&&t.state))return Ht.UNSUPPORTED;if(!(e==null||e==="available"))return Ht.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!Pb)return Ht.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Ht.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Ht.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Ht.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Ht.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var Fb={[$.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=Ms(a,{kind:Ct.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,v)=>g===0?p.endTime>o:g===v.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[$.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[$.MEDIA_PLAY_REQUEST](i,e){var t,r,s,n;let a="mediaPaused",l=i.mediaStreamType.get(e)===ci.LIVE,d=!((t=e.options)!=null&&t.noAutoSeekToLive),u=i.mediaTargetLiveWindow.get(e)>0;if(l&&d&&!u){let c=(r=i.mediaSeekable.get(e))==null?void 0:r[1];if(c){let h=(n=(s=e.options)==null?void 0:s.seekToLiveOffset)!=null?n:0,f=c-h;i.mediaCurrentTime.set(f,e)}}i[a].set(!1,e)},[$.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[$.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[$.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[$.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[$.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[$.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t,r,s;let n="mediaCurrentTime",a=(t=i.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;let o=(s=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?s:0,l=a-o;i[n].set(l,e)},[$.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=Pn(e),a=Xm(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&S.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Cs(Br.SHOWING,n,a)},[$.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=Pn(e),s=t!=null?t:[];Cs(Br.DISABLED,r,s)},[$.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){gu(e,t)},[$.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[$.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[$.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[$.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[$.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[$.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[$.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var Bb=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Nn,requestMap:s=Fb,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(vu(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[v,{get:y}])=>(g[v]=y(l),g),{});u(p)},h={},f,m=async(p,g)=>{var v,y,T,_,A,k,R,x,O,w,C,P,U,X,z,q;let ce=!!f;if(f={...l,...f!=null?f:{},...p},ce)return;await Ub(...Object.values(p));let fe=o.length>0&&g===0&&a,W=l.media!==f.media,G=((v=l.media)==null?void 0:v.textTracks)!==((y=f.media)==null?void 0:y.textTracks),pe=((T=l.media)==null?void 0:T.videoRenditions)!==((_=f.media)==null?void 0:_.videoRenditions),te=((A=l.media)==null?void 0:A.audioTracks)!==((k=f.media)==null?void 0:k.audioTracks),_e=((R=l.media)==null?void 0:R.remote)!==((x=f.media)==null?void 0:x.remote),Ke=l.documentElement!==f.documentElement,Ye=!!l.media&&(W||fe),ze=!!((O=l.media)!=null&&O.textTracks)&&(G||fe),xt=!!((w=l.media)!=null&&w.videoRenditions)&&(pe||fe),Er=!!((C=l.media)!=null&&C.audioTracks)&&(te||fe),rn=!!((P=l.media)!=null&&P.remote)&&(_e||fe),Kg=!!l.documentElement&&(Ke||fe),Vg=Ye||ze||xt||Er||rn||Kg,sn=o.length===0&&g===1&&a,Wg=!!f.media&&(W||sn),Yg=!!((U=f.media)!=null&&U.textTracks)&&(G||sn),qg=!!((X=f.media)!=null&&X.videoRenditions)&&(pe||sn),jg=!!((z=f.media)!=null&&z.audioTracks)&&(te||sn),zg=!!((q=f.media)!=null&&q.remote)&&(_e||sn),Xg=!!f.documentElement&&(Ke||sn),Qg=Wg||Yg||qg||jg||zg||Xg;if(!(Vg||Qg)){Object.entries(f).forEach(([Oe,ya])=>{l[Oe]=ya}),c(),f=void 0;return}Object.entries(r).forEach(([Oe,{get:ya,mediaEvents:Z_=[],textTracksEvents:J_=[],videoRenditionsEvents:eA=[],audioTracksEvents:tA=[],remoteEvents:iA=[],rootEvents:rA=[],stateOwnersUpdateHandlers:sA=[]}])=>{h[Oe]||(h[Oe]={});let Ut=Ze=>{let Ft=ya(l,Ze);u({[Oe]:Ft})},ut;ut=h[Oe].mediaEvents,Z_.forEach(Ze=>{ut&&Ye&&(l.media.removeEventListener(Ze,ut),h[Oe].mediaEvents=void 0),Wg&&(f.media.addEventListener(Ze,Ut),h[Oe].mediaEvents=Ut)}),ut=h[Oe].textTracksEvents,J_.forEach(Ze=>{var Ft,ti;ut&&ze&&((Ft=l.media.textTracks)==null||Ft.removeEventListener(Ze,ut),h[Oe].textTracksEvents=void 0),Yg&&((ti=f.media.textTracks)==null||ti.addEventListener(Ze,Ut),h[Oe].textTracksEvents=Ut)}),ut=h[Oe].videoRenditionsEvents,eA.forEach(Ze=>{var Ft,ti;ut&&xt&&((Ft=l.media.videoRenditions)==null||Ft.removeEventListener(Ze,ut),h[Oe].videoRenditionsEvents=void 0),qg&&((ti=f.media.videoRenditions)==null||ti.addEventListener(Ze,Ut),h[Oe].videoRenditionsEvents=Ut)}),ut=h[Oe].audioTracksEvents,tA.forEach(Ze=>{var Ft,ti;ut&&Er&&((Ft=l.media.audioTracks)==null||Ft.removeEventListener(Ze,ut),h[Oe].audioTracksEvents=void 0),jg&&((ti=f.media.audioTracks)==null||ti.addEventListener(Ze,Ut),h[Oe].audioTracksEvents=Ut)}),ut=h[Oe].remoteEvents,iA.forEach(Ze=>{var Ft,ti;ut&&rn&&((Ft=l.media.remote)==null||Ft.removeEventListener(Ze,ut),h[Oe].remoteEvents=void 0),zg&&((ti=f.media.remote)==null||ti.addEventListener(Ze,Ut),h[Oe].remoteEvents=Ut)}),ut=h[Oe].rootEvents,rA.forEach(Ze=>{ut&&Kg&&(l.documentElement.removeEventListener(Ze,ut),h[Oe].rootEvents=void 0),Xg&&(f.documentElement.addEventListener(Ze,Ut),h[Oe].rootEvents=Ut)});let Zg=h[Oe].stateOwnersUpdateHandlers;sA.forEach(Ze=>{Zg&&Vg&&Zg(),Qg&&(h[Oe].stateOwnersUpdateHandlers=Ze(Ut,f))})}),Object.entries(f).forEach(([Oe,ya])=>{l[Oe]=ya}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:v}=p;if(s[g]&&d.mediaErrorCode==null){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:v}):g==="fullscreenelementchangerequest"?m({fullscreenElement:v}):g==="documentelementchangerequest"?m({documentElement:v}):g==="optionschangerequest"&&Object.entries(v!=null?v:{}).forEach(([y,T])=>{l.options[y]=T})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var sp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},be=(i,e,t)=>(sp(i,e,"read from private field"),t?t.call(i):e.get(i)),ur=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kr=(i,e,t,r)=>(sp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Vr=(i,e,t)=>(sp(i,e,"access private method"),t),Ps,po,Fe,go,Ii,Tu,bu,tp,Un,vo,yu,ip,Vb=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],$b=10,Y={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",SEEK_TO_LIVE_OFFSET:"seektoliveoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset",LANG:"lang"},_u=class extends ks{constructor(){super(),ur(this,bu),ur(this,Un),ur(this,yu),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,ur(this,Ps,new Gr(this,Y.HOTKEYS)),ur(this,po,void 0),ur(this,Fe,void 0),ur(this,go,void 0),ur(this,Ii,void 0),ur(this,Tu,t=>{var r;(r=be(this,Fe))==null||r.dispatch(t)}),this.associateElement(this);let e={};Kr(this,go,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new S.CustomEvent(ib[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(Y.NO_HOTKEYS,Y.HOTKEYS,Y.DEFAULT_STREAM_TYPE,Y.DEFAULT_SUBTITLES,Y.DEFAULT_DURATION,Y.LANG)}get mediaStore(){return be(this,Fe)}set mediaStore(e){var t,r;if(be(this,Fe)&&((t=be(this,Ii))==null||t.call(this),Kr(this,Ii,void 0)),Kr(this,Fe,e),!be(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)){Vr(this,bu,tp).call(this);return}Kr(this,Ii,(r=be(this,Fe))==null?void 0:r.subscribe(be(this,go)))}get fullscreenElement(){var e;return(e=be(this,po))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(Y.FULLSCREEN_ELEMENT)&&this.removeAttribute(Y.FULLSCREEN_ELEMENT),Kr(this,po,e),(t=be(this,Fe))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return ae(this,Y.DEFAULT_SUBTITLES)}set defaultSubtitles(e){oe(this,Y.DEFAULT_SUBTITLES,e)}get defaultStreamType(){return de(this,Y.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){ue(this,Y.DEFAULT_STREAM_TYPE,e)}get defaultDuration(){return ge(this,Y.DEFAULT_DURATION)}set defaultDuration(e){ye(this,Y.DEFAULT_DURATION,e)}get noHotkeys(){return ae(this,Y.NO_HOTKEYS)}set noHotkeys(e){oe(this,Y.NO_HOTKEYS,e)}get keysUsed(){return de(this,Y.KEYS_USED)}set keysUsed(e){ue(this,Y.KEYS_USED,e)}get liveEdgeOffset(){return ge(this,Y.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){ye(this,Y.LIVE_EDGE_OFFSET,e)}get noAutoSeekToLive(){return ae(this,Y.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){oe(this,Y.NO_AUTO_SEEK_TO_LIVE,e)}get noVolumePref(){return ae(this,Y.NO_VOLUME_PREF)}set noVolumePref(e){oe(this,Y.NO_VOLUME_PREF,e)}get noSubtitlesLangPref(){return ae(this,Y.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){oe(this,Y.NO_SUBTITLES_LANG_PREF,e)}get noDefaultStore(){return ae(this,Y.NO_DEFAULT_STORE)}set noDefaultStore(e){oe(this,Y.NO_DEFAULT_STORE,e)}attributeChangedCallback(e,t,r){var s,n,a,o,l,d,u,c;if(super.attributeChangedCallback(e,t,r),e===Y.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(Y.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===Y.HOTKEYS)be(this,Ps).value=r;else if(e===Y.DEFAULT_SUBTITLES&&r!==t)(s=be(this,Fe))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES)}});else if(e===Y.DEFAULT_STREAM_TYPE)(a=be(this,Fe))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(Y.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===Y.LIVE_EDGE_OFFSET)(o=be(this,Fe))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(Y.LIVE_EDGE_OFFSET)}});else if(e===Y.SEEK_TO_LIVE_OFFSET)(l=be(this,Fe))==null||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(Y.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===Y.NO_AUTO_SEEK_TO_LIVE)(d=be(this,Fe))==null||d.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(Y.NO_AUTO_SEEK_TO_LIVE)}});else if(e===Y.FULLSCREEN_ELEMENT){let h=r?(u=this.getRootNode())==null?void 0:u.getElementById(r):void 0;Kr(this,po,h),(c=be(this,Fe))==null||c.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===Y.LANG&&r!==t&&hb(r)}connectedCallback(){var e,t;!be(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)&&Vr(this,bu,tp).call(this),(e=be(this,Fe))==null||e.dispatch({type:"documentelementchangerequest",detail:Ue}),super.connectedCallback(),be(this,Fe)&&!be(this,Ii)&&Kr(this,Ii,(t=be(this,Fe))==null?void 0:t.subscribe(be(this,go))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),be(this,Fe)&&((t=be(this,Fe))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=be(this,Fe))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),be(this,Ii)&&((s=be(this,Ii))==null||s.call(this),Kr(this,Ii,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=be(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=be(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Kb(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=Zk(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,be(this,Tu))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values($).forEach(s=>{e.removeEventListener(s,be(this,Tu))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),be(this,Fe)&&Object.entries(be(this,Fe).getState()).forEach(([s,n])=>{Kb([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",Vr(this,yu,ip))}disableHotkeys(){this.removeEventListener("keydown",Vr(this,yu,ip)),this.removeEventListener("keyup",Vr(this,Un,vo))}get hotkeys(){return de(this,Y.HOTKEYS)}set hotkeys(e){ue(this,Y.HOTKEYS,e)}keyboardShortcutHandler(e){var t,r,s,n,a;let o=e.target;if(((s=(r=(t=o.getAttribute(Y.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!be(this,Ps).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&be(this,Ps).contains("nospace")))switch(e.key){case" ":case"k":d=be(this,Fe).getState().mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new S.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new S.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(Y.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(Y.KEYBOARD_BACKWARD_SEEK_OFFSET):$b;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(Y.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(Y.KEYBOARD_FORWARD_SEEK_OFFSET):$b;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};Ps=new WeakMap;po=new WeakMap;Fe=new WeakMap;go=new WeakMap;Ii=new WeakMap;Tu=new WeakMap;bu=new WeakSet;tp=function(){var i;this.mediaStore=Bb({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(Y.DEFAULT_DURATION)?+this.getAttribute(Y.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(Y.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(Y.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(Y.SEEK_TO_LIVE_OFFSET):this.hasAttribute(Y.LIVE_EDGE_OFFSET)?+this.getAttribute(Y.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(Y.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(Y.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(Y.NO_SUBTITLES_LANG_PREF)}})};Un=new WeakSet;vo=function(i){let{key:e}=i;if(!Vb.includes(e)){this.removeEventListener("keyup",Vr(this,Un,vo));return}this.keyboardShortcutHandler(i)};yu=new WeakSet;ip=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!Vb.includes(r)){this.removeEventListener("keyup",Vr(this,Un,vo));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(be(this,Ps).contains(`no${r.toLowerCase()}`)||r===" "&&be(this,Ps).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Vr(this,Un,vo),{once:!0})};var qk=Object.values(b),jk=Object.values(Fm),Wb=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(S.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,me.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>qk.includes(o)):[]},zk=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&S.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof S.customElements.get(i.nodeName.toLowerCase()))&&S.customElements.upgrade(i),jk.some(r=>r in i)},rp=i=>zk(i)||!!Wb(i).length,Hb=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Gb={[b.MEDIA_SUBTITLES_LIST]:dr,[b.MEDIA_SUBTITLES_SHOWING]:dr,[b.MEDIA_SEEKABLE]:Hb,[b.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Hb).join(" "),[b.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[b.MEDIA_RENDITION_LIST]:sb,[b.MEDIA_AUDIO_TRACK_LIST]:ab},Xk=async(i,e,t)=>{var r,s;if(i.isConnected||await Xd(0),typeof t=="boolean"||t==null)return oe(i,e,t);if(typeof t=="number")return ye(i,e,t);if(typeof t=="string")return ue(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=Gb[e])==null?void 0:r.call(Gb,t))!=null?s:t;return i.setAttribute(e,n)},Qk=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Os=(i,e)=>{if(Qk(i))return;let t=(s,n)=>{var a,o;rp(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Os(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!rp(i)){S.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},Kb=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=Wb(r),n=e.toLowerCase();s.includes(n)&&Xk(r,n,t)})},Zk=(i,e,t)=>{Os(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,v=>Os(v,e)),Array.prototype.forEach.call(f,v=>Os(v,t))):m==="attributes"&&g===me.MEDIA_CHROME_ATTRIBUTES&&(rp(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>Os(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Os(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Os(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener($.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener($.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};S.customElements.get("media-controller")||S.customElements.define("media-controller",_u);var np=_u;var Fn={PLACEMENT:"placement",BOUNDS:"bounds"};function Jk(i){return`
|
|
284
284
|
<style>
|
|
285
285
|
:host {
|
|
286
286
|
--_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
|
|
@@ -500,7 +500,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
500
500
|
`}function nw(){return`
|
|
501
501
|
<slot name="tooltip-enter">${B("start airplay")}</slot>
|
|
502
502
|
<slot name="tooltip-exit">${B("stop airplay")}</slot>
|
|
503
|
-
`}var jb=i=>{let e=i.mediaIsAirplaying?B("stop airplay"):B("start airplay");i.setAttribute("aria-label",e)},
|
|
503
|
+
`}var jb=i=>{let e=i.mediaIsAirplaying?B("stop airplay"):B("start airplay");i.setAttribute("aria-label",e)},Eo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_AIRPLAYING,b.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),jb(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_AIRPLAYING&&jb(this)}get mediaIsAirplaying(){return ae(this,b.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){oe(this,b.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return de(this,b.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ue(this,b.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new S.CustomEvent($.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};Eo.getSlotTemplateHTML=sw;Eo.getTooltipContentHTML=nw;S.customElements.get("media-airplay-button")||S.customElements.define("media-airplay-button",Eo);var aw=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
504
504
|
<path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
|
|
505
505
|
</svg>`,ow=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
506
506
|
<path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
|
|
@@ -528,7 +528,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
528
528
|
`}function dw(){return`
|
|
529
529
|
<slot name="tooltip-enable">${B("Enable captions")}</slot>
|
|
530
530
|
<slot name="tooltip-disable">${B("Disable captions")}</slot>
|
|
531
|
-
`}var zb=i=>{i.setAttribute("aria-checked",mu(i).toString())},
|
|
531
|
+
`}var zb=i=>{i.setAttribute("aria-checked",mu(i).toString())},To=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",B("closed captions")),zb(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&zb(this)}get mediaSubtitlesList(){return Xb(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Qb(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Xb(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Qb(this,b.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new S.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}};To.getSlotTemplateHTML=lw;To.getTooltipContentHTML=dw;var Xb=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},Qb=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=dr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};S.customElements.get("media-captions-button")||S.customElements.define("media-captions-button",To);var uw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',cw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>';function hw(i){return`
|
|
532
532
|
<style>
|
|
533
533
|
:host([${b.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
|
|
534
534
|
display: none !important;
|
|
@@ -552,7 +552,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
552
552
|
`}function fw(){return`
|
|
553
553
|
<slot name="tooltip-enter">${B("Start casting")}</slot>
|
|
554
554
|
<slot name="tooltip-exit">${B("Stop casting")}</slot>
|
|
555
|
-
`}var Zb=i=>{let e=i.mediaIsCasting?B("stop casting"):B("start casting");i.setAttribute("aria-label",e)},
|
|
555
|
+
`}var Zb=i=>{let e=i.mediaIsCasting?B("stop casting"):B("start casting");i.setAttribute("aria-label",e)},bo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_CASTING,b.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Zb(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_CASTING&&Zb(this)}get mediaIsCasting(){return ae(this,b.MEDIA_IS_CASTING)}set mediaIsCasting(e){oe(this,b.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return de(this,b.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ue(this,b.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?$.MEDIA_EXIT_CAST_REQUEST:$.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};bo.getSlotTemplateHTML=hw;bo.getTooltipContentHTML=fw;S.customElements.get("media-cast-button")||S.customElements.define("media-cast-button",bo);var mp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Us=(i,e,t)=>(mp(i,e,"read from private field"),t?t.call(i):e.get(i)),cr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},pp=(i,e,t,r)=>(mp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ns=(i,e,t)=>(mp(i,e,"access private method"),t),Iu,_o,Fs,Ru,lp,dp,Jb,up,ey,cp,ty,hp,iy,fp,ry;function mw(i){return`
|
|
556
556
|
<style>
|
|
557
557
|
:host {
|
|
558
558
|
font: var(--media-font,
|
|
@@ -595,7 +595,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
595
595
|
${this.getSlotTemplateHTML(i)}
|
|
596
596
|
`}function pw(i){return`
|
|
597
597
|
<slot id="content"></slot>
|
|
598
|
-
`}var
|
|
598
|
+
`}var yo={OPEN:"open",ANCHOR:"anchor"},qr=class extends S.HTMLElement{constructor(){super(),cr(this,Ru),cr(this,dp),cr(this,up),cr(this,cp),cr(this,hp),cr(this,fp),cr(this,Iu,!1),cr(this,_o,null),cr(this,Fs,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[yo.OPEN,yo.ANCHOR]}get open(){return ae(this,yo.OPEN)}set open(e){oe(this,yo.OPEN,e)}handleEvent(e){switch(e.type){case"invoke":Ns(this,cp,ty).call(this,e);break;case"focusout":Ns(this,hp,iy).call(this,e);break;case"keydown":Ns(this,fp,ry).call(this,e);break}}connectedCallback(){Ns(this,Ru,lp).call(this),this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){Ns(this,Ru,lp).call(this),e===yo.OPEN&&r!==t&&(this.open?Ns(this,dp,Jb).call(this):Ns(this,up,ey).call(this))}focus(){pp(this,_o,oo());let e=!this.dispatchEvent(new Event("focus",{composed:!0,cancelable:!0})),t=!this.dispatchEvent(new Event("focusin",{composed:!0,bubbles:!0,cancelable:!0}));if(e||t)return;let r=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');r==null||r.focus()}get keysUsed(){return["Escape","Tab"]}};Iu=new WeakMap;_o=new WeakMap;Fs=new WeakMap;Ru=new WeakSet;lp=function(){if(!Us(this,Iu)&&(pp(this,Iu,!0),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);let i=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(i),queueMicrotask(()=>{let{style:e}=Me(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in")})}};dp=new WeakSet;Jb=function(){var i;(i=Us(this,Fs))==null||i.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};up=new WeakSet;ey=function(){var i;(i=Us(this,Fs))==null||i.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{composed:!0,bubbles:!0}))};cp=new WeakSet;ty=function(i){pp(this,Fs,i.relatedTarget),Rt(this,i.relatedTarget)||(this.open=!this.open)};hp=new WeakSet;iy=function(i){var e;Rt(this,i.relatedTarget)||((e=Us(this,_o))==null||e.focus(),Us(this,Fs)&&Us(this,Fs)!==i.relatedTarget&&this.open&&(this.open=!1))};fp=new WeakSet;ry=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=Us(this,_o))==null||n.focus(),this.open=!1))};qr.shadowRootOptions={mode:"open"};qr.getTemplateHTML=mw;qr.getSlotTemplateHTML=pw;S.customElements.get("media-chrome-dialog")||S.customElements.define("media-chrome-dialog",qr);var _p=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},je=(i,e,t)=>(_p(i,e,"read from private field"),t?t.call(i):e.get(i)),yt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},jr=(i,e,t,r)=>(_p(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fi=(i,e,t)=>(_p(i,e,"access private method"),t),ki,Uu,Lu,ku,mi,Pu,wu,Du,Cu,Ap,sy,Mu,gp,Ou,vp,Nu,Sp,Ep,ny,Tp,ay,bp,oy,yp,ly;function gw(i){return`
|
|
599
599
|
<style>
|
|
600
600
|
:host {
|
|
601
601
|
--_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
@@ -849,7 +849,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
849
849
|
</style>
|
|
850
850
|
|
|
851
851
|
<slot></slot>
|
|
852
|
-
`}var
|
|
852
|
+
`}var Ao=class extends S.HTMLElement{constructor(){if(super(),vw(this,Di,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Fu(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Bu(this,Di,null)),r&&this.isConnected&&(Bu(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Fu(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Bu(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Fu(this,Di))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Fu(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bu(this,Di,null)}};Di=new WeakMap;Ao.shadowRootOptions={mode:"open"};Ao.getTemplateHTML=Ew;S.customElements.get("media-control-bar")||S.customElements.define("media-control-bar",Ao);var uy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$u=(i,e,t)=>(uy(i,e,"read from private field"),t?t.call(i):e.get(i)),Tw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hu=(i,e,t,r)=>(uy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ci;function bw(i,e={}){return`
|
|
853
853
|
<style>
|
|
854
854
|
:host {
|
|
855
855
|
font: var(--media-font,
|
|
@@ -885,9 +885,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
885
885
|
${this.getSlotTemplateHTML(i,e)}
|
|
886
886
|
`}function yw(i,e){return`
|
|
887
887
|
<slot></slot>
|
|
888
|
-
`}var Ot=class extends S.HTMLElement{constructor(){if(super(),Tw(this,Ci,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=$u(this,Ci))==null?void 0:s.unassociateElement)==null||n.call(s,this),Hu(this,Ci,null)),r&&this.isConnected&&(Hu(this,Ci,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=$u(this,Ci))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=Me(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(Hu(this,Ci,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=$u(this,Ci))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$u(this,Ci))==null?void 0:e.unassociateElement)==null||t.call(e,this),Hu(this,Ci,null)}};Ci=new WeakMap;Ot.shadowRootOptions={mode:"open"};Ot.getTemplateHTML=bw;Ot.getSlotTemplateHTML=yw;S.customElements.get("media-text-display")||S.customElements.define("media-text-display",Ot);var hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},cy=(i,e,t)=>(hy(i,e,"read from private field"),t?t.call(i):e.get(i)),_w=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Aw=(i,e,t,r)=>(hy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),
|
|
888
|
+
`}var Ot=class extends S.HTMLElement{constructor(){if(super(),Tw(this,Ci,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER&&(t&&((n=(s=$u(this,Ci))==null?void 0:s.unassociateElement)==null||n.call(s,this),Hu(this,Ci,null)),r&&this.isConnected&&(Hu(this,Ci,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=$u(this,Ci))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=Me(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(Hu(this,Ci,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=$u(this,Ci))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$u(this,Ci))==null?void 0:e.unassociateElement)==null||t.call(e,this),Hu(this,Ci,null)}};Ci=new WeakMap;Ot.shadowRootOptions={mode:"open"};Ot.getTemplateHTML=bw;Ot.getSlotTemplateHTML=yw;S.customElements.get("media-text-display")||S.customElements.define("media-text-display",Ot);var hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},cy=(i,e,t)=>(hy(i,e,"read from private field"),t?t.call(i):e.get(i)),_w=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Aw=(i,e,t,r)=>(hy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),So;function Sw(i,e){return`
|
|
889
889
|
<slot>${hi(e.mediaDuration)}</slot>
|
|
890
|
-
`}var Gu=class extends Ot{constructor(){var e;super(),_w(this,
|
|
890
|
+
`}var Gu=class extends Ot{constructor(){var e;super(),_w(this,So,void 0),Aw(this,So,this.shadowRoot.querySelector("slot")),cy(this,So).textContent=hi((e=this.mediaDuration)!=null?e:0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===b.MEDIA_DURATION&&(cy(this,So).textContent=hi(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return ge(this,b.MEDIA_DURATION)}set mediaDuration(e){ye(this,b.MEDIA_DURATION,e)}};So=new WeakMap;Gu.getSlotTemplateHTML=Sw;S.customElements.get("media-duration-display")||S.customElements.define("media-duration-display",Gu);var xw={2:B("Network Error"),3:B("Decode Error"),4:B("Source Not Supported"),5:B("Encryption Error")},Rw={2:B("A network error caused the media download to fail."),3:B("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:B("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:B("The media is encrypted and there are no keys to decrypt it.")},xp=i=>{var e,t;return i.code===1?null:{title:(e=xw[i.code])!=null?e:`Error ${i.code}`,message:(t=Rw[i.code])!=null?t:i.message}};var my=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Iw=(i,e,t)=>(my(i,e,"read from private field"),t?t.call(i):e.get(i)),Lw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kw=(i,e,t,r)=>(my(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ku;function ww(i){return`
|
|
891
891
|
<style>
|
|
892
892
|
:host {
|
|
893
893
|
background: rgb(20 20 30 / .8);
|
|
@@ -934,7 +934,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
934
934
|
`}function Pw(){return`
|
|
935
935
|
<slot name="tooltip-enter">${B("Enter fullscreen mode")}</slot>
|
|
936
936
|
<slot name="tooltip-exit">${B("Exit fullscreen mode")}</slot>
|
|
937
|
-
`}var gy=i=>{let e=i.mediaIsFullscreen?B("exit fullscreen mode"):B("enter fullscreen mode");i.setAttribute("aria-label",e)},
|
|
937
|
+
`}var gy=i=>{let e=i.mediaIsFullscreen?B("exit fullscreen mode"):B("enter fullscreen mode");i.setAttribute("aria-label",e)},xo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_FULLSCREEN,b.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),gy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_FULLSCREEN&&gy(this)}get mediaFullscreenUnavailable(){return de(this,b.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ue(this,b.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return ae(this,b.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){oe(this,b.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?$.MEDIA_EXIT_FULLSCREEN_REQUEST:$.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};xo.getSlotTemplateHTML=Ow;xo.getTooltipContentHTML=Pw;S.customElements.get("media-fullscreen-button")||S.customElements.define("media-fullscreen-button",xo);var{MEDIA_TIME_IS_LIVE:Wu,MEDIA_PAUSED:Ro}=b,{MEDIA_SEEK_TO_LIVE_REQUEST:Nw,MEDIA_PLAY_REQUEST:Uw}=$,Fw='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>';function Bw(i){return`
|
|
938
938
|
<style>
|
|
939
939
|
:host { --media-tooltip-display: none; }
|
|
940
940
|
|
|
@@ -946,13 +946,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
946
946
|
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
947
947
|
}
|
|
948
948
|
|
|
949
|
-
:host([${Wu}]:not([${
|
|
950
|
-
:host([${Wu}]:not([${
|
|
949
|
+
:host([${Wu}]:not([${Ro}])) slot[name=indicator] > *,
|
|
950
|
+
:host([${Wu}]:not([${Ro}])) ::slotted([slot=indicator]) {
|
|
951
951
|
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
952
952
|
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
-
:host([${Wu}]:not([${
|
|
955
|
+
:host([${Wu}]:not([${Ro}])) {
|
|
956
956
|
cursor: var(--media-cursor, not-allowed);
|
|
957
957
|
}
|
|
958
958
|
|
|
@@ -965,7 +965,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
965
965
|
<slot name="indicator">${Fw}</slot>
|
|
966
966
|
|
|
967
967
|
<slot name="spacer"> </slot><slot name="text">${B("live")}</slot>
|
|
968
|
-
`}var vy=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?B("seek to live"):B("playing live");i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Yu=class extends Le{static get observedAttributes(){return[...super.observedAttributes,Wu,
|
|
968
|
+
`}var vy=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?B("seek to live"):B("playing live");i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Yu=class extends Le{static get observedAttributes(){return[...super.observedAttributes,Wu,Ro]}connectedCallback(){super.connectedCallback(),vy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),vy(this)}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return ae(this,b.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){oe(this,b.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new S.CustomEvent(Nw,{composed:!0,bubbles:!0})),this.hasAttribute(Ro)&&this.dispatchEvent(new S.CustomEvent(Uw,{composed:!0,bubbles:!0})))}};Yu.getSlotTemplateHTML=Bw;S.customElements.get("media-live-button")||S.customElements.define("media-live-button",Yu);var Ty=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Io=(i,e,t)=>(Ty(i,e,"read from private field"),t?t.call(i):e.get(i)),Ey=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Lo=(i,e,t,r)=>(Ty(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mi,ju,qu={LOADING_DELAY:"loadingdelay",NO_AUTOHIDE:"noautohide"},by=500,$w=`
|
|
969
969
|
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
970
970
|
<path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
|
|
971
971
|
<animateTransform
|
|
@@ -1025,7 +1025,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1025
1025
|
|
|
1026
1026
|
<slot name="icon">${$w}</slot>
|
|
1027
1027
|
<div id="status" role="status" aria-live="polite">${B("media loading")}</div>
|
|
1028
|
-
`}var
|
|
1028
|
+
`}var ko=class extends S.HTMLElement{constructor(){if(super(),Ey(this,Mi,void 0),Ey(this,ju,by),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,b.MEDIA_PAUSED,b.MEDIA_LOADING,qu.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===qu.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Io(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Lo(this,Mi,null)),r&&this.isConnected&&(Lo(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Io(this,Mi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Lo(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Io(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Io(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Lo(this,Mi,null)}get loadingDelay(){return Io(this,ju)}set loadingDelay(e){Lo(this,ju,e);let{style:t}=Me(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,b.MEDIA_LOADING)}set mediaLoading(e){oe(this,b.MEDIA_LOADING,e)}get mediaController(){return de(this,me.MEDIA_CONTROLLER)}set mediaController(e){ue(this,me.MEDIA_CONTROLLER,e)}get noAutohide(){return ae(this,qu.NO_AUTOHIDE)}set noAutohide(e){oe(this,qu.NO_AUTOHIDE,e)}};Mi=new WeakMap;ju=new WeakMap;ko.shadowRootOptions={mode:"open"};ko.getTemplateHTML=Hw;S.customElements.get("media-loading-indicator")||S.customElements.define("media-loading-indicator",ko);var Gw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1029
1029
|
<path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
|
|
1030
1030
|
</svg>`,yy=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1031
1031
|
<path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
|
|
@@ -1065,7 +1065,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1065
1065
|
`}function Ww(){return`
|
|
1066
1066
|
<slot name="tooltip-mute">${B("Mute")}</slot>
|
|
1067
1067
|
<slot name="tooltip-unmute">${B("Unmute")}</slot>
|
|
1068
|
-
`}var _y=i=>{let t=i.mediaVolumeLevel==="off"?B("unmute"):B("mute");i.setAttribute("aria-label",t)},
|
|
1068
|
+
`}var _y=i=>{let t=i.mediaVolumeLevel==="off"?B("unmute"):B("mute");i.setAttribute("aria-label",t)},wo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),_y(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_VOLUME_LEVEL&&_y(this)}get mediaVolumeLevel(){return de(this,b.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ue(this,b.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?$.MEDIA_UNMUTE_REQUEST:$.MEDIA_MUTE_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};wo.getSlotTemplateHTML=Vw;wo.getTooltipContentHTML=Ww;S.customElements.get("media-mute-button")||S.customElements.define("media-mute-button",wo);var Ay=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
1069
1069
|
<path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
|
|
1070
1070
|
</svg>`;function Yw(i){return`
|
|
1071
1071
|
<style>
|
|
@@ -1090,7 +1090,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1090
1090
|
`}function qw(){return`
|
|
1091
1091
|
<slot name="tooltip-enter">${B("Enter picture in picture mode")}</slot>
|
|
1092
1092
|
<slot name="tooltip-exit">${B("Exit picture in picture mode")}</slot>
|
|
1093
|
-
`}var Sy=i=>{let e=i.mediaIsPip?B("exit picture in picture mode"):B("enter picture in picture mode");i.setAttribute("aria-label",e)},
|
|
1093
|
+
`}var Sy=i=>{let e=i.mediaIsPip?B("exit picture in picture mode"):B("enter picture in picture mode");i.setAttribute("aria-label",e)},Do=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_PIP,b.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Sy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_PIP&&Sy(this)}get mediaPipUnavailable(){return de(this,b.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ue(this,b.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return ae(this,b.MEDIA_IS_PIP)}set mediaIsPip(e){oe(this,b.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?$.MEDIA_EXIT_PIP_REQUEST:$.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};Do.getSlotTemplateHTML=Yw;Do.getTooltipContentHTML=qw;S.customElements.get("media-pip-button")||S.customElements.define("media-pip-button",Do);var jw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vn=(i,e,t)=>(jw(i,e,"read from private field"),t?t.call(i):e.get(i)),zw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},zr,Rp={RATES:"rates"},Ip=[1,1.2,1.5,1.7,2],Bs=1;function Xw(i){return`
|
|
1094
1094
|
<style>
|
|
1095
1095
|
:host {
|
|
1096
1096
|
min-width: 5ch;
|
|
@@ -1098,7 +1098,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1098
1098
|
}
|
|
1099
1099
|
</style>
|
|
1100
1100
|
<slot name="icon">${i.mediaplaybackrate||Bs}x</slot>
|
|
1101
|
-
`}function Qw(){return B("Playback rate")}var
|
|
1101
|
+
`}function Qw(){return B("Playback rate")}var Co=class extends Le{constructor(){var e;super(),zw(this,zr,new Gr(this,Rp.RATES,{defaultValue:Ip})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:Bs}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Rp.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Rp.RATES&&(Vn(this,zr).value=r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Bs:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",B("Playback rate {playbackRate}",{playbackRate:n}))}}get rates(){return Vn(this,zr)}set rates(e){e?Array.isArray(e)?Vn(this,zr).value=e.join(" "):typeof e=="string"&&(Vn(this,zr).value=e):Vn(this,zr).value=""}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(Vn(this,zr).values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:Bs,n=new S.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};zr=new WeakMap;Co.getSlotTemplateHTML=Xw;Co.getTooltipContentHTML=Qw;S.customElements.get("media-playback-rate-button")||S.customElements.define("media-playback-rate-button",Co);var Zw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1102
1102
|
<path d="m6 21 15-9L6 3v18Z"/>
|
|
1103
1103
|
</svg>`,Jw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1104
1104
|
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
@@ -1122,7 +1122,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1122
1122
|
`}function tD(){return`
|
|
1123
1123
|
<slot name="tooltip-play">${B("Play")}</slot>
|
|
1124
1124
|
<slot name="tooltip-pause">${B("Pause")}</slot>
|
|
1125
|
-
`}var xy=i=>{let e=i.mediaPaused?B("play"):B("pause");i.setAttribute("aria-label",e)},
|
|
1125
|
+
`}var xy=i=>{let e=i.mediaPaused?B("play"):B("pause");i.setAttribute("aria-label",e)},Mo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),xy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PAUSED&&xy(this)}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};Mo.getSlotTemplateHTML=eD;Mo.getTooltipContentHTML=tD;S.customElements.get("media-play-button")||S.customElements.define("media-play-button",Mo);var Oi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"};function iD(i){return`
|
|
1126
1126
|
<style>
|
|
1127
1127
|
:host {
|
|
1128
1128
|
pointer-events: none;
|
|
@@ -1144,7 +1144,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1144
1144
|
</style>
|
|
1145
1145
|
|
|
1146
1146
|
<img part="poster img" aria-hidden="true" id="image"/>
|
|
1147
|
-
`}var rD=i=>{i.style.removeProperty("background-image")},sD=(i,e)=>{i.style["background-image"]=`url('${e}')`},
|
|
1147
|
+
`}var rD=i=>{i.style.removeProperty("background-image")},sD=(i,e)=>{i.style["background-image"]=`url('${e}')`},Oo=class extends S.HTMLElement{static get observedAttributes(){return[Oi.PLACEHOLDER_SRC,Oi.SRC]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Oi.SRC&&(r==null?this.image.removeAttribute(Oi.SRC):this.image.setAttribute(Oi.SRC,r)),e===Oi.PLACEHOLDER_SRC&&(r==null?rD(this.image):sD(this.image,r))}get placeholderSrc(){return de(this,Oi.PLACEHOLDER_SRC)}set placeholderSrc(e){ue(this,Oi.SRC,e)}get src(){return de(this,Oi.SRC)}set src(e){ue(this,Oi.SRC,e)}};Oo.shadowRootOptions={mode:"open"};Oo.getTemplateHTML=iD;S.customElements.get("media-poster-image")||S.customElements.define("media-poster-image",Oo);var Ry=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nD=(i,e,t)=>(Ry(i,e,"read from private field"),t?t.call(i):e.get(i)),aD=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},oD=(i,e,t,r)=>(Ry(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),zu,Lp=class extends Ot{constructor(){super(),aD(this,zu,void 0),oD(this,zu,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(nD(this,zu).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return de(this,b.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ue(this,b.MEDIA_PREVIEW_CHAPTER,e)}};zu=new WeakMap;S.customElements.get("media-preview-chapter-display")||S.customElements.define("media-preview-chapter-display",Lp);var Iy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Xu=(i,e,t)=>(Iy(i,e,"read from private field"),t?t.call(i):e.get(i)),lD=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qu=(i,e,t,r)=>(Iy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pi;function dD(i){return`
|
|
1148
1148
|
<style>
|
|
1149
1149
|
:host {
|
|
1150
1150
|
box-sizing: border-box;
|
|
@@ -1158,7 +1158,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1158
1158
|
}
|
|
1159
1159
|
</style>
|
|
1160
1160
|
<img crossorigin loading="eager" decoding="async">
|
|
1161
|
-
`}var Wn=class extends S.HTMLElement{constructor(){if(super(),lD(this,Pi,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Qu(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Xu(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Xu(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Qu(this,Pi,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Xu(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Qu(this,Pi,null)),r&&this.isConnected&&(Qu(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Xu(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return de(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(b.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(b.MEDIA_PREVIEW_COORDS);return}this.setAttribute(b.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:v}=Me(this.shadowRoot,":host"),y=Me(this.shadowRoot,"img").style,T=this.shadowRoot.querySelector("img"),_=p?"min":"max";v.setProperty(`${_}-width`,"initial","important"),v.setProperty(`${_}-height`,"initial","important"),v.width=`${n*g}px`,v.height=`${a*g}px`;let A=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};T.src!==o&&(T.onload=()=>{this.imgWidth=T.naturalWidth,this.imgHeight=T.naturalHeight,A()},T.src=o,A()),A(),y.transform=`translate(-${r*g}px, -${s*g}px)`}};Pi=new WeakMap;Wn.shadowRootOptions={mode:"open"};Wn.getTemplateHTML=dD;S.customElements.get("media-preview-thumbnail")||S.customElements.define("media-preview-thumbnail",Wn);var Zu=Wn;var ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ly=(i,e,t)=>(ky(i,e,"read from private field"),t?t.call(i):e.get(i)),uD=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cD=(i,e,t,r)=>(ky(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),
|
|
1161
|
+
`}var Wn=class extends S.HTMLElement{constructor(){if(super(),lD(this,Pi,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[me.MEDIA_CONTROLLER,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(me.MEDIA_CONTROLLER);s&&(Qu(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Xu(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Xu(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Qu(this,Pi,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===me.MEDIA_CONTROLLER&&(t&&((n=(s=Xu(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Qu(this,Pi,null)),r&&this.isConnected&&(Qu(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Xu(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return de(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(b.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(b.MEDIA_PREVIEW_COORDS);return}this.setAttribute(b.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:v}=Me(this.shadowRoot,":host"),y=Me(this.shadowRoot,"img").style,T=this.shadowRoot.querySelector("img"),_=p?"min":"max";v.setProperty(`${_}-width`,"initial","important"),v.setProperty(`${_}-height`,"initial","important"),v.width=`${n*g}px`,v.height=`${a*g}px`;let A=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};T.src!==o&&(T.onload=()=>{this.imgWidth=T.naturalWidth,this.imgHeight=T.naturalHeight,A()},T.src=o,A()),A(),y.transform=`translate(-${r*g}px, -${s*g}px)`}};Pi=new WeakMap;Wn.shadowRootOptions={mode:"open"};Wn.getTemplateHTML=dD;S.customElements.get("media-preview-thumbnail")||S.customElements.define("media-preview-thumbnail",Wn);var Zu=Wn;var ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ly=(i,e,t)=>(ky(i,e,"read from private field"),t?t.call(i):e.get(i)),uD=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cD=(i,e,t,r)=>(ky(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Po,kp=class extends Ot{constructor(){super(),uD(this,Po,void 0),cD(this,Po,this.shadowRoot.querySelector("slot")),Ly(this,Po).textContent=hi(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_TIME&&r!=null&&(Ly(this,Po).textContent=hi(parseFloat(r)))}get mediaPreviewTime(){return ge(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,b.MEDIA_PREVIEW_TIME,e)}};Po=new WeakMap;S.customElements.get("media-preview-time-display")||S.customElements.define("media-preview-time-display",kp);var Yn={SEEK_OFFSET:"seekoffset"},wp=30,hD=i=>`
|
|
1162
1162
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1163
1163
|
<defs>
|
|
1164
1164
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
@@ -1167,7 +1167,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1167
1167
|
<path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/>
|
|
1168
1168
|
</svg>`;function fD(i,e){return`
|
|
1169
1169
|
<slot name="icon">${hD(e.seekOffset)}</slot>
|
|
1170
|
-
`}function mD(){return B("Seek backward")}var pD=0,
|
|
1170
|
+
`}function mD(){return B("Seek backward")}var pD=0,No=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,Yn.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=ge(this,Yn.SEEK_OFFSET,wp)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===Yn.SEEK_OFFSET&&(this.seekOffset=ge(this,Yn.SEEK_OFFSET,wp))}get seekOffset(){return ge(this,Yn.SEEK_OFFSET,wp)}set seekOffset(e){ye(this,Yn.SEEK_OFFSET,e),this.setAttribute("aria-label",B("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),tu(iu(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME,pD)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};No.getSlotTemplateHTML=fD;No.getTooltipContentHTML=mD;S.customElements.get("media-seek-backward-button")||S.customElements.define("media-seek-backward-button",No);var qn={SEEK_OFFSET:"seekoffset"},Dp=30,gD=i=>`
|
|
1171
1171
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1172
1172
|
<defs>
|
|
1173
1173
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
@@ -1176,9 +1176,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1176
1176
|
<path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/>
|
|
1177
1177
|
</svg>`;function vD(i,e){return`
|
|
1178
1178
|
<slot name="icon">${gD(e.seekOffset)}</slot>
|
|
1179
|
-
`}function ED(){return B("Seek forward")}var TD=0,
|
|
1179
|
+
`}function ED(){return B("Seek forward")}var TD=0,Uo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,qn.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=ge(this,qn.SEEK_OFFSET,Dp)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===qn.SEEK_OFFSET&&(this.seekOffset=ge(this,qn.SEEK_OFFSET,Dp))}get seekOffset(){return ge(this,qn.SEEK_OFFSET,Dp)}set seekOffset(e){ye(this,qn.SEEK_OFFSET,e),this.setAttribute("aria-label",B("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),tu(iu(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME,TD)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};Uo.getSlotTemplateHTML=vD;Uo.getTooltipContentHTML=ED;S.customElements.get("media-seek-forward-button")||S.customElements.define("media-seek-forward-button",Uo);var Cy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Cp=(i,e,t)=>(Cy(i,e,"read from private field"),t?t.call(i):e.get(i)),bD=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yD=(i,e,t,r)=>(Cy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),jn,$s={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},wy=[...Object.values($s),b.MEDIA_CURRENT_TIME,b.MEDIA_DURATION,b.MEDIA_SEEKABLE],Dy=["Enter"," "],_D=" / ",Mp=(i,{timesSep:e=_D}={})=>{var t,r;let s=(t=i.mediaCurrentTime)!=null?t:0,[,n]=(r=i.mediaSeekable)!=null?r:[],a=0;Number.isFinite(i.mediaDuration)?a=i.mediaDuration:Number.isFinite(n)&&(a=n);let o=i.remaining?hi(0-(a-s)):hi(s);return i.showDuration?`${o}${e}${hi(a)}`:o},AD="video not loaded, unknown time.",SD=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",AD);return}let n=i.remaining?Rs(0-(s-t)):Rs(t);if(!i.showDuration){i.setAttribute("aria-valuetext",n);return}let a=Rs(s),o=`${n} of ${a}`;i.setAttribute("aria-valuetext",o)};function xD(i,e){return`
|
|
1180
1180
|
<slot>${Mp(e)}</slot>
|
|
1181
|
-
`}var Ju=class extends Ot{constructor(){super(),bD(this,jn,void 0),yD(this,jn,this.shadowRoot.querySelector("slot")),Cp(this,jn).innerHTML=`${Mp(this)}`}static get observedAttributes(){return[...super.observedAttributes,...wy,"disabled"]}connectedCallback(){let{style:e}=Me(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-cursor, pointer)"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",B("playback time"));let t=r=>{let{key:s}=r;if(!Dy.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Dy.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){wy.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return ae(this,$s.REMAINING)}set remaining(e){oe(this,$s.REMAINING,e)}get showDuration(){return ae(this,$s.SHOW_DURATION)}set showDuration(e){oe(this,$s.SHOW_DURATION,e)}get noToggle(){return ae(this,$s.NO_TOGGLE)}set noToggle(e){oe(this,$s.NO_TOGGLE,e)}get mediaDuration(){return ge(this,b.MEDIA_DURATION)}set mediaDuration(e){ye(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Mp(this);SD(this),e!==Cp(this,jn).innerHTML&&(Cp(this,jn).innerHTML=e)}};jn=new WeakMap;Ju.getSlotTemplateHTML=xD;S.customElements.get("media-time-display")||S.customElements.define("media-time-display",Ju);var My=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vt=(i,e,t)=>(My(i,e,"read from private field"),t?t.call(i):e.get(i)),Ni=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vt=(i,e,t,r)=>(My(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),RD=(i,e,t,r)=>({set _(s){Vt(i,e,s,t)},get _(){return vt(i,e,r)}}),zn,ec,Xn,
|
|
1181
|
+
`}var Ju=class extends Ot{constructor(){super(),bD(this,jn,void 0),yD(this,jn,this.shadowRoot.querySelector("slot")),Cp(this,jn).innerHTML=`${Mp(this)}`}static get observedAttributes(){return[...super.observedAttributes,...wy,"disabled"]}connectedCallback(){let{style:e}=Me(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-cursor, pointer)"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",B("playback time"));let t=r=>{let{key:s}=r;if(!Dy.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Dy.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){wy.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return ae(this,$s.REMAINING)}set remaining(e){oe(this,$s.REMAINING,e)}get showDuration(){return ae(this,$s.SHOW_DURATION)}set showDuration(e){oe(this,$s.SHOW_DURATION,e)}get noToggle(){return ae(this,$s.NO_TOGGLE)}set noToggle(e){oe(this,$s.NO_TOGGLE,e)}get mediaDuration(){return ge(this,b.MEDIA_DURATION)}set mediaDuration(e){ye(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Mp(this);SD(this),e!==Cp(this,jn).innerHTML&&(Cp(this,jn).innerHTML=e)}};jn=new WeakMap;Ju.getSlotTemplateHTML=xD;S.customElements.get("media-time-display")||S.customElements.define("media-time-display",Ju);var My=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vt=(i,e,t)=>(My(i,e,"read from private field"),t?t.call(i):e.get(i)),Ni=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vt=(i,e,t,r)=>(My(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),RD=(i,e,t,r)=>({set _(s){Vt(i,e,s,t)},get _(){return vt(i,e,r)}}),zn,ec,Xn,Fo,tc,ic,rc,Qn,Hs,sc,nc=class{constructor(e,t,r){Ni(this,zn,void 0),Ni(this,ec,void 0),Ni(this,Xn,void 0),Ni(this,Fo,void 0),Ni(this,tc,void 0),Ni(this,ic,void 0),Ni(this,rc,void 0),Ni(this,Qn,void 0),Ni(this,Hs,0),Ni(this,sc,(s=performance.now())=>{Vt(this,Hs,requestAnimationFrame(vt(this,sc))),Vt(this,Fo,performance.now()-vt(this,Xn));let n=1e3/this.fps;if(vt(this,Fo)>n){Vt(this,Xn,s-vt(this,Fo)%n);let a=1e3/((s-vt(this,ec))/++RD(this,tc)._),o=(s-vt(this,ic))/1e3/this.duration,l=vt(this,rc)+o*this.playbackRate;l-vt(this,zn).valueAsNumber>0?Vt(this,Qn,this.playbackRate/this.duration/a):(Vt(this,Qn,.995*vt(this,Qn)),l=vt(this,zn).valueAsNumber+vt(this,Qn)),this.callback(l)}}),Vt(this,zn,e),this.callback=t,this.fps=r}start(){vt(this,Hs)===0&&(Vt(this,Xn,performance.now()),Vt(this,ec,vt(this,Xn)),Vt(this,tc,0),vt(this,sc).call(this))}stop(){vt(this,Hs)!==0&&(cancelAnimationFrame(vt(this,Hs)),Vt(this,Hs,0))}update({start:e,duration:t,playbackRate:r}){let s=e-vt(this,zn).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),Vt(this,rc,e),Vt(this,ic,performance.now()),this.duration=t,this.playbackRate=r}};zn=new WeakMap;ec=new WeakMap;Xn=new WeakMap;Fo=new WeakMap;tc=new WeakMap;ic=new WeakMap;rc=new WeakMap;Qn=new WeakMap;Hs=new WeakMap;sc=new WeakMap;var Up=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dt=(i,e,t)=>(Up(i,e,"read from private field"),t?t.call(i):e.get(i)),Et=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ui=(i,e,t,r)=>(Up(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),St=(i,e,t)=>(Up(i,e,"access private method"),t),Zn,Gs,lc,$o,dc,oc,Ho,Go,Jn,ea,Bo,Fp,Oy,Op,uc,Bp,cc,$p,hc,Hp,Pp,Py,Ko,fc,Np,Ny,ID="video not loaded, unknown time.",LD=i=>{let e=i.range,t=Rs(+Uy(i)),r=Rs(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:ID;e.setAttribute("aria-valuetext",s)};function kD(i){return`
|
|
1182
1182
|
${wi.getTemplateHTML(i)}
|
|
1183
1183
|
<style>
|
|
1184
1184
|
:host {
|
|
@@ -1396,7 +1396,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1396
1396
|
|
|
1397
1397
|
</slot>
|
|
1398
1398
|
</div>
|
|
1399
|
-
`}var ac=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Uy=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},Ko=class extends wi{constructor(){super(),Et(this,ea),Et(this,Fp),Et(this,uc),Et(this,cc),Et(this,hc),Et(this,Pp),Et(this,Go),Et(this,Np),Et(this,Zn,void 0),Et(this,Gs,void 0),Et(this,lc,void 0),Et(this,Bo,void 0),Et(this,dc,void 0),Et(this,oc,void 0),Et(this,$o,void 0),Et(this,Ho,void 0),Et(this,Jn,void 0),Et(this,Op,r=>{this.dragging||(Ln(r)&&(this.range.valueAsNumber=r),this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),Ui(this,lc,this.shadowRoot.querySelectorAll('[part~="box"]')),Ui(this,dc,this.shadowRoot.querySelector('[part~="preview-box"]')),Ui(this,oc,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);Ui(this,$o,parseInt(t.getPropertyValue("--media-box-padding-left"))),Ui(this,Ho,parseInt(t.getPropertyValue("--media-box-padding-right"))),Ui(this,Gs,new nc(this.range,dt(this,Op),60))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_DURATION,b.MEDIA_SEEKABLE,b.MEDIA_CURRENT_TIME,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_TIME,b.MEDIA_PREVIEW_CHAPTER,b.MEDIA_BUFFERED,b.MEDIA_PLAYBACK_RATE,b.MEDIA_LOADING,b.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",B("seek")),St(this,ea,Fo).call(this),Ui(this,Zn,this.getRootNode()),(e=dt(this,Zn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),St(this,ea,Fo).call(this),(e=dt(this,Zn))==null||e.removeEventListener("transitionstart",this),Ui(this,Zn,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===b.MEDIA_CURRENT_TIME||e===b.MEDIA_PAUSED||e===b.MEDIA_ENDED||e===b.MEDIA_LOADING||e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE?(dt(this,Gs).update({start:ac(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),St(this,ea,Fo).call(this),LD(this)):e===b.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=dt(this,Jn),this.updateBar()))}get mediaChaptersCues(){return dt(this,Jn)}set mediaChaptersCues(e){var t;Ui(this,Jn,e),this.updateSegments((t=dt(this,Jn))==null?void 0:t.map(r=>({start:ac(this,r.startTime),end:ac(this,r.endTime)})))}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,b.MEDIA_LOADING)}set mediaLoading(e){oe(this,b.MEDIA_LOADING,e)}get mediaDuration(){return ge(this,b.MEDIA_DURATION)}set mediaDuration(e){ye(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(b.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(b.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(b.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return de(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ge(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,b.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return ae(this,b.MEDIA_ENDED)}set mediaEnded(e){oe(this,b.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=ac(this,a)}let{style:s}=Me(this.shadowRoot,"#buffered");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=Me(this.shadowRoot,"#current-rail"),r=Me(this.shadowRoot,'[part~="current-box"]'),s=St(this,uc,Bp).call(this,dt(this,oc)),n=St(this,cc,$p).call(this,s,this.range.valueAsNumber),a=St(this,hc,Hp).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":St(this,Np,Ny).call(this);break;case"pointermove":St(this,Pp,Py).call(this,e);break;case"pointerup":case"pointerleave":St(this,Go,fc).call(this,null);break;case"transitionstart":Rt(e.target,this)&&setTimeout(()=>St(this,ea,Fo).call(this),0);break}}};Zn=new WeakMap;Gs=new WeakMap;lc=new WeakMap;Bo=new WeakMap;dc=new WeakMap;oc=new WeakMap;$o=new WeakMap;Ho=new WeakMap;Jn=new WeakMap;ea=new WeakSet;Fo=function(){St(this,Fp,Oy).call(this)?dt(this,Gs).start():dt(this,Gs).stop()};Fp=new WeakSet;Oy=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&ru(this)};Op=new WeakMap;uc=new WeakSet;Bp=function(i){var e;let r=((e=this.getAttribute("bounds")?Ri(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};cc=new WeakSet;$p=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};hc=new WeakSet;Hp=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+dt(this,$o)){let a=i.range.left-i.bounds.left-dt(this,$o);return`${n-t/2+a}px`}if(n>s-dt(this,Ho)){let a=i.bounds.right-i.range.right-dt(this,Ho);return`${n+t/2-a-i.range.width}px`}return 0};Pp=new WeakSet;Py=function(i){let e=[...dt(this,lc)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){St(this,Go,fc).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=Me(this.shadowRoot,"#preview-rail"),s=Me(this.shadowRoot,'[part~="preview-box"]'),n=St(this,uc,Bp).call(this,dt(this,dc)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=St(this,cc,$p).call(this,n,a),l=St(this,hc,Hp).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(dt(this,Bo))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(Ui(this,Bo,a*t),St(this,Go,fc).call(this,dt(this,Bo)))};Go=new WeakSet;fc=function(i){this.dispatchEvent(new S.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Np=new WeakSet;Ny=function(){dt(this,Gs).stop();let i=Uy(this);this.dispatchEvent(new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Ko.shadowRootOptions={mode:"open"};Ko.getTemplateHTML=kD;S.customElements.get("media-time-range")||S.customElements.define("media-time-range",Ko);var wD=1,DD=i=>i.mediaMuted?0:i.mediaVolume,CD=i=>`${Math.round(i*100)}%`,Gp=class extends wi{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME,b.MEDIA_MUTED,b.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new S.CustomEvent($.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",B("volume"))}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===b.MEDIA_VOLUME||e===b.MEDIA_MUTED)&&(this.range.valueAsNumber=DD(this),this.range.setAttribute("aria-valuetext",CD(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return ge(this,b.MEDIA_VOLUME,wD)}set mediaVolume(e){ye(this,b.MEDIA_VOLUME,e)}get mediaMuted(){return ae(this,b.MEDIA_MUTED)}set mediaMuted(e){oe(this,b.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return de(this,b.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ue(this,b.MEDIA_VOLUME_UNAVAILABLE,e)}};S.customElements.get("media-volume-range")||S.customElements.define("media-volume-range",Gp);var Gy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ee=(i,e,t)=>(Gy(i,e,"read from private field"),t?t.call(i):e.get(i)),Fi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hr=(i,e,t,r)=>(Gy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ta,mc,Ks,Vo,Xr,Qr,Zr,Vs,ia,pc,pi,Fy=1,By=0,MD=1,OD={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof It&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof It?s.element[s.attributeName]=n:s.value=n}}}},fr=class extends S.DocumentFragment{constructor(e,t,r=OD){var s;super(),Fi(this,ta,void 0),Fi(this,mc,void 0),this.append(e.content.cloneNode(!0)),hr(this,ta,Ky(this)),hr(this,mc,r),(s=r.createCallback)==null||s.call(r,this,Ee(this,ta),t),r.processCallback(this,Ee(this,ta),t)}update(e){Ee(this,mc).processCallback(this,Ee(this,ta),e)}};ta=new WeakMap;mc=new WeakMap;var Ky=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Kp;for([t,r]of Hy(s.value))if(!t)n.append(r);else{let a=new It(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===Fy&&!(s instanceof HTMLTemplateElement))Ky(s,e);else{let n=s.data;if(s.nodeType===Fy||n.includes("{{")){let a=[];if(n)for([t,r]of Hy(n))if(!t)a.push(new Text(r));else{let o=new mr(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){let o=new Wo(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},$y={},Hy=i=>{let e="",t=0,r=$y[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([By,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([MD,e.trim()]),e="",s++):e+=n||"";return e&&r.push([By,(t>0?"{{":"")+e]),$y[i]=r},PD=11,gc=class{get value(){return""}set value(e){}toString(){return this.value}},Vy=new WeakMap,Kp=class{constructor(){Fi(this,Ks,[])}[Symbol.iterator](){return Ee(this,Ks).values()}get length(){return Ee(this,Ks).length}item(e){return Ee(this,Ks)[e]}append(...e){for(let t of e)t instanceof It&&Vy.set(t,this),Ee(this,Ks).push(t)}toString(){return Ee(this,Ks).join("")}};Ks=new WeakMap;var It=class extends gc{constructor(e,t,r){super(),Fi(this,Vs),Fi(this,Vo,""),Fi(this,Xr,void 0),Fi(this,Qr,void 0),Fi(this,Zr,void 0),hr(this,Xr,e),hr(this,Qr,t),hr(this,Zr,r)}get attributeName(){return Ee(this,Qr)}get attributeNamespace(){return Ee(this,Zr)}get element(){return Ee(this,Xr)}get value(){return Ee(this,Vo)}set value(e){Ee(this,Vo)!==e&&(hr(this,Vo,e),!Ee(this,Vs,ia)||Ee(this,Vs,ia).length===1?e==null?Ee(this,Xr).removeAttributeNS(Ee(this,Zr),Ee(this,Qr)):Ee(this,Xr).setAttributeNS(Ee(this,Zr),Ee(this,Qr),e):Ee(this,Xr).setAttributeNS(Ee(this,Zr),Ee(this,Qr),Ee(this,Vs,ia).toString()))}get booleanValue(){return Ee(this,Xr).hasAttributeNS(Ee(this,Zr),Ee(this,Qr))}set booleanValue(e){if(!Ee(this,Vs,ia)||Ee(this,Vs,ia).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Vo=new WeakMap;Xr=new WeakMap;Qr=new WeakMap;Zr=new WeakMap;Vs=new WeakSet;ia=function(){return Vy.get(this)};var mr=class extends gc{constructor(e,t){super(),Fi(this,pc,void 0),Fi(this,pi,void 0),hr(this,pc,e),hr(this,pi,t?[...t]:[new Text])}get replacementNodes(){return Ee(this,pi)}get parentNode(){return Ee(this,pc)}get nextSibling(){return Ee(this,pi)[Ee(this,pi).length-1].nextSibling}get previousSibling(){return Ee(this,pi)[0].previousSibling}get value(){return Ee(this,pi).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===PD?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),hr(this,pi,ND(Ee(this,pi)[0].parentNode,Ee(this,pi),t,this.nextSibling))}};pc=new WeakMap;pi=new WeakMap;var Wo=class extends mr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}};function ND(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var Wy={string:i=>String(i)},Ec=class{constructor(e){this.template=e,this.state=void 0}},Ws=new WeakMap,Ys=new WeakMap,Vp={partial:(i,e)=>{e[i.expression]=new Ec(i.template)},if:(i,e)=>{var t;if(qy(i.expression,e))if(Ws.get(i)!==i.template){Ws.set(i,i.template);let r=new fr(i.template,e,Tc);i.replace(r),Ys.set(i,r)}else(t=Ys.get(i))==null||t.update(e);else i.replace(""),Ws.delete(i),Ys.delete(i)}},UD=Object.keys(Vp),Tc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Wo){if(!a.directive){let l=UD.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Vp[a.directive])==null||r.call(Vp,a,t);continue}let o=qy(n,t);if(o instanceof Ec){Ws.get(a)!==o.template?(Ws.set(a,o.template),o=new fr(o.template,o.state,Tc),a.value=o,Ys.set(a,o)):(s=Ys.get(a))==null||s.update(o.state);continue}o?(a instanceof It&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof It?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Ws.delete(a),Ys.delete(a))):a instanceof It?a.value=void 0:(a.value=void 0,Ws.delete(a),Ys.delete(a))}}},Yy={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=Wy[e])==null?void 0:t.call(Wy,i)}};function FD(i){return BD(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function qy(i,e={}){var t,r,s,n,a,o,l;let d=FD(i);if(d.length===0||d.some(({type:u})=>!u))return Yo(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return Yo(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=qo(g,e))}return u}if(d.length===1)return vc(d[0])?qo(d[0].token,e):Yo(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=Yy[u];if(!c||!vc(d[1]))return Yo(i);let h=qo(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=Yy[u];if(!c||!vc(d[0])||!vc(d[2]))return Yo(i);let h=qo(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=qo(d[2].token,e);return c(h,f)}}function Yo(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function vc({type:i}){return["number","boolean","string","param"].includes(i)}function qo(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):zd(i)?parseFloat(i):e[i]}function BD(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Xp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},qp=(i,e,t)=>(Xp(i,e,"read from private field"),t?t.call(i):e.get(i)),jo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qs=(i,e,t,r)=>(Xp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Wp=(i,e,t)=>(Xp(i,e,"access private method"),t),ra,bc,sa,jp,jy,yc,zp,Yp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},zy=Ue.createElement("template");zy.innerHTML=`
|
|
1399
|
+
`}var ac=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Uy=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},Vo=class extends wi{constructor(){super(),Et(this,ea),Et(this,Fp),Et(this,uc),Et(this,cc),Et(this,hc),Et(this,Pp),Et(this,Ko),Et(this,Np),Et(this,Zn,void 0),Et(this,Gs,void 0),Et(this,lc,void 0),Et(this,$o,void 0),Et(this,dc,void 0),Et(this,oc,void 0),Et(this,Ho,void 0),Et(this,Go,void 0),Et(this,Jn,void 0),Et(this,Op,r=>{this.dragging||(Ln(r)&&(this.range.valueAsNumber=r),this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),Ui(this,lc,this.shadowRoot.querySelectorAll('[part~="box"]')),Ui(this,dc,this.shadowRoot.querySelector('[part~="preview-box"]')),Ui(this,oc,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);Ui(this,Ho,parseInt(t.getPropertyValue("--media-box-padding-left"))),Ui(this,Go,parseInt(t.getPropertyValue("--media-box-padding-right"))),Ui(this,Gs,new nc(this.range,dt(this,Op),60))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_DURATION,b.MEDIA_SEEKABLE,b.MEDIA_CURRENT_TIME,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_TIME,b.MEDIA_PREVIEW_CHAPTER,b.MEDIA_BUFFERED,b.MEDIA_PLAYBACK_RATE,b.MEDIA_LOADING,b.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",B("seek")),St(this,ea,Bo).call(this),Ui(this,Zn,this.getRootNode()),(e=dt(this,Zn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),St(this,ea,Bo).call(this),(e=dt(this,Zn))==null||e.removeEventListener("transitionstart",this),Ui(this,Zn,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===b.MEDIA_CURRENT_TIME||e===b.MEDIA_PAUSED||e===b.MEDIA_ENDED||e===b.MEDIA_LOADING||e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE?(dt(this,Gs).update({start:ac(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),St(this,ea,Bo).call(this),LD(this)):e===b.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=dt(this,Jn),this.updateBar()))}get mediaChaptersCues(){return dt(this,Jn)}set mediaChaptersCues(e){var t;Ui(this,Jn,e),this.updateSegments((t=dt(this,Jn))==null?void 0:t.map(r=>({start:ac(this,r.startTime),end:ac(this,r.endTime)})))}get mediaPaused(){return ae(this,b.MEDIA_PAUSED)}set mediaPaused(e){oe(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,b.MEDIA_LOADING)}set mediaLoading(e){oe(this,b.MEDIA_LOADING,e)}get mediaDuration(){return ge(this,b.MEDIA_DURATION)}set mediaDuration(e){ye(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,b.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(b.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(b.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(b.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return de(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ge(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,b.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return ae(this,b.MEDIA_ENDED)}set mediaEnded(e){oe(this,b.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=ac(this,a)}let{style:s}=Me(this.shadowRoot,"#buffered");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=Me(this.shadowRoot,"#current-rail"),r=Me(this.shadowRoot,'[part~="current-box"]'),s=St(this,uc,Bp).call(this,dt(this,oc)),n=St(this,cc,$p).call(this,s,this.range.valueAsNumber),a=St(this,hc,Hp).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":St(this,Np,Ny).call(this);break;case"pointermove":St(this,Pp,Py).call(this,e);break;case"pointerup":case"pointerleave":St(this,Ko,fc).call(this,null);break;case"transitionstart":Rt(e.target,this)&&setTimeout(()=>St(this,ea,Bo).call(this),0);break}}};Zn=new WeakMap;Gs=new WeakMap;lc=new WeakMap;$o=new WeakMap;dc=new WeakMap;oc=new WeakMap;Ho=new WeakMap;Go=new WeakMap;Jn=new WeakMap;ea=new WeakSet;Bo=function(){St(this,Fp,Oy).call(this)?dt(this,Gs).start():dt(this,Gs).stop()};Fp=new WeakSet;Oy=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&ru(this)};Op=new WeakMap;uc=new WeakSet;Bp=function(i){var e;let r=((e=this.getAttribute("bounds")?Ri(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};cc=new WeakSet;$p=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};hc=new WeakSet;Hp=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+dt(this,Ho)){let a=i.range.left-i.bounds.left-dt(this,Ho);return`${n-t/2+a}px`}if(n>s-dt(this,Go)){let a=i.bounds.right-i.range.right-dt(this,Go);return`${n+t/2-a-i.range.width}px`}return 0};Pp=new WeakSet;Py=function(i){let e=[...dt(this,lc)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){St(this,Ko,fc).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=Me(this.shadowRoot,"#preview-rail"),s=Me(this.shadowRoot,'[part~="preview-box"]'),n=St(this,uc,Bp).call(this,dt(this,dc)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=St(this,cc,$p).call(this,n,a),l=St(this,hc,Hp).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(dt(this,$o))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(Ui(this,$o,a*t),St(this,Ko,fc).call(this,dt(this,$o)))};Ko=new WeakSet;fc=function(i){this.dispatchEvent(new S.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Np=new WeakSet;Ny=function(){dt(this,Gs).stop();let i=Uy(this);this.dispatchEvent(new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Vo.shadowRootOptions={mode:"open"};Vo.getTemplateHTML=kD;S.customElements.get("media-time-range")||S.customElements.define("media-time-range",Vo);var wD=1,DD=i=>i.mediaMuted?0:i.mediaVolume,CD=i=>`${Math.round(i*100)}%`,Gp=class extends wi{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME,b.MEDIA_MUTED,b.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new S.CustomEvent($.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",B("volume"))}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===b.MEDIA_VOLUME||e===b.MEDIA_MUTED)&&(this.range.valueAsNumber=DD(this),this.range.setAttribute("aria-valuetext",CD(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return ge(this,b.MEDIA_VOLUME,wD)}set mediaVolume(e){ye(this,b.MEDIA_VOLUME,e)}get mediaMuted(){return ae(this,b.MEDIA_MUTED)}set mediaMuted(e){oe(this,b.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return de(this,b.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ue(this,b.MEDIA_VOLUME_UNAVAILABLE,e)}};S.customElements.get("media-volume-range")||S.customElements.define("media-volume-range",Gp);var Gy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ee=(i,e,t)=>(Gy(i,e,"read from private field"),t?t.call(i):e.get(i)),Fi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hr=(i,e,t,r)=>(Gy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ta,mc,Ks,Wo,Xr,Qr,Zr,Vs,ia,pc,pi,Fy=1,By=0,MD=1,OD={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof It&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof It?s.element[s.attributeName]=n:s.value=n}}}},fr=class extends S.DocumentFragment{constructor(e,t,r=OD){var s;super(),Fi(this,ta,void 0),Fi(this,mc,void 0),this.append(e.content.cloneNode(!0)),hr(this,ta,Ky(this)),hr(this,mc,r),(s=r.createCallback)==null||s.call(r,this,Ee(this,ta),t),r.processCallback(this,Ee(this,ta),t)}update(e){Ee(this,mc).processCallback(this,Ee(this,ta),e)}};ta=new WeakMap;mc=new WeakMap;var Ky=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Kp;for([t,r]of Hy(s.value))if(!t)n.append(r);else{let a=new It(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===Fy&&!(s instanceof HTMLTemplateElement))Ky(s,e);else{let n=s.data;if(s.nodeType===Fy||n.includes("{{")){let a=[];if(n)for([t,r]of Hy(n))if(!t)a.push(new Text(r));else{let o=new mr(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){let o=new Yo(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},$y={},Hy=i=>{let e="",t=0,r=$y[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([By,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([MD,e.trim()]),e="",s++):e+=n||"";return e&&r.push([By,(t>0?"{{":"")+e]),$y[i]=r},PD=11,gc=class{get value(){return""}set value(e){}toString(){return this.value}},Vy=new WeakMap,Kp=class{constructor(){Fi(this,Ks,[])}[Symbol.iterator](){return Ee(this,Ks).values()}get length(){return Ee(this,Ks).length}item(e){return Ee(this,Ks)[e]}append(...e){for(let t of e)t instanceof It&&Vy.set(t,this),Ee(this,Ks).push(t)}toString(){return Ee(this,Ks).join("")}};Ks=new WeakMap;var It=class extends gc{constructor(e,t,r){super(),Fi(this,Vs),Fi(this,Wo,""),Fi(this,Xr,void 0),Fi(this,Qr,void 0),Fi(this,Zr,void 0),hr(this,Xr,e),hr(this,Qr,t),hr(this,Zr,r)}get attributeName(){return Ee(this,Qr)}get attributeNamespace(){return Ee(this,Zr)}get element(){return Ee(this,Xr)}get value(){return Ee(this,Wo)}set value(e){Ee(this,Wo)!==e&&(hr(this,Wo,e),!Ee(this,Vs,ia)||Ee(this,Vs,ia).length===1?e==null?Ee(this,Xr).removeAttributeNS(Ee(this,Zr),Ee(this,Qr)):Ee(this,Xr).setAttributeNS(Ee(this,Zr),Ee(this,Qr),e):Ee(this,Xr).setAttributeNS(Ee(this,Zr),Ee(this,Qr),Ee(this,Vs,ia).toString()))}get booleanValue(){return Ee(this,Xr).hasAttributeNS(Ee(this,Zr),Ee(this,Qr))}set booleanValue(e){if(!Ee(this,Vs,ia)||Ee(this,Vs,ia).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Wo=new WeakMap;Xr=new WeakMap;Qr=new WeakMap;Zr=new WeakMap;Vs=new WeakSet;ia=function(){return Vy.get(this)};var mr=class extends gc{constructor(e,t){super(),Fi(this,pc,void 0),Fi(this,pi,void 0),hr(this,pc,e),hr(this,pi,t?[...t]:[new Text])}get replacementNodes(){return Ee(this,pi)}get parentNode(){return Ee(this,pc)}get nextSibling(){return Ee(this,pi)[Ee(this,pi).length-1].nextSibling}get previousSibling(){return Ee(this,pi)[0].previousSibling}get value(){return Ee(this,pi).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===PD?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),hr(this,pi,ND(Ee(this,pi)[0].parentNode,Ee(this,pi),t,this.nextSibling))}};pc=new WeakMap;pi=new WeakMap;var Yo=class extends mr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}};function ND(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var Wy={string:i=>String(i)},Ec=class{constructor(e){this.template=e,this.state=void 0}},Ws=new WeakMap,Ys=new WeakMap,Vp={partial:(i,e)=>{e[i.expression]=new Ec(i.template)},if:(i,e)=>{var t;if(qy(i.expression,e))if(Ws.get(i)!==i.template){Ws.set(i,i.template);let r=new fr(i.template,e,Tc);i.replace(r),Ys.set(i,r)}else(t=Ys.get(i))==null||t.update(e);else i.replace(""),Ws.delete(i),Ys.delete(i)}},UD=Object.keys(Vp),Tc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Yo){if(!a.directive){let l=UD.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Vp[a.directive])==null||r.call(Vp,a,t);continue}let o=qy(n,t);if(o instanceof Ec){Ws.get(a)!==o.template?(Ws.set(a,o.template),o=new fr(o.template,o.state,Tc),a.value=o,Ys.set(a,o)):(s=Ys.get(a))==null||s.update(o.state);continue}o?(a instanceof It&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof It?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Ws.delete(a),Ys.delete(a))):a instanceof It?a.value=void 0:(a.value=void 0,Ws.delete(a),Ys.delete(a))}}},Yy={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=Wy[e])==null?void 0:t.call(Wy,i)}};function FD(i){return BD(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function qy(i,e={}){var t,r,s,n,a,o,l;let d=FD(i);if(d.length===0||d.some(({type:u})=>!u))return qo(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return qo(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=jo(g,e))}return u}if(d.length===1)return vc(d[0])?jo(d[0].token,e):qo(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=Yy[u];if(!c||!vc(d[1]))return qo(i);let h=jo(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=Yy[u];if(!c||!vc(d[0])||!vc(d[2]))return qo(i);let h=jo(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=jo(d[2].token,e);return c(h,f)}}function qo(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function vc({type:i}){return["number","boolean","string","param"].includes(i)}function jo(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):zd(i)?parseFloat(i):e[i]}function BD(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Xp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},qp=(i,e,t)=>(Xp(i,e,"read from private field"),t?t.call(i):e.get(i)),zo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qs=(i,e,t,r)=>(Xp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Wp=(i,e,t)=>(Xp(i,e,"access private method"),t),ra,bc,sa,jp,jy,yc,zp,Yp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},zy=Ue.createElement("template");zy.innerHTML=`
|
|
1400
1400
|
<style>
|
|
1401
1401
|
:host {
|
|
1402
1402
|
display: inline-block;
|
|
@@ -1423,7 +1423,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1423
1423
|
display: none;
|
|
1424
1424
|
}
|
|
1425
1425
|
</style>
|
|
1426
|
-
`;var js=class extends S.HTMLElement{constructor(){super(),
|
|
1426
|
+
`;var js=class extends S.HTMLElement{constructor(){super(),zo(this,jp),zo(this,yc),zo(this,ra,void 0),zo(this,bc,void 0),zo(this,sa,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Yp[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Qt.BREAKPOINTS_COMPUTED,this.render),Wp(this,jp,jy).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=qp(this,ra))!=null?e:this.constructor.template}set template(e){qs(this,sa,null),qs(this,ra,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Yp[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Yp[a.name])!=null?r:lb(a.name),{value:l}=a;l!=null?(zd(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Wp(this,yc,zp).call(this)}connectedCallback(){Wp(this,yc,zp).call(this)}createRenderer(){this.template&&this.template!==qp(this,bc)&&(qs(this,bc,this.template),this.renderer=new fr(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(zy.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};ra=new WeakMap;bc=new WeakMap;sa=new WeakMap;jp=new WeakSet;jy=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};yc=new WeakSet;zp=function(){var i;let e=this.getAttribute("template");if(!e||e===qp(this,sa))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){qs(this,sa,e),qs(this,ra,r),this.createRenderer();return}$D(e)&&(qs(this,sa,e),HD(e).then(s=>{let n=Ue.createElement("template");n.innerHTML=s,qs(this,ra,n),this.createRenderer()}).catch(console.error))};js.observedAttributes=["template"];js.processor=Tc;function $D(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function HD(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}S.customElements.get("media-theme")||S.customElements.define("media-theme",js);function Xy({anchor:i,floating:e,placement:t}){let r=GD({anchor:i,floating:e}),{x:s,y:n}=VD(r,t);return{x:s,y:n}}function GD({anchor:i,floating:e}){return{anchor:KD(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function KD(i,e){var t;let r=i.getBoundingClientRect(),s=(t=e==null?void 0:e.getBoundingClientRect())!=null?t:{x:0,y:0};return{x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}function VD({anchor:i,floating:e},t){let r=WD(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=Qy(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2,d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function Qy(i){return i.split("-")[0]}function WD(i){return["top","bottom"].includes(Qy(i))?"y":"x"}var Jr=class extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),this.action=e,this.relatedTarget=t}},_c=class extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),this.newState=e,this.oldState=t}};var lg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Re=(i,e,t)=>(lg(i,e,"read from private field"),t?t.call(i):e.get(i)),Be=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Bi=(i,e,t,r)=>(lg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ge=(i,e,t)=>(lg(i,e,"access private method"),t),$i,Xs,es,Ac,Sc,Qs,Zo,Qp,Zy,Ic,xc,Zp,Jp,Jy,eg,e_,tg,t_,na,aa,oa,Jo,Lc,dg,ig,i_,ug,r_,rg,s_,cg,n_,sg,a_,ng,o_,Xo,kc,ag,l_,Qo,wc,Rc,og;function Hi({type:i,text:e,value:t,checked:r}){let s=Ue.createElement("media-chrome-menu-item");s.type=i!=null?i:"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;let n=Ue.createElement("span");return n.textContent=e,s.append(n),s}function gi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}function YD(i){return`
|
|
1427
1427
|
<style>
|
|
1428
1428
|
:host {
|
|
1429
1429
|
font: var(--media-font,
|
|
@@ -1597,7 +1597,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1597
1597
|
<slot></slot>
|
|
1598
1598
|
</div>
|
|
1599
1599
|
<slot name="checked-indicator" hidden></slot>
|
|
1600
|
-
`}var zs={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},Tt=class extends S.HTMLElement{constructor(){if(super(),Be(this,Qp),Be(this,xc),Be(this,Jp),Be(this,eg),Be(this,tg),Be(this,oa),Be(this,Lc),Be(this,ig),Be(this,ug),Be(this,rg),Be(this,cg),Be(this,sg),Be(this,ng),Be(this,zo),Be(this,ag),Be(this,Xo),Be(this,Rc),Be(this,$i,null),Be(this,Xs,null),Be(this,es,null),Be(this,Ac,new Set),Be(this,Sc,void 0),Be(this,Qs,!1),Be(this,Qo,null),Be(this,Ic,()=>{let e=Re(this,Ac),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));Bi(this,Ac,t)}),Be(this,na,()=>{Ge(this,oa,Zo).call(this),Ge(this,Lc,dg).call(this,!1)}),Be(this,aa,()=>{Ge(this,oa,Zo).call(this)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Bi(this,Sc,new MutationObserver(Re(this,Ic))),Re(this,Sc).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[zs.DISABLED,zs.HIDDEN,zs.STYLE,zs.ANCHOR,me.MEDIA_CONTROLLER]}static formatMenuItemText(e,t){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":Ge(this,Qp,Zy).call(this,e);break;case"invoke":Ge(this,Jp,Jy).call(this,e);break;case"click":Ge(this,ig,i_).call(this,e);break;case"toggle":Ge(this,rg,s_).call(this,e);break;case"focusout":Ge(this,sg,a_).call(this,e);break;case"keydown":Ge(this,ng,o_).call(this,e);break}}connectedCallback(){var e,t;Bi(this,Qo,Vm(this.shadowRoot,":host")),Ge(this,xc,Zp).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Bi(this,$i,eu(this)),(t=(e=Re(this,$i))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(ar(Jo(this),Re(this,na)),ar(this,Re(this,aa)))}disconnectedCallback(){var e,t;or(Jo(this),Re(this,na)),or(this,Re(this,aa)),this.disable(),(t=(e=Re(this,$i))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bi(this,$i,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===zs.HIDDEN&&r!==t?(Re(this,Qs)||Bi(this,Qs,!0),this.hidden?Ge(this,tg,t_).call(this):Ge(this,eg,e_).call(this),this.dispatchEvent(new _c({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===me.MEDIA_CONTROLLER?(t&&((n=(s=Re(this,$i))==null?void 0:s.unassociateElement)==null||n.call(s,this),Bi(this,$i,null)),r&&this.isConnected&&(Bi(this,$i,eu(this)),(o=(a=Re(this,$i))==null?void 0:a.associateElement)==null||o.call(a,this))):e===zs.DISABLED&&r!==t?r==null?this.enable():this.disable():e===zs.STYLE&&r!==t&&Ge(this,xc,Zp).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Is(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(qD)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&Ge(this,Rc,og).call(this,t)}focus(){if(Bi(this,Xs,ao()),this.items.length){Ge(this,Xo,wc).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=Ge(this,zo,kc).call(this,e);r&&(Ge(this,Rc,og).call(this,r,r.type==="checkbox"),Re(this,es)&&!this.hidden&&((t=Re(this,Xs))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=Ge(this,zo,kc).call(this,e))!=null?t:Ge(this,ag,l_).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),Ge(this,Xo,wc).call(this,n[l]),n[l].focus()}};$i=new WeakMap;Xs=new WeakMap;es=new WeakMap;Ac=new WeakMap;Sc=new WeakMap;Qs=new WeakMap;Qo=new WeakMap;Qp=new WeakSet;Zy=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Re(this,Ic).call(this)};Ic=new WeakMap;xc=new WeakSet;Zp=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Jp=new WeakSet;Jy=function(i){Bi(this,es,i.relatedTarget),Rt(this,i.relatedTarget)||(this.hidden=!this.hidden)};eg=new WeakSet;e_=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),ar(Jo(this),Re(this,na)),ar(this,Re(this,aa))};tg=new WeakSet;t_=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","false"),or(Jo(this),Re(this,na)),or(this,Re(this,aa))};na=new WeakMap;aa=new WeakMap;oa=new WeakSet;Zo=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=Xy({anchor:this.anchorElement,floating:this,placement:"top-start"});i!=null||(i=this.offsetWidth);let s=Jo(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=Re(this,Qo);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);let l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};Lc=new WeakSet;dg=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Re(this,Qo);if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),Ge(this,oa,Zo).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),Ge(this,oa,Zo).call(this);r.removeProperty("--media-menu-transition-in")};ig=new WeakSet;i_=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Re(this,ug,r_))){(e=Re(this,Xs))==null||e.focus(),this.hidden=!0;return}let t=Ge(this,zo,kc).call(this,i);!t||t.hasAttribute("disabled")||(Ge(this,Xo,wc).call(this,t),this.handleSelect(i))};ug=new WeakSet;r_=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};rg=new WeakSet;s_=function(i){if(i.target===this)return;Ge(this,cg,n_).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Jr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);Ge(this,Lc,dg).call(this,!0)};cg=new WeakSet;n_=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};sg=new WeakSet;a_=function(i){var e;Rt(this,i.relatedTarget)||(Re(this,Qs)&&((e=Re(this,Xs))==null||e.focus()),Re(this,es)&&Re(this,es)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};ng=new WeakSet;o_=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Re(this,Qs)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Re(this,Xs))==null||n.focus(),Re(this,Qs)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};zo=new WeakSet;kc=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};ag=new WeakSet;l_=function(){return this.items.find(i=>i.tabIndex===0)};Xo=new WeakSet;wc=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Rc=new WeakSet;og=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};Tt.shadowRootOptions={mode:"open"};Tt.getTemplateHTML=YD;function qD(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Jo(i){var e;return(e=i.getAttribute("bounds")?Ri(i,`#${i.getAttribute("bounds")}`):We(i)||i.parentElement)!=null?e:i}S.customElements.get("media-chrome-menu")||S.customElements.define("media-chrome-menu",Tt);var vg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ki=(i,e,t)=>(vg(i,e,"read from private field"),t?t.call(i):e.get(i)),pr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hg=(i,e,t,r)=>(vg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gi=(i,e,t)=>(vg(i,e,"access private method"),t),Dc,tl,fg,d_,Eg,u_,Tg,c_,Vi,la,il,mg,h_,Cc,pg;function jD(i){return`
|
|
1600
|
+
`}var zs={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},Tt=class extends S.HTMLElement{constructor(){if(super(),Be(this,Qp),Be(this,xc),Be(this,Jp),Be(this,eg),Be(this,tg),Be(this,oa),Be(this,Lc),Be(this,ig),Be(this,ug),Be(this,rg),Be(this,cg),Be(this,sg),Be(this,ng),Be(this,Xo),Be(this,ag),Be(this,Qo),Be(this,Rc),Be(this,$i,null),Be(this,Xs,null),Be(this,es,null),Be(this,Ac,new Set),Be(this,Sc,void 0),Be(this,Qs,!1),Be(this,Zo,null),Be(this,Ic,()=>{let e=Re(this,Ac),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));Bi(this,Ac,t)}),Be(this,na,()=>{Ge(this,oa,Jo).call(this),Ge(this,Lc,dg).call(this,!1)}),Be(this,aa,()=>{Ge(this,oa,Jo).call(this)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Bi(this,Sc,new MutationObserver(Re(this,Ic))),Re(this,Sc).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[zs.DISABLED,zs.HIDDEN,zs.STYLE,zs.ANCHOR,me.MEDIA_CONTROLLER]}static formatMenuItemText(e,t){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":Ge(this,Qp,Zy).call(this,e);break;case"invoke":Ge(this,Jp,Jy).call(this,e);break;case"click":Ge(this,ig,i_).call(this,e);break;case"toggle":Ge(this,rg,s_).call(this,e);break;case"focusout":Ge(this,sg,a_).call(this,e);break;case"keydown":Ge(this,ng,o_).call(this,e);break}}connectedCallback(){var e,t;Bi(this,Zo,Vm(this.shadowRoot,":host")),Ge(this,xc,Zp).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Bi(this,$i,eu(this)),(t=(e=Re(this,$i))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(ar(el(this),Re(this,na)),ar(this,Re(this,aa)))}disconnectedCallback(){var e,t;or(el(this),Re(this,na)),or(this,Re(this,aa)),this.disable(),(t=(e=Re(this,$i))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bi(this,$i,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===zs.HIDDEN&&r!==t?(Re(this,Qs)||Bi(this,Qs,!0),this.hidden?Ge(this,tg,t_).call(this):Ge(this,eg,e_).call(this),this.dispatchEvent(new _c({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===me.MEDIA_CONTROLLER?(t&&((n=(s=Re(this,$i))==null?void 0:s.unassociateElement)==null||n.call(s,this),Bi(this,$i,null)),r&&this.isConnected&&(Bi(this,$i,eu(this)),(o=(a=Re(this,$i))==null?void 0:a.associateElement)==null||o.call(a,this))):e===zs.DISABLED&&r!==t?r==null?this.enable():this.disable():e===zs.STYLE&&r!==t&&Ge(this,xc,Zp).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Is(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(qD)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&Ge(this,Rc,og).call(this,t)}focus(){if(Bi(this,Xs,oo()),this.items.length){Ge(this,Qo,wc).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=Ge(this,Xo,kc).call(this,e);r&&(Ge(this,Rc,og).call(this,r,r.type==="checkbox"),Re(this,es)&&!this.hidden&&((t=Re(this,Xs))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=Ge(this,Xo,kc).call(this,e))!=null?t:Ge(this,ag,l_).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),Ge(this,Qo,wc).call(this,n[l]),n[l].focus()}};$i=new WeakMap;Xs=new WeakMap;es=new WeakMap;Ac=new WeakMap;Sc=new WeakMap;Qs=new WeakMap;Zo=new WeakMap;Qp=new WeakSet;Zy=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Re(this,Ic).call(this)};Ic=new WeakMap;xc=new WeakSet;Zp=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Jp=new WeakSet;Jy=function(i){Bi(this,es,i.relatedTarget),Rt(this,i.relatedTarget)||(this.hidden=!this.hidden)};eg=new WeakSet;e_=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),ar(el(this),Re(this,na)),ar(this,Re(this,aa))};tg=new WeakSet;t_=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","false"),or(el(this),Re(this,na)),or(this,Re(this,aa))};na=new WeakMap;aa=new WeakMap;oa=new WeakSet;Jo=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=Xy({anchor:this.anchorElement,floating:this,placement:"top-start"});i!=null||(i=this.offsetWidth);let s=el(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=Re(this,Zo);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);let l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};Lc=new WeakSet;dg=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Re(this,Zo);if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),Ge(this,oa,Jo).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),Ge(this,oa,Jo).call(this);r.removeProperty("--media-menu-transition-in")};ig=new WeakSet;i_=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Re(this,ug,r_))){(e=Re(this,Xs))==null||e.focus(),this.hidden=!0;return}let t=Ge(this,Xo,kc).call(this,i);!t||t.hasAttribute("disabled")||(Ge(this,Qo,wc).call(this,t),this.handleSelect(i))};ug=new WeakSet;r_=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};rg=new WeakSet;s_=function(i){if(i.target===this)return;Ge(this,cg,n_).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Jr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);Ge(this,Lc,dg).call(this,!0)};cg=new WeakSet;n_=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};sg=new WeakSet;a_=function(i){var e;Rt(this,i.relatedTarget)||(Re(this,Qs)&&((e=Re(this,Xs))==null||e.focus()),Re(this,es)&&Re(this,es)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};ng=new WeakSet;o_=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Re(this,Qs)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Re(this,Xs))==null||n.focus(),Re(this,Qs)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};Xo=new WeakSet;kc=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};ag=new WeakSet;l_=function(){return this.items.find(i=>i.tabIndex===0)};Qo=new WeakSet;wc=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Rc=new WeakSet;og=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};Tt.shadowRootOptions={mode:"open"};Tt.getTemplateHTML=YD;function qD(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function el(i){var e;return(e=i.getAttribute("bounds")?Ri(i,`#${i.getAttribute("bounds")}`):We(i)||i.parentElement)!=null?e:i}S.customElements.get("media-chrome-menu")||S.customElements.define("media-chrome-menu",Tt);var vg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ki=(i,e,t)=>(vg(i,e,"read from private field"),t?t.call(i):e.get(i)),pr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hg=(i,e,t,r)=>(vg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gi=(i,e,t)=>(vg(i,e,"access private method"),t),Dc,il,fg,d_,Eg,u_,Tg,c_,Vi,la,rl,mg,h_,Cc,pg;function jD(i){return`
|
|
1601
1601
|
<style>
|
|
1602
1602
|
:host {
|
|
1603
1603
|
transition: var(--media-menu-item-transition,
|
|
@@ -1715,7 +1715,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1715
1715
|
${this.getSuffixSlotInnerHTML(i)}
|
|
1716
1716
|
</slot>
|
|
1717
1717
|
<slot name="submenu"></slot>
|
|
1718
|
-
`}function zD(i){return""}var Jt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},Wi=class extends S.HTMLElement{constructor(){if(super(),pr(this,fg),pr(this,Eg),pr(this,Tg),pr(this,la),pr(this,mg),pr(this,Cc),pr(this,Dc,!1),pr(this,
|
|
1718
|
+
`}function zD(i){return""}var Jt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},Wi=class extends S.HTMLElement{constructor(){if(super(),pr(this,fg),pr(this,Eg),pr(this,Tg),pr(this,la),pr(this,mg),pr(this,Cc),pr(this,Dc,!1),pr(this,il,void 0),pr(this,Vi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let r=this.shadowRoot.querySelector('slot[name="description"]'),s=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=s==null?void 0:s.dataset.description)!=null?t:s==null?void 0:s.text,a=Ue.createElement("span");a.textContent=n!=null?n:"",r.replaceChildren(a)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[Jt.TYPE,Jt.DISABLED,Jt.CHECKED,Jt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),tl(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Gi(this,fg,d_).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Gi(this,mg,h_).call(this,e);break;case"keyup":Gi(this,la,rl).call(this,e);break}}attributeChangedCallback(e,t,r){e===Jt.CHECKED&&tl(this)&&!Ki(this,Dc)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===Jt.TYPE&&r!==t?this.role="menuitem"+r:e===Jt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Jt.DISABLED)||this.enable(),this.role="menuitem"+this.type,hg(this,il,gg(this,this.parentNode)),Gi(this,Cc,pg).call(this)}disconnectedCallback(){this.disable(),Gi(this,Cc,pg).call(this),hg(this,il,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Is(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(Jt.TYPE))!=null?e:""}set type(e){this.setAttribute(Jt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(Jt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Jt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(tl(this))return this.getAttribute("aria-checked")==="true"}set checked(e){tl(this)&&(hg(this,Dc,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){tl(this)||this.invokeTargetElement&&Rt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Jr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};Dc=new WeakMap;il=new WeakMap;fg=new WeakSet;d_=function(i){let e=i.target;if(!(e!=null&&e.name))for(let r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?Gi(this,Eg,u_).call(this):Gi(this,Tg,c_).call(this))};Eg=new WeakSet;u_=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Ki(this,Vi)),this.submenuElement.addEventListener("addmenuitem",Ki(this,Vi)),this.submenuElement.addEventListener("removemenuitem",Ki(this,Vi)),Ki(this,Vi).call(this)};Tg=new WeakSet;c_=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Ki(this,Vi)),this.submenuElement.removeEventListener("addmenuitem",Ki(this,Vi)),this.submenuElement.removeEventListener("removemenuitem",Ki(this,Vi)),Ki(this,Vi).call(this)};Vi=new WeakMap;la=new WeakSet;rl=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Gi(this,la,rl));return}this.handleClick(i)};mg=new WeakSet;h_=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Gi(this,la,rl));return}this.addEventListener("keyup",Gi(this,la,rl),{once:!0})};Cc=new WeakSet;pg=function(){var i;let e=(i=Ki(this,il))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};Wi.shadowRootOptions={mode:"open"};Wi.getTemplateHTML=jD;Wi.getSuffixSlotInnerHTML=zD;function tl(i){return i.type==="radio"||i.type==="checkbox"}function gg(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?gg(i,t):e!=null&&e.items?e:gg(e,e==null?void 0:e.parentNode)}S.customElements.get("media-chrome-menu-item")||S.customElements.define("media-chrome-menu-item",Wi);function XD(i){return`
|
|
1719
1719
|
${Tt.getTemplateHTML(i)}
|
|
1720
1720
|
<style>
|
|
1721
1721
|
:host {
|
|
@@ -1750,7 +1750,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1750
1750
|
--media-settings-menu-item-opacity: 0;
|
|
1751
1751
|
}
|
|
1752
1752
|
</style>
|
|
1753
|
-
`}var
|
|
1753
|
+
`}var sl=class extends Tt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-settings-menu-button")}};sl.getTemplateHTML=XD;S.customElements.get("media-settings-menu")||S.customElements.define("media-settings-menu",sl);function QD(i){return`
|
|
1754
1754
|
${Wi.getTemplateHTML.call(this,i)}
|
|
1755
1755
|
<style>
|
|
1756
1756
|
slot:not([name="submenu"]) {
|
|
@@ -1776,7 +1776,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1776
1776
|
<path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
|
|
1777
1777
|
</svg>
|
|
1778
1778
|
</slot>
|
|
1779
|
-
`}function eC(){return B("Settings")}var da=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("settings"))}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-settings-menu")}};da.getSlotTemplateHTML=JD;da.getTooltipContentHTML=eC;S.customElements.get("media-settings-menu-button")||S.customElements.define("media-settings-menu-button",da);var Ag=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},f_=(i,e,t)=>(Ag(i,e,"read from private field"),t?t.call(i):e.get(i)),Mc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},bg=(i,e,t,r)=>(Ag(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Oc=(i,e,t)=>(Ag(i,e,"access private method"),t),
|
|
1779
|
+
`}function eC(){return B("Settings")}var da=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,"target"]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("settings"))}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-settings-menu")}};da.getSlotTemplateHTML=JD;da.getTooltipContentHTML=eC;S.customElements.get("media-settings-menu-button")||S.customElements.define("media-settings-menu-button",da);var Ag=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},f_=(i,e,t)=>(Ag(i,e,"read from private field"),t?t.call(i):e.get(i)),Mc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},bg=(i,e,t,r)=>(Ag(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Oc=(i,e,t)=>(Ag(i,e,"access private method"),t),nl,Uc,Pc,yg,Nc,_g,Fc=class extends Tt{constructor(){super(...arguments),Mc(this,Pc),Mc(this,Nc),Mc(this,nl,[]),Mc(this,Uc,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===b.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(bg(this,nl,ob(r!=null?r:"")),Oc(this,Pc,yg).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Oc(this,Nc,_g))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Oc(this,Nc,_g))}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return f_(this,nl)}set mediaAudioTrackList(e){bg(this,nl,e),Oc(this,Pc,yg).call(this)}get mediaAudioTrackEnabled(){var e;return(e=de(this,b.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ue(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};nl=new WeakMap;Uc=new WeakMap;Pc=new WeakSet;yg=function(){if(f_(this,Uc)===JSON.stringify(this.mediaAudioTrackList))return;bg(this,Uc,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of i){let t=this.formatMenuItemText(e.label,e),r=Hi({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(gi(this,"checked-indicator")),this.defaultSlot.append(r)}};Nc=new WeakSet;_g=function(){if(this.value==null)return;let i=new S.CustomEvent($.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};S.customElements.get("media-audio-track-menu")||S.customElements.define("media-audio-track-menu",Fc);var tC=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1780
1780
|
<path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
|
|
1781
1781
|
<path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
|
|
1782
1782
|
</svg>`;function iC(){return`
|
|
@@ -1792,7 +1792,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1792
1792
|
</svg>`;function oC(i){return`
|
|
1793
1793
|
${Tt.getTemplateHTML(i)}
|
|
1794
1794
|
<slot name="captions-indicator" hidden>${aC}</slot>
|
|
1795
|
-
`}var
|
|
1795
|
+
`}var al=class extends Tt{constructor(){super(...arguments),Sg(this,Rg),Sg(this,Bc),Sg(this,$c,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_LIST&&t!==r?xg(this,Rg,g_).call(this):e===b.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",xg(this,Bc,Ig))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",xg(this,Bc,Ig))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return m_(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){p_(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return m_(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){p_(this,b.MEDIA_SUBTITLES_SHOWING,e)}};$c=new WeakMap;Rg=new WeakSet;g_=function(){var i;if(sC(this,$c)===JSON.stringify(this.mediaSubtitlesList))return;nC(this,$c,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=Hi({type:"radio",text:this.formatMenuItemText(B("Off")),value:"off",checked:e});t.prepend(gi(this,"checked-indicator")),this.defaultSlot.append(t);let r=this.mediaSubtitlesList;for(let s of r){let n=Hi({type:"radio",text:this.formatMenuItemText(s.label,s),value:fu(s),checked:this.value==fu(s)});n.prepend(gi(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(gi(this,"captions-indicator")),this.defaultSlot.append(n)}};Bc=new WeakSet;Ig=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(b.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new S.CustomEvent($.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new S.CustomEvent($.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};al.getTemplateHTML=oC;var m_=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},p_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=dr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};S.customElements.get("media-captions-menu")||S.customElements.define("media-captions-menu",al);var lC=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1796
1796
|
<path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
|
|
1797
1797
|
</svg>`,dC=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1798
1798
|
<path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
|
|
@@ -1816,7 +1816,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1816
1816
|
<slot name="on">${lC}</slot>
|
|
1817
1817
|
<slot name="off">${dC}</slot>
|
|
1818
1818
|
</slot>
|
|
1819
|
-
`}function cC(){return B("Captions")}var v_=i=>{i.setAttribute("aria-checked",mu(i).toString())},ca=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("closed captions")),v_(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&v_(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return E_(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){T_(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return E_(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){T_(this,b.MEDIA_SUBTITLES_SHOWING,e)}};ca.getSlotTemplateHTML=uC;ca.getTooltipContentHTML=cC;var E_=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},T_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=dr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};S.customElements.get("media-captions-menu-button")||S.customElements.define("media-captions-menu-button",ca);var b_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ha=(i,e,t)=>(b_(i,e,"read from private field"),t?t.call(i):e.get(i)),kg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},
|
|
1819
|
+
`}function cC(){return B("Captions")}var v_=i=>{i.setAttribute("aria-checked",mu(i).toString())},ca=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("closed captions")),v_(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&v_(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return E_(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){T_(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return E_(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){T_(this,b.MEDIA_SUBTITLES_SHOWING,e)}};ca.getSlotTemplateHTML=uC;ca.getTooltipContentHTML=cC;var E_=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},T_=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=dr(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};S.customElements.get("media-captions-menu-button")||S.customElements.define("media-captions-menu-button",ca);var b_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ha=(i,e,t)=>(b_(i,e,"read from private field"),t?t.call(i):e.get(i)),kg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ol=(i,e,t)=>(b_(i,e,"access private method"),t),ts,ll,Hc,Gc,Dg,wg={RATES:"rates"},Kc=class extends Tt{constructor(){super(),kg(this,ll),kg(this,Gc),kg(this,ts,new Gr(this,wg.RATES,{defaultValue:Ip})),ol(this,ll,Hc).call(this)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,wg.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===wg.RATES&&t!=r&&(ha(this,ts).value=r,ol(this,ll,Hc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ol(this,Gc,Dg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ol(this,Gc,Dg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-playback-rate-menu-button")}get rates(){return ha(this,ts)}set rates(e){e?Array.isArray(e)?ha(this,ts).value=e.join(" "):typeof e=="string"&&(ha(this,ts).value=e):ha(this,ts).value="",ol(this,ll,Hc).call(this)}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}};ts=new WeakMap;ll=new WeakSet;Hc=function(){this.defaultSlot.textContent="";for(let i of ha(this,ts)){let e=Hi({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate===Number(i)});e.prepend(gi(this,"checked-indicator")),this.defaultSlot.append(e)}};Gc=new WeakSet;Dg=function(){if(!this.value)return;let i=new S.CustomEvent($.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};S.customElements.get("media-playback-rate-menu")||S.customElements.define("media-playback-rate-menu",Kc);var Vc=1;function hC(i){return`
|
|
1820
1820
|
<style>
|
|
1821
1821
|
:host {
|
|
1822
1822
|
min-width: 5ch;
|
|
@@ -1828,7 +1828,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1828
1828
|
}
|
|
1829
1829
|
</style>
|
|
1830
1830
|
<slot name="icon">${i.mediaplaybackrate||Vc}x</slot>
|
|
1831
|
-
`}function fC(){return B("Playback rate")}var fa=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:Vc}x`}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Vc:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",B("Playback rate {playbackRate}",{playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,Vc)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}};fa.getSlotTemplateHTML=hC;fa.getTooltipContentHTML=fC;S.customElements.get("media-playback-rate-menu-button")||S.customElements.define("media-playback-rate-menu-button",fa);var Mg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},
|
|
1831
|
+
`}function fC(){return B("Playback rate")}var fa=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE]}constructor(){var e;super(),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:Vc}x`}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Vc:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",B("Playback rate {playbackRate}",{playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-playback-rate-menu")}get mediaPlaybackRate(){return ge(this,b.MEDIA_PLAYBACK_RATE,Vc)}set mediaPlaybackRate(e){ye(this,b.MEDIA_PLAYBACK_RATE,e)}};fa.getSlotTemplateHTML=hC;fa.getTooltipContentHTML=fC;S.customElements.get("media-playback-rate-menu-button")||S.customElements.define("media-playback-rate-menu-button",fa);var Mg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},dl=(i,e,t)=>(Mg(i,e,"read from private field"),t?t.call(i):e.get(i)),Wc=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},y_=(i,e,t,r)=>(Mg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ma=(i,e,t)=>(Mg(i,e,"access private method"),t),ul,ga,pa,cl,Yc,Cg,qc=class extends Tt{constructor(){super(...arguments),Wc(this,pa),Wc(this,Yc),Wc(this,ul,[]),Wc(this,ga,{})}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_LIST,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE,b.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_RENDITION_SELECTED&&t!==r?(this.value=r!=null?r:"auto",ma(this,pa,cl).call(this)):e===b.MEDIA_RENDITION_LIST&&t!==r?(y_(this,ul,nb(r)),ma(this,pa,cl).call(this)):e===b.MEDIA_HEIGHT&&t!==r&&ma(this,pa,cl).call(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",ma(this,Yc,Cg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",ma(this,Yc,Cg))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return dl(this,ul)}set mediaRenditionList(e){y_(this,ul,e),ma(this,pa,cl).call(this)}get mediaRenditionSelected(){return de(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ue(this,b.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return ge(this,b.MEDIA_HEIGHT)}set mediaHeight(e){ye(this,b.MEDIA_HEIGHT,e)}};ul=new WeakMap;ga=new WeakMap;pa=new WeakSet;cl=function(){if(dl(this,ga).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&dl(this,ga).mediaHeight===this.mediaHeight)return;dl(this,ga).mediaRenditionList=JSON.stringify(this.mediaRenditionList),dl(this,ga).mediaHeight=this.mediaHeight;let i=this.mediaRenditionList.sort((n,a)=>a.height-n.height);for(let n of i)n.selected=n.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let n of i){let a=this.formatMenuItemText(`${Math.min(n.width,n.height)}p`,n),o=Hi({type:"radio",text:a,value:`${n.id}`,checked:n.selected&&!e});o.prepend(gi(this,"checked-indicator")),this.defaultSlot.append(o)}let t=e?this.formatMenuItemText(`${B("Auto")} (${this.mediaHeight}p)`):this.formatMenuItemText(B("Auto")),r=Hi({type:"radio",text:t,value:"auto",checked:e}),s=this.mediaHeight>0?`${B("Auto")} (${this.mediaHeight}p)`:B("Auto");r.dataset.description=s,r.prepend(gi(this,"checked-indicator")),this.defaultSlot.append(r)};Yc=new WeakSet;Cg=function(){if(this.value==null)return;let i=new S.CustomEvent($.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};S.customElements.get("media-rendition-menu")||S.customElements.define("media-rendition-menu",qc);var mC=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1832
1832
|
<path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
|
|
1833
1833
|
</svg>`;function pC(){return`
|
|
1834
1834
|
<style>
|
|
@@ -1838,7 +1838,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1838
1838
|
</style>
|
|
1839
1839
|
<slot name="icon">${mC}</slot>
|
|
1840
1840
|
`}function gC(){return B("Quality")}var va=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE,b.MEDIA_HEIGHT]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("quality"))}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:We(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return de(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ue(this,b.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return ge(this,b.MEDIA_HEIGHT)}set mediaHeight(e){ye(this,b.MEDIA_HEIGHT,e)}};va.getSlotTemplateHTML=pC;va.getTooltipContentHTML=gC;S.customElements.get("media-rendition-menu-button")||S.customElements.define("media-rendition-menu-button",va);var U_=i=>{throw TypeError(i)},Bg=(i,e,t)=>e.has(i)||U_("Cannot "+t),De=(i,e,t)=>(Bg(i,e,"read from private field"),t?t.call(i):e.get(i)),vi=(i,e,t)=>e.has(i)?U_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),qi=(i,e,t,r)=>(Bg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),nt=(i,e,t)=>(Bg(i,e,"access private method"),t),eh=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends eh{}globalThis.DocumentFragment=i}var $g=class extends eh{},vC=class extends eh{},EC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve($g)}},jc,TC=class{constructor(i,e={}){vi(this,jc),qi(this,jc,e==null?void 0:e.detail)}get detail(){return De(this,jc)}initCustomEvent(){}};jc=new WeakMap;function bC(i,e){return new $g}var F_={document:{createElement:bC},DocumentFragment,customElements:EC,CustomEvent:TC,EventTarget:eh,HTMLElement:$g,HTMLVideoElement:vC},B_=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Yi=B_?F_:globalThis,Hg=B_?F_.document:globalThis.document;function yC(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Pg(t)}: ${r}; `)}),e?e.trim():void 0}function Pg(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $_(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Wt(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function H_(i){let e=_C(i).toString();return e?"?"+e:""}function _C(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}var G_=(i,e)=>!i||!e?!1:i.contains(e)?!0:G_(i,e.getRootNode().host),K_="mux.com",AC=()=>{try{return"3.4.1"}catch{}return"UNKNOWN"},SC=AC(),V_=()=>SC,xC=(i,{token:e,customDomain:t=K_,thumbnailTime:r,programTime:s}={})=>{var n;let a=e==null?r:void 0,{aud:o}=(n=Sr(e))!=null?n:{};if(!(e&&o!=="t"))return`https://image.${t}/${i}/thumbnail.webp${H_({token:e,time:a,program_time:s})}`},RC=(i,{token:e,customDomain:t=K_,programStartTime:r,programEndTime:s}={})=>{var n;let{aud:a}=(n=Sr(e))!=null?n:{};if(!(e&&a!=="s"))return`https://image.${t}/${i}/storyboard.vtt${H_({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Gg=i=>{if(i){if([Se.LIVE,Se.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return Se.LIVE}},IC={crossorigin:"crossOrigin",playsinline:"playsInline"};function LC(i){var e;return(e=IC[i])!=null?e:$_(i)}var Ea,Ta,Nt,kC=class{constructor(i,e){vi(this,Ea),vi(this,Ta),vi(this,Nt,[]),qi(this,Ea,i),qi(this,Ta,e)}[Symbol.iterator](){return De(this,Nt).values()}get length(){return De(this,Nt).length}get value(){var i;return(i=De(this,Nt).join(" "))!=null?i:""}set value(i){var e;i!==this.value&&(qi(this,Nt,[]),this.add(...(e=i==null?void 0:i.split(" "))!=null?e:[]))}toString(){return this.value}item(i){return De(this,Nt)[i]}values(){return De(this,Nt).values()}keys(){return De(this,Nt).keys()}forEach(i){De(this,Nt).forEach(i)}add(...i){var e,t;i.forEach(r=>{this.contains(r)||De(this,Nt).push(r)}),!(this.value===""&&!((e=De(this,Ea))!=null&&e.hasAttribute(`${De(this,Ta)}`)))&&((t=De(this,Ea))==null||t.setAttribute(`${De(this,Ta)}`,`${this.value}`))}remove(...i){var e;i.forEach(t=>{De(this,Nt).splice(De(this,Nt).indexOf(t),1)}),(e=De(this,Ea))==null||e.setAttribute(`${De(this,Ta)}`,`${this.value}`)}contains(i){return De(this,Nt).includes(i)}toggle(i,e){return typeof e!="undefined"?e?(this.add(i),!0):(this.remove(i),!1):this.contains(i)?(this.remove(i),!1):(this.add(i),!0)}replace(i,e){this.remove(i),this.add(e)}};Ea=new WeakMap,Ta=new WeakMap,Nt=new WeakMap;var W_=`[mux-player ${V_()}]`;function vr(...i){console.warn(W_,...i)}function ei(...i){console.error(W_,...i)}function Y_(i){var e;let t=(e=i.message)!=null?e:"";i.context&&(t+=` ${i.context}`),i.file&&(t+=` ${Q("Read more: ")}
|
|
1841
|
-
https://github.com/muxinc/elements/blob/main/errors/${i.file}`),vr(t)}var _t={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},rs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},R8={..._t,...rs},__=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),wC=Object.values(_t).filter(i=>_t.PLAYSINLINE!==i),DC=Object.values(rs),CC=[...wC,...DC],MC=class extends Yi.HTMLElement{static get observedAttributes(){return CC}constructor(){super()}attributeChangedCallback(i,e,t){var r,s;switch(i){case rs.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case rs.VOLUME:{let n=(r=Wt(t))!=null?r:1;this.media&&(this.media.volume=n);return}case rs.PLAYBACKRATE:{let n=(s=Wt(t))!=null?s:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}load(){var i;(i=this.media)==null||i.load()}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:__}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:__}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentSrc(){var i,e;return(e=(i=this.media)==null?void 0:i.currentSrc)!=null?e:""}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=Wt(this.getAttribute(rs.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(rs.PLAYBACKRATE,`${i}`):this.removeAttribute(rs.PLAYBACKRATE)}get crossOrigin(){return
|
|
1841
|
+
https://github.com/muxinc/elements/blob/main/errors/${i.file}`),vr(t)}var _t={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},rs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},R8={..._t,...rs},__=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),wC=Object.values(_t).filter(i=>_t.PLAYSINLINE!==i),DC=Object.values(rs),CC=[...wC,...DC],MC=class extends Yi.HTMLElement{static get observedAttributes(){return CC}constructor(){super()}attributeChangedCallback(i,e,t){var r,s;switch(i){case rs.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case rs.VOLUME:{let n=(r=Wt(t))!=null?r:1;this.media&&(this.media.volume=n);return}case rs.PLAYBACKRATE:{let n=(s=Wt(t))!=null?s:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}load(){var i;(i=this.media)==null||i.load()}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:__}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:__}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentSrc(){var i,e;return(e=(i=this.media)==null?void 0:i.currentSrc)!=null?e:""}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=Wt(this.getAttribute(rs.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(rs.PLAYBACKRATE,`${i}`):this.removeAttribute(rs.PLAYBACKRATE)}get crossOrigin(){return hl(this,_t.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(_t.CROSSORIGIN,`${i}`)}get autoplay(){return hl(this,_t.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(_t.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(_t.AUTOPLAY)}get loop(){return hl(this,_t.LOOP)!=null}set loop(i){i?this.setAttribute(_t.LOOP,""):this.removeAttribute(_t.LOOP)}get muted(){var i,e;return(e=(i=this.media)==null?void 0:i.muted)!=null?e:!1}set muted(i){this.media&&(this.media.muted=!!i)}get defaultMuted(){return hl(this,_t.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(_t.MUTED,""):this.removeAttribute(_t.MUTED)}get playsInline(){return hl(this,_t.PLAYSINLINE)!=null}set playsInline(i){ei("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(i){["","none","metadata","auto"].includes(i)?this.setAttribute(_t.PRELOAD,i):this.removeAttribute(_t.PRELOAD)}};function hl(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var A_=MC,OC=`:host {
|
|
1842
1842
|
--media-control-display: var(--controls);
|
|
1843
1843
|
--media-loading-indicator-display: var(--loading-indicator);
|
|
1844
1844
|
--media-dialog-display: var(--dialog);
|
|
@@ -1988,7 +1988,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
1988
1988
|
:host([no-tooltips]) {
|
|
1989
1989
|
--media-tooltip-display: none;
|
|
1990
1990
|
}
|
|
1991
|
-
`,
|
|
1991
|
+
`,fl=new WeakMap,PC=class q_{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let r=fl.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=fl.get(this.element);t&&t.delete(this.type)}}static for(e){fl.has(e.element)||fl.set(e.element,new Map);let t=e.attributeName.slice(2),r=fl.get(e.element);return r&&r.has(t)?r.get(t):new q_(e.element,t)}};function NC(i,e){return i instanceof It&&i.attributeName.startsWith("on")?(PC.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function UC(i,e){return e instanceof j_&&i instanceof mr?(e.renderInto(i),!0):!1}function FC(i,e){return e instanceof DocumentFragment&&i instanceof mr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function BC(i,e){if(i instanceof It){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function $C(i,e){if(i instanceof It&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function HC(i,e){if(typeof e=="boolean"&&i instanceof It){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function GC(i,e){return e===!1&&i instanceof mr?(i.replace(""),!0):!1}function KC(i,e){$C(i,e)||HC(i,e)||NC(i,e)||GC(i,e)||UC(i,e)||FC(i,e)||BC(i,e)}var Og=new Map,S_=new WeakMap,x_=new WeakMap,j_=class{constructor(i,e,t){this.strings=i,this.values=e,this.processor=t,this.stringsKey=this.strings.join("")}get template(){if(Og.has(this.stringsKey))return Og.get(this.stringsKey);{let i=Hg.createElement("template"),e=this.strings.length-1;return i.innerHTML=this.strings.reduce((t,r,s)=>t+r+(s<e?`{{ ${s} }}`:""),""),Og.set(this.stringsKey,i),i}}renderInto(i){var e;let t=this.template;if(S_.get(i)!==t){S_.set(i,t);let s=new fr(t,this.values,this.processor);x_.set(i,s),i instanceof mr?i.replace(...s.children):i.appendChild(s);return}let r=x_.get(i);(e=r==null?void 0:r.update)==null||e.call(r,this.values)}},VC={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";KC(n,a)}}}};function zc(i,...e){return new j_(i,e,VC)}function WC(i,e){i.renderInto(e)}var YC=i=>{let{tokens:e}=i;return e.drm?":host(:not([cast-receiver])) { --_cast-button-drm-display: none; }":""},qC=i=>zc`
|
|
1992
1992
|
<style>
|
|
1993
1993
|
${YC(i)}
|
|
1994
1994
|
${OC}
|
|
@@ -3199,8 +3199,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
3199
3199
|
>${(t=r.linkText)!=null?t:r.linkUrl}</a
|
|
3200
3200
|
>`:""}
|
|
3201
3201
|
</p>`:""}
|
|
3202
|
-
`}return nM(i)};function aM(i){var e,t;let r=i.theme;if(r){let s=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,r);if(s&&s instanceof HTMLTemplateElement)return s;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let n=Yi.customElements.get(r);if(n!=null&&n.template)return n.template}}function oM(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function k_(i){let e=i.videoTitle?{video_title:i.videoTitle}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var lM=Object.values(D),dM=Object.values(gr),uM=Object.values(F),w_=V_(),D_="mux-player",C_={isDialogOpen:!1},cM={redundant_streams:!0},Xc,Qc,Zc,en,Jc,ba,Qe,is,Q_,Fg,tn,M_,O_,P_,N_,hM=class extends A_{constructor(){super(),vi(this,Qe),vi(this,Xc),vi(this,Qc,!1),vi(this,Zc,{}),vi(this,en,!0),vi(this,Jc,new kC(this,"hotkeys")),vi(this,ba,{...C_,onCloseErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&nt(this,Qe,Fg).call(this,{isDialogOpen:!1})},onFocusInErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&(G_(this,Hg.activeElement)||i.preventDefault())}}),qi(this,Xc,Ad()),this.attachShadow({mode:"open"}),nt(this,Qe,Q_).call(this),this.isConnected&&nt(this,Qe,is).call(this)}static get NAME(){return D_}static get VERSION(){return w_}static get observedAttributes(){var i;return[...(i=A_.observedAttributes)!=null?i:[],...dM,...lM,...uM]}get mediaTheme(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("media-theme")}get mediaController(){var i,e;return(e=(i=this.mediaTheme)==null?void 0:i.shadowRoot)==null?void 0:e.querySelector("media-controller")}connectedCallback(){let i=this.media;i&&(i.metadata=k_(this))}attributeChangedCallback(i,e,t){switch(nt(this,Qe,is).call(this),super.attributeChangedCallback(i,e,t),i){case F.HOTKEYS:De(this,Jc).value=t;break;case F.THUMBNAIL_TIME:{t!=null&&this.tokens.thumbnail&&vr(Q("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").toString());break}case F.THUMBNAIL_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.THUMBNAIL;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"thumbnail"}))}}break}case F.STORYBOARD_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.STORYBOARD;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"storyboard"}))}}break}case F.DRM_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.DRM;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"drm"}))}}break}case D.PLAYBACK_ID:{t!=null&&t.includes("?token")&&ei(Q("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:t}));break}case D.STREAM_TYPE:t&&![Se.LIVE,Se.ON_DEMAND,Se.UNKNOWN].includes(t)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=t.includes("dvr")?Number.POSITIVE_INFINITY:0:Y_({file:"invalid-stream-type.md",message:Q("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):t===Se.LIVE?this.getAttribute(F.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[D.PLAYBACK_ID,gr.SRC,F.PLAYBACK_TOKEN].includes(i)&&e!==t&&qi(this,ba,{...De(this,ba),...C_}),nt(this,Qe,tn).call(this,{[LC(i)]:t})}async requestFullscreen(i){var e;if(!(!this.mediaController||this.mediaController.hasAttribute(b.MEDIA_IS_FULLSCREEN)))return(e=this.mediaController)==null||e.dispatchEvent(new Yi.CustomEvent($.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((t,r)=>{var s;(s=this.mediaController)==null||s.addEventListener(Qt.MEDIA_IS_FULLSCREEN,()=>t(),{once:!0})})}async exitFullscreen(){var i;if(!(!this.mediaController||!this.mediaController.hasAttribute(b.MEDIA_IS_FULLSCREEN)))return(i=this.mediaController)==null||i.dispatchEvent(new Yi.CustomEvent($.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>{var r;(r=this.mediaController)==null||r.addEventListener(Qt.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}get preferCmcd(){var i;return(i=this.getAttribute(D.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?vn.includes(i)?this.setAttribute(D.PREFER_CMCD,i):vr(`Invalid value for preferCmcd. Must be one of ${vn.join()}`):this.removeAttribute(D.PREFER_CMCD))}get hasPlayed(){var i,e;return(e=(i=this.mediaController)==null?void 0:i.hasAttribute(b.MEDIA_HAS_PLAYED))!=null?e:!1}get inLiveWindow(){var i;return(i=this.mediaController)==null?void 0:i.hasAttribute(b.MEDIA_TIME_IS_LIVE)}get _hls(){var i;return(i=this.media)==null?void 0:i._hls}get mux(){var i;return(i=this.media)==null?void 0:i.mux}get theme(){var i;return(i=this.getAttribute(F.THEME))!=null?i:rM}set theme(i){this.setAttribute(F.THEME,`${i}`)}get themeProps(){let i=this.mediaTheme;if(!i)return;let e={};for(let t of i.getAttributeNames()){if(Ug.includes(t))continue;let r=i.getAttribute(t);e[$_(t)]=r===""?!0:r}return e}set themeProps(i){var e,t;nt(this,Qe,is).call(this);let r={...this.themeProps,...i};for(let s in r){if(Ug.includes(s))continue;let n=i==null?void 0:i[s];typeof n=="boolean"||n==null?(e=this.mediaTheme)==null||e.toggleAttribute(Pg(s),!!n):(t=this.mediaTheme)==null||t.setAttribute(Pg(s),n)}}get playbackId(){var i;return(i=this.getAttribute(D.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i?this.setAttribute(D.PLAYBACK_ID,i):this.removeAttribute(D.PLAYBACK_ID)}get src(){var i,e;return this.playbackId?(i=Js(this,gr.SRC))!=null?i:void 0:(e=this.getAttribute(gr.SRC))!=null?e:void 0}set src(i){i?this.setAttribute(gr.SRC,i):this.removeAttribute(gr.SRC)}get poster(){var i;let e=this.getAttribute(gr.POSTER);if(e!=null)return e;let{tokens:t}=this;if(t.playback&&!t.thumbnail){vr("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return xC(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(i=this.thumbnailTime)!=null?i:this.startTime,programTime:this.programStartTime,token:t.thumbnail})}set poster(i){i||i===""?this.setAttribute(gr.POSTER,i):this.removeAttribute(gr.POSTER)}get storyboardSrc(){var i;return(i=this.getAttribute(F.STORYBOARD_SRC))!=null?i:void 0}set storyboardSrc(i){i?this.setAttribute(F.STORYBOARD_SRC,i):this.removeAttribute(F.STORYBOARD_SRC)}get storyboard(){let{tokens:i}=this;if(this.storyboardSrc&&!i.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Se.LIVE,Se.UNKNOWN].includes(this.streamType)||i.playback&&!i.storyboard))return RC(this.playbackId,{customDomain:this.customDomain,token:i.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(F.AUDIO)}set audio(i){if(!i){this.removeAttribute(F.AUDIO);return}this.setAttribute(F.AUDIO,"")}get hotkeys(){return De(this,Jc)}get nohotkeys(){return this.hasAttribute(F.NOHOTKEYS)}set nohotkeys(i){if(!i){this.removeAttribute(F.NOHOTKEYS);return}this.setAttribute(F.NOHOTKEYS,"")}get thumbnailTime(){return Wt(this.getAttribute(F.THUMBNAIL_TIME))}set thumbnailTime(i){this.setAttribute(F.THUMBNAIL_TIME,`${i}`)}get videoTitle(){var i,e;return(e=(i=this.getAttribute(F.VIDEO_TITLE))!=null?i:this.getAttribute(F.TITLE))!=null?e:""}set videoTitle(i){i!==this.videoTitle&&(i?this.setAttribute(F.VIDEO_TITLE,i):this.removeAttribute(F.VIDEO_TITLE))}get placeholder(){var i;return(i=Js(this,F.PLACEHOLDER))!=null?i:""}set placeholder(i){this.setAttribute(F.PLACEHOLDER,`${i}`)}get primaryColor(){var i,e;let t=this.getAttribute(F.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_primary-color"))==null?void 0:e.trim(),t))return t}set primaryColor(i){this.setAttribute(F.PRIMARY_COLOR,`${i}`)}get secondaryColor(){var i,e;let t=this.getAttribute(F.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_secondary-color"))==null?void 0:e.trim(),t))return t}set secondaryColor(i){this.setAttribute(F.SECONDARY_COLOR,`${i}`)}get accentColor(){var i,e;let t=this.getAttribute(F.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_accent-color"))==null?void 0:e.trim(),t))return t}set accentColor(i){this.setAttribute(F.ACCENT_COLOR,`${i}`)}get defaultShowRemainingTime(){return this.hasAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(i){i?this.setAttribute(F.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(F.PLAYBACK_RATES))return this.getAttribute(F.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(i=>Number(i)).filter(i=>!Number.isNaN(i)).sort((i,e)=>i-e)}set playbackRates(i){if(!i){this.removeAttribute(F.PLAYBACK_RATES);return}this.setAttribute(F.PLAYBACK_RATES,i.join(" "))}get forwardSeekOffset(){var i;return(i=Wt(this.getAttribute(F.FORWARD_SEEK_OFFSET)))!=null?i:10}set forwardSeekOffset(i){this.setAttribute(F.FORWARD_SEEK_OFFSET,`${i}`)}get backwardSeekOffset(){var i;return(i=Wt(this.getAttribute(F.BACKWARD_SEEK_OFFSET)))!=null?i:10}set backwardSeekOffset(i){this.setAttribute(F.BACKWARD_SEEK_OFFSET,`${i}`)}get defaultHiddenCaptions(){return this.hasAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(i){i?this.setAttribute(F.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Wt(this.getAttribute(F.DEFAULT_DURATION))}set defaultDuration(i){i==null?this.removeAttribute(F.DEFAULT_DURATION):this.setAttribute(F.DEFAULT_DURATION,`${i}`)}get playerInitTime(){return this.hasAttribute(D.PLAYER_INIT_TIME)?Wt(this.getAttribute(D.PLAYER_INIT_TIME)):De(this,Xc)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(D.PLAYER_INIT_TIME):this.setAttribute(D.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=this.getAttribute(D.PLAYER_SOFTWARE_NAME))!=null?i:D_}get playerSoftwareVersion(){var i;return(i=this.getAttribute(D.PLAYER_SOFTWARE_VERSION))!=null?i:w_}get beaconCollectionDomain(){var i;return(i=this.getAttribute(D.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(D.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(D.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var i;return(i=this.getAttribute(D.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(D.MAX_RESOLUTION,i):this.removeAttribute(D.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(D.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(D.MIN_RESOLUTION,i):this.removeAttribute(D.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(D.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(D.RENDITION_ORDER,i):this.removeAttribute(D.RENDITION_ORDER))}get programStartTime(){return Wt(this.getAttribute(D.PROGRAM_START_TIME))}set programStartTime(i){i==null?this.removeAttribute(D.PROGRAM_START_TIME):this.setAttribute(D.PROGRAM_START_TIME,`${i}`)}get programEndTime(){return Wt(this.getAttribute(D.PROGRAM_END_TIME))}set programEndTime(i){i==null?this.removeAttribute(D.PROGRAM_END_TIME):this.setAttribute(D.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){return Wt(this.getAttribute(D.ASSET_START_TIME))}set assetStartTime(i){i==null?this.removeAttribute(D.ASSET_START_TIME):this.setAttribute(D.ASSET_START_TIME,`${i}`)}get assetEndTime(){return Wt(this.getAttribute(D.ASSET_END_TIME))}set assetEndTime(i){i==null?this.removeAttribute(D.ASSET_END_TIME):this.setAttribute(D.ASSET_END_TIME,`${i}`)}get extraSourceParams(){return this.hasAttribute(F.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(F.EXTRA_SOURCE_PARAMS)).entries()].reduce((i,[e,t])=>(i[e]=t,i),{}):cM}set extraSourceParams(i){i==null?this.removeAttribute(F.EXTRA_SOURCE_PARAMS):this.setAttribute(F.EXTRA_SOURCE_PARAMS,new URLSearchParams(i).toString())}get customDomain(){var i;return(i=this.getAttribute(D.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(D.CUSTOM_DOMAIN,i):this.removeAttribute(D.CUSTOM_DOMAIN))}get envKey(){var i;return(i=Js(this,D.ENV_KEY))!=null?i:void 0}set envKey(i){this.setAttribute(D.ENV_KEY,`${i}`)}get noVolumePref(){return this.hasAttribute(F.NO_VOLUME_PREF)}set noVolumePref(i){i?this.setAttribute(F.NO_VOLUME_PREF,""):this.removeAttribute(F.NO_VOLUME_PREF)}get debug(){return Js(this,D.DEBUG)!=null}set debug(i){i?this.setAttribute(D.DEBUG,""):this.removeAttribute(D.DEBUG)}get disableTracking(){return Js(this,D.DISABLE_TRACKING)!=null}set disableTracking(i){this.toggleAttribute(D.DISABLE_TRACKING,!!i)}get disableCookies(){return Js(this,D.DISABLE_COOKIES)!=null}set disableCookies(i){i?this.setAttribute(D.DISABLE_COOKIES,""):this.removeAttribute(D.DISABLE_COOKIES)}get streamType(){var i,e,t;return(t=(e=this.getAttribute(D.STREAM_TYPE))!=null?e:(i=this.media)==null?void 0:i.streamType)!=null?t:Se.UNKNOWN}set streamType(i){this.setAttribute(D.STREAM_TYPE,`${i}`)}get defaultStreamType(){var i,e,t;return(t=(e=this.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?e:(i=this.mediaController)==null?void 0:i.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?t:Se.ON_DEMAND}set defaultStreamType(i){i?this.setAttribute(F.DEFAULT_STREAM_TYPE,i):this.removeAttribute(F.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var i,e;return this.hasAttribute(F.TARGET_LIVE_WINDOW)?+this.getAttribute(F.TARGET_LIVE_WINDOW):(e=(i=this.media)==null?void 0:i.targetLiveWindow)!=null?e:Number.NaN}set targetLiveWindow(i){i==this.targetLiveWindow||Number.isNaN(i)&&Number.isNaN(this.targetLiveWindow)||(i==null?this.removeAttribute(F.TARGET_LIVE_WINDOW):this.setAttribute(F.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i;return(i=this.media)==null?void 0:i.liveEdgeStart}get startTime(){return Wt(Js(this,D.START_TIME))}set startTime(i){this.setAttribute(D.START_TIME,`${i}`)}get preferPlayback(){let i=this.getAttribute(D.PREFER_PLAYBACK);if(i===zt.MSE||i===zt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===zt.MSE||i===zt.NATIVE?this.setAttribute(D.PREFER_PLAYBACK,i):this.removeAttribute(D.PREFER_PLAYBACK))}get metadata(){var i;return(i=this.media)==null?void 0:i.metadata}set metadata(i){if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...k_(this),...i}}get _hlsConfig(){var i;return(i=this.media)==null?void 0:i._hlsConfig}set _hlsConfig(i){if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=i}async addCuePoints(i){var e;if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(e=this.media)==null?void 0:e.addCuePoints(i)}get activeCuePoint(){var i;return(i=this.media)==null?void 0:i.activeCuePoint}get cuePoints(){var i,e;return(e=(i=this.media)==null?void 0:i.cuePoints)!=null?e:[]}addChapters(i){var e;if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(e=this.media)==null?void 0:e.addChapters(i)}get activeChapter(){var i;return(i=this.media)==null?void 0:i.activeChapter}get chapters(){var i,e;return(e=(i=this.media)==null?void 0:i.chapters)!=null?e:[]}getStartDate(){var i;return(i=this.media)==null?void 0:i.getStartDate()}get currentPdt(){var i;return(i=this.media)==null?void 0:i.currentPdt}get tokens(){let i=this.getAttribute(F.PLAYBACK_TOKEN),e=this.getAttribute(F.DRM_TOKEN),t=this.getAttribute(F.THUMBNAIL_TOKEN),r=this.getAttribute(F.STORYBOARD_TOKEN);return{...De(this,Zc),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{},...t!=null?{thumbnail:t}:{},...r!=null?{storyboard:r}:{}}}set tokens(i){qi(this,Zc,i!=null?i:{})}get playbackToken(){var i;return(i=this.getAttribute(F.PLAYBACK_TOKEN))!=null?i:void 0}set playbackToken(i){this.setAttribute(F.PLAYBACK_TOKEN,`${i}`)}get drmToken(){var i;return(i=this.getAttribute(F.DRM_TOKEN))!=null?i:void 0}set drmToken(i){this.setAttribute(F.DRM_TOKEN,`${i}`)}get thumbnailToken(){var i;return(i=this.getAttribute(F.THUMBNAIL_TOKEN))!=null?i:void 0}set thumbnailToken(i){this.setAttribute(F.THUMBNAIL_TOKEN,`${i}`)}get storyboardToken(){var i;return(i=this.getAttribute(F.STORYBOARD_TOKEN))!=null?i:void 0}set storyboardToken(i){this.setAttribute(F.STORYBOARD_TOKEN,`${i}`)}addTextTrack(i,e,t,r){var s;let n=(s=this.media)==null?void 0:s.nativeEl;if(n)return _d(n,i,e,t,r)}removeTextTrack(i){var e;let t=(e=this.media)==null?void 0:e.nativeEl;if(t)return BE(t,i)}get textTracks(){var i;return(i=this.media)==null?void 0:i.textTracks}get castReceiver(){var i;return(i=this.getAttribute(F.CAST_RECEIVER))!=null?i:void 0}set castReceiver(i){i!==this.castReceiver&&(i?this.setAttribute(F.CAST_RECEIVER,i):this.removeAttribute(F.CAST_RECEIVER))}get castCustomData(){var i;return(i=this.media)==null?void 0:i.castCustomData}set castCustomData(i){if(!this.media){ei("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=i}get noTooltips(){return this.hasAttribute(F.NO_TOOLTIPS)}set noTooltips(i){if(!i){this.removeAttribute(F.NO_TOOLTIPS);return}this.setAttribute(F.NO_TOOLTIPS,"")}get proudlyDisplayMuxBadge(){return this.hasAttribute(F.PROUDLY_DISPLAY_MUX_BADGE)}set proudlyDisplayMuxBadge(i){i?this.setAttribute(F.PROUDLY_DISPLAY_MUX_BADGE,""):this.removeAttribute(F.PROUDLY_DISPLAY_MUX_BADGE)}};Xc=new WeakMap,Qc=new WeakMap,Zc=new WeakMap,en=new WeakMap,Jc=new WeakMap,ba=new WeakMap,Qe=new WeakSet,is=function(){var i,e,t,r;if(!De(this,Qc)){qi(this,Qc,!0),nt(this,Qe,tn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Yi.HTMLElement))throw""}catch{ei("<media-theme> failed to upgrade!")}try{customElements.upgrade(this.media)}catch{ei("underlying media element failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof np))throw""}catch{ei("<media-controller> failed to upgrade!")}nt(this,Qe,M_).call(this),nt(this,Qe,O_).call(this),nt(this,Qe,P_).call(this),qi(this,en,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(ee.USER_INACTIVE))!=null?e:!0),nt(this,Qe,N_).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>nt(this,Qe,tn).call(this)),(r=this.media)==null||r.addEventListener("loadstart",()=>nt(this,Qe,tn).call(this))}},Q_=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Fg=function(i){Object.assign(De(this,ba),i),nt(this,Qe,tn).call(this)},tn=function(i={}){WC(qC(sM(this,{...De(this,ba),...i})),this.shadowRoot)},M_=function(){let i=e=>{var t,r;if(!(e!=null&&e.startsWith("theme-")))return;let s=e.replace(/^theme-/,"");if(Ug.includes(s))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(s,n):(r=this.mediaTheme)==null||r.removeAttribute(s)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},O_=function(){let i=e=>{var t;let r=(t=this.media)==null?void 0:t.error;if(!(r instanceof K)){let{message:n,code:a}=r!=null?r:{};r=new K(n,a)}if(!(r!=null&&r.fatal)){vr(r),r.data&&vr(`${r.name} data:`,r.data);return}let s=R_(r,!1);s.message&&Y_(s),ei(r),r.data&&ei(`${r.name} data:`,r.data),nt(this,Qe,Fg).call(this,{isDialogOpen:!0})};this.addEventListener("error",i),this.media&&(this.media.errorTranslator=(e={})=>{var t,r,s;if(!(((t=this.media)==null?void 0:t.error)instanceof K))return e;let n=R_((r=this.media)==null?void 0:r.error,!1);return{player_error_code:(s=this.media)==null?void 0:s.error.code,player_error_message:n.message?String(n.message):e.player_error_message,player_error_context:n.context?String(n.context):e.player_error_context}})},P_=function(){var i,e,t,r;let s=()=>nt(this,Qe,tn).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",s),(r=(t=this.media)==null?void 0:t.textTracks)==null||r.addEventListener("removetrack",s)},N_=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,r=new WeakMap,s=()=>this.streamType===Se.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,u=!1)=>{s()||Array.from(l&&l.activeCues||[]).forEach(c=>{if(!(!c.snapToLines||c.line<-5||c.line>=0&&c.line<10))if(!d||this.paused){let h=c.text.split(`
|
|
3203
|
-
`).length,f=-3;this.streamType===Se.LIVE&&(f=-2);let m=f-h;if(c.line===m&&!u)return;r.has(c)||r.set(c,c.line),c.line=m}else setTimeout(()=>{c.line=r.get(c)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ee.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let u=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(c=>["subtitles","captions"].includes(c.kind)&&c.mode==="showing")[0];u!==t&&(t==null||t.removeEventListener("cuechange",a)),t=u,t==null||t.addEventListener("cuechange",a),n(t,De(this,en))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let u=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ee.USER_INACTIVE))!=null?d:!0;De(this,en)!==u&&(qi(this,en,u),n(t,De(this,en)))})};function Js(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var th=hM;
|
|
3202
|
+
`}return nM(i)};function aM(i){var e,t;let r=i.theme;if(r){let s=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,r);if(s&&s instanceof HTMLTemplateElement)return s;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let n=Yi.customElements.get(r);if(n!=null&&n.template)return n.template}}function oM(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function k_(i){let e=i.videoTitle?{video_title:i.videoTitle}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var lM=Object.values(D),dM=Object.values(gr),uM=Object.values(F),w_=V_(),D_="mux-player",C_={isDialogOpen:!1},cM={redundant_streams:!0},Xc,Qc,Zc,en,Jc,ba,Qe,is,Q_,Fg,tn,M_,O_,P_,N_,hM=class extends A_{constructor(){super(),vi(this,Qe),vi(this,Xc),vi(this,Qc,!1),vi(this,Zc,{}),vi(this,en,!0),vi(this,Jc,new kC(this,"hotkeys")),vi(this,ba,{...C_,onCloseErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&nt(this,Qe,Fg).call(this,{isDialogOpen:!1})},onFocusInErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&(G_(this,Hg.activeElement)||i.preventDefault())}}),qi(this,Xc,Sd()),this.attachShadow({mode:"open"}),nt(this,Qe,Q_).call(this),this.isConnected&&nt(this,Qe,is).call(this)}static get NAME(){return D_}static get VERSION(){return w_}static get observedAttributes(){var i;return[...(i=A_.observedAttributes)!=null?i:[],...dM,...lM,...uM]}get mediaTheme(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("media-theme")}get mediaController(){var i,e;return(e=(i=this.mediaTheme)==null?void 0:i.shadowRoot)==null?void 0:e.querySelector("media-controller")}connectedCallback(){let i=this.media;i&&(i.metadata=k_(this))}attributeChangedCallback(i,e,t){switch(nt(this,Qe,is).call(this),super.attributeChangedCallback(i,e,t),i){case F.HOTKEYS:De(this,Jc).value=t;break;case F.THUMBNAIL_TIME:{t!=null&&this.tokens.thumbnail&&vr(Q("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").toString());break}case F.THUMBNAIL_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.THUMBNAIL;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"thumbnail"}))}}break}case F.STORYBOARD_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.STORYBOARD;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"storyboard"}))}}break}case F.DRM_TOKEN:{if(t){let r=Sr(t);if(r){let{aud:s}=r,n=gn.DRM;s!==n&&vr(Q("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({aud:s,expectedAud:n,tokenNamePrefix:"drm"}))}}break}case D.PLAYBACK_ID:{t!=null&&t.includes("?token")&&ei(Q("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:t}));break}case D.STREAM_TYPE:t&&![Se.LIVE,Se.ON_DEMAND,Se.UNKNOWN].includes(t)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=t.includes("dvr")?Number.POSITIVE_INFINITY:0:Y_({file:"invalid-stream-type.md",message:Q("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):t===Se.LIVE?this.getAttribute(F.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[D.PLAYBACK_ID,gr.SRC,F.PLAYBACK_TOKEN].includes(i)&&e!==t&&qi(this,ba,{...De(this,ba),...C_}),nt(this,Qe,tn).call(this,{[LC(i)]:t})}async requestFullscreen(i){var e;if(!(!this.mediaController||this.mediaController.hasAttribute(b.MEDIA_IS_FULLSCREEN)))return(e=this.mediaController)==null||e.dispatchEvent(new Yi.CustomEvent($.MEDIA_ENTER_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((t,r)=>{var s;(s=this.mediaController)==null||s.addEventListener(Qt.MEDIA_IS_FULLSCREEN,()=>t(),{once:!0})})}async exitFullscreen(){var i;if(!(!this.mediaController||!this.mediaController.hasAttribute(b.MEDIA_IS_FULLSCREEN)))return(i=this.mediaController)==null||i.dispatchEvent(new Yi.CustomEvent($.MEDIA_EXIT_FULLSCREEN_REQUEST,{composed:!0,bubbles:!0})),new Promise((e,t)=>{var r;(r=this.mediaController)==null||r.addEventListener(Qt.MEDIA_IS_FULLSCREEN,()=>e(),{once:!0})})}get preferCmcd(){var i;return(i=this.getAttribute(D.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?vn.includes(i)?this.setAttribute(D.PREFER_CMCD,i):vr(`Invalid value for preferCmcd. Must be one of ${vn.join()}`):this.removeAttribute(D.PREFER_CMCD))}get hasPlayed(){var i,e;return(e=(i=this.mediaController)==null?void 0:i.hasAttribute(b.MEDIA_HAS_PLAYED))!=null?e:!1}get inLiveWindow(){var i;return(i=this.mediaController)==null?void 0:i.hasAttribute(b.MEDIA_TIME_IS_LIVE)}get _hls(){var i;return(i=this.media)==null?void 0:i._hls}get mux(){var i;return(i=this.media)==null?void 0:i.mux}get theme(){var i;return(i=this.getAttribute(F.THEME))!=null?i:rM}set theme(i){this.setAttribute(F.THEME,`${i}`)}get themeProps(){let i=this.mediaTheme;if(!i)return;let e={};for(let t of i.getAttributeNames()){if(Ug.includes(t))continue;let r=i.getAttribute(t);e[$_(t)]=r===""?!0:r}return e}set themeProps(i){var e,t;nt(this,Qe,is).call(this);let r={...this.themeProps,...i};for(let s in r){if(Ug.includes(s))continue;let n=i==null?void 0:i[s];typeof n=="boolean"||n==null?(e=this.mediaTheme)==null||e.toggleAttribute(Pg(s),!!n):(t=this.mediaTheme)==null||t.setAttribute(Pg(s),n)}}get playbackId(){var i;return(i=this.getAttribute(D.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i?this.setAttribute(D.PLAYBACK_ID,i):this.removeAttribute(D.PLAYBACK_ID)}get src(){var i,e;return this.playbackId?(i=Js(this,gr.SRC))!=null?i:void 0:(e=this.getAttribute(gr.SRC))!=null?e:void 0}set src(i){i?this.setAttribute(gr.SRC,i):this.removeAttribute(gr.SRC)}get poster(){var i;let e=this.getAttribute(gr.POSTER);if(e!=null)return e;let{tokens:t}=this;if(t.playback&&!t.thumbnail){vr("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return xC(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(i=this.thumbnailTime)!=null?i:this.startTime,programTime:this.programStartTime,token:t.thumbnail})}set poster(i){i||i===""?this.setAttribute(gr.POSTER,i):this.removeAttribute(gr.POSTER)}get storyboardSrc(){var i;return(i=this.getAttribute(F.STORYBOARD_SRC))!=null?i:void 0}set storyboardSrc(i){i?this.setAttribute(F.STORYBOARD_SRC,i):this.removeAttribute(F.STORYBOARD_SRC)}get storyboard(){let{tokens:i}=this;if(this.storyboardSrc&&!i.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[Se.LIVE,Se.UNKNOWN].includes(this.streamType)||i.playback&&!i.storyboard))return RC(this.playbackId,{customDomain:this.customDomain,token:i.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(F.AUDIO)}set audio(i){if(!i){this.removeAttribute(F.AUDIO);return}this.setAttribute(F.AUDIO,"")}get hotkeys(){return De(this,Jc)}get nohotkeys(){return this.hasAttribute(F.NOHOTKEYS)}set nohotkeys(i){if(!i){this.removeAttribute(F.NOHOTKEYS);return}this.setAttribute(F.NOHOTKEYS,"")}get thumbnailTime(){return Wt(this.getAttribute(F.THUMBNAIL_TIME))}set thumbnailTime(i){this.setAttribute(F.THUMBNAIL_TIME,`${i}`)}get videoTitle(){var i,e;return(e=(i=this.getAttribute(F.VIDEO_TITLE))!=null?i:this.getAttribute(F.TITLE))!=null?e:""}set videoTitle(i){i!==this.videoTitle&&(i?this.setAttribute(F.VIDEO_TITLE,i):this.removeAttribute(F.VIDEO_TITLE))}get placeholder(){var i;return(i=Js(this,F.PLACEHOLDER))!=null?i:""}set placeholder(i){this.setAttribute(F.PLACEHOLDER,`${i}`)}get primaryColor(){var i,e;let t=this.getAttribute(F.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_primary-color"))==null?void 0:e.trim(),t))return t}set primaryColor(i){this.setAttribute(F.PRIMARY_COLOR,`${i}`)}get secondaryColor(){var i,e;let t=this.getAttribute(F.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_secondary-color"))==null?void 0:e.trim(),t))return t}set secondaryColor(i){this.setAttribute(F.SECONDARY_COLOR,`${i}`)}get accentColor(){var i,e;let t=this.getAttribute(F.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(e=(i=Yi.getComputedStyle(this.mediaTheme))==null?void 0:i.getPropertyValue("--_accent-color"))==null?void 0:e.trim(),t))return t}set accentColor(i){this.setAttribute(F.ACCENT_COLOR,`${i}`)}get defaultShowRemainingTime(){return this.hasAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(i){i?this.setAttribute(F.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(F.PLAYBACK_RATES))return this.getAttribute(F.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(i=>Number(i)).filter(i=>!Number.isNaN(i)).sort((i,e)=>i-e)}set playbackRates(i){if(!i){this.removeAttribute(F.PLAYBACK_RATES);return}this.setAttribute(F.PLAYBACK_RATES,i.join(" "))}get forwardSeekOffset(){var i;return(i=Wt(this.getAttribute(F.FORWARD_SEEK_OFFSET)))!=null?i:10}set forwardSeekOffset(i){this.setAttribute(F.FORWARD_SEEK_OFFSET,`${i}`)}get backwardSeekOffset(){var i;return(i=Wt(this.getAttribute(F.BACKWARD_SEEK_OFFSET)))!=null?i:10}set backwardSeekOffset(i){this.setAttribute(F.BACKWARD_SEEK_OFFSET,`${i}`)}get defaultHiddenCaptions(){return this.hasAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(i){i?this.setAttribute(F.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return Wt(this.getAttribute(F.DEFAULT_DURATION))}set defaultDuration(i){i==null?this.removeAttribute(F.DEFAULT_DURATION):this.setAttribute(F.DEFAULT_DURATION,`${i}`)}get playerInitTime(){return this.hasAttribute(D.PLAYER_INIT_TIME)?Wt(this.getAttribute(D.PLAYER_INIT_TIME)):De(this,Xc)}set playerInitTime(i){i!=this.playerInitTime&&(i==null?this.removeAttribute(D.PLAYER_INIT_TIME):this.setAttribute(D.PLAYER_INIT_TIME,`${+i}`))}get playerSoftwareName(){var i;return(i=this.getAttribute(D.PLAYER_SOFTWARE_NAME))!=null?i:D_}get playerSoftwareVersion(){var i;return(i=this.getAttribute(D.PLAYER_SOFTWARE_VERSION))!=null?i:w_}get beaconCollectionDomain(){var i;return(i=this.getAttribute(D.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(D.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(D.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var i;return(i=this.getAttribute(D.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(D.MAX_RESOLUTION,i):this.removeAttribute(D.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(D.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(D.MIN_RESOLUTION,i):this.removeAttribute(D.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(D.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(D.RENDITION_ORDER,i):this.removeAttribute(D.RENDITION_ORDER))}get programStartTime(){return Wt(this.getAttribute(D.PROGRAM_START_TIME))}set programStartTime(i){i==null?this.removeAttribute(D.PROGRAM_START_TIME):this.setAttribute(D.PROGRAM_START_TIME,`${i}`)}get programEndTime(){return Wt(this.getAttribute(D.PROGRAM_END_TIME))}set programEndTime(i){i==null?this.removeAttribute(D.PROGRAM_END_TIME):this.setAttribute(D.PROGRAM_END_TIME,`${i}`)}get assetStartTime(){return Wt(this.getAttribute(D.ASSET_START_TIME))}set assetStartTime(i){i==null?this.removeAttribute(D.ASSET_START_TIME):this.setAttribute(D.ASSET_START_TIME,`${i}`)}get assetEndTime(){return Wt(this.getAttribute(D.ASSET_END_TIME))}set assetEndTime(i){i==null?this.removeAttribute(D.ASSET_END_TIME):this.setAttribute(D.ASSET_END_TIME,`${i}`)}get extraSourceParams(){return this.hasAttribute(F.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(F.EXTRA_SOURCE_PARAMS)).entries()].reduce((i,[e,t])=>(i[e]=t,i),{}):cM}set extraSourceParams(i){i==null?this.removeAttribute(F.EXTRA_SOURCE_PARAMS):this.setAttribute(F.EXTRA_SOURCE_PARAMS,new URLSearchParams(i).toString())}get customDomain(){var i;return(i=this.getAttribute(D.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(D.CUSTOM_DOMAIN,i):this.removeAttribute(D.CUSTOM_DOMAIN))}get envKey(){var i;return(i=Js(this,D.ENV_KEY))!=null?i:void 0}set envKey(i){this.setAttribute(D.ENV_KEY,`${i}`)}get noVolumePref(){return this.hasAttribute(F.NO_VOLUME_PREF)}set noVolumePref(i){i?this.setAttribute(F.NO_VOLUME_PREF,""):this.removeAttribute(F.NO_VOLUME_PREF)}get debug(){return Js(this,D.DEBUG)!=null}set debug(i){i?this.setAttribute(D.DEBUG,""):this.removeAttribute(D.DEBUG)}get disableTracking(){return Js(this,D.DISABLE_TRACKING)!=null}set disableTracking(i){this.toggleAttribute(D.DISABLE_TRACKING,!!i)}get disableCookies(){return Js(this,D.DISABLE_COOKIES)!=null}set disableCookies(i){i?this.setAttribute(D.DISABLE_COOKIES,""):this.removeAttribute(D.DISABLE_COOKIES)}get streamType(){var i,e,t;return(t=(e=this.getAttribute(D.STREAM_TYPE))!=null?e:(i=this.media)==null?void 0:i.streamType)!=null?t:Se.UNKNOWN}set streamType(i){this.setAttribute(D.STREAM_TYPE,`${i}`)}get defaultStreamType(){var i,e,t;return(t=(e=this.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?e:(i=this.mediaController)==null?void 0:i.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?t:Se.ON_DEMAND}set defaultStreamType(i){i?this.setAttribute(F.DEFAULT_STREAM_TYPE,i):this.removeAttribute(F.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var i,e;return this.hasAttribute(F.TARGET_LIVE_WINDOW)?+this.getAttribute(F.TARGET_LIVE_WINDOW):(e=(i=this.media)==null?void 0:i.targetLiveWindow)!=null?e:Number.NaN}set targetLiveWindow(i){i==this.targetLiveWindow||Number.isNaN(i)&&Number.isNaN(this.targetLiveWindow)||(i==null?this.removeAttribute(F.TARGET_LIVE_WINDOW):this.setAttribute(F.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i;return(i=this.media)==null?void 0:i.liveEdgeStart}get startTime(){return Wt(Js(this,D.START_TIME))}set startTime(i){this.setAttribute(D.START_TIME,`${i}`)}get preferPlayback(){let i=this.getAttribute(D.PREFER_PLAYBACK);if(i===zt.MSE||i===zt.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===zt.MSE||i===zt.NATIVE?this.setAttribute(D.PREFER_PLAYBACK,i):this.removeAttribute(D.PREFER_PLAYBACK))}get metadata(){var i;return(i=this.media)==null?void 0:i.metadata}set metadata(i){if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...k_(this),...i}}get _hlsConfig(){var i;return(i=this.media)==null?void 0:i._hlsConfig}set _hlsConfig(i){if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=i}async addCuePoints(i){var e;if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(e=this.media)==null?void 0:e.addCuePoints(i)}get activeCuePoint(){var i;return(i=this.media)==null?void 0:i.activeCuePoint}get cuePoints(){var i,e;return(e=(i=this.media)==null?void 0:i.cuePoints)!=null?e:[]}addChapters(i){var e;if(nt(this,Qe,is).call(this),!this.media){ei("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(e=this.media)==null?void 0:e.addChapters(i)}get activeChapter(){var i;return(i=this.media)==null?void 0:i.activeChapter}get chapters(){var i,e;return(e=(i=this.media)==null?void 0:i.chapters)!=null?e:[]}getStartDate(){var i;return(i=this.media)==null?void 0:i.getStartDate()}get currentPdt(){var i;return(i=this.media)==null?void 0:i.currentPdt}get tokens(){let i=this.getAttribute(F.PLAYBACK_TOKEN),e=this.getAttribute(F.DRM_TOKEN),t=this.getAttribute(F.THUMBNAIL_TOKEN),r=this.getAttribute(F.STORYBOARD_TOKEN);return{...De(this,Zc),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{},...t!=null?{thumbnail:t}:{},...r!=null?{storyboard:r}:{}}}set tokens(i){qi(this,Zc,i!=null?i:{})}get playbackToken(){var i;return(i=this.getAttribute(F.PLAYBACK_TOKEN))!=null?i:void 0}set playbackToken(i){this.setAttribute(F.PLAYBACK_TOKEN,`${i}`)}get drmToken(){var i;return(i=this.getAttribute(F.DRM_TOKEN))!=null?i:void 0}set drmToken(i){this.setAttribute(F.DRM_TOKEN,`${i}`)}get thumbnailToken(){var i;return(i=this.getAttribute(F.THUMBNAIL_TOKEN))!=null?i:void 0}set thumbnailToken(i){this.setAttribute(F.THUMBNAIL_TOKEN,`${i}`)}get storyboardToken(){var i;return(i=this.getAttribute(F.STORYBOARD_TOKEN))!=null?i:void 0}set storyboardToken(i){this.setAttribute(F.STORYBOARD_TOKEN,`${i}`)}addTextTrack(i,e,t,r){var s;let n=(s=this.media)==null?void 0:s.nativeEl;if(n)return Ad(n,i,e,t,r)}removeTextTrack(i){var e;let t=(e=this.media)==null?void 0:e.nativeEl;if(t)return BE(t,i)}get textTracks(){var i;return(i=this.media)==null?void 0:i.textTracks}get castReceiver(){var i;return(i=this.getAttribute(F.CAST_RECEIVER))!=null?i:void 0}set castReceiver(i){i!==this.castReceiver&&(i?this.setAttribute(F.CAST_RECEIVER,i):this.removeAttribute(F.CAST_RECEIVER))}get castCustomData(){var i;return(i=this.media)==null?void 0:i.castCustomData}set castCustomData(i){if(!this.media){ei("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=i}get noTooltips(){return this.hasAttribute(F.NO_TOOLTIPS)}set noTooltips(i){if(!i){this.removeAttribute(F.NO_TOOLTIPS);return}this.setAttribute(F.NO_TOOLTIPS,"")}get proudlyDisplayMuxBadge(){return this.hasAttribute(F.PROUDLY_DISPLAY_MUX_BADGE)}set proudlyDisplayMuxBadge(i){i?this.setAttribute(F.PROUDLY_DISPLAY_MUX_BADGE,""):this.removeAttribute(F.PROUDLY_DISPLAY_MUX_BADGE)}};Xc=new WeakMap,Qc=new WeakMap,Zc=new WeakMap,en=new WeakMap,Jc=new WeakMap,ba=new WeakMap,Qe=new WeakSet,is=function(){var i,e,t,r;if(!De(this,Qc)){qi(this,Qc,!0),nt(this,Qe,tn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Yi.HTMLElement))throw""}catch{ei("<media-theme> failed to upgrade!")}try{customElements.upgrade(this.media)}catch{ei("underlying media element failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof np))throw""}catch{ei("<media-controller> failed to upgrade!")}nt(this,Qe,M_).call(this),nt(this,Qe,O_).call(this),nt(this,Qe,P_).call(this),qi(this,en,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(ee.USER_INACTIVE))!=null?e:!0),nt(this,Qe,N_).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>nt(this,Qe,tn).call(this)),(r=this.media)==null||r.addEventListener("loadstart",()=>nt(this,Qe,tn).call(this))}},Q_=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Fg=function(i){Object.assign(De(this,ba),i),nt(this,Qe,tn).call(this)},tn=function(i={}){WC(qC(sM(this,{...De(this,ba),...i})),this.shadowRoot)},M_=function(){let i=e=>{var t,r;if(!(e!=null&&e.startsWith("theme-")))return;let s=e.replace(/^theme-/,"");if(Ug.includes(s))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(s,n):(r=this.mediaTheme)==null||r.removeAttribute(s)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},O_=function(){let i=e=>{var t;let r=(t=this.media)==null?void 0:t.error;if(!(r instanceof K)){let{message:n,code:a}=r!=null?r:{};r=new K(n,a)}if(!(r!=null&&r.fatal)){vr(r),r.data&&vr(`${r.name} data:`,r.data);return}let s=R_(r,!1);s.message&&Y_(s),ei(r),r.data&&ei(`${r.name} data:`,r.data),nt(this,Qe,Fg).call(this,{isDialogOpen:!0})};this.addEventListener("error",i),this.media&&(this.media.errorTranslator=(e={})=>{var t,r,s;if(!(((t=this.media)==null?void 0:t.error)instanceof K))return e;let n=R_((r=this.media)==null?void 0:r.error,!1);return{player_error_code:(s=this.media)==null?void 0:s.error.code,player_error_message:n.message?String(n.message):e.player_error_message,player_error_context:n.context?String(n.context):e.player_error_context}})},P_=function(){var i,e,t,r;let s=()=>nt(this,Qe,tn).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",s),(r=(t=this.media)==null?void 0:t.textTracks)==null||r.addEventListener("removetrack",s)},N_=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,r=new WeakMap,s=()=>this.streamType===Se.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,u=!1)=>{s()||Array.from(l&&l.activeCues||[]).forEach(c=>{if(!(!c.snapToLines||c.line<-5||c.line>=0&&c.line<10))if(!d||this.paused){let h=c.text.split(`
|
|
3203
|
+
`).length,f=-3;this.streamType===Se.LIVE&&(f=-2);let m=f-h;if(c.line===m&&!u)return;r.has(c)||r.set(c,c.line),c.line=m}else setTimeout(()=>{c.line=r.get(c)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ee.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let u=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(c=>["subtitles","captions"].includes(c.kind)&&c.mode==="showing")[0];u!==t&&(t==null||t.removeEventListener("cuechange",a)),t=u,t==null||t.addEventListener("cuechange",a),n(t,De(this,en))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let u=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ee.USER_INACTIVE))!=null?d:!0;De(this,en)!==u&&(qi(this,en,u),n(t,De(this,en)))})};function Js(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var th=hM;pl.customElements.get("mux-player")||(pl.customElements.define("mux-player",th),pl.MuxPlayerElement=th);var Y8=th;})();
|
|
3204
3204
|
/*! Bundled license information:
|
|
3205
3205
|
|
|
3206
3206
|
mux-embed/dist/mux.mjs:
|