@mux/mux-player 3.4.2-canary.1 → 3.4.2-canary.2
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 +160 -156
- package/dist/mux-player.mjs +160 -156
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/mux-player.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";(()=>{var iA=Object.defineProperty;var rA=Object.getPrototypeOf;var sA=Reflect.get;var Qg=i=>{throw TypeError(i)};var nA=(i,e,t)=>e in i?iA(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Ee=(i,e,t)=>nA(i,typeof e!="symbol"?e+"":e,t),eh=(i,e,t)=>e.has(i)||Qg("Cannot "+t);var I=(i,e,t)=>(eh(i,e,"read from private field"),t?t.call(i):e.get(i)),ie=(i,e,t)=>e.has(i)?Qg("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Z=(i,e,t,r)=>(eh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ce=(i,e,t)=>(eh(i,e,"access private method"),t);var hl=(i,e,t)=>sA(rA(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{},th=class extends nn{},aA={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(_a)}},Aa,ih=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 oA(i,e){return new _a}var Zg={document:{createElement:oA},DocumentFragment,customElements:aA,CustomEvent:ih,EventTarget:nn,HTMLElement:_a,HTMLVideoElement:th},Jg=typeof window=="undefined"||typeof globalThis.customElements=="undefined",fl=Jg?Zg:globalThis,dM=Jg?Zg.document:globalThis.document;var lA=Object.create,l0=Object.defineProperty,dA=Object.getOwnPropertyDescriptor,uA=Object.getOwnPropertyNames,cA=Object.getPrototypeOf,hA=Object.prototype.hasOwnProperty,d0=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}},fA=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=uA(e),n=0,a=s.length,o;n<a;n++)o=s[n],!hA.call(i,o)&&o!==t&&l0(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=dA(e,o))||r.enumerable});return i},Bt=function(i,e,t){return t=i!=null?lA(cA(i)):{},fA(e||!i||!i.__esModule?l0(t,"default",{value:i,enumerable:!0}):t,i)},si=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=d0(function(){ls()});function u0(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var c0=d0(function(){}),h0=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))}}}),mA=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]"}}),pA=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}}),f0=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)}}),m0=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)}}),p0=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)}}}),gA=Lt(function(i,e){c0(),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=u0(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,""")}}),g0=Lt(function(i,e){ls();var t=h0(),r=f0(),s=m0(),n=p0(),a=gA(),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}}),vA=Lt(function(i,e){ls();var t=g0();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("")}}),EA=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(){}}),bA=Lt(function(i,e){ls();var t=h0(),r=mA(),s=pA(),n=g0(),a=vA(),o=EA(),l=f0(),d=m0(),u=p0();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}),TA=Lt(function(i,e){var t=bA();e.exports=new t}),v0=Lt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=TA(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function yA(i){if(Array.isArray(i))return i}function _A(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 AA(){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
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ii(i){return RA(i)||IA(i)||E0(i)||LA()}var ns={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},kA=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,ii(o)),d=(r=console.info).bind.apply(r,ii(o)),u=(s=console.debug).bind.apply(s,ii(o)),c=(n=console.warn).bind.apply(n,ii(o)),h=(a=console.error).bind.apply(a,ii(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,ii(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,ii(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,ii(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,ii(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,ii(p))},get level(){return f},set level(m){m!==this.level&&(f=m!=null?m:e)}}},Pe=kA("[mux]"),rh=Bt(si());function dh(){var i=rh.default.doNotTrack||rh.default.navigator&&rh.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 t0(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 vi(i,e,t){return e&&t0(i.prototype,e),t&&t0(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 wA(i,e){for(;!Object.prototype.hasOwnProperty.call(i,e)&&(i=on(i),i!==null););return i}function pl(i,e,t){return typeof Reflect!="undefined"&&Reflect.get?pl=Reflect.get:pl=function(r,s,n){var a=wA(r,s);if(a){var o=Object.getOwnPropertyDescriptor(a,s);return o.get?o.get.call(n||r):o.value}},pl(i,e,t||i)}function uh(i,e){return uh=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},uh(i,e)}function DA(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&&uh(i,e)}function CA(){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}}c0();function MA(i,e){return e&&(u0(e)==="object"||typeof e=="function")?e:le(i)}function OA(i){var e=CA();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 MA(this,r)}}var ri=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]},sh=Bt(si()),PA={exists:function(){var i=sh.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=sh.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=sh.default.performance,e=i&&i.timing;return e&&e.navigationStart}},vl=PA;function Je(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function El(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 NA(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 hh(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):NA(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var UA=["x-cdn","content-type"],T0=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],FA=UA.concat(T0);function fh(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&&(FA.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function bl(i){if(i){var e=T0.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var BA=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},y0=BA,ml=function(i){if(!i)return{};var e=vl.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 fh(i.getAllResponseHeaders())},$A=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),b;return y===1&&v.programDateTime!==null&&(b=v.programDateTime),y===0&&v.pdt!==null&&(b=v.pdt),b};if(!vl.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 b=y.levels,_=y.audioTracks,A=y.url,k=y.stats,R=y.networkDetails,x=y.sessionData,O={},w={};b.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=ml(k),P=C.bytesLoaded,U=C.requestStart,X=C.responseStart,z=C.responseEnd;l("requestcompleted",hh(El({},y0(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:ri(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 b=y.details,_=y.level,A=y.networkDetails,k=y.stats,R=ml(k),x=R.bytesLoaded,O=R.requestStart,w=R.responseStart,C=R.responseEnd,P=b.fragments[b.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:ri(b.url),request_response_headers:Sa(A),video_holdback:b.holdBack&&a(b.holdBack),video_part_holdback:b.partHoldBack&&a(b.partHoldBack),video_part_target_duration:b.partTarget&&a(b.partTarget),video_target_duration:b.targetduration&&a(b.targetduration),video_source_is_live:b.live,player_manifest_newest_program_time:isNaN(U)?void 0:U})};t.on(s.Events.LEVEL_LOADED,u);var c=function(v,y){var b=y.details,_=y.networkDetails,A=y.stats,k=ml(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:ri(b.url),request_response_headers:Sa(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(v,y){var b=y.stats,_=y.networkDetails,A=y.frag;b=b||A.stats;var k=ml(b),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:_?ri(_.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 b=y.frag,_=b.start,A=o(b),k={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",k)};t.on(s.Events.FRAG_CHANGED,f);var m=function(v,y){var b=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:ri(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 be=(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,mM=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)}}}),bA=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=bA(),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}}),TA=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=TA(),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}),b0=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 T0(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)||T0(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},vl=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)||T0(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 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 Tl(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),b;return y===1&&v.programDateTime!==null&&(b=v.programDateTime),y===0&&v.pdt!==null&&(b=v.pdt),b};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 b=y.levels,_=y.audioTracks,A=y.url,k=y.stats,R=y.networkDetails,x=y.sessionData,O={},w={};b.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(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 b=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=b.fragments[b.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(b.url),request_response_headers:Sa(A),video_holdback:b.holdBack&&a(b.holdBack),video_part_holdback:b.partHoldBack&&a(b.partHoldBack),video_part_target_duration:b.partTarget&&a(b.partTarget),video_target_duration:b.targetduration&&a(b.targetduration),video_source_is_live:b.live,player_manifest_newest_program_time:isNaN(U)?void 0:U})};t.on(s.Events.LEVEL_LOADED,u);var c=function(v,y){var b=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(b.url),request_response_headers:Sa(_)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(v,y){var b=y.stats,_=y.networkDetails,A=y.frag;b=b||A.stats;var k=pl(b),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?Tl(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 b=y.frag,_=b.start,A=o(b),k={currentFragmentPDT:A,currentFragmentStart:a(_)};l("fragmentchange",k)};t.on(s.Events.FRAG_CHANGED,f);var m=function(v,y){var b=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?Tl(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,38 +9,39 @@ 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:b,player_error_message:_,player_error_context:P})}};t.on(s.Events.ERROR,m);var p=function(v,y){var b=y.frag,_=b&&b._url||"";l("requestcanceled",{request_event_type:v,request_url:_,request_type:"media",request_hostname:
|
|
12
|
+
`):"");l("error",{player_error_code:b,player_error_message:_,player_error_context:P})}};t.on(s.Events.ERROR,m);var p=function(v,y){var b=y.frag,_=b&&b._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 b=y.level,_=t.levels[b];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?Tl(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(b,_){return i.emit(e,b,_)},o=function(b){var _=b.type,A=b.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(b){if(typeof b.getRequests!="function")return null;var _=b.getRequests({state:"executed"});return _.length===0?null:_[_.length-1]},u=function(b){var _=b.type,A=b.fragmentModel,k=b.chunk,R=d(A);c({type:_,request:R,chunk:k})},c=function(b){var _=b.type,A=b.chunk,k=b.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(b){var _=b.type,A=b.fragmentModel,k=b.chunk,R=d(A);f({type:_,request:R,chunk:k})},f=function(b){var _=b.type,A=b.chunk,k=b.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 b=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(b+=m.audio.bitrate),b!==m.totalBitrate)return m.totalBitrate=b,{video_source_bitrate:b,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:YA(m.video.codec)}}},g=function(b,_,A){if(typeof b.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",b);return}var k=b.mediaType;if(k==="audio"||k==="video"){var R=t.getBitrateInfoListFor(k).find(function(O){var w=O.qualityIndex;return w===b.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(b){var _=b.request,A=b.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(b){var _=b.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}},YA=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},r0=0,qA=function(){"use strict";function i(){ct(this,i),H(this,"_listeners",void 0)}return vi(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++r0,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||++r0;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}(),jA=qA,nh=Bt(si()),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&&(nh.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return vi(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=nh.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(nh.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),XA=zA,QA=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})},ZA=QA,JA=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 vi(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),Je(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}(),e1=JA,t1=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=et.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=et.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return vi(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=et.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&Je(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),i1=t1,r1=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 vi(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}(),s1=r1,s0=5*60*1e3,n1=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;Je(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>s0&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(s0,"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||(Je(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)})}},a1=n1,o1=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:et.now()})}))}return vi(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}(),l1=o1,d1=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||et.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return vi(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}(),u1=d1,c1=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),Je(e.data,"view_total_content_playback_time",a),Je(e.data,"view_total_upscaling",l*a),Je(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})})},h1=c1,f1=2e3,m1=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=et.now(),a=(e.data.viewer_time||n)-(r||n);Je(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<=f1){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,Je(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})},p1=m1,n0=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},g1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],v1=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}),g1.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),n0(t._adRequests,n),Je(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||Je(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),n0(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&Je(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,Je(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||Je(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||Je(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return vi(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}(),E1=v1,a0=Bt(si()),b1=function i(e){"use strict";ct(this,i);var t,r,s=function(){e.disableRebufferTracking||(Je(e.data,"view_waiting_rebuffer_count",1),t=et.now(),r=a0.default.setInterval(function(){if(t){var d=et.now();Je(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(Je(e.data,"view_waiting_rebuffer_duration",et.now()-t),t=!1,a0.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)},T1=b1,y1=function i(e){"use strict";var t=this;ct(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=et.now(),e.on("before*",s)},s=function(n){var a=et.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)})},_1=y1,ah=Bt(si()),_0=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(){})}),A0="muxData",A1=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("&")},S1=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},{})},S0=function(){var i;try{i=S1(_0.get(A0)||"")}catch{i={}}return i},x0=function(i){try{_0.set(A0,A1(i),{expires:365})}catch{}},x1=function(){var i=S0();return i.mux_viewer_id=i.mux_viewer_id||La(),i.msn=i.msn||Math.random(),x0(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},R1=function(){var i=S0(),e=et.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,x0(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function I1(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 L1=Bt(si()),R0=function(){var i;switch(I0()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},I0=function(){var i=L1.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};R0.getConnectionFromAPI=I0;var k1=R0,w1={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"},D1=L0(w1),C1={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"},o0=L0(C1);function L0(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function ch(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=D1[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),o0[l]?o+=o0[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(si()),M1=Bt(v0()),O1={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},P1=56*1024,N1=["hb","requestcompleted","requestfailed","requestcanceled"],U1="https://img.litix.io",zi=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||U1,this._eventQueue=[],this._postInFlight=!1,this._resendAfterPost=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},O1,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],ch({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);k0(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=et.now();k0(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=et.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(et.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 N1.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 F1=typeof M1.default.exitPictureInPicture=="function"?function(i){return i.length<=P1}:function(i){return!1},k0=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:F1(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()},B1=zi,$1=["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"],H1=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],G1=["ad_id","ad_creative_id","ad_universal_id"],K1=["viewstart","error","ended","viewend"],V1=10*60*1e3,W1=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 B1(I1(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:k1(),page_url:ah.default===null||ah.default===void 0||(p=ah.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:x1()}return vi(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&dh())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?{}:R1(),s=hh(El({},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=ch(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):K1.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=ch(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>=V1)s=El({},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]||$1.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||G1.includes(t)&&H1.includes(e))}}]),i}(),Y1=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,b;if(p?(y=p-(m!=null?m:0),b=(g!=null?g:0)-p):b=(g!=null?g:0)-(m!=null?m:0),b>0&&v&&v>0){var _=v/b*8e3;a++,r+=v,s+=b,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)},q1=Y1,j1=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=et.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>j1){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}))}})},X1=z1,Q1=["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"],Z1=new Set(["requestcompleted","requestfailed","requestcanceled"]),J1=function(i){"use strict";DA(t,i);var e=OA(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=vl.domContentLoadedEventEnd(),a.NAVIGATION_START=vl.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 W1(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)}),Q1.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 X1(le(a)),a.errorTracker=new ZA(le(a)),new _1(le(a)),a.seekingTracker=new p1(le(a)),a.playheadTime=new s1(le(a)),a.playbackHeartbeat=new XA(le(a)),new h1(le(a)),a.watchTimeTracker=new e1(le(a)),new i1(le(a)),a.adTracker=new E1(le(a)),new l1(le(a)),new a1(le(a)),new u1(le(a)),new T1(le(a)),new q1(le(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return vi(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=pl(on(t.prototype),"emit",this)).call.apply(n,[this].concat(ii(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++,Z1.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&&Je(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,$A(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(HA(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,WA(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(YA(this.dashjs),this.dashjs=void 0)}}]),t}(jA),eS=J1,xa=Bt(v0());function tS(){return xa.default&&!!(xa.default.fullscreenElement||xa.default.webkitFullscreenElement||xa.default.mozFullScreenElement||xa.default.msFullscreenElement)}var iS=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],rS={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function sS(i,e,t){var r=ji(gl(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(),b={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:tS(),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(b.player_program_time=A+g,s.seekable.length>0){var k=A+s.seekable.end(s.seekable.length-1);b.player_live_edge_program_time=k}}}return b}};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(gl(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={},iS.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=rS[s.error.code]||s.error.message}i.emit(n,f,m)},s.addEventListener(f,s.mux.listeners[f],!1))})}function nS(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(si()),an;Ia.default&&Ia.default.WeakMap&&(an=new WeakMap);function aS(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 oS(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"},Tl=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Tl.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})},b1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],T1=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}),b1.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=T1,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(b0()),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,b;if(p?(y=p-(m!=null?m:0),b=(g!=null?g:0)-p):b=(g!=null?g:0)-(m!=null?m:0),b>0&&v&&v>0){var _=v/b*8e3;a++,r+=v,s+=b,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(b0());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(),b={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(b.player_program_time=A+g,s.seekable.length>0){var k=A+s.seekable.end(s.seekable.length-1);b.player_live_edge_program_time=k}}}return b}};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(`
|
|
15
15
|
`);e>-1;e=this.buffer.indexOf(`
|
|
16
|
-
`))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Tl.prototype.processLine=function(i){var e=i.indexOf(":"),t=cS(i,e),r=t[0],s=t.length===2?mh(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:{oh(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case ss.SERVER_CONTROL:{oh(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:{oh(this.manifest,t);break}case ss.SESSION_DATA:{var o=hS(t[1]),l=y0(o);Object.assign(this.manifest.sessionData,l)}}};Tl.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 oh=function(i,e){var t=w0(e[0].replace("#EXT-X-","")),r;uS(e[1])?(r={},r=Object.assign(dS(e[1]),r)):r=mh(e[1]),i[t]=r},w0=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},mh=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},lS=function(i){var e={},t=i.split("=");if(t.length>1){var r=w0(t[0]);e[r]=mh(t[1])}return e},dS=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=lS(s);t=Object.assign(n,t)}return t},uS=function(i){return i.indexOf("=")>-1},cS=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},hS=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}}},fS=Tl,mS={safeCall:nS,safeIncrement:Je,getComputedStyle:aS,secondsToMs:oS,assign:Object.assign,headersStringToObject:fh,cdnHeadersToRequestId:bl,extractHostnameAndDomain:ka,extractHostname:ri,manifestParser:fS,generateShortID:b0,generateUUID:La,now:et.now,findMediaElement:gl},pS=mS,gS={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"},vS=gS,ES="mux-embed",bS="5.9.0",TS="2.1",Ze={},Er=function(i){var e=arguments;typeof i=="string"?Er.hasOwnProperty(i)?Ra.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Er[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ra.default.setTimeout(function(){i(Er)},0):Pe.warn("`"+i+"` is invalid.")},yS={loaded:et.now(),NAME:ES,VERSION:bS,API_VERSION:TS,PLAYER_TRACKED:!1,monitor:function(i,e){return sS(Er,i,e)},destroyMonitor:function(i){var e=ji(gl(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=ti(i);Ze[t]?Ze[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=ti(i);Ze[t]?Ze[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=ti(i);Ze[e]?Ze[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=ti(i);Ze[e]?Ze[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){dh()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=ti(i);Ze[t]=new eS(Er,t,e)},emit:function(i,e,t){var r=ti(i);Ze[r]?(Ze[r].emit(e,t),e==="destroy"&&delete Ze[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},updateData:function(i,e){var t=ti(i);Ze[t]?Ze[t].emit("hb",e):Pe.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(i,e){var t=ti(i);Ze[t]?Ze[t].emitTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(i,e){var t=ti(i);Ze[t]?Ze[t].stateDataTranslator=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(i,e){var t=ti(i);Ze[t]?Ze[t].getPlayheadTime=e:Pe.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:dh,log:Pe,utils:pS,events:vS,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Er,yS);typeof Ra.default!="undefined"&&typeof Ra.default.addEventListener=="function"&&Ra.default.addEventListener("pagehide",function(i){i.persisted||(Er.WINDOW_UNLOADING=!0)},!1);var yl=Er;function _S(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Av={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})()})(Av);var Yf=Av.exports;function D0(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?D0(Object(t),!0).forEach(function(r){xS(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):D0(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function AS(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 SS(i){var e=AS(i,"string");return typeof e=="symbol"?e:String(e)}function xS(i,e,t){return e=SS(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function tt(){return tt=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},tt.apply(this,arguments)}var j=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},RS=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=IS},IS=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(){},Nh={trace:us,debug:us,log:us,warn:us,info:us,error:us},Da=Nh;function LS(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):us}function kS(i,...e){e.forEach(function(t){Da[t]=i[t]?i[t].bind(i):LS(t)})}function wS(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){kS(i,"debug","log","info","warn","error");try{Da.log(`Debug logs enabled for "${e}" in hls.js version 1.5.20`)}catch{Da=Nh}}else Da=Nh}var L=Da,DS=/^(\d+)x(\d+)$/,C0=/(.+?)=(".*?"|.*?)(?:,|$)/g,qe=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),tt(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=DS.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(C0.lastIndex=0;(t=C0.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 CS(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function MS(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Hl=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=tt(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"},Gl=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=Yf.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},Ca=class extends Gl{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}},Uh=class extends Gl{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)}},OS=10,Fh=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||OS}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 qf(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function PS(i){let e=Bh(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function NS(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 US(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=qf(a)):t=PS(a)}}return t}function Bh(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 ph(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 _l={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function gh(i){if(i===_l.WIDEVINE)return ke.WIDEVINE;if(i===_l.PLAYREADY)return ke.PLAYREADY;if(i===_l.CENC||i===_l.CLEARKEY)return ke.CLEARKEY}function vh(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 Al(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 Sv=function(i){return pn!=null&&(i=pn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function FS(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 BS(s,e,t,r)}function BS(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 xv(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=qf(o).subarray(0,16);return NS(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 jf=(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,Rv=(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(;jf(i,e);){r+=10;let s=md(i,e+6);r+=s,Rv(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},md=(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},$S=(i,e)=>jf(i,e)&&md(i,e+6)+10<=i.length-e,zf=i=>{let e=Lv(i);for(let t=0;t<e.length;t++){let r=e[t];if(Iv(r))return YS(r)}},Iv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",HS=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=md(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},Lv=i=>{let e=0,t=[];for(;jf(i,e);){let r=md(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=HS(i.subarray(e)),a=GS(n);a&&t.push(a),e+=n.size+10}Rv(i,e)&&(e+=10)}return t},GS=i=>i.type==="PRIV"?KS(i):i.type[0]==="W"?WS(i):VS(i),KS=i=>{if(i.size<2)return;let e=_i(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},VS=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=_i(i.data.subarray(t),!0);t+=r.length+1;let s=_i(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=_i(i.data.subarray(1));return{key:i.type,data:e}},WS=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=_i(i.data.subarray(t),!0);t+=r.length+1;let s=_i(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=_i(i.data);return{key:i.type,data:e}},YS=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)}},_i=(i,e=!1)=>{let t=qS();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},Eh;function qS(){if(!navigator.userAgent.includes("PlayStation 4"))return!Eh&&typeof self.TextDecoder!="undefined"&&(Eh=new self.TextDecoder("utf-8")),Eh}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}},Kl=Math.pow(2,32)-1,jS=[].push,kv={video:1,audio:2,id3:3,text:4};function at(i){return String.fromCharCode.apply(null,i)}function wv(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function re(i,e){let t=Dv(i,e);return t<0?4294967296+t:t}function M0(i,e){let t=re(i,e);return t*=Math.pow(2,32),t+=re(i,e+4),t}function Dv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function bh(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&&jS.apply(t,l)}s=o}return t}function XS(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=M0(i,r),a=M0(i,r+8),r+=16),r+=2;let o=i.length+a,l=wv(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 Cv(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=QS(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 QS(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+="."+Sl(a[1])+Sl(a[2])+Sl(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=Th(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=Th(o,l);let u=o[l++];if(u===64)s+="."+Sl(u);else break;if(l+=12,o[l++]!==5)break;l=Th(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+="."+Ei(o)+"."+Ei(l);break}case"vp09":{let a=he(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Ei(o)+"."+Ei(l)+"."+Ei(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+"."+Ei(l)+d+"."+Ei(h)+"."+f+"."+m+p+g+"."+Ei(1)+"."+Ei(1)+"."+Ei(1)+"."+0;break}}return{codec:s,encrypted:n}}function Th(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function Sl(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Ei(i){return(i<10?"0":"")+i}function ZS(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=Mv(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 Mv(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 JS(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===Kl)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Kl+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 ex(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=tx(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=XS(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 tx(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 ix(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),bh(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/(Kl+1)),f=Math.floor(c%(Kl+1));bh(l,4,h),bh(l,8,f)}}})})})}function rx(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 O0(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,b=0,_=(p&16)!==0,A=0,k=(p&32)!==0,R=8;m===n&&(g&&(R+=8),v&&(R+=4),y&&(b=re(f,R),R+=4),_&&(A=re(f,R),R+=4),k&&(R+=4),e.type==="video"&&(a=sx(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=b,q?(ce=re(x,te),te+=4):ce=A,fe&&(te+=4),W&&(O===0?G=re(x,te):G=Dv(x,te),te+=4),e.type===we.VIDEO){let Ye=0;for(;Ye<ce;){let ze=re(r,_e);if(_e+=4,nx(a,r[_e])){let St=r.subarray(_e,_e+ze);Ov(St,a?2:1,i+G/s,t)}_e+=ze,Ye+=ze+4}}i+=z/s}}))})})}),t}function sx(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 nx(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Ov(i,e,t,r){let s=Pv(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=wv(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,b=new Uint8Array(y);if(v){b[0]=p;for(let _=1;_<y;_++)b[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}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:_i(f),userDataBytes:f})}}}function Pv(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 ax(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,RS(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 ox(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 lx(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),ox([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function dx(i){let e=[];if(i instanceof ArrayBuffer){let t=i.byteLength,r=0;for(;r+32<t;){let s=new DataView(i,r),n=ux(s);e.push(n),r+=n.size}}return e}function ux(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 xl={},Pa=class i{static clearKeyUriToKeyIdMap(){xl={}}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=cx(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=US(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=lx(r,null,t),this.keyId=xv(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=xl[this.uri];if(!r){let s=Object.keys(xl).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),xl[this.uri]=r}this.keyId=r}return this}};function cx(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var Nv=/\{\$([a-zA-Z0-9-_]+)\}/g;function P0(i){return Nv.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]=$h(i,n))}}function $h(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(Nv,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 N0(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 hx(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 fx(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var Vl={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 mx(i,e){let t=Vl[e];return!!t&&!!t[i.slice(0,4)]}function yh(i,e,t=!0){return!i.split(",").some(r=>!Uv(r,e,t))}function Uv(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 U0(i){if(i){let e=i.substring(0,4);return Vl.video[e]}return 2}function Wl(i){return i.split(",").reduce((e,t)=>{let r=Vl.video[t];return r?(r*2+e)/(e?3:2):(Vl.audio[t]+e)/(e?2:1)},0)}var _h={};function px(i,e=!0){if(_h[i])return _h[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(Uv(t[r],"audio",e))return _h[i]=t[r],t[r];return i}var gx=/flac|opus/i;function Yl(i,e=!0){return i.replace(gx,t=>px(t.toLowerCase(),e))}function F0(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function vx(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 B0=/#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,$0=/#EXT-X-MEDIA:(.*)/g,Ex=/^#EXT(?:INF|-X-TARGETDURATION):/m,H0=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"),bx=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 Yf.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Ex.test(e)}static parseMasterPlaylist(e,t){let r=P0(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];B0.lastIndex=0;let a;for(;(a=B0.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=$h(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),Tx(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=G0(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"]),N0(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=K0(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($0.lastIndex=0;(s=$0.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 b=i.findGroup(c,y.groupId)||c[0];V0(y,b,"audioCodec"),V0(y,b,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new Fh(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new Ca(s,t),g,v,y,b=-1,_=!1,A=null;for(H0.lastIndex=0,o.m3u8=e,o.hasVariableRefs=P0(e);(g=H0.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&&q0(p,y,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let w=(" "+g[3]).slice(1);p.relurl=$h(o,w),W0(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]),b===-1&&(b=l.length);else{if(g=g[0].match(bx),!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 Hl(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?hx(o,U,a):N0(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{let U=G0(C,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=tt({},y)),y[U.keyFormat]=U}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=K0(C);break;case"MAP":{let U=new qe(C);if(kt(o,U,["BYTERANGE","URI"]),p.duration){let X=new Ca(s,t);Y0(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;Y0(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 Uh(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&&(W0(p,m),p.cc=f,o.fragmentHint=p,y&&q0(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,b>0&&yx(l,b),o}};function G0(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 K0(i){let t=new qe(i).decimalFloatingPoint("TIME-OFFSET");return j(t)?t:null}function Tx(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>mx(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function V0(i,e,t){let r=e[t];r&&(i[t]=r)}function yx(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 W0(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 Y0(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 q0(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 j0(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 Ah(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Hh=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=tt({},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=tt({},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=Ah(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(b=>!b.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=Ah(e,r),c=0,h=j(l)?l:j(o)?o:0,f=j0(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=Ah(t,s),m=j0(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 Fv(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 Bv(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 Gh(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=Ax(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 _x(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 Ax(i,e,t){let r=[],s=_x(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 Ol(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 li={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Sx=.25;function Kh(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function z0(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 Rl=(()=>{let i=Kh();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Sh(i,e){return i.getTime()/1e3-e}function xx(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Vh=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 Fv(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=Kh();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===li.emsg&&!r||!s)continue;let d=Lv(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>Rl&&(c=Rl),c-u<=0&&(c=u+Sx);for(let f=0;f<d.length;f++){let m=d[f];if(!Iv(m)){this.updateId3CueEnds(u,l);let p=z0(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===Rl&&(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===li.audioId3&&l:s==="video"?d=u=>u.type===li.emsg&&o:d=u=>u.type===li.audioId3&&l||u.type===li.emsg&&o,Gh(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=Kh();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=Sh(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,v=Rl,y=h.endDate;if(y)v=Sh(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=Sh(_.startDate,l),g=!0)}let b=Object.keys(h.attr);for(let _=0;_<b.length;_++){let A=b[_];if(!CS(A))continue;let k=p[A];if(k)g&&!m.durationKnown&&(k.endTime=v);else if(d){let R=h.attr[A];MS(A)&&(R=xx(R));let x=z0(d,f,v,{key:A,data:R},li.dateRange);x&&(x.id=c,this.id3Track.addCue(x),p[A]=x)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},Wh=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}},Yh=["NONE","TYPE-0","TYPE-1",null];function Rx(i){return Yh.indexOf(i)>-1}var ql=["SDR","PQ","HLG"];function Ix(i){return!!i&&ql.indexOf(i)>-1}var Pl={No:"",Yes:"YES",v2:"v2"};function X0(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Pl.v2:Pl.Yes:Pl.No}var jl=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}},yr=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 Q0(this._audioGroups,e)}hasSubtitleGroup(e){return Q0(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 Q0(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function xh(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 $v(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--)xh(p[f],p[f-1]);for(f=m;f<p.length-1;f++)xh(p[f],p[f+1]);return i.fragmentHint&&xh(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function Lx(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;Dx(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=kx(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));e.startCC=e.fragments[0].cc,e.endCC=n[n.length-1].cc}wx(i.partList,e.partList,(o,l)=>{l.elementaryStreams=o.elementaryStreams,l.stats=o.stats}),s?$v(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Hv(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 kx(i,e,t){let r=tt({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Hl(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 wx(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 Dx(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 Hv(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||qh(e,r[t].start)}function qh(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 Cx(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 Mx(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 Z0(i,e,t){var r;return i!=null&&i.details?Gv((r=i.details)==null?void 0:r.partList,e,t):null}function Gv(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 Kv(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function zl(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 J0(i,e){let t=zl(e);return i.default[`${t?"timeout":"error"}Retry`]}function Xf(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function ev(i){return pt(pt({},i),{errorRetry:null,timeoutRetry:null})}function Xl(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(Ox(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function Ox(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var Vv={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 Px(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(Ux(e,t,a))return a}return null}function Ql(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)&&jh(t,r,n)===0||Nx(n,i,Math.min(s,r))))return n;let a=Vv.search(e,jh.bind(null,t,r));return a&&(a!==i||!n)?a:n}function Nx(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 jh(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 Ux(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function Fx(i,e){return Vv.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},ni={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},zh=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:ni.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=ni.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:ni.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:ni.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=J0(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Xl(s,n,zl(e),e.response))return{action:ft.RetryRequest,flags:ni.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=J0(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++,Xl(o,l,zl(e),e.response)))return{action:ft.RetryRequest,flags:ni.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),b=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=Ql(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||b&&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:ni.None,nextAutoLevel:u}}return{action:ft.SendAlternateToPenaltyBox,flags:ni.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 ni.None:this.switchLevel(e,a);break;case ni.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Yh[Yh.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&&X0(r);return new jl(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&&Lx(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,b=s.lastPartIndex,_=b!==-1,A=v===y,k=g?0:b;_?(d=A?y+1:v,u=A?k:b+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=Cx(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=X0(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Pl.No),new jl(r,s,n)}checkRetry(e){let t=e.details,r=zl(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=Xf(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}},Tr=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_}},Xh=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 Tr(e),this.fast_=new Tr(t),this.defaultTTFB_=s,this.ttfb_=new Tr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Tr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Tr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Tr(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(){}},Wv={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},tv={};function Bx(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 $x(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(Wv);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=Hx(l);return tv[d]||(tv[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 Hx(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 Gx(){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 Kx(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||ql.slice(0),t=e.preferHDR!==void 0?e.preferHDR:Gx(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function Vx(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}=Kx(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),b=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>b?(Xi(k,`min framerate of ${R.minFramerate} > maximum of ${b}`),A):p.some(x=>R.videoRanges[x]>0)?R.maxScore<m?(Xi(k,`max score of ${R.maxScore} < selected max of ${m}`),A):A&&(Wl(k)>=Wl(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 Wx(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 Yx(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 yi(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)||qx(i.characteristics||"",e.characteristics))&&(t===void 0||t(i,e))}function qx(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 jx(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=iv(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 yi(i,m,s)>-1});return c>-1?c:iv(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return yi(i,m,s)>-1})}function iv(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 Qh=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(),b=s.levels,_=b[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=b[C].maxBitrate;if(w=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[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=b[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)};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:Tl,extractHostnameAndDomain:ka,extractHostname:si,manifestParser:gS,generateShortID:y0,generateUUID:La,now:tt.now,findMediaElement:vl},ES=vS,bS={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"},TS=bS,yS="mux-embed",_S="5.9.0",AS="2.1",Je={},br=function(i){var e=arguments;typeof i=="string"?br.hasOwnProperty(i)?Ra.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),br[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Ra.default.setTimeout(function(){i(br)},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(br,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(br,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:TS,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(br,SS);typeof Ra.default!="undefined"&&typeof Ra.default.addEventListener=="function"&&Ra.default.addEventListener("pagehide",function(i){i.persisted||(br.WINDOW_UNLOADING=!0)},!1);var _l=br;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 bh(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},Th;function XS(){if(!navigator.userAgent.includes("PlayStation 4"))return!Th&&typeof self.TextDecoder!="undefined"&&(Th=new self.TextDecoder("utf-8")),Th}var Ti={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+="."+bi(o)+"."+bi(l);break}case"vp09":{let a=he(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+bi(o)+"."+bi(l)+"."+bi(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+"."+bi(l)+d+"."+bi(h)+"."+f+"."+m+p+g+"."+bi(1)+"."+bi(1)+"."+bi(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 bi(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: ${Ti.hexDump(m)} -> ${Ti.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,b=0,_=(p&16)!==0,A=0,k=(p&32)!==0,R=8;m===n&&(g&&(R+=8),v&&(R+=4),y&&(b=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=b,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,b=new Uint8Array(y);if(v){b[0]=p;for(let _=1;_<y;_++)b[_]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}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=Ti.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 bx=/flac|opus/i;function ql(i,e=!0){return i.replace(bx,t=>Ex(t.toLowerCase(),e))}function $0(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function Tx(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 b=i.findGroup(c,y.groupId)||c[0];Y0(y,b,"audioCodec"),Y0(y,b,"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,b=-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]),b===-1&&(b=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,b>0&&Sx(l,b),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(b=>!b.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 b=Object.keys(h.attr);for(let _=0;_<b.length;_++){let A=b[_];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),b=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||b&&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,b=s.lastPartIndex,_=b!==-1,A=v===y,k=g?0:b;_?(d=A?y+1:v,u=A?k:b+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),b=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>b?(Xi(k,`min framerate of ${R.minFramerate} > maximum of ${b}`),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(),b=s.levels,_=b[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=b[C].maxBitrate;if(w=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[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=b[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 Xh(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],b=!!(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=Wx(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=Yx(m,w,t,r)),q=Vx(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"&&Bx(q,w,k,R,e,x)?(q.supportedPromise=$x(q,w,Ke),q.supportedPromise.then(Ye=>{if(!this.hls)return;q.supportedResult=Ye;let ze=this.hls.levels,St=ze.indexOf(q);Ye.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${Ye.error}" for level ${St} ${JSON.stringify(Ye)}`):Ye.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${St} ${JSON.stringify(Ye)}`),St>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${St}`),this.hls.removeLevel(St)))})):q.supportedResult=Wv}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)||b&&!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)}},Zh=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"},Jh=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),Il(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&&Il(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||Il(t))}getState(e){let t=ln(e),r=this.fragments[t];return r?r.buffered?Il(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 Il(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=Ll(),this.buffering={audio:Ll(),video:Ll(),audiovideo:Ll()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function Ll(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Nl(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 Xx(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function Qx(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){L.log("No fragments to align");return}let s=Nl(t,r[0].cc);if(!s||s&&!s.startPTS){L.log("No frag in previous level to align on");return}return s}function rv(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Yv(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)rv(t[r],i);e.fragmentHint&&rv(e.fragmentHint,i),e.alignedSliding=!0}function Zx(i,e,t){e&&(Jx(i,t,e),!t.alignedSliding&&e&&Zl(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Hv(e,t))}function Jx(i,e,t){if(Xx(i,t,e)){let r=Qx(t,e);r&&j(r.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Yv(r.start,e))}}function Zl(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=Nl(r,a),n=Nl(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Nl(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);Yv(d,i)}var sv=Math.pow(2,17),ef=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 oi({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(av(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=nv(e),c=ev(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:sv};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 oi({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 oi({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 oi({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(av(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=nv(e,t),c=ev(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:sv};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 oi({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 oi({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 oi({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 nv(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 av(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 oi(r)}var oi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},tf=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)}},rf=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 eR(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ms(i,0,e-t):i}var sf=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],b=f[y],_=f[b],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^b*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,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?u[l]=b:u[l]=m[c[b>>>24]]^p[c[b>>>16&255]]^g[c[b>>>8&255]]^v[c[b&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),b,_,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++)b=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=b,x=_,O=A,w=k,z=z+4;b=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(b^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}},tR=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?eR(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 sf),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 rf(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new tf(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%tR;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)}},iR={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 Zh{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 ef(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?iR.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=Z0(r,e.sn,c.index+1)||Gv(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?Z0(o,n,a):null,d=l?l.fragment:Mx(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=Px(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=Fx(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=Ql(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;Zx(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=Xf(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:$v(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}},Jl=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=rR(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function rR(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 sR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function nR(){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 aR(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Ti(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?zf(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&j(l))&&(this.basePTS=oR(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:li.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 $S(e,s)?(r=Oa(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:li.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:Ti(),id3Track:o,textTrack:Ti()}}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:Ti(),id3Track:this._id3Track,textTrack:Ti()}}destroy(){}},oR=(i,e,t)=>{if(j(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function lR(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 qv(i,e){return i[e]===255&&(i[e+1]&246)===240}function jv(i,e){return i[e+1]&1?7:9}function Qf(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function dR(i,e){return e+5<i.length}function ed(i,e){return e+1<i.length&&qv(i,e)}function uR(i,e){return dR(i,e)&&qv(i,e)&&Qf(i,e)<=i.length-e}function cR(i,e){if(ed(i,e)){let t=jv(i,e);if(e+t>=i.length)return!1;let r=Qf(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||ed(i,s)}return!1}function zv(i,e,t,r,s){if(!i.samplerate){let n=lR(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 Xv(i){return 1024*9e4/i}function hR(i,e){let t=jv(i,e);if(e+t<=i.length){let r=Qf(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Qv(i,e,t,r,s){let n=Xv(i.samplerate),a=r+s*n,o=hR(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 kl=null,fR=[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],mR=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],pR=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],gR=[0,1,1,4];function Zv(i,e,t,r,s){if(t+24>e.length)return;let n=Jv(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 Jv(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=fR[l*14+s-1]*1e3,c=mR[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=pR[t][r],m=gR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(kl===null){let b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);kl=b?parseInt(b[1]):0}return!!kl&&kl<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function Zf(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function eE(i,e){return e+1<i.length&&Zf(i,e)}function vR(i,e){return Zf(i,e)&&4<=i.length-e}function tE(i,e){if(e+1<i.length&&Zf(i,e)){let r=Jv(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||eE(i,n)}return!1}var nf=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(tE(e,r))return!1;for(let s=e.length;r<s;r++)if(cR(e,r))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return uR(e,t)}appendFrame(e,t,r){zv(e,this.observer,t,r,e.manifestCodec);let s=Qv(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},ER=/\/emsg[-/]ID3/i,af=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=Ti("video",1),a=this.audioTrack=Ti("audio",1),o=this.txtTrack=Ti("text",1);if(this.id3Track=Ti("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=Cv(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=kv.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=rx(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=O0(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=O0(e,t),{videoTrack:t,audioTrack:Ti(),id3Track:s,textTrack:Ti()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=he(e.samples,["emsg"]);s&&s.forEach(n=>{let a=ax(n);if(ER.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:li.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},iE=(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},of=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=rE(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&&zf(t)!==void 0&&iE(e,r)<16}};function rE(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]),b=1536/o*9e4,_=r+s*b,A=e.subarray(t,t+u);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:_}),u}var lf=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)}},td=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(),b=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-_)*(b+1)*16-(_?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},df=class extends lf{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 td(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,Ov(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,v=new td(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),b="avc1.";for(let _=0;_<3;_++){let A=y[_].toString(16);A.length<2&&(A="0"+A),b+=A}e.codec=b}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}},uf=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=Pv(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,cf=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 df}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=hf(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:kv[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,b=e.length;if(this.remainderData&&(e=qt(this.remainderData,e),b=e.length,this.remainderData=null),b<ht&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));b-=(b-_)%ht,b<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let A=0;for(let R=_;R<b;R+=ht)if(e[R]===71){let x=!!(e[R+1]&64),O=hf(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=bR(e,C);break;case y:{x&&(C+=e[C]+1);let P=TR(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&&id(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 uf(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&&!ed(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",id(this.observer,new Error(c),h),!h)return}zv(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=Xv(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=Qv(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!ed(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(eE(r,a)){let l=Zv(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=rE(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=tt({},t,{type:this._videoTrack?li.emsg:li.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function hf(i,e){return((i[e+1]&31)<<8)+i[e+2]}function bR(i,e){return(i[e+10]&31)<<8|i[e+11]}function TR(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=hf(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){Rh("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){Rh("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){Rh("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 id(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return id(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function id(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 Rh(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 ff=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&&zf(t)!==void 0&&iE(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(tE(e,r))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return vR(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Zv(e,t,r,this.basePTS,this.frameIndex)}},rd=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 sE=9e4;function Jf(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function yR(i,e,t=1,r=!1){return Jf(i,e,1/t,r)}function wa(i,e=!1){return Jf(i,1e3,1/sE,e)}function _R(i,e=1){return Jf(i,sE,1/e)}var AR=10*1e3,ov=1024,SR=1152,xR=1536,un=null,Ih=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(Ih===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);Ih=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,b=t.samples.length,_=e.samples.length>0,A=o&&b>0||b>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=RR(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,P>0){L.warn(`[mp4-remuxer]: Dropped ${P} out of ${b} 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 ${b} 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=nE(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=aE(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 b=m-f,_=b?Math.round(b/(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 St=pe[Ye],vr=St.data,rn=St.data.byteLength;w.setUint32(c,rn),c+=4,O.set(vr,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 St=Math.floor(Ye.maxBufferHole*n),vr=(s?p+s*n:this.nextAudioPts)-G.pts;vr>St?(h=vr-ze,h<0?h=ze:C=!0,L.log(`[mp4-remuxer]: It is approximately ${vr/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 sd(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(Ih&&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,tt({},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 SR;case"ac3":return xR;default:return ov}}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,b=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-b,y)-v)<20*u),p.forEach(function(q){q.pts=Yt(q.pts-b,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<AR&&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=rd.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 sd(!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,tt({},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*ov,m=Math.ceil((h-c)/f),p=rd.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 RR(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function nE(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 aE(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 sd=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}}},mf=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(ZS(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=Cv(e);s.audio&&(t=lv(s.audio,we.AUDIO)),s.video&&(r=lv(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=ex(h,m),g=JS(m,h),v=g===null?n:g;(IR(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,b=y+p;ix(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(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:b,endDTS:b,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=nE(r,n,d,d),s.samples.length&&(c.text=aE(s,n,d)),c}};function IR(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 lv(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 Yl(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 Ul=[{demux:af,remux:mf},{demux:cf,remux:fn},{demux:nf,remux:fn},{demux:ff,remux:fn}];Ul.splice(2,0,{demux:of,remux:fn});var nd=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:b}=l,_=LR(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(),Lh(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(),Lh(r)}(u||c||m||A)&&this.resetInitSegment(b,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(),[Lh(e)];let u=l.flush(o);return Fl(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=Ul.length;h<f;h++){var o;if((o=Ul[h].demux)!=null&&o.probe(e)){a=Ul[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 LR(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 Lh=i=>({remuxResult:{},chunkMeta:i});function Fl(i){return"then"in i&&i.then instanceof Function}var pf=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}},gf=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}},oE={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,b;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(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var _=g.length,A;for(b=0;b<_;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),v){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].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[b].fn.apply(g[b].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})(oE);var kR=oE.exports,em=_S(kR),ad=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 em,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||sR())){try{n.workerPath?(L.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=aR(n.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=nR()),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 nd(this.observer,l,n,"",t)}return}this.transmuxer=new nd(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),b=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),k=!y&&(b===1||b===0&&(_===1||A&&_<=0)),R=self.performance.now();(y||b||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 gf(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],b=!!(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)||b&&!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],b=f[y],_=f[b],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^b*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,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?u[l]=b:u[l]=m[c[b>>>24]]^p[c[b>>>16&255]]^g[c[b>>>8&255]]^v[c[b&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),b,_,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++)b=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=b,x=_,O=A,w=k,z=z+4;b=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(b^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]],bR=[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=bR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(wl===null){let b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);wl=b?parseInt(b[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 TR(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]),b=1536/o*9e4,_=r+s*b,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(),b=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-_)*(b+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),b="avc1.";for(let _=0;_<3;_++){let A=y[_].toString(16);A.length<2&&(A="0"+A),b+=A}e.codec=b}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,b=e.length;if(this.remainderData&&(e=qt(this.remainderData,e),b=e.length,this.remainderData=null),b<ht&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let _=Math.max(0,i.syncOffset(e));b-=(b-_)%ht,b<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let A=0;for(let R=_;R<b;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 TR(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}}},Tr=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/(Tr+1)),s=Math.floor(t%(Tr+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/(Tr+1)),s=Math.floor(t%(Tr+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/(Tr+1)),o=Math.floor(r%(Tr+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/(Tr+1)),a=Math.floor(t%(Tr+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,b=t.samples.length,_=e.samples.length>0,A=o&&b>0||b>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 ${b} 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 ${b} 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 b=m-f,_=b?Math.round(b/(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,b=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-b,y)-v)<20*u),p.forEach(function(q){q.pts=Yt(q.pts-b,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,b=y+p;nx(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(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:b,endDTS:b,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:b}=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(b,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,b;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(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var _=g.length,A;for(b=0;b<_;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),v){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].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[b].fn.apply(g[b].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),b=g?d.sn-g.sn:-1,_=this.part?d.part-this.part.index:-1,A=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),k=!y&&(b===1||b===0&&(_===1||A&&_<=0)),R=self.performance.now();(y||b||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 pf(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);Fl(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);Fl(r)||t.async?(Fl(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)}},dv=100,vf=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(dv),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);jh(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 b=u&&v.start>u.end+o.targetduration;if(b||!(u!=null&&u.len)&&d.len){let _=this.getAppendedFrag(v.start,se.MAIN);if(_===null||(y||(y=!!_.gap||!!b&&u.len===0),b&&!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 yr(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(dv):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)Zl(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 ad(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 Jl,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:b}=h;d&&(d.elementaryStreams[we.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(we.AUDIO,g,v,y,b),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=tt({id:r,frag:l,details:c},m);s.trigger(E.FRAG_PARSING_METADATA,g)}if(f){let g=tt({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&&Zl(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 lE(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 Ef(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var bf=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=yi(l,o,cs);if(h>-1)n=o[h];else{let f=yi(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=yi(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=jx(e,t.levels,r,a,cs);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=yi(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})}}},uv=500,Tf=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(uv),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&&lE(this.levels,t)){this.levels=t.map(r=>new yr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new yr(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(uv)}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?(Zl(a,c),d=a.fragments[0].start):h&&(d=h.start,qh(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,qh(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&&(Ql(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=Ql(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 yf(this.tracksBuffered[this.currentTrackId]||[])}},yf=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)}}}},_f=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=Ol(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),Ol(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=yi(o,a);if(u>-1)n=a[u];else{let c=yi(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(Ef(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=yi(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=yi(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=Ol(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>Ef(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)}},Af=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]}},cv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Sf=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=fx(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 Af(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,hv(r),wR(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&&hv(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=F0(l.codec,l.levelCodec),p=m==null?void 0:m.replace(cv,"$1"),g=F0(u,c),v=(o=g)==null?void 0:o.replace(cv,"$1");if(g&&p!==v){a.slice(0,5)==="audio"&&(g=Yl(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 b=this.sourceBuffer[o];if(b){let _=v-b.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${_}) sn: ${l.sn})`),b.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let b=self.performance.now();c.executeEnd=c.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);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:b=>{let _={type:ne.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:b,err:b,fatal:!1};if(b.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=Yl(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 hv(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function wR(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var DR={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},dE=i=>String.fromCharCode(DR[i]||i),ai=15,Qi=100,CR={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},MR={17:2,18:4,21:6,22:8,23:10,19:13,20:15},OR={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},PR={25:2,26:4,29:6,30:8,31:10,27:13,28:15},NR=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],xf=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},od=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}},Rf=class{constructor(){this.uchar=" ",this.penState=new od}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()}},If=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new od,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Qi;t++)this.chars.push(new Rf);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=dE(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=ai-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<ai;t++)this.rows.push(new If(e));this.logger=e}reset(){for(let e=0;e<ai;e++)this.rows[e].clear();this.currRow=ai-1}equals(e){let t=!0;for(let r=0;r<ai;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<ai;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<ai;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<ai;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<ai;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}},ld=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[ai-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[ai-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))}},dd=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=FR(),this.logger=void 0;let s=this.logger=new xf;this.channels=[null,new ld(e,t,s),new ld(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(UR(s,n,l)){wl(null,null,l),this.logger.log(3,()=>"Repeated command ("+ds([s,n])+") is dropped");continue}wl(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 wl(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?CR[e]:OR[e]:r=a===1?MR[e]:PR[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 '"+dE(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=NR[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()}wl(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 wl(i,e,t){t.a=i,t.b=e}function UR(i,e,t){return t.a===i&&t.b===e}function FR(){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}},tm=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="",b=!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 b},set:function(w){b=!!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}(),Lf=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function uE(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 kf=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 cE(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 wf=new tm(0,0,""),Dl=wf.align==="middle"?"middle":"center";function BR(i,e,t){let r=i;function s(){let o=uE(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 kf;cE(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",Dl,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Dl,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Dl,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&wf.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",Dl);let c=d.get("position","auto");c==="auto"&&wf.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 hE(i){return i.replace(/<br(?: \/)?>/gi,`
|
|
31
|
-
`)}var
|
|
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,bf=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 b=u&&v.start>u.end+o.targetduration;if(b||!(u!=null&&u.len)&&d.len){let _=this.getAppendedFrag(v.start,se.MAIN);if(_===null||(y||(y=!!_.gap||!!b&&u.len===0),b&&!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:b}=h;d&&(d.elementaryStreams[we.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(we.AUDIO,g,v,y,b),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 Tf(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(Tf(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=>Tf(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 b=this.sourceBuffer[o];if(b){let _=v-b.timestampOffset;Math.abs(_)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${_}) sn: ${l.sn})`),b.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let b=self.performance.now();c.executeEnd=c.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);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:b=>{let _={type:ne.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:b,err:b,fatal:!1};if(b.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="",b=!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 b},set:function(w){b=!!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,`
|
|
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
|
-
`&&++a,t.buffer=n.slice(a),o}function s(n){
|
|
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+=`
|
|
34
34
|
`),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
35
35
|
|
|
36
|
-
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}
|
|
36
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},KR=/\r\n|\n\r|\n|\r/g,Dh=function(e,t,r=0){return e.slice(r,r+t.length)===t},VR=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!j(t)||!j(r)||!j(s)||!j(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},Ch=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function sm(i,e,t){return Ch(i.toString())+Ch(e.toString())+Ch(t)}var WR=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function YR(i,e,t,r,s,n,a){let o=new Mf,l=Ai(new Uint8Array(i)).trim().replace(KR,`
|
|
37
37
|
`).split(`
|
|
38
|
-
`),d=[],u=e?
|
|
39
|
-
`)}),o.flush()}var
|
|
40
|
-
`:(n=r.childNodes)!=null&&n.length?pE(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function YR(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=Mh(e,r,l)||Mh(i,r,l)||Mh(s,r,l);return d&&(o[l]=d),o},{})}function Mh(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function pv(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Oh(i,e){if(!i)return null;let t=uE(i);return t===null&&(fE.test(i)?t=qR(i,e):mE.test(i)&&(t=jR(i,e))),t}function qR(i,e){let t=fE.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 jR(i,e){let t=mE.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 Cf=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=vv(),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 dd(1,e,t),this.cea608Parser2=new dd(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(gv(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]),Fv(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=vv(),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===Dh);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(lE(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?Ol(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]&&gv(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)cn(u);else{let c=gE(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===Dh?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;fv(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;KR(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||fv(t,this.initPTS[e.cc],()=>{r.textCodec=Dh,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=>Bv(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=>Gh(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Gh(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 gE(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function gv(i,e){return!!i&&i.kind===gE(e)&&Ef(e,i)}function zR(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function vv(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Mf=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}},Of=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)}},Cl="[eme]",ud=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,Cl),this.log=L.log.bind(L,Cl),this.warn=L.warn.bind(L,Cl),this.error=L.error.bind(L,Cl),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=Al(this.config));let o=a.map(vh).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o=ph(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=qf(JSON.parse(m).sinf),g=Mv(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=dx(s),p=m.filter(v=>!!v.systemId&&gh(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=>gh(v.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(d=gh(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=xv(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=vh(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 Sv===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=FS(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=Al(this.config),n=e.map(ph).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=vh(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=ph(e.keyFormat),n=s?[s]:Al(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Al(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 em,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,Bh("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 Bh(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}`)})}}};ud.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}},_t;(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"})(_t||(_t={}));var Pf;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(Pf||(Pf={}));var fs;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(fs||(fs={}));var XR={[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}},cd=class{constructor(e){this.description=void 0,this.description=e}},QR="Dict";function ZR(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 JR(i,e,t,r){return new Error(`failed to ${i} "${ZR(e)}" as ${t}`,{cause:r})}var Ev="Bare Item",eI="Boolean",tI="Byte Sequence",iI="Decimal",rI="Integer";function sI(i){return i<-999999999999999||999999999999999<i}var nI=/[\x00-\x1f\x7f]+/,aI="Token",oI="Key";function Ai(i,e,t){return JR("serialize",i,e,t)}function lI(i){if(typeof i!="boolean")throw Ai(i,eI);return i?"?1":"?0"}function dI(i){return btoa(String.fromCharCode(...i))}function uI(i){if(ArrayBuffer.isView(i)===!1)throw Ai(i,tI);return`:${dI(i)}:`}function vE(i){if(sI(i))throw Ai(i,rI);return i.toString()}function cI(i){return`@${vE(i.getTime()/1e3)}`}function EE(i,e){if(i<0)return-EE(-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 hI(i){let e=EE(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Ai(i,iI);let t=e.toString();return t.includes(".")?t:`${t}.0`}var fI="String";function mI(i){if(nI.test(i))throw Ai(i,fI);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function pI(i){return i.description||i.toString().slice(7,-1)}function bv(i){let e=pI(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Ai(e,aI);return e}function Nf(i){switch(typeof i){case"number":if(!j(i))throw Ai(i,Ev);return Number.isInteger(i)?vE(i):hI(i);case"string":return mI(i);case"symbol":return bv(i);case"boolean":return lI(i);case"object":if(i instanceof Date)return cI(i);if(i instanceof Uint8Array)return uI(i);if(i instanceof cd)return bv(i);default:throw Ai(i,Ev)}}function Uf(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Ai(i,oI);return i}function rm(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${Uf(e)}`:`;${Uf(e)}=${Nf(t)}`).join("")}function bE(i){return i instanceof Ka?`${Nf(i.value)}${rm(i.params)}`:Nf(i)}function gI(i){return`(${i.value.map(bE).join(" ")})${rm(i.params)}`}function vI(i,e={whitespace:!0}){if(typeof i!="object")throw Ai(i,QR);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=Uf(s);return n.value===!0?a+=rm(n.params):(a+="=",Array.isArray(n.value)?a+=gI(n):a+=bE(n)),a}).join(`,${r}`)}function EI(i,e){return vI(i,e)}var bI=i=>i==="ot"||i==="sf"||i==="st",TI=i=>typeof i=="number"?j(i):i!=null&&i!==""&&i!==!1;function yI(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 _I(){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 Bl=i=>Math.round(i),AI=(i,e)=>(e!=null&&e.baseUrl&&(i=yI(i,e.baseUrl)),encodeURIComponent(i)),Ml=i=>Bl(i/100)*100,SI={br:Bl,d:Bl,bl:Ml,dl:Ml,mtp:Ml,nor:AI,rtp:Ml,tb:Bl};function xI(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=tt({},SI,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||TI(o)&&(bI(a)&&typeof o=="string"&&(o=new cd(o)),t[a]=o))}),t}function TE(i,e={}){return i?EI(xI(i,e),tt({whitespace:!1},e)):""}function RI(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(XR).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]=TE(o,e),n),{})}function II(i,e,t){return tt(i,RI(e,t))}var LI="CMCD";function kI(i,e={}){if(!i)return"";let t=TE(i,e);return`${LI}=${encodeURIComponent(t)}`}var Tv=/CMCD=[^&#]+/;function wI(i,e,t){let r=kI(e,t);if(!r)return i;if(Tv.test(i))return i.replace(Tv,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var Ff=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:_t.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===_t.VIDEO||o===_t.AUDIO||o==_t.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||_I(),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:Pf.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){tt(t,this.createData());let r=t.ot===_t.INIT||t.ot===_t.VIDEO||t.ot===_t.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={}),II(e.headers,t)):e.url=wI(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return _t.TIMED_TEXT;if(e.sn==="initSegment")return _t.INIT;if(t==="audio")return _t.AUDIO;if(t==="main")return this.hls.audioTracks.length?_t.VIDEO:_t.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===_t.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===_t.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)}}}},DI=3e5,Bf=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===ni.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]>DI&&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,Kv(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=yE(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new yr({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),yv(this.audioTracks,r,l,a),yv(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 yv(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=tt({},a);return o.details=void 0,o.attrs=new qe(o.attrs),o.url=o.attrs.URI=yE(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 yE(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 CI=/^age:\s*[\d.]+\s*$/im,hd=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};Xl(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(Xl(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=Xf(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&&CI.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 MI(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var OI=/(\d+)-(\d+)\/(\d+)/,fd=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||FI,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=PI(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 $f(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=UI(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 Jl,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 PI(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(tt({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function NI(i){let e=OI.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function UI(i){let e=i.get("Content-Range");if(e){let r=NI(e);if(j(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function FI(i,e){return new self.Request(i.url,e)}var $f=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},BI=/\s/,$I={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++)BI.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=hE(d.trim()),m=im(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=>Bv(i,h))),s}},HI={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},_E=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:hd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Qh,bufferController:Sf,capLevelController:Mf,errorController:zh,fpsController:Of,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:Sv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:HI},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},GI()),{},{subtitleStreamController:Tf,subtitleTrackController:_f,timelineController:Cf,audioStreamController:vf,audioTrackController:bf,emeController:ud,cmcdController:Ff,contentSteeringController:Bf});function GI(){return{cueHandler:$I,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 KI(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=Hf(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 Hf(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Hf):Object.keys(i).reduce((e,t)=>(e[t]=Hf(i[t]),e),{}):i}function VI(i){let e=i.loader;e!==fd&&e!==hd?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):MI()&&(i.loader=fd,i.progressive=!0,i.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ph,Gf=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&&(Ph||(Ph=/chrome|firefox/i.test(navigator.userAgent)),Ph&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Yl(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=vx(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&&!yh(m,"audio",r)||p&&!yh(p,"video",r))return;let{CODECS:b,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":k,RESOLUTION:R,"VIDEO-RANGE":x}=f,w=`${`${k||"."}-`}${u.bitrate}-${R}-${_}-${b}-${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 yr(u);n[w]=P,s.push(P)}else n[w].addGroupId("audio",f.AUDIO),n[w].addGroupId("text",f.SUBTITLES);else{let C=new yr(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))&&Ix(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||yh(p.audioCodec,"audio",m)),_v(a)}t.subtitles&&(o=t.subtitles,_v(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 ql.indexOf(m.videoRange)-ql.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=U0(m.videoCodec),v=U0(p.videoCodec);if(g!==v)return v-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=Wl(m.codecSet),v=Wl(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===_E.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));Kv(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 _v(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Kf=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 oi({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 AE(){return self.SourceBuffer||self.WebKitSourceBuffer}function SE(){if(!gs())return!1;let e=AE();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function WI(){if(!SE())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 YI(){var i;let e=AE();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var qI=250,$l=2,jI=.1,zI=.05,Vf=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>$l,v=!c||t&&t.start<=a||c-a>$l&&!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:$l,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>=qI&&(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+jI);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})}}},XI=100,Wf=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(XI),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 Vf(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&&!YI(),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 ad(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 b=l.initSegment||l;this._bufferInitSegment(u,m.tracks,b,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:b,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,b=!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&&!b&&(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&&!b){this.backtrack(l);return}else b&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,R,!0)}else y&&_>$l&&(l.gap=!0);l.setElementaryStreamInfo(c.type,_,A,k,R),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,y||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:v,endPTS:y,startDTS:b,endDTS:_}=g;d&&(d.elementaryStreams[we.AUDIO]={startPTS:v,endPTS:y,startDTS:b,endDTS:_}),l.setElementaryStreamInfo(we.AUDIO,v,y,b,_),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 SE()}static isSupported(){return WI()}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:_E}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 em,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,wS(e.debug||!1,"Hls instance");let t=this.config=KI(i.DefaultConfig,e);this.userConfig=e,t.progressive&&VI(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 Hh(this),m=new Vh(this),p=t.contentSteeringController,g=p?new p(this):null,v=this.levelController=new Gf(this,g),y=new Jh(this),b=new Kf(this.config),_=this.streamController=new Wf(this,y,b);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,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let x=t.subtitleStreamController;x&&A.push(new x(this,y,b)),this.createController(t.timelineController,k),b.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(Wh,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=Yf.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){Rx(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 be=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,_r=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:"")}};_r.MEDIA_ERR_ABORTED=1,_r.MEDIA_ERR_NETWORK=2,_r.MEDIA_ERR_DECODE=3,_r.MEDIA_ERR_SRC_NOT_SUPPORTED=4,_r.MEDIA_ERR_ENCRYPTED=5,_r.MEDIA_ERR_CUSTOM=100,_r.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=_r,QI=i=>i==null,hm=(i,e)=>QI(e)?!1:i in e,am={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"},om={HLS:Ji.M3U8},EM=Object.keys(om),bM=[...Object.values(Ji),"hls","HLS"];var ZI="en",lm={code:ZI},it=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function JI(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]},Td=i=>{let{type:e}=i;if(e){let t=e.toUpperCase();return hm(t,om)?om[t]:e}return eL(i)},OE=i=>i==="VOD"?Se.ON_DEMAND:Se.LIVE,PE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,eL=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 iL(i)?Ji.M3U8:"";let s=t.slice(r+1).toUpperCase();return hm(s,Ji)?Ji[s]:""},tL="mux.com",iL=({src:i,customDomain:e=tL})=>{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}},rL=({exp:i},e=Date.now())=>!i||i*1e3<e,sL=({sub:i},e)=>i!==e,nL=({aud:i},e)=>!i,aL=({aud:i},e)=>i!==e,NE="en";function Q(i,e=!0){var t,r;let s=e&&(r=(t=lm)==null?void 0:t[i])!=null?r:i,n=e?lm.code:NE;return new oL(s,n)}var oL=class{constructor(i,e=(t=>(t=lm)!=null?t:NE)()){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}},lL=Object.values(am),xE=i=>typeof i=="boolean"||typeof i=="string"&&lL.includes(i),dL=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=xE(r)?r:!!r,o=()=>{s||it(e,"playing",()=>{s=!0},{once:!0})};if(o(),it(e,"loadstart",()=>{s=!1,o(),sm(e,a)},{once:!0}),it(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==Se.UNKNOWN?n=i.streamType===Se.LIVE:n=!Number.isFinite(e.duration)),sm(e,a)},{once:!0}),t&&t.once(be.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&&it(e,"play",()=>{e.preload==="metadata"?t.once(be.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=xE(l)?l:!!l,sm(e,a))}},sm=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case am.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case am.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},uL=({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 it(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function cL(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(be.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(be.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(be.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(be.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(be.Events.BUFFER_FLUSHING,h),c||e.trigger(be.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(be.Events.DESTROYING,l)}var nm=i=>"time"in i?i.time:i.startTime;function hL(i,e){e.on(be.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}`;yd(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(be.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(be.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(be.Events.MANIFEST_LOADED,r),e.once(be.Events.MEDIA_ATTACHED,r)}function yd(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 UE(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 FE(i,e,t,r){let s=ja(i,t,r);return s||(s=yd(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)=>nm(a)-nm(n)).forEach(n=>{var a,o;let l=n.value,d=nm(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 fm="cuepoints",BE=Object.freeze({label:fm});async function mm(i,e,t=BE){return FE(i,e,t.label,"metadata")}var dm=i=>({time:i.startTime,value:JSON.parse(i.text)});function $E(i,e={label:fm}){let t=ja(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>dm(r)):[]}function pm(i,e={label:fm}){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 dm(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 dm(a||s.activeCues[0])}async function fL(i,e=BE){return new Promise(t=>{it(i,"loadstart",async()=>{let r=await mm(i,[],e);it(i,"cuechange",()=>{let s=pm(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var gm="chapters",HE=Object.freeze({label:gm}),um=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function vm(i,e,t=HE){return FE(i,e,t.label,"chapters")}function GE(i,e={label:gm}){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=>um(s)):[]}function Em(i,e={label:gm}){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 um(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 um(a||s.activeCues[0])}async function mL(i,e=HE){return new Promise(t=>{it(i,"loadstart",async()=>{let r=await vm(i,[],e);it(i,"cuechange",()=>{let s=Em(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function KE(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 VE(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"},pL=i=>{if(i===Ne.VIDEO)return gn.VIDEO;if(i===Ne.DRM)return gn.DRM},gL=(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]:hm(n,e)?e[n]:void 0},vd=(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,b=K.MEDIA_ERR_NETWORK,_=new K(v,b,!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=gL(e,t),f=pL(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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_MALFORMED,b.data=i,b}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(rL(p,d)){let v={timeStyle:"medium",dateStyle:"medium"},y=Q("The video\u2019s secured {tokenNamePrefix}-token has expired.",s).format({tokenNamePrefix:c}),b=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,b);return _.errorCategory=e,_.muxCode=J.NETWORK_TOKEN_EXPIRED,_.data=i,_}if(sL(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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_SUB_MISMATCH,b.data=i,b}if(nL(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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_AUD_MISSING,b.data=i,b}if(aL(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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_AUD_MISMATCH,b.data=i,b}}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_MISSING,b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_NOT_READY,b.streamType=t.streamType===Se.LIVE?"live":t.streamType===Se.ON_DEMAND?"on-demand":"unknown",b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_NOT_FOUND,b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_INVALID_URL,b.data=i,b}let g=new K("",u,r!=null?r:!0);return g.errorCategory=e,g.muxCode=J.NETWORK_UNKNOWN_ERROR,g.data=i,g},RE=be.DefaultConfig.capLevelController,WE=class YE extends RE{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=YE.minMaxResolution;return s>=n?t:RE.getMaxLevelByMediaSize(r,n*(16/9),n)}};WE.minMaxResolution=720;var vL=WE,EL=vL,pd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},bL=i=>{if(i.includes("fps"))return pd.FAIRPLAY;if(i.includes("playready"))return pd.PLAYREADY;if(i.includes("widevine"))return pd.WIDEVINE},TL=async i=>fetch(i).then(e=>e.status!==200?Promise.reject(e):e.text()).then(e=>{let t=e.split(`
|
|
42
|
-
`).find((r,s
|
|
43
|
-
`))}),yL=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=OE(s),a=PE(s),o;if(n===Se.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u!=null?u:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},_L=async(i,e)=>{if(e===Ji.MP4)return{streamType:Se.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Ji.M3U8){let t=await TL(i);return yL(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},AL=async(i,e,t=Td({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await _L(i,t);((r=rt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=rt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=rt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},SL=i=>{var e;let t=i.type,r=OE(t),s=PE(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}},xL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=SL(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=rt.get(e))!=null?o:{}).seekable=p}((l=rt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=rt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=rt.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},IE,LE,RL=(LE=(IE=globalThis==null?void 0:globalThis.navigator)==null?void 0:IE.userAgent)!=null?LE:"",kE,wE,DE,IL=(DE=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgentData)==null?void 0:wE.platform)!=null?DE:"",LL=RL.toLowerCase().includes("android")||["x11","android"].some(i=>IL.toLowerCase().includes(i)),rt=new WeakMap,Ar="mux.com",CE,ME,qE=(ME=(CE=be).isSupported)==null?void 0:ME.call(CE),kL=LL,_d=()=>yl.utils.now(),wL=yl.utils.generateUUID,za=({playbackId:i,customDomain:e=Ar,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()},Ad=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},bm=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},DL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:tb(i)&&(r=(t=Ad(i.playbackId))!=null?t:bm(i.src))!=null?r:i.src},Tm=i=>{var e;return(e=rt.get(i))==null?void 0:e.error},Ed=i=>{var e,t;return(t=(e=rt.get(i))==null?void 0:e.streamType)!=null?t:Se.UNKNOWN},jE=i=>{var e,t;return(t=(e=rt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},Sd=i=>{var e,t;return(t=(e=rt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},zE=i=>{var e;let t=(e=rt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Sd(i);return r.length?r.end(r.length-1)-t:Number.NaN},ym=.034,CL=(i,e,t=ym)=>Math.abs(i-e)<=t,XE=(i,e,t=ym)=>i>e||CL(i,e,t),ML=(i,e=ym)=>i.paused&&XE(i.currentTime,i.duration,e),QE=(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},_m=(i,e)=>i.ended||i.loop?i.ended:e&&QE(i,e)?!0:ML(i),ZE=(i,e,t)=>{Am(e,t,i);let{metadata:r={}}=i,{view_session_id:s=wL()}=r,n=DL(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,rt.set(e,{retryCount:0});let o=OL(i,e),l=uL(i,e,o);i!=null&&i.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?be:void 0}):$L(i,e,o),HL(i,e,o),fL(e),mL(e);let d=dL(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},Am=(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",rb),i.removeEventListener("error",cm),i.removeEventListener("durationchange",ib),rt.delete(i),i.dispatchEvent(new Event("teardown")))};function JE(i,e){var t;let r=Td(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||!(qE&&(a||kL)))}var OL=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Td(i)===Ji.M3U8,d=JE(i,e);if(l&&!d&&qE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=PL(r),h=NL(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;return new be({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,v;if(a&&a!==Ya.QUERY)return;let y=new URL(p);if(!y.searchParams.has("CMCD"))return;let b=((v=(g=y.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?v:[]).filter(_=>_.startsWith("sid")||_.startsWith("cid")).join(",");y.searchParams.set("CMCD",b),m.open("GET",y)},capLevelController:EL,...u,...c,...h,...o})}},PL=i=>i===Se.LIVE?{backBufferLength:8}:{},NL=i=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:r}=i,s=Ad(t);return!e||!s?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:gd(i,"fairplay"),serverCertificateUrl:eb(i,"fairplay")},"com.widevine.alpha":{licenseUrl:gd(i,"widevine")},"com.microsoft.playready":{licenseUrl:gd(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=bL(n);return r==null||r(l),o}))}},UL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},FL=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)},BL=(i,e)=>{it(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,pd.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 UL(eb(i,"fairplay")).catch(c=>{if(c instanceof Response){let h=vd(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 FL(a,gd(i,"fairplay")).catch(l=>{if(l instanceof Response){let d=vd(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}})},gd=({playbackId:i,tokens:{drm:e}={},customDomain:t=Ar},r)=>{let s=Ad(i);return`https://license.${t.toLocaleLowerCase().endsWith(Ar)?t:Ar}/license/${r}/${s}?token=${e}`},eb=({playbackId:i,tokens:{drm:e}={},customDomain:t=Ar},r)=>{let s=Ad(i);return`https://license.${t.toLocaleLowerCase().endsWith(Ar)?t:Ar}/appcert/${r}/${s}?token=${e}`},tb=({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(Ar)||!!t&&s.includes(t.toLocaleLowerCase())},$L=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=yl,muxDataSDKOptions:o={}}=i,l=tb(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?be: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}})}},HL=(i,e,t)=>{var r,s;let n=JE(i,e),{src:a}=i,o=()=>{e.ended||!_m(e,t)||(QE(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},l,d,u=()=>{let c=Sd(e),h,f;c.length>0&&(h=c.start(0),f=c.end(0)),(d!==f||l!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),l=h,d=f};if(it(e,"durationchange",u),e&&n){let c=Td(i);if(typeof a=="string"){let h=()=>{if(Ed(e)!==Se.LIVE||Number.isFinite(e.duration))return;let m=setInterval(u,1e3);e.addEventListener("teardown",()=>{clearInterval(m)},{once:!0}),it(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(m)})},f=async()=>AL(a,e,c).then(h).catch(m=>{if(m instanceof Response){let p=vd(m,Ne.VIDEO,i);if(p){jt(e,p);return}}else m instanceof Error});if(e.preload==="none"){let m=()=>{f(),e.removeEventListener("loadedmetadata",p)},p=()=>{f(),e.removeEventListener("play",m)};it(e,"play",m,{once:!0}),it(e,"loadedmetadata",p,{once:!0})}else f();(r=i.tokens)!=null&&r.drm?BL(i,e):it(e,"encrypted",()=>{let m=Q("Attempting to play DRM-protected content without providing a DRM token."),p=new K(m,K.MEDIA_ERR_ENCRYPTED,!0);p.errorCategory=Ne.DRM,p.muxCode=J.ENCRYPTED_MISSING_TOKEN,jt(e,p)},{once:!0}),e.setAttribute("src",a),i.startTime&&(((s=rt.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",ib,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",rb),e.addEventListener("error",cm),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(h=>{h.remove()})},{once:!0}),it(e,"pause",o),it(e,"seeked",o),it(e,"play",()=>{e.ended||XE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(be.Events.LEVEL_LOADED,(c,h)=>{xL(h.details,e,t),u(),Ed(e)===Se.LIVE&&!Number.isFinite(e.duration)&&(t.on(be.Events.LEVEL_UPDATED,u),it(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(be.Events.LEVELS_UPDATED,u)}))}),t.on(be.Events.ERROR,(c,h)=>{var f,m;let p=GL(h,i);if(p.muxCode===J.NETWORK_NOT_READY){let g=(f=rt.get(e))!=null?f:{},v=(m=g.retryCount)!=null?m:0;if(v<6){let y=v===0?5e3:6e4,b=new K(`Retrying in ${y/1e3} seconds...`,p.code,p.fatal);Object.assign(b,p),jt(e,b),setTimeout(()=>{g.retryCount=v+1,h.details==="manifestLoadError"&&h.url&&t.loadSource(h.url)},y);return}else{g.retryCount=0;let y=new K('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',p.code,p.fatal);Object.assign(y,p),jt(e,y);return}}jt(e,p)}),t.on(be.Events.MANIFEST_LOADED,()=>{let c=rt.get(e);c&&c.error&&(c.error=null,c.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",cm),it(e,"waiting",o),cL(i,t),hL(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 ib(i){var e;let t=i.target,r=(e=rt.get(t))==null?void 0:e.startTime;if(r&&JI(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function rb(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=Tm(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=rt.get(i))!=null?t:{}).error=e,i.dispatchEvent(new CustomEvent("error",{detail:e})))}function cm(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof K))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=rt.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 GL=(i,e)=>{var t,r,s;console.error("getErrorFromHlsErrorData()",i);let n={[be.ErrorTypes.NETWORK_ERROR]:K.MEDIA_ERR_NETWORK,[be.ErrorTypes.MEDIA_ERROR]:K.MEDIA_ERR_DECODE,[be.ErrorTypes.KEY_SYSTEM_ERROR]:K.MEDIA_ERR_ENCRYPTED},a=u=>[be.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,be.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(u.details)?K.MEDIA_ERR_NETWORK:n[u.type],o=u=>{if(u.type===be.ErrorTypes.KEY_SYSTEM_ERROR)return Ne.DRM;if(u.type===be.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=vd(i.response,u,e,i.fatal))!=null?r:new K("",d,i.fatal)}else if(d===K.MEDIA_ERR_ENCRYPTED)if(i.details===be.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===be.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===be.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===be.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===be.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===be.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===be.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}
|
|
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,b=(h-u)/9e4;if(v!=null&&v.new&&(f!==void 0?y=t.ccOffset=v.start:WR(t,r,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=b-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
|
+
`)}),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")],b=zR(v,y,l),{textAlign:_}=b;if(_){let A=qR[_];A&&(g.lineAlign=A),g.align=_}return it(g,b),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=bv(),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=bv(),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)&&Tf(e,i)}function ZR(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function bv(){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(bh).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=Ti.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=Ti.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=bh(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: ${Ti.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 Ti.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Ti.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=bh(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: ${Ti.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Ti.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 Tv="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 bE(i){if(oI(i))throw Si(i,aI);return i.toString()}function mI(i){return`@${bE(i.getTime()/1e3)}`}function TE(i,e){if(i<0)return-TE(-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=TE(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,Tv);return Number.isInteger(i)?bE(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,Tv)}}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 bI(i){return`(${i.value.map(yE).join(" ")})${nm(i.params)}`}function TI(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+=bI(n):a+=yE(n)),a}).join(`,${r}`)}function yI(i,e){return TI(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:bf,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=Tx(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:b,"FRAME-RATE":_,"HDCP-LEVEL":A,"PATHWAY-ID":k,RESOLUTION:R,"VIDEO-RANGE":x}=f,w=`${`${k||"."}-`}${u.bitrate}-${R}-${_}-${b}-${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 b=l.initSegment||l;this._bufferInitSegment(u,m.tracks,b,a),s.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:b,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,b=!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&&!b&&(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&&!b){this.backtrack(l);return}else b&&(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||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:v,endPTS:y,startDTS:b,endDTS:_}=g;d&&(d.elementaryStreams[we.AUDIO]={startPTS:v,endPTS:y,startDTS:b,endDTS:_}),l.setElementaryStreamInfo(we.AUDIO,v,y,b,_),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),b=new Wf(this.config),_=this.streamController=new qf(this,y,b);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,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let x=t.subtitleStreamController;x&&A.push(new x(this,y,b)),this.createController(t.timelineController,k),b.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},AM=Object.keys(dm),SM=[...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 Td=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 bm(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 Tm(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 bm(i,[],e);rt(i,"cuechange",()=>{let s=Tm(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},bL=(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,b=K.MEDIA_ERR_NETWORK,_=new K(v,b,!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=bL(e,t),f=EL(e),[m]=Td((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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_MALFORMED,b.data=i,b}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}),b=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,b);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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_SUB_MISMATCH,b.data=i,b}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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_AUD_MISSING,b.data=i,b}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}),b=new K(v,u,!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_AUD_MISMATCH,b.data=i,b}}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_TOKEN_MISSING,b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_NOT_READY,b.streamType=t.streamType===Se.LIVE?"live":t.streamType===Se.ON_DEMAND?"on-demand":"unknown",b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_NOT_FOUND,b.data=i,b}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}),b=new K(v,u,r!=null?r:!0,y);return b.errorCategory=e,b.muxCode=J.NETWORK_INVALID_URL,b.data=i,b}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 TL=qE,yL=TL,gd={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},_L=i=>{if(i.includes("fps"))return gd.FAIRPLAY;if(i.includes("playready"))return gd.PLAYREADY;if(i.includes("widevine"))return gd.WIDEVINE},AL=i=>{let e=i.split(`
|
|
42
|
+
`).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
|
+
`).filter(r=>r.startsWith("#EXT-X-SESSION-DATA"));if(!e.length)return{};let t={};for(let r of e){let s=xL(r),n=s["DATA-ID"];n&&(t[n]={...s})}return{sessionData:t}};function xL(i){let e=/(\w+[-\w]*)="([^"]*)"/g,t=[...i.matchAll(e)];return Object.fromEntries(t.map(([,r,s])=>[r,s]))}var RL=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}},IL=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),...RL(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}},LL=async(i,e,t=yd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l,sessionData:d}=await IL(i,t),u=d==null?void 0:d["com.apple.hls.chapters"];u!=null&&u.VALUE&&ym(u.VALUE,e),((r=Xe.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=Xe.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=Xe.get(e))!=null?n:{}).streamType=a,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)}},kL=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}},wL=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=kL(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,DL=(wE=(kE=globalThis==null?void 0:globalThis.navigator)==null?void 0:kE.userAgent)!=null?wE:"",DE,CE,ME,CL=(ME=(CE=(DE=globalThis==null?void 0:globalThis.navigator)==null?void 0:DE.userAgentData)==null?void 0:CE.platform)!=null?ME:"",ML=DL.toLowerCase().includes("android")||["x11","android"].some(i=>CL.toLowerCase().includes(i)),Xe=new WeakMap,er="mux.com",OE,PE,zE=(PE=(OE=ve).isSupported)==null?void 0:PE.call(OE),OL=ML,Ad=()=>_l.utils.now(),PL=_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=""]=Td(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},NL=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:sb(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},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},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,UL=(i,e,t=Am)=>Math.abs(i-e)<=t,JE=(i,e,t=Am)=>i>e||UL(i,e,t),FL=(i,e=Am)=>i.paused&&JE(i.currentTime,i.duration,e),eb=(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&&eb(i,e)?!0:FL(i),tb=(i,e,t)=>{xm(e,t,i);let{metadata:r={}}=i,{view_session_id:s=PL()}=r,n=NL(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=BL(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}):WL(i,e,o),YL(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",ab),i.removeEventListener("error",fm),i.removeEventListener("durationchange",nb),Xe.delete(i),i.dispatchEvent(new Event("teardown")))};function ib(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||OL)))}var BL=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yd(i)===Ji.M3U8,d=ib(i,e);if(l&&!d&&zE){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=$L(r),h=HL(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 b=new URL(g);if(!b.searchParams.has("CMCD"))return;let _=((y=(v=b.searchParams.get("CMCD"))==null?void 0:v.split(","))!=null?y:[]).filter(A=>A.startsWith("sid")||A.startsWith("cid")).join(",");b.searchParams.set("CMCD",_),p.open("GET",b)},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}},$L=i=>i===Se.LIVE?{backBufferLength:8}:{},HL=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:rb(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}))}},GL=async i=>{let e=await fetch(i);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},KL=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)},VL=(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 GL(rb(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 KL(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}`},rb=({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}`},sb=({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())},WL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n,muxDataSDK:a=_l,muxDataSDKOptions:o={}}=i,l=sb(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}})}},YL=(i,e,t)=>{var r,s;let n=ib(i,e),{src:a,customDomain:o=er}=i,l=()=>{e.ended||!Sm(e,t)||(eb(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(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()=>LL(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?VL(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",nb,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",ab),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)=>{wL(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=qL(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 b=y===0?5e3:6e4,_=new K(`Retrying in ${b/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)},b);return}else{v.retryCount=0;let b=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(b,g),jt(e,b);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 nb(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 ab(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 qL=(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
45
|
`:""}${i.response&&(i.response.code||i.response.text)?`response: ${i.response.code}, ${i.response.text}
|
|
45
46
|
`:""}${i.reason?`failure reason: ${i.reason}
|
|
46
47
|
`:""}${i.level?`level: ${i.level}
|
|
@@ -49,7 +50,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
49
50
|
`:""}${i.error?`error: ${i.error}
|
|
50
51
|
`:""}${i.event?`event: ${i.event}
|
|
51
52
|
`:""}${i.err?`error message: ${(s=i.err)==null?void 0:s.message}
|
|
52
|
-
`:""}`),l.data=i,l};var
|
|
53
|
+
`:""}`),l.data=i,l};var db=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],ub=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function jL(i){return`
|
|
53
54
|
<style>
|
|
54
55
|
:host {
|
|
55
56
|
display: inline-flex;
|
|
@@ -63,10 +64,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
63
64
|
}
|
|
64
65
|
</style>
|
|
65
66
|
<slot name="media">
|
|
66
|
-
<audio${
|
|
67
|
+
<audio${gb(i)}></audio>
|
|
67
68
|
</slot>
|
|
68
69
|
<slot></slot>
|
|
69
|
-
`}function
|
|
70
|
+
`}function zL(i){return`
|
|
70
71
|
<style>
|
|
71
72
|
:host {
|
|
72
73
|
display: inline-block;
|
|
@@ -88,45 +89,48 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
88
89
|
}
|
|
89
90
|
</style>
|
|
90
91
|
<slot name="media">
|
|
91
|
-
<video${
|
|
92
|
+
<video${gb(i)}></video>
|
|
92
93
|
</slot>
|
|
93
94
|
<slot></slot>
|
|
94
|
-
`}function
|
|
95
|
-
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
|
|
95
|
+
`}function pb(i,{tag:e,is:t}){var n,a,o,l,d,cb,c,h,f,m,p,vs,Rm,hb,Im,fb,mb;let r=(a=(n=globalThis.document)==null?void 0:n.createElement)==null?void 0:a.call(n,e,{is:t}),s=r?XL(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);be(this,"get");be(this,"set");be(this,"call")}static get observedAttributes(){var O,w,C;return Ce(O=o,d,cb).call(O),[...(C=(w=r==null?void 0:r.constructor)==null?void 0:w.observedAttributes)!=null?C:[],...ub]}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=QL(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,fb).call(this,x);Z(this,m,new MutationObserver(Ce(this,p,hb).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,mb).call(this,x,O,w)}connectedCallback(){Ce(this,p,vs).call(this)}},l=new WeakMap,d=new WeakSet,cb=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)})},hb=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")},fb=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let O=this[x];delete this[x],this[x]=O}},mb=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),be(o,"getTemplateHTML",e.endsWith("audio")?jL:zL),be(o,"shadowRootOptions",{mode:"open"}),be(o,"Events",db),ie(o,l,!1),o}function XL(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 gb(i){let e="";for(let t in i){if(!ub.includes(t))continue;let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function QL(i){let e={};for(let t of i)e[t.name]=t.value;return e}var ob,Id=pb((ob=globalThis.HTMLElement)!=null?ob:class{},{tag:"video"}),lb,IM=pb((lb=globalThis.HTMLElement)!=null?lb:class{},{tag:"audio"});var bb=i=>{throw TypeError(i)},km=(i,e,t)=>e.has(i)||bb("Cannot "+t),Tt=(i,e,t)=>(km(i,e,"read from private field"),t?t.call(i):e.get(i)),ui=(i,e,t)=>e.has(i)?bb("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),ZL=()=>{try{return"0.25.3"}catch{}return"UNKNOWN"},JL=ZL(),ek=()=>JL,tk=`
|
|
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"},ik=Object.values(D),vb=ek(),Eb="mux-video",xi,Xa,Ld,Qa,kd,wd,Dd,Cd,Md,Za,Ja,Od,Tb=class extends Id{constructor(){super(),ui(this,Ja),ui(this,xi),ui(this,Xa),ui(this,Ld),ui(this,Qa,{}),ui(this,kd,{}),ui(this,wd),ui(this,Dd),ui(this,Cd),ui(this,Md),ui(this,Za,""),Xt(this,Ld,Ad()),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,Za,"default"),this.updateLogo())})}static get NAME(){return Eb}static get VERSION(){return vb}static get observedAttributes(){var i;return[...ik,...(i=Id.observedAttributes)!=null?i:[]]}static getLogoHTML(i){return!i||i==="false"?"":i==="default"?tk:`<img part="logo" src="${i}" />`}static getTemplateHTML(i={}){var e;return`
|
|
97
|
+
${super.getTemplateHTML(i)}
|
|
96
98
|
<style>
|
|
97
99
|
:host {
|
|
98
100
|
position: relative;
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
slot[name="logo"] {
|
|
101
103
|
display: flex;
|
|
102
104
|
justify-content: end;
|
|
103
105
|
position: absolute;
|
|
104
106
|
top: 1rem;
|
|
105
107
|
right: 1rem;
|
|
106
|
-
|
|
108
|
+
opacity: 0;
|
|
109
|
+
transition: opacity 0.25s ease-in-out;
|
|
110
|
+
z-index: 1;
|
|
111
|
+
}
|
|
112
|
+
slot[name="logo"]:has([part="logo"]) {
|
|
113
|
+
opacity: 1;
|
|
107
114
|
}
|
|
108
|
-
|
|
115
|
+
slot[name="logo"] [part="logo"] {
|
|
109
116
|
width: 5rem;
|
|
110
117
|
pointer-events: none;
|
|
111
118
|
user-select: none;
|
|
112
|
-
|
|
119
|
+
}
|
|
113
120
|
</style>
|
|
114
121
|
<slot name="logo">
|
|
115
|
-
${
|
|
122
|
+
${this.getLogoHTML((e=i[D.LOGO])!=null?e:"")}
|
|
116
123
|
</slot>
|
|
117
|
-
`:"";return`
|
|
118
|
-
|
|
119
|
-
${n}
|
|
120
|
-
`}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):xt(this,Rd)}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=xt(this,wd))!=null?i:pb}set playerSoftwareName(i){di(this,wd,i)}get playerSoftwareVersion(){var i;return(i=xt(this,kd))!=null?i:mb}set playerSoftwareVersion(i){di(this,kd,i)}get _hls(){var i;return(i=xt(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=Tm(this.nativeEl))!=null?i:null}get errorTranslator(){return xt(this,Dd)}set errorTranslator(i){di(this,Dd,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=bm(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{...xt(this,Id),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{}}}set tokens(i){di(this,Id,i!=null?i:{})}get ended(){return _m(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:Ed(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):jE(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 Sd(this.nativeEl)}async addCuePoints(i){return mm(this.nativeEl,i)}get activeCuePoint(){return pm(this.nativeEl)}get cuePoints(){return $E(this.nativeEl)}async addChapters(i){return vm(this.nativeEl,i)}get activeChapter(){return Em(this.nativeEl)}get chapters(){return GE(this.nativeEl)}getStartDate(){return KE(this.nativeEl,this._hls)}get currentPdt(){return VE(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},{}),...xt(this,Qa)}}set metadata(i){di(this,Qa,i!=null?i:{}),this.mux&&this.mux.emit("hb",xt(this,Qa))}get _hlsConfig(){return xt(this,Ld)}set _hlsConfig(i){di(this,Ld,i)}get logo(){return this.getAttribute(D.LOGO)}set logo(i){i?this.setAttribute(D.LOGO,i):this.removeAttribute(D.LOGO)}load(){di(this,xi,ZE(this,this.nativeEl,xt(this,xi)))}unload(){Am(this.nativeEl,xt(this,xi),this),di(this,xi,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(xd.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?Rm(this,Za,Cd).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Rm(this,Za,Cd).call(this));break}case"autoplay":if(t===e)break;(r=xt(this,xi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=xt(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;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!xt(this,xi)&&Rm(this,Za,Cd).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,Rd=new WeakMap,Qa=new WeakMap,Id=new WeakMap,Ld=new WeakMap,kd=new WeakMap,wd=new WeakMap,Dd=new WeakMap,Za=new WeakSet,Cd=async function(){xt(this,Xa)||(await di(this,Xa,Promise.resolve()),di(this,Xa,null),this.load())};var er=new WeakMap,En=class extends Error{},Md=class extends Error{};var ZL=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],Eb=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 bb(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 Tb(){return globalThis.chrome}function yb(){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 tr(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function Ja(){var i;return(i=tr())==null?void 0:i.getCurrentSession()}function Od(){var i;return(i=Ja())==null?void 0:i.getSessionObj().media[0]}function _b(i){return new Promise((e,t)=>{Od().editTracksInfo(i,e,t)})}function Ab(i){return new Promise((e,t)=>{Od().getStatus(i,e,t)})}function Lm(i){return tr().setOptions({...km(),...i})}function km(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}function JL(i){if(!i)return;let e=/\.([a-zA-Z0-9]+)(?:\?.*)?$/,t=i.match(e);return t?t[1]:null}function ek(i){let e=i.split(`
|
|
121
|
-
`),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 tk(i){return i.split(`
|
|
122
|
-
`).find(r=>!r.trim().startsWith("#")&&r.trim()!=="")}async function Sb(i){try{let t=(await fetch(i,{method:"HEAD"})).headers.get("Content-Type");return ZL.some(r=>t===r)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function xb(i){try{let e=await(await fetch(i)).text(),t=e,r=ek(e);if(r.length>0){let a=new URL(r[0],i).toString();t=await(await fetch(a)).text()}let s=tk(t);return JL(s)}catch(e){console.error("Error while trying to parse the manifest playlist",e);return}}var Pd=new Eb,xr=new WeakSet,lt;bb(()=>{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,tr().addEventListener(lt.CastContextEventType.CAST_STATE_CHANGED,s=>{Pd.forEach(n=>{var a,o;return(o=(a=er.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),tr().addEventListener(lt.CastContextEventType.SESSION_STATE_CHANGED,s=>{Pd.forEach(n=>{var a,o;return(o=(a=er.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),Pd.forEach(s=>{var n,a;return(a=(n=er.get(s)).init)==null?void 0:a.call(n)}))});var Rb=0,Ie,eo,$t,ir,bs,Ts,Rr,Ud,$e,Es,Ib,Lb,wm,kb,Dm,wb,Cm,Nd=class extends EventTarget{constructor(t){super();ie(this,$e);ie(this,Ie);ie(this,eo);ie(this,$t);ie(this,ir);ie(this,bs,"disconnected");ie(this,Ts,!1);ie(this,Rr,new Set);ie(this,Ud,new WeakMap);Z(this,Ie,t),Pd.add(this),er.set(this,{init:()=>Ce(this,$e,Dm).call(this),onCastStateChanged:()=>Ce(this,$e,wm).call(this),onSessionStateChanged:()=>Ce(this,$e,kb).call(this),getCastPlayer:()=>I(this,$e,Es)}),Ce(this,$e,Dm).call(this)}get state(){return I(this,bs)}async watchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");return I(this,Ud).set(t,++Rb),I(this,Rr).add(t),queueMicrotask(()=>t(Ce(this,$e,Lb).call(this))),Rb}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 Md("The RemotePlayback API is disabled on this platform.");let t=xr.has(I(this,Ie));xr.add(I(this,Ie)),Lm(I(this,Ie).castOptions),Object.entries(I(this,ir)).forEach(([o,l])=>{I(this,$t).controller.addEventListener(o,l)});try{await tr().requestSession()}catch(o){if(t||xr.delete(I(this,Ie)),o==="cancel")return;throw new Error(o)}(a=(n=er.get(I(this,Ie)))==null?void 0:n.loadOnPrompt)==null||a.call(n)}};Ie=new WeakMap,eo=new WeakMap,$t=new WeakMap,ir=new WeakMap,bs=new WeakMap,Ts=new WeakMap,Rr=new WeakMap,Ud=new WeakMap,$e=new WeakSet,Es=function(){if(xr.has(I(this,Ie)))return I(this,$t)},Ib=function(){xr.has(I(this,Ie))&&(Object.entries(I(this,ir)).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())},Lb=function(){var r;let t=(r=tr())==null?void 0:r.getCastState();return t&&t!=="NO_DEVICES_AVAILABLE"},wm=function(){let t=tr().getCastState();if(xr.has(I(this,Ie))&&t==="CONNECTING"&&(Z(this,bs,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,Ts)&&(t!=null&&t.includes("CONNECT"))){Z(this,Ts,!0);for(let r of I(this,Rr))r(!0)}else if(I(this,Ts)&&(!t||t==="NO_DEVICES_AVAILABLE")){Z(this,Ts,!1);for(let r of I(this,Rr))r(!1)}},kb=async function(){var r;let{SESSION_RESUMED:t}=lt.SessionState;if(tr().getSessionState()===t&&I(this,Ie).castSrc===((r=Od())==null?void 0:r.media.contentId)){xr.add(I(this,Ie)),Object.entries(I(this,ir)).forEach(([s,n])=>{I(this,$t).controller.addEventListener(s,n)});try{await Ab(new chrome.cast.media.GetStatusRequest)}catch(s){console.error(s)}I(this,ir)[lt.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,ir)[lt.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Dm=function(){!lt||I(this,eo)||(Z(this,eo,!0),Lm(I(this,Ie).castOptions),I(this,Ie).textTracks.addEventListener("change",()=>Ce(this,$e,Cm).call(this)),Ce(this,$e,wm).call(this),Z(this,$t,new lt.RemotePlayer),new lt.RemotePlayerController(I(this,$t)),Z(this,ir,{[lt.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:t})=>{t===!0?(Z(this,bs,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,$e,Ib).call(this),Z(this,bs,"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,wb).call(this))}}))},wb=function(){Ce(this,$e,Cm).call(this)},Cm=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:b})=>{var A;let{mode:_}=(A=s.find(k=>k.language===v&&k.label===y))!=null?A:{};return _?{mode:_,trackId:b}:!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=Ja())==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(b=>y.includes(b)))(d,u))try{let v=new chrome.cast.media.EditTracksInfoRequest(u);await _b(v)}catch(v){console.error(v)}};var Db=i=>{var e,t,r,s,n,a,o,xe,Cb;return t=class extends i{constructor(){super(...arguments);ie(this,o);ie(this,r,{paused:!1});ie(this,s,km());ie(this,n);ie(this,a)}get remote(){return I(this,a)?I(this,a):Tb()?(this.disableRemotePlayback||yb(),er.set(this,{loadOnPrompt:()=>Ce(this,o,Cb).call(this)}),Z(this,a,new Nd(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:b,src:_})=>_&&(b==="subtitles"||b==="captions")),m=[],p=0;if(f.length&&(h.tracks=f.map(b=>{let _=++p;m.length===0&&b.track.mode==="showing"&&m.push(_);let A=new chrome.cast.media.Track(_,chrome.cast.media.TrackType.TEXT);return A.trackContentId=b.src,A.trackContentType="text/vtt",A.subtype=b.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,A.name=b.label,A.language=b.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}],Sb(this.castSrc)){let b=await xb(this.castSrc);((b==null?void 0:b.includes("m4s"))||(b==null?void 0:b.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=Ja())==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=er.get(this.remote))==null?void 0:h.getCastPlayer)==null?void 0:f.call(h)},Cb=async function(){I(this,r).paused=hl(t.prototype,this,"paused"),hl(t.prototype,this,"pause").call(this),this.muted=hl(t.prototype,this,"muted");try{await this.load()}catch(h){console.error(h)}},Ee(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t};var rr=class extends Event{constructor(t,r){super(t);Ee(this,"track");this.track=r.track}};var Mm=new WeakMap;function V(i){var e;return(e=Mm.get(i))!=null?e:ik(i,{})}function ik(i,e){let t=Mm.get(i);return t||Mm.set(i,t={}),Object.assign(t,e)}function Fd(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 rr("addtrack",{track:e}))})}function Bd(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 rr("removetrack",{track:i}))})}function Mb(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,to,_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,to).values()}get length(){return I(this,ys,to).size}getTrackById(t){var r;return(r=[...I(this,ys,to)].find(s=>s.id===t))!=null?r:null}get selectedIndex(){return[...I(this,ys,to)].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,to=function(){return V(this).trackSet};var sr=class extends Event{constructor(t,r){super(t);Ee(this,"rendition");this.rendition=r.rendition}};function Ob(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 bn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new sr("addrendition",{rendition:e}))})}function Pb(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new sr("removerendition",{rendition:i}))})}function Nb(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 bn(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 bn(this).values()}get length(){return bn(this).length}getRenditionById(t){var r;return(r=bn(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return bn(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of bn(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 Tn,io=class{constructor(){Ee(this,"src");Ee(this,"id");Ee(this,"width");Ee(this,"height");Ee(this,"bitrate");Ee(this,"frameRate");Ee(this,"codec");ie(this,Tn,!1)}get selected(){return I(this,Tn)}set selected(e){I(this,Tn)!==e&&(Z(this,Tn,e),Nb(this))}};Tn=new WeakMap;var yn,_n=class{constructor(){Ee(this,"id");Ee(this,"kind");Ee(this,"label","");Ee(this,"language","");Ee(this,"sourceBuffer");ie(this,yn,!1)}addRendition(e,t,r,s,n,a){let o=new io;return o.src=e,o.width=t,o.height=r,o.frameRate=a,o.bitrate=n,o.codec=s,Ob(this,o),o}removeRendition(e){Pb(e)}get selected(){return I(this,yn)}set selected(e){I(this,yn)!==e&&(Z(this,yn,e),e===!0&&Mb(this))}};yn=new WeakMap;function Ub(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 sr("addrendition",{rendition:e}))})}function Fb(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new sr("removerendition",{rendition:i}))})}function Bb(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,ro=class{constructor(){Ee(this,"src");Ee(this,"id");Ee(this,"bitrate");Ee(this,"codec");ie(this,Sn,!1)}get selected(){return I(this,Sn)}set selected(e){I(this,Sn)!==e&&(Z(this,Sn,e),Bb(this))}};Sn=new WeakMap;function Hd(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 rr("addtrack",{track:e}))})}function Gd(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 rr("removetrack",{track:i}))})}function $b(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,$d,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,$d).values()}get length(){return I(this,xn,$d).size}getTrackById(t){var r;return(r=[...I(this,xn,$d)].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,$d=function(){return V(this).trackSet};var Rn,In=class{constructor(){Ee(this,"id");Ee(this,"kind");Ee(this,"label","");Ee(this,"language","");Ee(this,"sourceBuffer");ie(this,Rn,!1)}addRendition(e,t,r){let s=new ro;return s.src=e,s.codec=t,s.bitrate=r,Ub(this,s),s}removeRendition(e){Fb(e)}get enabled(){return I(this,Rn)}set enabled(e){I(this,Rn)!==e&&(Z(this,Rn,e),$b(this))}};Rn=new WeakMap;var Hb=Kd(globalThis.HTMLMediaElement,"video"),Gb=Kd(globalThis.HTMLMediaElement,"audio");function Kb(i){if(!(i!=null&&i.prototype))return i;let e=Kd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return rk(this)}});let t=Kd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return sk(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,Fd(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Bd),"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,Hd(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=Gd),"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 Kd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function rk(i){var t;let e=V(i).videoTracks;if(!e&&(e=new _s,V(i).videoTracks=e,Hb)){let r=Hb.call((t=i.nativeEl)!=null?t:i);for(let s of r)Fd(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)Bd(n);return}Fd(i,s.track)}),r.addEventListener("removetrack",s=>{Bd(s.track)})}return e}function sk(i){var t;let e=V(i).audioTracks;if(!e&&(e=new xs,V(i).audioTracks=e,Gb)){let r=Gb.call((t=i.nativeEl)!=null?t:i);for(let s of r)Hd(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)Gd(n);return}Hd(i,s.track)}),r.addEventListener("removetrack",s=>{Gd(s.track)})}return e}var Wb=i=>{throw TypeError(i)},Yb=(i,e,t)=>e.has(i)||Wb("Cannot "+t),qb=(i,e,t)=>(Yb(i,e,"read from private field"),t?t.call(i):e.get(i)),jb=(i,e,t)=>e.has(i)?Wb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),zb=(i,e,t,r)=>(Yb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Yd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Yd{}globalThis.DocumentFragment=i}var Pm=class extends Yd{},nk=class extends Yd{},ak={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Pm)}},Vd,ok=class{constructor(i,e={}){jb(this,Vd),zb(this,Vd,e==null?void 0:e.detail)}get detail(){return qb(this,Vd)}initCustomEvent(){}};Vd=new WeakMap;function lk(i,e){return new Pm}var Xb={document:{createElement:lk},DocumentFragment,customElements:ak,CustomEvent:ok,EventTarget:Yd,HTMLElement:Pm,HTMLVideoElement:nk},Qb=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Om=Qb?Xb:globalThis,KO=Qb?Xb.document:globalThis.document,Wd,Vb=class extends Db(Kb(vb)){constructor(){super(...arguments),jb(this,Wd)}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=qb(this,Wd))!=null?i:this.muxCastCustomData}set castCustomData(i){zb(this,Wd,i)}};Wd=new WeakMap;Om.customElements.get("mux-video")||(Om.customElements.define("mux-video",Vb),Om.MuxVideoElement=Vb);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"},Nm={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"},Zb=Object.entries(Nm),T=Zb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),dk={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Xt=Zb.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...dk}),eP=Object.entries(Xt).reduce((i,[e,t])=>{let r=T[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Jb=Object.entries(T).reduce((i,[e,t])=>{let r=Xt[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 Um={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ht={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ui={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var eT={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function tT(i){return i==null?void 0:i.map(ck).join(" ")}function iT(i){return i==null?void 0:i.split(/\s+/).map(hk)}function ck(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function hk(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function rT(i){return i==null?void 0:i.map(fk).join(" ")}function sT(i){return i==null?void 0:i.split(/\s+/).map(mk)}function fk(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function mk(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function nT(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 qd(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var jd=i=>new Promise(e=>setTimeout(e,i));var aT=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],pk=(i,e)=>{let t=i===1?aT[e].singular:aT[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&&pk(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function ci(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 rP=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 oT={"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 lT,Fm={en:oT},Bm=((lT=globalThis.navigator)==null?void 0:lT.language)||"en",dT=i=>{Bm=i};var vk=i=>{var e,t,r;let[s]=Bm.split("-");return((e=Fm[Bm])==null?void 0:e[i])||((t=Fm[s])==null?void 0:t[i])||((r=Fm.en)==null?void 0:r[i])||i},B=(i,e={})=>vk(i).replace(/\{(\w+)\}/g,(t,r)=>r in e?String(e[r]):`{${r}}`);var zd=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Xd=class extends zd{},Qd=class extends Xd{constructor(){super(...arguments),this.role=null}},$m=class{observe(){}unobserve(){}disconnect(){}},uT={createElement:function(){return new so.HTMLElement},createElementNS:function(){return new so.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},so={ResizeObserver:$m,document:uT,Node:Xd,Element:Qd,HTMLElement:class extends Qd{constructor(){super(...arguments),this.innerHTML=""}get content(){return new so.DocumentFragment}},DocumentFragment:class extends zd{},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}}}}},cT=typeof window=="undefined"||typeof window.customElements=="undefined",hT=Object.keys(so).every(i=>i in globalThis),S=cT&&!hT?so:globalThis,Ue=cT&&!hT?uT:globalThis.document;var fT=new WeakMap,Hm=i=>{let e=fT.get(i);return e||fT.set(i,e=new Set),e},mT=new S.ResizeObserver(i=>{for(let e of i)for(let t of Hm(e.target))t(e)});function nr(i,e){Hm(i).add(e),mT.observe(i)}function ar(i,e){let t=Hm(i);t.delete(e),t.size||mT.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=Zd(i))!=null?e:Ri(i,"media-controller")}function Zd(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 Jd=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},Ek=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},eu=(i,e)=>Ek(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 no(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=no(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 tu(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 pT(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=bk(i,r=>r===e);return t||Gm(i,e)}function bk(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 Gm(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 gT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$r=(i,e,t)=>(gT(i,e,"read from private field"),t?t.call(i):e.get(i)),Tk=(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)},iu=(i,e,t,r)=>(gT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mt;function yk(i){return`
|
|
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):Tt(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=Tt(this,Cd))!=null?i:Eb}set playerSoftwareName(i){Xt(this,Cd,i)}get playerSoftwareVersion(){var i;return(i=Tt(this,Dd))!=null?i:vb}set playerSoftwareVersion(i){Xt(this,Dd,i)}get _hls(){var i;return(i=Tt(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 Tt(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]=Td((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{...Tt(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 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 bm(this.nativeEl,i)}get activeChapter(){return Tm(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},{}),...Tt(this,Qa)}}set metadata(i){Xt(this,Qa,i!=null?i:{}),this.mux&&this.mux.emit("hb",Tt(this,Qa))}get _hlsConfig(){return Tt(this,wd)}set _hlsConfig(i){Xt(this,wd,i)}get logo(){var i;return(i=this.getAttribute(D.LOGO))!=null?i:Tt(this,Za)}set logo(i){i?this.setAttribute(D.LOGO,i):this.removeAttribute(D.LOGO)}load(){Xt(this,xi,tb(this,this.nativeEl,Tt(this,xi)))}unload(){xm(this.nativeEl,Tt(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=Tt(this,xi))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=Tt(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(Tt(this,Za)||this.logo);i.innerHTML=e}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!Tt(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(){Tt(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 rk=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],yb=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 _b(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 Ab(){return globalThis.chrome}function Sb(){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 xb(i){return new Promise((e,t)=>{Nd().editTracksInfo(i,e,t)})}function Rb(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 sk(i){if(!i)return;let e=/\.([a-zA-Z0-9]+)(?:\?.*)?$/,t=i.match(e);return t?t[1]:null}function nk(i){let e=i.split(`
|
|
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 ak(i){return i.split(`
|
|
126
|
+
`).find(r=>!r.trim().startsWith("#")&&r.trim()!=="")}async function Ib(i){try{let t=(await fetch(i,{method:"HEAD"})).headers.get("Content-Type");return rk.some(r=>t===r)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function Lb(i){try{let e=await(await fetch(i)).text(),t=e,r=nk(e);if(r.length>0){let a=new URL(r[0],i).toString();t=await(await fetch(a)).text()}let s=ak(t);return sk(s)}catch(e){console.error("Error while trying to parse the manifest playlist",e);return}}var Ud=new yb,xr=new WeakSet,lt;_b(()=>{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 kb=0,Ie,to,$t,rr,bs,Ts,Rr,Bd,$e,Es,wb,Db,Cm,Cb,Mm,Mb,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,bs,"disconnected");ie(this,Ts,!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,Cb).call(this),getCastPlayer:()=>I(this,$e,Es)}),Ce(this,$e,Mm).call(this)}get state(){return I(this,bs)}async watchAvailability(t){if(I(this,Ie).disableRemotePlayback)throw new En("disableRemotePlayback attribute is present.");return I(this,Bd).set(t,++kb),I(this,Rr).add(t),queueMicrotask(()=>t(Ce(this,$e,Db).call(this))),kb}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,bs=new WeakMap,Ts=new WeakMap,Rr=new WeakMap,Bd=new WeakMap,$e=new WeakSet,Es=function(){if(xr.has(I(this,Ie)))return I(this,$t)},wb=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())},Db=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,bs,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,Ts)&&(t!=null&&t.includes("CONNECT"))){Z(this,Ts,!0);for(let r of I(this,Rr))r(!0)}else if(I(this,Ts)&&(!t||t==="NO_DEVICES_AVAILABLE")){Z(this,Ts,!1);for(let r of I(this,Rr))r(!1)}},Cb=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 Rb(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,bs,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,$e,wb).call(this),Z(this,bs,"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,Mb).call(this))}}))},Mb=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:b})=>{var A;let{mode:_}=(A=s.find(k=>k.language===v&&k.label===y))!=null?A:{};return _?{mode:_,trackId:b}:!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(b=>y.includes(b)))(d,u))try{let v=new chrome.cast.media.EditTracksInfoRequest(u);await xb(v)}catch(v){console.error(v)}};var Ob=i=>{var e,t,r,s,n,a,o,xe,Pb;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):Ab()?(this.disableRemotePlayback||Sb(),tr.set(this,{loadOnPrompt:()=>Ce(this,o,Pb).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:b,src:_})=>_&&(b==="subtitles"||b==="captions")),m=[],p=0;if(f.length&&(h.tracks=f.map(b=>{let _=++p;m.length===0&&b.track.mode==="showing"&&m.push(_);let A=new chrome.cast.media.Track(_,chrome.cast.media.TrackType.TEXT);return A.trackContentId=b.src,A.trackContentType="text/vtt",A.subtype=b.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,A.name=b.label,A.language=b.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}],Ib(this.castSrc)){let b=await Lb(this.castSrc);((b==null?void 0:b.includes("m4s"))||(b==null?void 0:b.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)},Pb=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)}},be(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);be(this,"track");this.track=r.track}};var Pm=new WeakMap;function V(i){var e;return(e=Pm.get(i))!=null?e:ok(i,{})}function ok(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 Nb(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);be(this,"rendition");this.rendition=r.rendition}};function Ub(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 bn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new nr("addrendition",{rendition:e}))})}function Fb(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 Bb(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 bn(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 bn(this).values()}get length(){return bn(this).length}getRenditionById(t){var r;return(r=bn(this).find(s=>`${s.id}`==`${t}`))!=null?r:null}get selectedIndex(){return bn(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[r,s]of bn(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 Tn,ro=class{constructor(){be(this,"src");be(this,"id");be(this,"width");be(this,"height");be(this,"bitrate");be(this,"frameRate");be(this,"codec");ie(this,Tn,!1)}get selected(){return I(this,Tn)}set selected(e){I(this,Tn)!==e&&(Z(this,Tn,e),Bb(this))}};Tn=new WeakMap;var yn,_n=class{constructor(){be(this,"id");be(this,"kind");be(this,"label","");be(this,"language","");be(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,Ub(this,o),o}removeRendition(e){Fb(e)}get selected(){return I(this,yn)}set selected(e){I(this,yn)!==e&&(Z(this,yn,e),e===!0&&Nb(this))}};yn=new WeakMap;function $b(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 Hb(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 Gb(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(){be(this,"src");be(this,"id");be(this,"bitrate");be(this,"codec");ie(this,Sn,!1)}get selected(){return I(this,Sn)}set selected(e){I(this,Sn)!==e&&(Z(this,Sn,e),Gb(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 Kb(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(){be(this,"id");be(this,"kind");be(this,"label","");be(this,"language","");be(this,"sourceBuffer");ie(this,Rn,!1)}addRendition(e,t,r){let s=new so;return s.src=e,s.codec=t,s.bitrate=r,$b(this,s),s}removeRendition(e){Hb(e)}get enabled(){return I(this,Rn)}set enabled(e){I(this,Rn)!==e&&(Z(this,Rn,e),Kb(this))}};Rn=new WeakMap;var Vb=Wd(globalThis.HTMLMediaElement,"video"),Wb=Wd(globalThis.HTMLMediaElement,"audio");function Yb(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 lk(this)}});let t=Wd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return dk(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 lk(i){var t;let e=V(i).videoTracks;if(!e&&(e=new _s,V(i).videoTracks=e,Vb)){let r=Vb.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 dk(i){var t;let e=V(i).audioTracks;if(!e&&(e=new xs,V(i).audioTracks=e,Wb)){let r=Wb.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 jb=i=>{throw TypeError(i)},zb=(i,e,t)=>e.has(i)||jb("Cannot "+t),Xb=(i,e,t)=>(zb(i,e,"read from private field"),t?t.call(i):e.get(i)),Qb=(i,e,t)=>e.has(i)?jb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),Zb=(i,e,t,r)=>(zb(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{},uk=class extends jd{},ck={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Um)}},Yd,hk=class{constructor(i,e={}){Qb(this,Yd),Zb(this,Yd,e==null?void 0:e.detail)}get detail(){return Xb(this,Yd)}initCustomEvent(){}};Yd=new WeakMap;function fk(i,e){return new Um}var Jb={document:{createElement:fk},DocumentFragment,customElements:ck,CustomEvent:hk,EventTarget:jd,HTMLElement:Um,HTMLVideoElement:uk},eT=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Nm=eT?Jb:globalThis,jO=eT?Jb.document:globalThis.document,qd,qb=class extends Ob(Yb(Tb)){constructor(){super(...arguments),Qb(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=Xb(this,qd))!=null?i:this.muxCastCustomData}set castCustomData(i){Zb(this,qd,i)}};qd=new WeakMap;Nm.customElements.get("mux-video")||(Nm.customElements.define("mux-video",qb),Nm.MuxVideoElement=qb);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"},tT=Object.entries(Fm),T=tT.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),mk={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Qt=tT.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...mk}),nP=Object.entries(Qt).reduce((i,[e,t])=>{let r=T[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),iT=Object.entries(T).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 rT={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};function sT(i){return i==null?void 0:i.map(gk).join(" ")}function nT(i){return i==null?void 0:i.split(/\s+/).map(vk)}function gk(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function vk(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function aT(i){return i==null?void 0:i.map(Ek).join(" ")}function oT(i){return i==null?void 0:i.split(/\s+/).map(bk)}function Ek(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 lT(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 dT=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],Tk=(i,e)=>{let t=i===1?dT[e].singular:dT[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&&Tk(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 lP=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 uT={"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 cT,$m={en:uT},Hm=((cT=globalThis.navigator)==null?void 0:cT.language)||"en",hT=i=>{Hm=i};var _k=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={})=>_k(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(){}},fT={createElement:function(){return new no.HTMLElement},createElementNS:function(){return new no.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},no={ResizeObserver:Gm,document:fT,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}}}}},mT=typeof window=="undefined"||typeof window.customElements=="undefined",pT=Object.keys(no).every(i=>i in globalThis),S=mT&&!pT?no:globalThis,Ue=mT&&!pT?fT:globalThis.document;var gT=new WeakMap,Km=i=>{let e=gT.get(i);return e||gT.set(i,e=new Set),e},vT=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),vT.observe(i)}function or(i,e){let t=Km(i);t.delete(e),t.size||vT.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)},Ak=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},iu=(i,e)=>Ak(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 ET(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=Sk(i,r=>r===e);return t||Vm(i,e)}function Sk(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 bT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$r=(i,e,t)=>(bT(i,e,"read from private field"),t?t.call(i):e.get(i)),xk=(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)=>(bT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mt;function Rk(i){return`
|
|
123
127
|
<style>
|
|
124
128
|
:host {
|
|
125
129
|
display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
|
|
126
130
|
box-sizing: border-box;
|
|
127
131
|
}
|
|
128
132
|
</style>
|
|
129
|
-
`}var kn=class extends S.HTMLElement{constructor(){if(super(),
|
|
133
|
+
`}var kn=class extends S.HTMLElement{constructor(){if(super(),xk(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,T.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,Ik(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,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.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=Rk;function Ik(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,lo,Dn,au,Wm,TT,oo,ou,Ym,yT,qm,_T,uo,du,uu,zm,Cn,co,ee={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};function Lk(i){return`
|
|
130
134
|
<style>
|
|
131
135
|
|
|
132
136
|
:host([${T.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
|
|
@@ -263,8 +267,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
263
267
|
<slot name="poster" part="layer poster-layer"></slot>
|
|
264
268
|
<slot name="gestures-chrome" part="layer gesture-layer">
|
|
265
269
|
<media-gesture-receiver slot="gestures-chrome">
|
|
266
|
-
<template shadowrootmode="${
|
|
267
|
-
${
|
|
270
|
+
<template shadowrootmode="${nu.shadowRootOptions.mode}">
|
|
271
|
+
${nu.getTemplateHTML({})}
|
|
268
272
|
</template>
|
|
269
273
|
</media-gesture-receiver>
|
|
270
274
|
</slot>
|
|
@@ -276,7 +280,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
276
280
|
<slot part="bottom chrome"></slot>
|
|
277
281
|
</span>
|
|
278
282
|
<slot name="dialog" part="layer dialog-layer"></slot>
|
|
279
|
-
`}var Sk=Object.values(T),xk="sm:384 md:576 lg:768 xl:960";function Rk(i){TT(i.target,i.contentRect.width)}function TT(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ee.BREAKPOINTS))!=null?t:xk,s=Ik(r),n=Lk(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(Xt.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}i.breakpointsComputed||(i.breakpointsComputed=!0,i.dispatchEvent(new CustomEvent(Xt.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}function Ik(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Lk(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}var ks=class extends S.HTMLElement{constructor(){if(super(),Gt(this,Km),Gt(this,Vm),Gt(this,Wm),Gt(this,lo),Gt(this,lu),Gt(this,Cn),Gt(this,au,0),Gt(this,wn,null),Gt(this,oo,null),Gt(this,Dn,void 0),this.breakpointsComputed=!1,Gt(this,su,new MutationObserver(Qt(this,Km,vT).bind(this))),Gt(this,ao,!1),Gt(this,nu,t=>{Kt(this,ao)||(setTimeout(()=>{Rk(t),Ls(this,ao,!1)},0),Ls(this,ao,!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(Sk).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES,T.MEDIA_WIDTH,T.MEDIA_HEIGHT,T.MEDIA_ERROR,T.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,su).observe(this,{childList:!0,subtree:!0}),nr(this,Kt(this,nu));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,""),TT(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,su).disconnect(),ar(this,Kt(this,nu)),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,au,e.timeStamp);break;case"pointermove":Qt(this,Vm,ET).call(this,e);break;case"pointerup":Qt(this,Wm,bT).call(this,e);break;case"mouseleave":Qt(this,lo,ou).call(this);break;case"mouseup":this.removeAttribute(ee.KEYBOARD_CONTROL);break;case"keyup":Qt(this,Cn,uo).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)}};au=new WeakMap;wn=new WeakMap;oo=new WeakMap;Dn=new WeakMap;su=new WeakMap;Km=new WeakSet;vT=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)}};ao=new WeakMap;nu=new WeakMap;Vm=new WeakSet;ET=function(i){if(i.pointerType!=="mouse"&&i.timeStamp-Kt(this,au)<250)return;Qt(this,lu,qm).call(this),clearTimeout(Kt(this,oo));let e=this.hasAttribute(ee.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(i.target)||e)&&Qt(this,Cn,uo).call(this)};Wm=new WeakSet;bT=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(ee.USER_INACTIVE);[this,this.media].includes(i.target)&&e?Qt(this,lo,ou).call(this):Qt(this,Cn,uo).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&Qt(this,Cn,uo).call(this)};lo=new WeakSet;ou=function(){if(Kt(this,Dn)<0||this.hasAttribute(ee.USER_INACTIVE))return;this.setAttribute(ee.USER_INACTIVE,"");let i=new S.CustomEvent(Xt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};lu=new WeakSet;qm=function(){if(!this.hasAttribute(ee.USER_INACTIVE))return;this.removeAttribute(ee.USER_INACTIVE);let i=new S.CustomEvent(Xt.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Cn=new WeakSet;uo=function(){Qt(this,lu,qm).call(this),clearTimeout(Kt(this,oo));let i=parseInt(this.autohide);i<0||Ls(this,oo,setTimeout(()=>{Qt(this,lo,ou).call(this)},i*1e3))};ks.shadowRootOptions={mode:"open"};ks.getTemplateHTML=Ak;S.customElements.get("media-container")||S.customElements.define("media-container",ks);var yT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(yT(i,e,"read from private field"),t?t.call(i):e.get(i)),co=(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)},du=(i,e,t,r)=>(yT(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mn,On,uu,ws,or,Hr,Gr=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){co(this,or),co(this,Mn,void 0),co(this,On,void 0),co(this,uu,void 0),co(this,ws,new Set),du(this,Mn,e),du(this,On,t),du(this,uu,new Set(r))}[Symbol.iterator](){return gt(this,or,Hr).values()}get length(){return gt(this,or,Hr).size}get value(){var e;return(e=[...gt(this,or,Hr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(du(this,ws,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...gt(this,or,Hr)][e]}values(){return gt(this,or,Hr).values()}forEach(e,t){gt(this,or,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,or,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;uu=new WeakMap;ws=new WeakMap;or=new WeakSet;Hr=function(){return gt(this,ws).size?gt(this,ws):gt(this,uu)};var kk=(i="")=>i.split(/\s+/),_T=(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={})=>kk(i).map(t=>{let r=_T(t);return{...e,...r}}),jm=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?_T(e):e):typeof i=="string"?Ds(i):[i]:[],cu=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,lr=(i=[])=>Array.prototype.map.call(i,cu).join(" "),wk=(i,e)=>t=>t[i]===e,AT=i=>{let e=Object.entries(i).map(([t,r])=>wk(t,r));return t=>e.every(r=>r(t))},Cs=(i,e=[],t=[])=>{let r=jm(t).map(AT),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:AT(e);return Array.from(i.textTracks).filter(t)},hu=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)};var xT=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)}},ST="exitFullscreen"in Ue?"exitFullscreen":"webkitExitFullscreen"in Ue?"webkitExitFullscreen":"webkitCancelFullScreen"in Ue?"webkitCancelFullScreen":void 0,RT=i=>{var e;let{documentElement:t}=i;if(ST){let r=(e=t==null?void 0:t[ST])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},ho="fullscreenElement"in Ue?"fullscreenElement":"webkitFullscreenElement"in Ue?"webkitFullscreenElement":void 0,Dk=i=>{let{documentElement:e,media:t}=i,r=e==null?void 0:e[ho];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===eT.FULLSCREEN?t:r},IT=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=Dk(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(ho in a))return Rt(n,s);for(;a!=null&&a[ho];){if(a[ho]===s)return!0;a=(e=a[ho])==null?void 0:e.shadowRoot}}return!1},Ck="fullscreenEnabled"in Ue?"fullscreenEnabled":"webkitFullscreenEnabled"in Ue?"webkitFullscreenEnabled":void 0,LT=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[Ck])||t&&"webkitSupportsFullscreen"in t};var fu,zm=()=>{var i,e;return fu||(fu=(e=(i=Ue)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),fu)},kT=async(i=zm())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([Mk(i,t.signal),Ok(i,e)]);return t.abort(),r},Mk=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),Ok=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await jd(10)}return i.volume!==e},Pk=/.*Version\/.*Safari\/.*/.test(S.navigator.userAgent),Xm=(i=zm())=>S.matchMedia("(display-mode: standalone)").matches&&Pk?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Qm=(i=zm())=>LT({documentElement:Ue,media:i}),wT=Qm(),DT=Xm(),CT=!!S.WebKitPlaybackTargetAvailabilityEvent,MT=!!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),Zm=i=>Ms(i.media,e=>e.mode===Br.SHOWING&&[Ct.SUBTITLES,Ct.CAPTIONS].includes(e.kind)),mu=(i,e)=>{let t=Pn(i),r=Zm(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}])}}},pu=(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)?Nk(i,e):Object.entries(i).every(([t,r])=>t in e&&pu(r,e[t])),Nk=(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)=>pu(s,e[n])):!0};var Uk=Object.values(ui),gu,Fk=kT().then(i=>(gu=i,gu)),OT=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))}))},Bk=new S.DOMParser,$k=i=>i&&(Bk.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=[ui.LIVE,ui.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(Uk.includes(s))return s===ui.UNKNOWN?r:s;let n=e.duration;return n===1/0?ui.LIVE:Number.isFinite(n)?ui.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===ui.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)===ui.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 Zm(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)||mu(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:$k(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 IT(i)},set(i,e){i?xT(e):RT(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(!wT||!Qm(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!DT||!Xm(e))return Ht.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(gu===!1||(e==null?void 0:e.volume)==null)return Ht.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{gu==null&&Fk.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!MT||!((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(!CT)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 PT={[$.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)===ui.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=jm(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}){mu(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 NT=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Nn,requestMap:s=PT,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&&(pu(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,b,_,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 OT(...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=((b=l.media)==null?void 0:b.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),St=!!((w=l.media)!=null&&w.videoRenditions)&&(pe||fe),vr=!!((C=l.media)!=null&&C.audioTracks)&&(te||fe),rn=!!((P=l.media)!=null&&P.remote)&&(_e||fe),Hg=!!l.documentElement&&(Ke||fe),Gg=Ye||ze||St||vr||rn||Hg,sn=o.length===0&&g===1&&a,Kg=!!f.media&&(W||sn),Vg=!!((U=f.media)!=null&&U.textTracks)&&(G||sn),Wg=!!((X=f.media)!=null&&X.videoRenditions)&&(pe||sn),Yg=!!((z=f.media)!=null&&z.audioTracks)&&(te||sn),qg=!!((q=f.media)!=null&&q.remote)&&(_e||sn),jg=!!f.documentElement&&(Ke||sn),zg=Kg||Vg||Wg||Yg||qg||jg;if(!(Gg||zg)){Object.entries(f).forEach(([Oe,ya])=>{l[Oe]=ya}),c(),f=void 0;return}Object.entries(r).forEach(([Oe,{get:ya,mediaEvents:z_=[],textTracksEvents:X_=[],videoRenditionsEvents:Q_=[],audioTracksEvents:Z_=[],remoteEvents:J_=[],rootEvents:eA=[],stateOwnersUpdateHandlers:tA=[]}])=>{h[Oe]||(h[Oe]={});let Ut=Qe=>{let Ft=ya(l,Qe);u({[Oe]:Ft})},ut;ut=h[Oe].mediaEvents,z_.forEach(Qe=>{ut&&Ye&&(l.media.removeEventListener(Qe,ut),h[Oe].mediaEvents=void 0),Kg&&(f.media.addEventListener(Qe,Ut),h[Oe].mediaEvents=Ut)}),ut=h[Oe].textTracksEvents,X_.forEach(Qe=>{var Ft,ei;ut&&ze&&((Ft=l.media.textTracks)==null||Ft.removeEventListener(Qe,ut),h[Oe].textTracksEvents=void 0),Vg&&((ei=f.media.textTracks)==null||ei.addEventListener(Qe,Ut),h[Oe].textTracksEvents=Ut)}),ut=h[Oe].videoRenditionsEvents,Q_.forEach(Qe=>{var Ft,ei;ut&&St&&((Ft=l.media.videoRenditions)==null||Ft.removeEventListener(Qe,ut),h[Oe].videoRenditionsEvents=void 0),Wg&&((ei=f.media.videoRenditions)==null||ei.addEventListener(Qe,Ut),h[Oe].videoRenditionsEvents=Ut)}),ut=h[Oe].audioTracksEvents,Z_.forEach(Qe=>{var Ft,ei;ut&&vr&&((Ft=l.media.audioTracks)==null||Ft.removeEventListener(Qe,ut),h[Oe].audioTracksEvents=void 0),Yg&&((ei=f.media.audioTracks)==null||ei.addEventListener(Qe,Ut),h[Oe].audioTracksEvents=Ut)}),ut=h[Oe].remoteEvents,J_.forEach(Qe=>{var Ft,ei;ut&&rn&&((Ft=l.media.remote)==null||Ft.removeEventListener(Qe,ut),h[Oe].remoteEvents=void 0),qg&&((ei=f.media.remote)==null||ei.addEventListener(Qe,Ut),h[Oe].remoteEvents=Ut)}),ut=h[Oe].rootEvents,eA.forEach(Qe=>{ut&&Hg&&(l.documentElement.removeEventListener(Qe,ut),h[Oe].rootEvents=void 0),jg&&(f.documentElement.addEventListener(Qe,Ut),h[Oe].rootEvents=Ut)});let Xg=h[Oe].stateOwnersUpdateHandlers;tA.forEach(Qe=>{Xg&&Gg&&Xg(),zg&&(h[Oe].stateOwnersUpdateHandlers=Qe(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,b])=>{l.options[y]=b})},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 ip=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Te=(i,e,t)=>(ip(i,e,"read from private field"),t?t.call(i):e.get(i)),dr=(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)=>(ip(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Vr=(i,e,t)=>(ip(i,e,"access private method"),t),Ps,fo,Fe,mo,Ii,vu,Eu,Jm,Un,po,bu,ep,HT=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],UT=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"},Tu=class extends ks{constructor(){super(),dr(this,Eu),dr(this,Un),dr(this,bu),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,dr(this,Ps,new Gr(this,Y.HOTKEYS)),dr(this,fo,void 0),dr(this,Fe,void 0),dr(this,mo,void 0),dr(this,Ii,void 0),dr(this,vu,t=>{var r;(r=Te(this,Fe))==null||r.dispatch(t)}),this.associateElement(this);let e={};Kr(this,mo,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(Jb[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 Te(this,Fe)}set mediaStore(e){var t,r;if(Te(this,Fe)&&((t=Te(this,Ii))==null||t.call(this),Kr(this,Ii,void 0)),Kr(this,Fe,e),!Te(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)){Vr(this,Eu,Jm).call(this);return}Kr(this,Ii,(r=Te(this,Fe))==null?void 0:r.subscribe(Te(this,mo)))}get fullscreenElement(){var e;return(e=Te(this,fo))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(Y.FULLSCREEN_ELEMENT)&&this.removeAttribute(Y.FULLSCREEN_ELEMENT),Kr(this,fo,e),(t=Te(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)Te(this,Ps).value=r;else if(e===Y.DEFAULT_SUBTITLES&&r!==t)(s=Te(this,Fe))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES)}});else if(e===Y.DEFAULT_STREAM_TYPE)(a=Te(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=Te(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=Te(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=Te(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,fo,h),(c=Te(this,Fe))==null||c.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===Y.LANG&&r!==t&&dT(r)}connectedCallback(){var e,t;!Te(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)&&Vr(this,Eu,Jm).call(this),(e=Te(this,Fe))==null||e.dispatch({type:"documentelementchangerequest",detail:Ue}),super.connectedCallback(),Te(this,Fe)&&!Te(this,Ii)&&Kr(this,Ii,(t=Te(this,Fe))==null?void 0:t.subscribe(Te(this,mo))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),Te(this,Fe)&&((t=Te(this,Fe))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=Te(this,Fe))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),Te(this,Ii)&&((s=Te(this,Ii))==null||s.call(this),Kr(this,Ii,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=Te(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=Te(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){$T(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=Yk(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,Te(this,vu))}),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,Te(this,vu))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Te(this,Fe)&&Object.entries(Te(this,Fe).getState()).forEach(([s,n])=>{$T([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,bu,ep))}disableHotkeys(){this.removeEventListener("keydown",Vr(this,bu,ep)),this.removeEventListener("keyup",Vr(this,Un,po))}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(!Te(this,Ps).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Te(this,Ps).contains("nospace")))switch(e.key){case" ":case"k":d=Te(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):UT;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):UT;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;fo=new WeakMap;Fe=new WeakMap;mo=new WeakMap;Ii=new WeakMap;vu=new WeakMap;Eu=new WeakSet;Jm=function(){var i;this.mediaStore=NT({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;po=function(i){let{key:e}=i;if(!HT.includes(e)){this.removeEventListener("keyup",Vr(this,Un,po));return}this.keyboardShortcutHandler(i)};bu=new WeakSet;ep=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!HT.includes(r)){this.removeEventListener("keyup",Vr(this,Un,po));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(Te(this,Ps).contains(`no${r.toLowerCase()}`)||r===" "&&Te(this,Ps).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Vr(this,Un,po),{once:!0})};var Hk=Object.values(T),Gk=Object.values(Nm),GT=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=>Hk.includes(o)):[]},Kk=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),Gk.some(r=>r in i)},tp=i=>Kk(i)||!!GT(i).length,FT=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},BT={[T.MEDIA_SUBTITLES_LIST]:lr,[T.MEDIA_SUBTITLES_SHOWING]:lr,[T.MEDIA_SEEKABLE]:FT,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(FT).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:tT,[T.MEDIA_AUDIO_TRACK_LIST]:rT},Vk=async(i,e,t)=>{var r,s;if(i.isConnected||await jd(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=BT[e])==null?void 0:r.call(BT,t))!=null?s:t;return i.setAttribute(e,n)},Wk=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Os=(i,e)=>{if(Wk(i))return;let t=(s,n)=>{var a,o;tp(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("-")&&!tp(i)){S.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},$T=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=GT(r),n=e.toLowerCase();s.includes(n)&&Vk(r,n,t)})},Yk=(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&&(tp(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",Tu);var rp=Tu;var Fn={PLACEMENT:"placement",BOUNDS:"bounds"};function qk(i){return`
|
|
283
|
+
`}var kk=Object.values(T),wk="sm:384 md:576 lg:768 xl:960";function Dk(i){AT(i.target,i.contentRect.width)}function AT(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(ee.BREAKPOINTS))!=null?t:wk,s=Ck(r),n=Mk(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 Ck(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Mk(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,TT).bind(this))),Gt(this,oo,!1),Gt(this,ou,t=>{Kt(this,oo)||(setTimeout(()=>{Dk(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(kk).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES,T.MEDIA_WIDTH,T.MEDIA_HEIGHT,T.MEDIA_ERROR,T.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,""),AT(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,yT).call(this,e);break;case"pointerup":Zt(this,qm,_T).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;TT=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;yT=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;_T=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=Lk;S.customElements.get("media-container")||S.customElements.define("media-container",ks);var ST=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(ST(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)=>(ST(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 Ok=(i="")=>i.split(/\s+/),xT=(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={})=>Ok(i).map(t=>{let r=xT(t);return{...e,...r}}),Xm=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?xT(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(" "),Pk=(i,e)=>t=>t[i]===e,RT=i=>{let e=Object.entries(i).map(([t,r])=>Pk(t,r));return t=>e.every(r=>r(t))},Cs=(i,e=[],t=[])=>{let r=Xm(t).map(RT),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:RT(e);return Array.from(i.textTracks).filter(t)},mu=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)};var LT=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)}},IT="exitFullscreen"in Ue?"exitFullscreen":"webkitExitFullscreen"in Ue?"webkitExitFullscreen":"webkitCancelFullScreen"in Ue?"webkitCancelFullScreen":void 0,kT=i=>{var e;let{documentElement:t}=i;if(IT){let r=(e=t==null?void 0:t[IT])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},fo="fullscreenElement"in Ue?"fullscreenElement":"webkitFullscreenElement"in Ue?"webkitFullscreenElement":void 0,Nk=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===rT.FULLSCREEN?t:r},wT=i=>{var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;let n=Nk(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},Uk="fullscreenEnabled"in Ue?"fullscreenEnabled":"webkitFullscreenEnabled"in Ue?"webkitFullscreenEnabled":void 0,DT=i=>{let{documentElement:e,media:t}=i;return!!(e!=null&&e[Uk])||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)},CT=async(i=Qm())=>{if(!i)return!1;let e=i.volume;i.volume=e/2+.1;let t=new AbortController,r=await Promise.race([Fk(i,t.signal),Bk(i,e)]);return t.abort(),r},Fk=(i,e)=>new Promise(t=>{i.addEventListener("volumechange",()=>t(!0),{signal:e})}),Bk=async(i,e)=>{for(let t=0;t<10;t++){if(i.volume===e)return!1;await Xd(10)}return i.volume!==e},$k=/.*Version\/.*Safari\/.*/.test(S.navigator.userAgent),Zm=(i=Qm())=>S.matchMedia("(display-mode: standalone)").matches&&$k?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Jm=(i=Qm())=>DT({documentElement:Ue,media:i}),MT=Jm(),OT=Zm(),PT=!!S.WebKitPlaybackTargetAvailabilityEvent,NT=!!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)?Hk(i,e):Object.entries(i).every(([t,r])=>t in e&&vu(r,e[t])),Hk=(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 Gk=Object.values(ci),Eu,Kk=CT().then(i=>(Eu=i,Eu)),UT=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))}))},Vk=new S.DOMParser,Wk=i=>i&&(Vk.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(Gk.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:Wk(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 wT(i)},set(i,e){i?LT(e):kT(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(!MT||!Jm(e))return Ht.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!OT||!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&&Kk.then(e=>i(e?void 0:Ht.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!NT||!((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(!PT)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 FT={[$.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 BT=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Nn,requestMap:s=FT,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,b,_,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 UT(...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=((b=l.media)==null?void 0:b.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,b])=>{l.options[y]=b})},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)},Te=(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,bu,Tu,tp,Un,go,yu,ip,VT=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],$T=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,Tu),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,bu,t=>{var r;(r=Te(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(iT[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 Te(this,Fe)}set mediaStore(e){var t,r;if(Te(this,Fe)&&((t=Te(this,Ii))==null||t.call(this),Kr(this,Ii,void 0)),Kr(this,Fe,e),!Te(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)){Vr(this,Tu,tp).call(this);return}Kr(this,Ii,(r=Te(this,Fe))==null?void 0:r.subscribe(Te(this,po)))}get fullscreenElement(){var e;return(e=Te(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=Te(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)Te(this,Ps).value=r;else if(e===Y.DEFAULT_SUBTITLES&&r!==t)(s=Te(this,Fe))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(Y.DEFAULT_SUBTITLES)}});else if(e===Y.DEFAULT_STREAM_TYPE)(a=Te(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=Te(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=Te(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=Te(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=Te(this,Fe))==null||c.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===Y.LANG&&r!==t&&hT(r)}connectedCallback(){var e,t;!Te(this,Fe)&&!this.hasAttribute(Y.NO_DEFAULT_STORE)&&Vr(this,Tu,tp).call(this),(e=Te(this,Fe))==null||e.dispatch({type:"documentelementchangerequest",detail:Ue}),super.connectedCallback(),Te(this,Fe)&&!Te(this,Ii)&&Kr(this,Ii,(t=Te(this,Fe))==null?void 0:t.subscribe(Te(this,po))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),Te(this,Fe)&&((t=Te(this,Fe))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=Te(this,Fe))==null||r.dispatch({type:$.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),Te(this,Ii)&&((s=Te(this,Ii))==null||s.call(this),Kr(this,Ii,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=Te(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=Te(this,Fe))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){KT(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=Qk(e,r,s);Object.values($).forEach(a=>{e.addEventListener(a,Te(this,bu))}),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,Te(this,bu))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),Te(this,Fe)&&Object.entries(Te(this,Fe).getState()).forEach(([s,n])=>{KT([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(!Te(this,Ps).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&Te(this,Ps).contains("nospace")))switch(e.key){case" ":case"k":d=Te(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):$T;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):$T;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;bu=new WeakMap;Tu=new WeakSet;tp=function(){var i;this.mediaStore=BT({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(!VT.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||!VT.includes(r)){this.removeEventListener("keyup",Vr(this,Un,go));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(Te(this,Ps).contains(`no${r.toLowerCase()}`)||r===" "&&Te(this,Ps).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",Vr(this,Un,go),{once:!0})};var Yk=Object.values(T),qk=Object.values(Fm),WT=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=>Yk.includes(o)):[]},jk=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),qk.some(r=>r in i)},rp=i=>jk(i)||!!WT(i).length,HT=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},GT={[T.MEDIA_SUBTITLES_LIST]:dr,[T.MEDIA_SUBTITLES_SHOWING]:dr,[T.MEDIA_SEEKABLE]:HT,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(HT).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:sT,[T.MEDIA_AUDIO_TRACK_LIST]:aT},zk=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=GT[e])==null?void 0:r.call(GT,t))!=null?s:t;return i.setAttribute(e,n)},Xk=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Os=(i,e)=>{if(Xk(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)},KT=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=WT(r),n=e.toLowerCase();s.includes(n)&&zk(r,n,t)})},Qk=(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 Zk(i){return`
|
|
280
284
|
<style>
|
|
281
285
|
:host {
|
|
282
286
|
--_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
|
|
@@ -385,7 +389,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
385
389
|
</style>
|
|
386
390
|
<slot></slot>
|
|
387
391
|
<div id="arrow"></div>
|
|
388
|
-
`}var Bn=class extends S.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!
|
|
392
|
+
`}var Bn=class extends S.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!ru(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;let t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}let r=getComputedStyle(this),s=(e=Ri(this,"#"+this.bounds))!=null?e:We(this);if(!s)return;let{x:n,width:a}=s.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,u=n+a,c=r.getPropertyValue("--media-tooltip-offset-x"),h=c?parseFloat(c.replace("px","")):0,f=r.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,p=o-n+h-m,g=d-u+h+m;if(p<0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}if(g>0){this.style.setProperty("--media-tooltip-offset-x",`${g}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}if(this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){let e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[Fn.PLACEMENT,Fn.BOUNDS]}get placement(){return de(this,Fn.PLACEMENT)}set placement(e){ue(this,Fn.PLACEMENT,e)}get bounds(){return de(this,Fn.BOUNDS)}set bounds(e){ue(this,Fn.BOUNDS,e)}};Bn.shadowRootOptions={mode:"open"};Bn.getTemplateHTML=Zk;S.customElements.get("media-tooltip")||S.customElements.define("media-tooltip",Bn);var Au=Bn;var op=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},st=(i,e,t)=>(op(i,e,"read from private field"),t?t.call(i):e.get(i)),$n=(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)=>(op(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Jk=(i,e,t)=>(op(i,e,"access private method"),t),Li,Gn,Yr,Hn,xu,ap,YT,Wr={TOOLTIP_PLACEMENT:"tooltipplacement",DISABLED:"disabled",NO_TOOLTIP:"notooltip"};function ew(i,e={}){return`
|
|
389
393
|
<style>
|
|
390
394
|
:host {
|
|
391
395
|
position: relative;
|
|
@@ -459,20 +463,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
459
463
|
|
|
460
464
|
<slot name="tooltip">
|
|
461
465
|
<media-tooltip part="tooltip" aria-hidden="true">
|
|
462
|
-
<template shadowrootmode="${
|
|
463
|
-
${
|
|
466
|
+
<template shadowrootmode="${Au.shadowRootOptions.mode}">
|
|
467
|
+
${Au.getTemplateHTML({})}
|
|
464
468
|
</template>
|
|
465
469
|
<slot name="tooltip-content">
|
|
466
470
|
${this.getTooltipContentHTML(i)}
|
|
467
471
|
</slot>
|
|
468
472
|
</media-tooltip>
|
|
469
473
|
</slot>
|
|
470
|
-
`}function
|
|
474
|
+
`}function tw(i,e){return`
|
|
471
475
|
<slot></slot>
|
|
472
|
-
`}function
|
|
476
|
+
`}function iw(){return""}var Le=class extends S.HTMLElement{constructor(){if(super(),$n(this,ap),$n(this,Li,void 0),this.preventClick=!1,this.tooltipEl=null,$n(this,Gn,e=>{this.preventClick||this.handleClick(e),setTimeout(st(this,Yr),0)}),$n(this,Yr,()=>{var e,t;(t=(e=this.tooltipEl)==null?void 0:e.updateXOffset)==null||t.call(e)}),$n(this,Hn,e=>{let{key:t}=e;if(!this.keysUsed.includes(t)){this.removeEventListener("keyup",st(this,Hn));return}this.preventClick||this.handleClick(e)}),$n(this,xu,e=>{let{metaKey:t,altKey:r,key:s}=e;if(t||r||!this.keysUsed.includes(s)){this.removeEventListener("keyup",st(this,Hn));return}this.addEventListener("keyup",st(this,Hn),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",Wr.TOOLTIP_PLACEMENT,me.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",st(this,Gn)),this.addEventListener("keydown",st(this,xu)),this.tabIndex=0}disable(){this.removeEventListener("click",st(this,Gn)),this.removeEventListener("keydown",st(this,xu)),this.removeEventListener("keyup",st(this,Hn)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=st(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),Su(this,Li,null)),r&&this.isConnected&&(Su(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=st(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t?r==null?this.enable():this.disable():e===Wr.TOOLTIP_PLACEMENT&&this.tooltipEl&&r!==t&&(this.tooltipEl.placement=r),st(this,Yr).call(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))`),this.hasAttribute("disabled")?this.disable():this.enable(),this.setAttribute("role","button");let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(Su(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=st(this,Li))==null?void 0:t.associateElement)==null||r.call(t,this)),S.customElements.whenDefined("media-tooltip").then(()=>Jk(this,ap,YT).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=st(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),Su(this,Li,null),this.removeEventListener("mouseenter",st(this,Yr)),this.removeEventListener("focus",st(this,Yr)),this.removeEventListener("click",st(this,Gn))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return de(this,Wr.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){ue(this,Wr.TOOLTIP_PLACEMENT,e)}get mediaController(){return de(this,me.MEDIA_CONTROLLER)}set mediaController(e){ue(this,me.MEDIA_CONTROLLER,e)}get disabled(){return ae(this,Wr.DISABLED)}set disabled(e){oe(this,Wr.DISABLED,e)}get noTooltip(){return ae(this,Wr.NO_TOOLTIP)}set noTooltip(e){oe(this,Wr.NO_TOOLTIP,e)}handleClick(e){}};Li=new WeakMap;Gn=new WeakMap;Yr=new WeakMap;Hn=new WeakMap;xu=new WeakMap;ap=new WeakSet;YT=function(){this.addEventListener("mouseenter",st(this,Yr)),this.addEventListener("focus",st(this,Yr)),this.addEventListener("click",st(this,Gn));let i=this.tooltipPlacement;i&&this.tooltipEl&&(this.tooltipEl.placement=i)};Le.shadowRootOptions={mode:"open"};Le.getTemplateHTML=ew;Le.getSlotTemplateHTML=tw;Le.getTooltipContentHTML=iw;S.customElements.get("media-chrome-button")||S.customElements.define("media-chrome-button",Le);var qT=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
473
477
|
<path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
|
|
474
478
|
</svg>
|
|
475
|
-
`;function
|
|
479
|
+
`;function rw(i){return`
|
|
476
480
|
<style>
|
|
477
481
|
:host([${T.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
|
|
478
482
|
display: none !important;
|
|
@@ -490,17 +494,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
490
494
|
</style>
|
|
491
495
|
|
|
492
496
|
<slot name="icon">
|
|
493
|
-
<slot name="enter">${
|
|
494
|
-
<slot name="exit">${
|
|
497
|
+
<slot name="enter">${qT}</slot>
|
|
498
|
+
<slot name="exit">${qT}</slot>
|
|
495
499
|
</slot>
|
|
496
|
-
`}function
|
|
500
|
+
`}function sw(){return`
|
|
497
501
|
<slot name="tooltip-enter">${B("start airplay")}</slot>
|
|
498
502
|
<slot name="tooltip-exit">${B("stop airplay")}</slot>
|
|
499
|
-
`}var
|
|
503
|
+
`}var jT=i=>{let e=i.mediaIsAirplaying?B("stop airplay"):B("start airplay");i.setAttribute("aria-label",e)},vo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),jT(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_AIRPLAYING&&jT(this)}get mediaIsAirplaying(){return ae(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){oe(this,T.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return de(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){ue(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new S.CustomEvent($.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};vo.getSlotTemplateHTML=rw;vo.getTooltipContentHTML=sw;S.customElements.get("media-airplay-button")||S.customElements.define("media-airplay-button",vo);var nw=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
500
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"/>
|
|
501
|
-
</svg>`,
|
|
505
|
+
</svg>`,aw=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
502
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"/>
|
|
503
|
-
</svg>`;function
|
|
507
|
+
</svg>`;function ow(i){return`
|
|
504
508
|
<style>
|
|
505
509
|
:host([aria-checked="true"]) slot[name=off] {
|
|
506
510
|
display: none !important;
|
|
@@ -518,13 +522,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
518
522
|
</style>
|
|
519
523
|
|
|
520
524
|
<slot name="icon">
|
|
521
|
-
<slot name="on">${
|
|
522
|
-
<slot name="off">${
|
|
525
|
+
<slot name="on">${nw}</slot>
|
|
526
|
+
<slot name="off">${aw}</slot>
|
|
523
527
|
</slot>
|
|
524
|
-
`}function
|
|
528
|
+
`}function lw(){return`
|
|
525
529
|
<slot name="tooltip-enable">${B("Enable captions")}</slot>
|
|
526
530
|
<slot name="tooltip-disable">${B("Disable captions")}</slot>
|
|
527
|
-
`}var
|
|
531
|
+
`}var zT=i=>{i.setAttribute("aria-checked",mu(i).toString())},Eo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",B("closed captions")),zT(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_SHOWING&&zT(this)}get mediaSubtitlesList(){return XT(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){QT(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return XT(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){QT(this,T.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new S.CustomEvent($.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}};Eo.getSlotTemplateHTML=ow;Eo.getTooltipContentHTML=lw;var XT=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},QT=(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",Eo);var dw='<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>',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"/><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 cw(i){return`
|
|
528
532
|
<style>
|
|
529
533
|
:host([${T.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
|
|
530
534
|
display: none !important;
|
|
@@ -542,13 +546,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
542
546
|
</style>
|
|
543
547
|
|
|
544
548
|
<slot name="icon">
|
|
545
|
-
<slot name="enter">${
|
|
546
|
-
<slot name="exit">${
|
|
549
|
+
<slot name="enter">${dw}</slot>
|
|
550
|
+
<slot name="exit">${uw}</slot>
|
|
547
551
|
</slot>
|
|
548
|
-
`}function
|
|
552
|
+
`}function hw(){return`
|
|
549
553
|
<slot name="tooltip-enter">${B("Start casting")}</slot>
|
|
550
554
|
<slot name="tooltip-exit">${B("Stop casting")}</slot>
|
|
551
|
-
`}var
|
|
555
|
+
`}var ZT=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,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),ZT(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_CASTING&&ZT(this)}get mediaIsCasting(){return ae(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){oe(this,T.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return de(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){ue(this,T.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=cw;bo.getTooltipContentHTML=hw;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,yo,Fs,Ru,lp,dp,JT,up,ey,cp,ty,hp,iy,fp,ry;function fw(i){return`
|
|
552
556
|
<style>
|
|
553
557
|
:host {
|
|
554
558
|
font: var(--media-font,
|
|
@@ -589,9 +593,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
589
593
|
}
|
|
590
594
|
</style>
|
|
591
595
|
${this.getSlotTemplateHTML(i)}
|
|
592
|
-
`}function
|
|
596
|
+
`}function mw(i){return`
|
|
593
597
|
<slot id="content"></slot>
|
|
594
|
-
`}var
|
|
598
|
+
`}var To={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,yo,null),cr(this,Fs,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[To.OPEN,To.ANCHOR]}get open(){return ae(this,To.OPEN)}set open(e){oe(this,To.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===To.OPEN&&r!==t&&(this.open?Ns(this,dp,JT).call(this):Ns(this,up,ey).call(this))}focus(){pp(this,yo,ao());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;yo=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;JT=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,yo))==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,yo))==null||n.focus(),this.open=!1))};qr.shadowRootOptions={mode:"open"};qr.getTemplateHTML=fw;qr.getSlotTemplateHTML=mw;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,bp,ay,Tp,oy,yp,ly;function pw(i){return`
|
|
595
599
|
<style>
|
|
596
600
|
:host {
|
|
597
601
|
--_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
|
|
@@ -819,7 +823,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
819
823
|
<input id="range" type="range" min="0" max="1" step="any" value="0">
|
|
820
824
|
</div>
|
|
821
825
|
<div id="rightgap"></div>
|
|
822
|
-
`}var wi=class extends S.HTMLElement{constructor(){if(super(),
|
|
826
|
+
`}var wi=class extends S.HTMLElement{constructor(){if(super(),yt(this,Ap),yt(this,Mu),yt(this,Ou),yt(this,Nu),yt(this,Ep),yt(this,bp),yt(this,Tp),yt(this,yp),yt(this,ki,void 0),yt(this,Uu,void 0),yt(this,Lu,void 0),yt(this,ku,void 0),yt(this,mi,{}),yt(this,Pu,[]),yt(this,wu,()=>{if(this.range.matches(":focus-visible")){let{style:e}=Me(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),yt(this,Du,()=>{let{style:e}=Me(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),yt(this,Cu,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);let e=He(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.container=this.shadowRoot.querySelector("#container"),jr(this,Lu,this.shadowRoot.querySelector("#startpoint")),jr(this,ku,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",me.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===me.MEDIA_CONTROLLER?(t&&((n=(s=je(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),jr(this,ki,null)),r&&this.isConnected&&(jr(this,ki,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=je(this,ki))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),fi(this,Mu,gp).call(this)):(this.range.setAttribute(e,r),fi(this,Ou,vp).call(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))`),je(this,mi).pointer=Me(this.shadowRoot,"#pointer"),je(this,mi).progress=Me(this.shadowRoot,"#progress"),je(this,mi).thumb=Me(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),je(this,mi).activeSegment=Me(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let n=this.getAttribute(me.MEDIA_CONTROLLER);n&&(jr(this,ki,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=je(this,ki))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",je(this,wu)),this.shadowRoot.addEventListener("focusout",je(this,Du)),fi(this,Mu,gp).call(this),ar(this.container,je(this,Cu))}disconnectedCallback(){var e,t;fi(this,Ou,vp).call(this),(t=(e=je(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),jr(this,ki,null),this.shadowRoot.removeEventListener("focusin",je(this,wu)),this.shadowRoot.removeEventListener("focusout",je(this,Du)),or(this.container,je(this,Cu))}updatePointerBar(e){var t;(t=je(this,mi).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=je(this,mi).progress)==null||e.style.setProperty("width",`${r}%`),(t=je(this,mi).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];jr(this,Pu,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=Ue.createElementNS("http://www.w3.org/2000/svg","rect"),f=Me(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){return ET(e.clientX,e.clientY,je(this,Lu).getBoundingClientRect(),je(this,ku).getBoundingClientRect())}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":fi(this,yp,ly).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":fi(this,Ep,ny).call(this,e);break;case"pointerdown":fi(this,Nu,Sp).call(this,e);break;case"pointerup":fi(this,bp,ay).call(this);break;case"pointerleave":fi(this,Tp,oy).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};ki=new WeakMap;Uu=new WeakMap;Lu=new WeakMap;ku=new WeakMap;mi=new WeakMap;Pu=new WeakMap;wu=new WeakMap;Du=new WeakMap;Cu=new WeakMap;Ap=new WeakSet;sy=function(i){let e=je(this,mi).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${je(this,Pu).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Mu=new WeakSet;gp=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Ou=new WeakSet;vp=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=S.window)==null||i.removeEventListener("pointerup",this),(e=S.window)==null||e.removeEventListener("pointermove",this)};Nu=new WeakSet;Sp=function(i){var e;jr(this,Uu,i.composedPath().includes(this.range)),(e=S.window)==null||e.addEventListener("pointerup",this)};Ep=new WeakSet;ny=function(i){var e;i.pointerType!=="mouse"&&fi(this,Nu,Sp).call(this,i),this.addEventListener("pointerleave",this),(e=S.window)==null||e.addEventListener("pointermove",this)};bp=new WeakSet;ay=function(){var i;(i=S.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Tp=new WeakSet;oy=function(){var i,e;this.removeEventListener("pointerleave",this),(i=S.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=je(this,mi).activeSegment)==null||e.style.removeProperty("transform")};yp=new WeakSet;ly=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),fi(this,Ap,sy).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!je(this,Uu))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};wi.shadowRootOptions={mode:"open"};wi.getTemplateHTML=pw;S.customElements.get("media-chrome-range")||S.customElements.define("media-chrome-range",wi);var dy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Fu=(i,e,t)=>(dy(i,e,"read from private field"),t?t.call(i):e.get(i)),gw=(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)},Bu=(i,e,t,r)=>(dy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Di;function vw(i){return`
|
|
823
827
|
<style>
|
|
824
828
|
:host {
|
|
825
829
|
|
|
@@ -845,7 +849,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
845
849
|
</style>
|
|
846
850
|
|
|
847
851
|
<slot></slot>
|
|
848
|
-
`}var
|
|
852
|
+
`}var _o=class extends S.HTMLElement{constructor(){if(super(),gw(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;_o.shadowRootOptions={mode:"open"};_o.getTemplateHTML=vw;S.customElements.get("media-control-bar")||S.customElements.define("media-control-bar",_o);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)),Ew=(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`
|
|
849
853
|
<style>
|
|
850
854
|
:host {
|
|
851
855
|
font: var(--media-font,
|
|
@@ -879,11 +883,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
879
883
|
</style>
|
|
880
884
|
|
|
881
885
|
${this.getSlotTemplateHTML(i,e)}
|
|
882
|
-
`}function
|
|
886
|
+
`}function Tw(i,e){return`
|
|
883
887
|
<slot></slot>
|
|
884
|
-
`}var Ot=class extends S.HTMLElement{constructor(){if(super(),
|
|
885
|
-
<slot>${
|
|
886
|
-
`}var
|
|
888
|
+
`}var Ot=class extends S.HTMLElement{constructor(){if(super(),Ew(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=Tw;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)),yw=(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)},_w=(i,e,t,r)=>(hy(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ao;function Aw(i,e){return`
|
|
889
|
+
<slot>${hi(e.mediaDuration)}</slot>
|
|
890
|
+
`}var Gu=class extends Ot{constructor(){var e;super(),yw(this,Ao,void 0),_w(this,Ao,this.shadowRoot.querySelector("slot")),cy(this,Ao).textContent=hi((e=this.mediaDuration)!=null?e:0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===T.MEDIA_DURATION&&(cy(this,Ao).textContent=hi(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return ge(this,T.MEDIA_DURATION)}set mediaDuration(e){ye(this,T.MEDIA_DURATION,e)}};Ao=new WeakMap;Gu.getSlotTemplateHTML=Aw;S.customElements.get("media-duration-display")||S.customElements.define("media-duration-display",Gu);var Sw={2:B("Network Error"),3:B("Decode Error"),4:B("Source Not Supported"),5:B("Encryption Error")},xw={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=Sw[i.code])!=null?e:`Error ${i.code}`,message:(t=xw[i.code])!=null?t:i.message}};var my=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Rw=(i,e,t)=>(my(i,e,"read from private field"),t?t.call(i):e.get(i)),Iw=(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)},Lw=(i,e,t,r)=>(my(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ku;function kw(i){return`
|
|
887
891
|
<style>
|
|
888
892
|
:host {
|
|
889
893
|
background: rgb(20 20 30 / .8);
|
|
@@ -900,13 +904,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
900
904
|
}
|
|
901
905
|
</style>
|
|
902
906
|
<slot name="error-${i.mediaerrorcode}" id="content">
|
|
903
|
-
${
|
|
907
|
+
${py({code:+i.mediaerrorcode,message:i.mediaerrormessage})}
|
|
904
908
|
</slot>
|
|
905
|
-
`}function
|
|
909
|
+
`}function ww(i){return i.code&&xp(i)!==null}function py(i){var e;let{title:t,message:r}=(e=xp(i))!=null?e:{},s="";return t&&(s+=`<slot name="error-${i.code}-title"><h3>${t}</h3></slot>`),r&&(s+=`<slot name="error-${i.code}-message"><p>${r}</p></slot>`),s}var fy=[T.MEDIA_ERROR_CODE,T.MEDIA_ERROR_MESSAGE],Kn=class extends qr{constructor(){super(...arguments),Iw(this,Ku,null)}static get observedAttributes(){return[...super.observedAttributes,...fy]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,r){var s;if(super.attributeChangedCallback(e,t,r),!fy.includes(e))return;let n=(s=this.mediaError)!=null?s:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=ww(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n))}get mediaError(){return Rw(this,Ku)}set mediaError(e){Lw(this,Ku,e)}get mediaErrorCode(){return ge(this,"mediaerrorcode")}set mediaErrorCode(e){ye(this,"mediaerrorcode",e)}get mediaErrorMessage(){return de(this,"mediaerrormessage")}set mediaErrorMessage(e){ue(this,"mediaerrormessage",e)}};Ku=new WeakMap;Kn.getSlotTemplateHTML=kw;Kn.formatErrorMessage=py;S.customElements.get("media-error-dialog")||S.customElements.define("media-error-dialog",Kn);var Vu=Kn;var Dw=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
906
910
|
<path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
|
|
907
|
-
</svg>`,
|
|
911
|
+
</svg>`,Cw=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
908
912
|
<path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
|
|
909
|
-
</svg>`;function
|
|
913
|
+
</svg>`;function Mw(i){return`
|
|
910
914
|
<style>
|
|
911
915
|
:host([${T.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
|
|
912
916
|
display: none !important;
|
|
@@ -924,13 +928,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
924
928
|
</style>
|
|
925
929
|
|
|
926
930
|
<slot name="icon">
|
|
927
|
-
<slot name="enter">${
|
|
928
|
-
<slot name="exit">${
|
|
931
|
+
<slot name="enter">${Dw}</slot>
|
|
932
|
+
<slot name="exit">${Cw}</slot>
|
|
929
933
|
</slot>
|
|
930
|
-
`}function
|
|
934
|
+
`}function Ow(){return`
|
|
931
935
|
<slot name="tooltip-enter">${B("Enter fullscreen mode")}</slot>
|
|
932
936
|
<slot name="tooltip-exit">${B("Exit fullscreen mode")}</slot>
|
|
933
|
-
`}var
|
|
937
|
+
`}var gy=i=>{let e=i.mediaIsFullscreen?B("exit fullscreen mode"):B("enter fullscreen mode");i.setAttribute("aria-label",e)},So=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),gy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_FULLSCREEN&&gy(this)}get mediaFullscreenUnavailable(){return de(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){ue(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return ae(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){oe(this,T.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}))}};So.getSlotTemplateHTML=Mw;So.getTooltipContentHTML=Ow;S.customElements.get("media-fullscreen-button")||S.customElements.define("media-fullscreen-button",So);var{MEDIA_TIME_IS_LIVE:Wu,MEDIA_PAUSED:xo}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:Pw,MEDIA_PLAY_REQUEST:Nw}=$,Uw='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>';function Fw(i){return`
|
|
934
938
|
<style>
|
|
935
939
|
:host { --media-tooltip-display: none; }
|
|
936
940
|
|
|
@@ -942,13 +946,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
942
946
|
color: var(--media-live-button-icon-color, rgb(140, 140, 140));
|
|
943
947
|
}
|
|
944
948
|
|
|
945
|
-
:host([${
|
|
946
|
-
:host([${
|
|
949
|
+
:host([${Wu}]:not([${xo}])) slot[name=indicator] > *,
|
|
950
|
+
:host([${Wu}]:not([${xo}])) ::slotted([slot=indicator]) {
|
|
947
951
|
fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
948
952
|
color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
|
|
949
953
|
}
|
|
950
954
|
|
|
951
|
-
:host([${
|
|
955
|
+
:host([${Wu}]:not([${xo}])) {
|
|
952
956
|
cursor: var(--media-cursor, not-allowed);
|
|
953
957
|
}
|
|
954
958
|
|
|
@@ -958,10 +962,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
958
962
|
|
|
959
963
|
</style>
|
|
960
964
|
|
|
961
|
-
<slot name="indicator">${
|
|
965
|
+
<slot name="indicator">${Uw}</slot>
|
|
962
966
|
|
|
963
967
|
<slot name="spacer"> </slot><slot name="text">${B("live")}</slot>
|
|
964
|
-
`}var
|
|
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,xo]}connectedCallback(){super.connectedCallback(),vy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),vy(this)}get mediaPaused(){return ae(this,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return ae(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){oe(this,T.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new S.CustomEvent(Pw,{composed:!0,bubbles:!0})),this.hasAttribute(xo)&&this.dispatchEvent(new S.CustomEvent(Nw,{composed:!0,bubbles:!0})))}};Yu.getSlotTemplateHTML=Fw;S.customElements.get("media-live-button")||S.customElements.define("media-live-button",Yu);var by=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ro=(i,e,t)=>(by(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)},Io=(i,e,t,r)=>(by(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"},Ty=500,Bw=`
|
|
965
969
|
<svg aria-hidden="true" viewBox="0 0 100 100">
|
|
966
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">
|
|
967
971
|
<animateTransform
|
|
@@ -974,13 +978,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
974
978
|
repeatCount="indefinite" />
|
|
975
979
|
</path>
|
|
976
980
|
</svg>
|
|
977
|
-
`;function
|
|
981
|
+
`;function $w(i){return`
|
|
978
982
|
<style>
|
|
979
983
|
:host {
|
|
980
984
|
display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
|
|
981
985
|
vertical-align: middle;
|
|
982
986
|
box-sizing: border-box;
|
|
983
|
-
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${
|
|
987
|
+
--_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${Ty}ms);
|
|
984
988
|
}
|
|
985
989
|
|
|
986
990
|
#status {
|
|
@@ -1019,15 +1023,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1019
1023
|
}
|
|
1020
1024
|
</style>
|
|
1021
1025
|
|
|
1022
|
-
<slot name="icon">${
|
|
1026
|
+
<slot name="icon">${Bw}</slot>
|
|
1023
1027
|
<div id="status" role="status" aria-live="polite">${B("media loading")}</div>
|
|
1024
|
-
`}var
|
|
1028
|
+
`}var Lo=class extends S.HTMLElement{constructor(){if(super(),Ey(this,Mi,void 0),Ey(this,ju,Ty),!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,T.MEDIA_PAUSED,T.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=Ro(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Io(this,Mi,null)),r&&this.isConnected&&(Io(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ro(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&&(Io(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Ro(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ro(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Io(this,Mi,null)}get loadingDelay(){return Ro(this,ju)}set loadingDelay(e){Io(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,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,T.MEDIA_LOADING)}set mediaLoading(e){oe(this,T.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;Lo.shadowRootOptions={mode:"open"};Lo.getTemplateHTML=$w;S.customElements.get("media-loading-indicator")||S.customElements.define("media-loading-indicator",Lo);var Hw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1025
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"/>
|
|
1026
|
-
</svg>`,
|
|
1030
|
+
</svg>`,yy=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1027
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"/>
|
|
1028
|
-
</svg>`,
|
|
1032
|
+
</svg>`,Gw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1029
1033
|
<path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
|
|
1030
|
-
</svg>`;function
|
|
1034
|
+
</svg>`;function Kw(i){return`
|
|
1031
1035
|
<style>
|
|
1032
1036
|
:host(:not([${T.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
|
|
1033
1037
|
:host([${T.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
|
|
@@ -1053,17 +1057,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1053
1057
|
</style>
|
|
1054
1058
|
|
|
1055
1059
|
<slot name="icon">
|
|
1056
|
-
<slot name="off">${
|
|
1057
|
-
<slot name="low">${
|
|
1058
|
-
<slot name="medium">${
|
|
1059
|
-
<slot name="high">${
|
|
1060
|
+
<slot name="off">${Hw}</slot>
|
|
1061
|
+
<slot name="low">${yy}</slot>
|
|
1062
|
+
<slot name="medium">${yy}</slot>
|
|
1063
|
+
<slot name="high">${Gw}</slot>
|
|
1060
1064
|
</slot>
|
|
1061
|
-
`}function
|
|
1065
|
+
`}function Vw(){return`
|
|
1062
1066
|
<slot name="tooltip-mute">${B("Mute")}</slot>
|
|
1063
1067
|
<slot name="tooltip-unmute">${B("Unmute")}</slot>
|
|
1064
|
-
`}var
|
|
1068
|
+
`}var _y=i=>{let t=i.mediaVolumeLevel==="off"?B("unmute"):B("mute");i.setAttribute("aria-label",t)},ko=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),_y(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_VOLUME_LEVEL&&_y(this)}get mediaVolumeLevel(){return de(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){ue(this,T.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}))}};ko.getSlotTemplateHTML=Kw;ko.getTooltipContentHTML=Vw;S.customElements.get("media-mute-button")||S.customElements.define("media-mute-button",ko);var Ay=`<svg aria-hidden="true" viewBox="0 0 28 24">
|
|
1065
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"/>
|
|
1066
|
-
</svg>`;function
|
|
1070
|
+
</svg>`;function Ww(i){return`
|
|
1067
1071
|
<style>
|
|
1068
1072
|
:host([${T.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
|
|
1069
1073
|
display: none !important;
|
|
@@ -1080,13 +1084,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1080
1084
|
</style>
|
|
1081
1085
|
|
|
1082
1086
|
<slot name="icon">
|
|
1083
|
-
<slot name="enter">${
|
|
1084
|
-
<slot name="exit">${
|
|
1087
|
+
<slot name="enter">${Ay}</slot>
|
|
1088
|
+
<slot name="exit">${Ay}</slot>
|
|
1085
1089
|
</slot>
|
|
1086
|
-
`}function
|
|
1090
|
+
`}function Yw(){return`
|
|
1087
1091
|
<slot name="tooltip-enter">${B("Enter picture in picture mode")}</slot>
|
|
1088
1092
|
<slot name="tooltip-exit">${B("Exit picture in picture mode")}</slot>
|
|
1089
|
-
`}var
|
|
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)},wo=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Sy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_PIP&&Sy(this)}get mediaPipUnavailable(){return de(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){ue(this,T.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return ae(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){oe(this,T.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}))}};wo.getSlotTemplateHTML=Ww;wo.getTooltipContentHTML=Yw;S.customElements.get("media-pip-button")||S.customElements.define("media-pip-button",wo);var qw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vn=(i,e,t)=>(qw(i,e,"read from private field"),t?t.call(i):e.get(i)),jw=(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 zw(i){return`
|
|
1090
1094
|
<style>
|
|
1091
1095
|
:host {
|
|
1092
1096
|
min-width: 5ch;
|
|
@@ -1094,11 +1098,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1094
1098
|
}
|
|
1095
1099
|
</style>
|
|
1096
1100
|
<slot name="icon">${i.mediaplaybackrate||Bs}x</slot>
|
|
1097
|
-
`}function
|
|
1101
|
+
`}function Xw(){return B("Playback rate")}var Do=class extends Le{constructor(){var e;super(),jw(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,T.MEDIA_PLAYBACK_RATE,Rp.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Rp.RATES&&(Vn(this,zr).value=r),e===T.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,T.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){ye(this,T.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;Do.getSlotTemplateHTML=zw;Do.getTooltipContentHTML=Xw;S.customElements.get("media-playback-rate-button")||S.customElements.define("media-playback-rate-button",Do);var Qw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1098
1102
|
<path d="m6 21 15-9L6 3v18Z"/>
|
|
1099
|
-
</svg>`,
|
|
1103
|
+
</svg>`,Zw=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1100
1104
|
<path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
|
|
1101
|
-
</svg>`;function
|
|
1105
|
+
</svg>`;function Jw(i){return`
|
|
1102
1106
|
<style>
|
|
1103
1107
|
:host([${T.MEDIA_PAUSED}]) slot[name=pause],
|
|
1104
1108
|
:host(:not([${T.MEDIA_PAUSED}])) slot[name=play] {
|
|
@@ -1112,13 +1116,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1112
1116
|
</style>
|
|
1113
1117
|
|
|
1114
1118
|
<slot name="icon">
|
|
1115
|
-
<slot name="play">${
|
|
1116
|
-
<slot name="pause">${
|
|
1119
|
+
<slot name="play">${Qw}</slot>
|
|
1120
|
+
<slot name="pause">${Zw}</slot>
|
|
1117
1121
|
</slot>
|
|
1118
|
-
`}function
|
|
1122
|
+
`}function eD(){return`
|
|
1119
1123
|
<slot name="tooltip-play">${B("Play")}</slot>
|
|
1120
1124
|
<slot name="tooltip-pause">${B("Pause")}</slot>
|
|
1121
|
-
`}var
|
|
1125
|
+
`}var xy=i=>{let e=i.mediaPaused?B("play"):B("pause");i.setAttribute("aria-label",e)},Co=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),xy(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PAUSED&&xy(this)}get mediaPaused(){return ae(this,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?$.MEDIA_PLAY_REQUEST:$.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new S.CustomEvent(e,{composed:!0,bubbles:!0}))}};Co.getSlotTemplateHTML=Jw;Co.getTooltipContentHTML=eD;S.customElements.get("media-play-button")||S.customElements.define("media-play-button",Co);var Oi={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"};function tD(i){return`
|
|
1122
1126
|
<style>
|
|
1123
1127
|
:host {
|
|
1124
1128
|
pointer-events: none;
|
|
@@ -1140,7 +1144,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1140
1144
|
</style>
|
|
1141
1145
|
|
|
1142
1146
|
<img part="poster img" aria-hidden="true" id="image"/>
|
|
1143
|
-
`}var
|
|
1147
|
+
`}var iD=i=>{i.style.removeProperty("background-image")},rD=(i,e)=>{i.style["background-image"]=`url('${e}')`},Mo=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?iD(this.image):rD(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)}};Mo.shadowRootOptions={mode:"open"};Mo.getTemplateHTML=tD;S.customElements.get("media-poster-image")||S.customElements.define("media-poster-image",Mo);var Ry=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},sD=(i,e,t)=>(Ry(i,e,"read from private field"),t?t.call(i):e.get(i)),nD=(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)},aD=(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(),nD(this,zu,void 0),aD(this,zu,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(sD(this,zu).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return de(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){ue(this,T.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)),oD=(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 lD(i){return`
|
|
1144
1148
|
<style>
|
|
1145
1149
|
:host {
|
|
1146
1150
|
box-sizing: border-box;
|
|
@@ -1154,27 +1158,27 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1154
1158
|
}
|
|
1155
1159
|
</style>
|
|
1156
1160
|
<img crossorigin loading="eager" decoding="async">
|
|
1157
|
-
`}var Wn=class extends S.HTMLElement{constructor(){if(super(),
|
|
1161
|
+
`}var Wn=class extends S.HTMLElement{constructor(){if(super(),oD(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,T.MEDIA_PREVIEW_IMAGE,T.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;[T.MEDIA_PREVIEW_IMAGE,T.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,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.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,b=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"};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,A()},b.src=o,A()),A(),y.transform=`translate(-${r*g}px, -${s*g}px)`}};Pi=new WeakMap;Wn.shadowRootOptions={mode:"open"};Wn.getTemplateHTML=lD;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)),dD=(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)},uD=(i,e,t,r)=>(ky(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Oo,kp=class extends Ot{constructor(){super(),dD(this,Oo,void 0),uD(this,Oo,this.shadowRoot.querySelector("slot")),Ly(this,Oo).textContent=hi(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_TIME&&r!=null&&(Ly(this,Oo).textContent=hi(parseFloat(r)))}get mediaPreviewTime(){return ge(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,T.MEDIA_PREVIEW_TIME,e)}};Oo=new WeakMap;S.customElements.get("media-preview-time-display")||S.customElements.define("media-preview-time-display",kp);var Yn={SEEK_OFFSET:"seekoffset"},wp=30,cD=i=>`
|
|
1158
1162
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1159
1163
|
<defs>
|
|
1160
1164
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
1161
1165
|
</defs>
|
|
1162
1166
|
<text class="text value" transform="translate(2.18 19.87)">${i}</text>
|
|
1163
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"/>
|
|
1164
|
-
</svg>`;function
|
|
1165
|
-
<slot name="icon">${
|
|
1166
|
-
`}function
|
|
1168
|
+
</svg>`;function hD(i,e){return`
|
|
1169
|
+
<slot name="icon">${cD(e.seekOffset)}</slot>
|
|
1170
|
+
`}function fD(){return B("Seek backward")}var mD=0,Po=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.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,T.MEDIA_CURRENT_TIME,mD)}set mediaCurrentTime(e){ye(this,T.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)}};Po.getSlotTemplateHTML=hD;Po.getTooltipContentHTML=fD;S.customElements.get("media-seek-backward-button")||S.customElements.define("media-seek-backward-button",Po);var qn={SEEK_OFFSET:"seekoffset"},Dp=30,pD=i=>`
|
|
1167
1171
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1168
1172
|
<defs>
|
|
1169
1173
|
<style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
|
|
1170
1174
|
</defs>
|
|
1171
1175
|
<text class="text value" transform="translate(8.9 19.87)">${i}</text>
|
|
1172
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"/>
|
|
1173
|
-
</svg>`;function
|
|
1174
|
-
<slot name="icon">${
|
|
1175
|
-
`}function
|
|
1176
|
-
<slot>${
|
|
1177
|
-
`}var
|
|
1177
|
+
</svg>`;function gD(i,e){return`
|
|
1178
|
+
<slot name="icon">${pD(e.seekOffset)}</slot>
|
|
1179
|
+
`}function vD(){return B("Seek forward")}var ED=0,No=class extends Le{static get observedAttributes(){return[...super.observedAttributes,T.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,T.MEDIA_CURRENT_TIME,ED)}set mediaCurrentTime(e){ye(this,T.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)}};No.getSlotTemplateHTML=gD;No.getTooltipContentHTML=vD;S.customElements.get("media-seek-forward-button")||S.customElements.define("media-seek-forward-button",No);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)},TD=(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),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],Dy=["Enter"," "],yD=" / ",Mp=(i,{timesSep:e=yD}={})=>{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},_D="video not loaded, unknown time.",AD=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",_D);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 SD(i,e){return`
|
|
1180
|
+
<slot>${Mp(e)}</slot>
|
|
1181
|
+
`}var Ju=class extends Ot{constructor(){super(),bD(this,jn,void 0),TD(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,T.MEDIA_DURATION)}set mediaDuration(e){ye(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,T.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Mp(this);AD(this),e!==Cp(this,jn).innerHTML&&(Cp(this,jn).innerHTML=e)}};jn=new WeakMap;Ju.getSlotTemplateHTML=SD;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),xD=(i,e,t,r)=>({set _(s){Vt(i,e,s,t)},get _(){return vt(i,e,r)}}),zn,ec,Xn,Uo,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,Uo,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,Uo,performance.now()-vt(this,Xn));let n=1e3/this.fps;if(vt(this,Uo)>n){Vt(this,Xn,s-vt(this,Uo)%n);let a=1e3/((s-vt(this,ec))/++xD(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;Uo=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,Bo,dc,oc,$o,Ho,Jn,ea,Fo,Fp,Oy,Op,uc,Bp,cc,$p,hc,Hp,Pp,Py,Go,fc,Np,Ny,RD="video not loaded, unknown time.",ID=i=>{let e=i.range,t=Rs(+Uy(i)),r=Rs(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:RD;e.setAttribute("aria-valuetext",s)};function LD(i){return`
|
|
1178
1182
|
${wi.getTemplateHTML(i)}
|
|
1179
1183
|
<style>
|
|
1180
1184
|
:host {
|
|
@@ -1378,8 +1382,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1378
1382
|
<div id="preview-rail">
|
|
1379
1383
|
<slot name="preview" part="box preview-box">
|
|
1380
1384
|
<media-preview-thumbnail>
|
|
1381
|
-
<template shadowrootmode="${
|
|
1382
|
-
${
|
|
1385
|
+
<template shadowrootmode="${Zu.shadowRootOptions.mode}">
|
|
1386
|
+
${Zu.getTemplateHTML({})}
|
|
1383
1387
|
</template>
|
|
1384
1388
|
</media-preview-thumbnail>
|
|
1385
1389
|
<media-preview-chapter-display></media-preview-chapter-display>
|
|
@@ -1392,7 +1396,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1392
1396
|
|
|
1393
1397
|
</slot>
|
|
1394
1398
|
</div>
|
|
1395
|
-
`}var sc=(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))},Oy=(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},Go=class extends wi{constructor(){super(),Et(this,ea),Et(this,Np),Et(this,lc),Et(this,dc),Et(this,uc),Et(this,Mp),Et(this,Ho),Et(this,Op),Et(this,Zn,void 0),Et(this,Gs,void 0),Et(this,ac,void 0),Et(this,Fo,void 0),Et(this,oc,void 0),Et(this,nc,void 0),Et(this,Bo,void 0),Et(this,$o,void 0),Et(this,Jn,void 0),Et(this,Cp,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,ac,this.shadowRoot.querySelectorAll('[part~="box"]')),Ui(this,oc,this.shadowRoot.querySelector('[part~="preview-box"]')),Ui(this,nc,this.shadowRoot.querySelector('[part~="current-box"]'));let t=getComputedStyle(this);Ui(this,Bo,parseInt(t.getPropertyValue("--media-box-padding-left"))),Ui(this,$o,parseInt(t.getPropertyValue("--media-box-padding-right"))),Ui(this,Gs,new rc(this.range,dt(this,Cp),60))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",B("seek")),At(this,ea,Uo).call(this),Ui(this,Zn,this.getRootNode()),(e=dt(this,Zn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),At(this,ea,Uo).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===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(dt(this,Gs).update({start:sc(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),At(this,ea,Uo).call(this),_D(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.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:sc(this,r.startTime),end:sc(this,r.endTime)})))}get mediaPaused(){return ae(this,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,T.MEDIA_LOADING)}set mediaLoading(e){oe(this,T.MEDIA_LOADING,e)}get mediaDuration(){return ge(this,T.MEDIA_DURATION)}set mediaDuration(e){ye(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ge(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ye(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.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,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ge(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return ae(this,T.MEDIA_ENDED)}set mediaEnded(e){oe(this,T.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=sc(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=At(this,lc,Up).call(this,dt(this,nc)),n=At(this,dc,Fp).call(this,s,this.range.valueAsNumber),a=At(this,uc,Bp).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":At(this,Op,My).call(this);break;case"pointermove":At(this,Mp,Cy).call(this,e);break;case"pointerup":case"pointerleave":At(this,Ho,cc).call(this,null);break;case"transitionstart":Rt(e.target,this)&&setTimeout(()=>At(this,ea,Uo).call(this),0);break}}};Zn=new WeakMap;Gs=new WeakMap;ac=new WeakMap;Fo=new WeakMap;oc=new WeakMap;nc=new WeakMap;Bo=new WeakMap;$o=new WeakMap;Jn=new WeakMap;ea=new WeakSet;Uo=function(){At(this,Np,Dy).call(this)?dt(this,Gs).start():dt(this,Gs).stop()};Np=new WeakSet;Dy=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&tu(this)};Cp=new WeakMap;lc=new WeakSet;Up=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}};dc=new WeakSet;Fp=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};uc=new WeakSet;Bp=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+dt(this,Bo)){let a=i.range.left-i.bounds.left-dt(this,Bo);return`${n-t/2+a}px`}if(n>s-dt(this,$o)){let a=i.bounds.right-i.range.right-dt(this,$o);return`${n+t/2-a-i.range.width}px`}return 0};Mp=new WeakSet;Cy=function(i){let e=[...dt(this,ac)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){At(this,Ho,cc).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=At(this,lc,Up).call(this,dt(this,oc)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=At(this,dc,Fp).call(this,n,a),l=At(this,uc,Bp).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,Fo))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(Ui(this,Fo,a*t),At(this,Ho,cc).call(this,dt(this,Fo)))};Ho=new WeakSet;cc=function(i){this.dispatchEvent(new S.CustomEvent($.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Op=new WeakSet;My=function(){dt(this,Gs).stop();let i=Oy(this);this.dispatchEvent(new S.CustomEvent($.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Go.shadowRootOptions={mode:"open"};Go.getTemplateHTML=AD;S.customElements.get("media-time-range")||S.customElements.define("media-time-range",Go);var SD=1,xD=i=>i.mediaMuted?0:i.mediaVolume,RD=i=>`${Math.round(i*100)}%`,$p=class extends wi{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.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===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=xD(this),this.range.setAttribute("aria-valuetext",RD(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return ge(this,T.MEDIA_VOLUME,SD)}set mediaVolume(e){ye(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return ae(this,T.MEDIA_MUTED)}set mediaMuted(e){oe(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return de(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ue(this,T.MEDIA_VOLUME_UNAVAILABLE,e)}};S.customElements.get("media-volume-range")||S.customElements.define("media-volume-range",$p);var By=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ve=(i,e,t)=>(By(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)},cr=(i,e,t,r)=>(By(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ta,hc,Ks,Ko,Xr,Qr,Zr,Vs,ia,fc,mi,Py=1,Ny=0,ID=1,LD={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}}}},hr=class extends S.DocumentFragment{constructor(e,t,r=LD){var s;super(),Fi(this,ta,void 0),Fi(this,hc,void 0),this.append(e.content.cloneNode(!0)),cr(this,ta,$y(this)),cr(this,hc,r),(s=r.createCallback)==null||s.call(r,this,ve(this,ta),t),r.processCallback(this,ve(this,ta),t)}update(e){ve(this,hc).processCallback(this,ve(this,ta),e)}};ta=new WeakMap;hc=new WeakMap;var $y=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new Hp;for([t,r]of Fy(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===Py&&!(s instanceof HTMLTemplateElement))$y(s,e);else{let n=s.data;if(s.nodeType===Py||n.includes("{{")){let a=[];if(n)for([t,r]of Fy(n))if(!t)a.push(new Text(r));else{let o=new fr(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){let o=new Vo(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},Uy={},Fy=i=>{let e="",t=0,r=Uy[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([Ny,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([ID,e.trim()]),e="",s++):e+=n||"";return e&&r.push([Ny,(t>0?"{{":"")+e]),Uy[i]=r},kD=11,mc=class{get value(){return""}set value(e){}toString(){return this.value}},Hy=new WeakMap,Hp=class{constructor(){Fi(this,Ks,[])}[Symbol.iterator](){return ve(this,Ks).values()}get length(){return ve(this,Ks).length}item(e){return ve(this,Ks)[e]}append(...e){for(let t of e)t instanceof It&&Hy.set(t,this),ve(this,Ks).push(t)}toString(){return ve(this,Ks).join("")}};Ks=new WeakMap;var It=class extends mc{constructor(e,t,r){super(),Fi(this,Vs),Fi(this,Ko,""),Fi(this,Xr,void 0),Fi(this,Qr,void 0),Fi(this,Zr,void 0),cr(this,Xr,e),cr(this,Qr,t),cr(this,Zr,r)}get attributeName(){return ve(this,Qr)}get attributeNamespace(){return ve(this,Zr)}get element(){return ve(this,Xr)}get value(){return ve(this,Ko)}set value(e){ve(this,Ko)!==e&&(cr(this,Ko,e),!ve(this,Vs,ia)||ve(this,Vs,ia).length===1?e==null?ve(this,Xr).removeAttributeNS(ve(this,Zr),ve(this,Qr)):ve(this,Xr).setAttributeNS(ve(this,Zr),ve(this,Qr),e):ve(this,Xr).setAttributeNS(ve(this,Zr),ve(this,Qr),ve(this,Vs,ia).toString()))}get booleanValue(){return ve(this,Xr).hasAttributeNS(ve(this,Zr),ve(this,Qr))}set booleanValue(e){if(!ve(this,Vs,ia)||ve(this,Vs,ia).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Ko=new WeakMap;Xr=new WeakMap;Qr=new WeakMap;Zr=new WeakMap;Vs=new WeakSet;ia=function(){return Hy.get(this)};var fr=class extends mc{constructor(e,t){super(),Fi(this,fc,void 0),Fi(this,mi,void 0),cr(this,fc,e),cr(this,mi,t?[...t]:[new Text])}get replacementNodes(){return ve(this,mi)}get parentNode(){return ve(this,fc)}get nextSibling(){return ve(this,mi)[ve(this,mi).length-1].nextSibling}get previousSibling(){return ve(this,mi)[0].previousSibling}get value(){return ve(this,mi).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===kD?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),cr(this,mi,wD(ve(this,mi)[0].parentNode,ve(this,mi),t,this.nextSibling))}};fc=new WeakMap;mi=new WeakMap;var Vo=class extends fr{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 wD(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 Gy={string:i=>String(i)},gc=class{constructor(e){this.template=e,this.state=void 0}},Ws=new WeakMap,Ys=new WeakMap,Gp={partial:(i,e)=>{e[i.expression]=new gc(i.template)},if:(i,e)=>{var t;if(Vy(i.expression,e))if(Ws.get(i)!==i.template){Ws.set(i,i.template);let r=new hr(i.template,e,vc);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)}},DD=Object.keys(Gp),vc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Vo){if(!a.directive){let l=DD.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Gp[a.directive])==null||r.call(Gp,a,t);continue}let o=Vy(n,t);if(o instanceof gc){Ws.get(a)!==o.template?(Ws.set(a,o.template),o=new hr(o.template,o.state,vc),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))}}},Ky={"!":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=Gy[e])==null?void 0:t.call(Gy,i)}};function CD(i){return MD(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function Vy(i,e={}){var t,r,s,n,a,o,l;let d=CD(i);if(d.length===0||d.some(({type:u})=>!u))return Wo(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return Wo(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]=Yo(g,e))}return u}if(d.length===1)return pc(d[0])?Yo(d[0].token,e):Wo(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=Ky[u];if(!c||!pc(d[1]))return Wo(i);let h=Yo(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=Ky[u];if(!c||!pc(d[0])||!pc(d[2]))return Wo(i);let h=Yo(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=Yo(d[2].token,e);return c(h,f)}}function Wo(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function pc({type:i}){return["number","boolean","string","param"].includes(i)}function Yo(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):qd(i)?parseFloat(i):e[i]}function MD(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 jp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wp=(i,e,t)=>(jp(i,e,"read from private field"),t?t.call(i):e.get(i)),qo=(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)=>(jp(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Kp=(i,e,t)=>(jp(i,e,"access private method"),t),ra,Ec,sa,Yp,Wy,bc,qp,Vp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},Yy=Ue.createElement("template");Yy.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},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,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.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===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(dt(this,Gs).update({start:ac(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),St(this,ea,Fo).call(this),ID(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.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,T.MEDIA_PAUSED)}set mediaPaused(e){oe(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return ae(this,T.MEDIA_LOADING)}set mediaLoading(e){oe(this,T.MEDIA_LOADING,e)}get mediaDuration(){return ge(this,T.MEDIA_DURATION)}set mediaDuration(e){ye(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return ge(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ye(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ge(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ye(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.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,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){ue(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ge(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ye(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return ae(this,T.MEDIA_ENDED)}set mediaEnded(e){oe(this,T.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=LD;S.customElements.get("media-time-range")||S.customElements.define("media-time-range",Ko);var kD=1,wD=i=>i.mediaMuted?0:i.mediaVolume,DD=i=>`${Math.round(i*100)}%`,Gp=class extends wi{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.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===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=wD(this),this.range.setAttribute("aria-valuetext",DD(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return ge(this,T.MEDIA_VOLUME,kD)}set mediaVolume(e){ye(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return ae(this,T.MEDIA_MUTED)}set mediaMuted(e){oe(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return de(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){ue(this,T.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,CD=1,MD={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=MD){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([CD,e.trim()]),e="",s++):e+=n||"";return e&&r.push([By,(t>0?"{{":"")+e]),$y[i]=r},OD=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===OD?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),hr(this,pi,PD(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 PD(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,bc);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)}},ND=Object.keys(Vp),bc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Wo){if(!a.directive){let l=ND.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,bc),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 UD(i){return FD(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=UD(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 FD(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,Tc,sa,jp,jy,yc,zp,Yp={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},zy=Ue.createElement("template");zy.innerHTML=`
|
|
1396
1400
|
<style>
|
|
1397
1401
|
:host {
|
|
1398
1402
|
display: inline-block;
|
|
@@ -1419,7 +1423,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1419
1423
|
display: none;
|
|
1420
1424
|
}
|
|
1421
1425
|
</style>
|
|
1422
|
-
`;var js=class extends S.HTMLElement{constructor(){super(),
|
|
1426
|
+
`;var js=class extends S.HTMLElement{constructor(){super(),jo(this,jp),jo(this,yc),jo(this,ra,void 0),jo(this,Tc,void 0),jo(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:lT(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,Tc)&&(qs(this,Tc,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;Tc=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}BD(e)&&(qs(this,sa,e),$D(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=bc;function BD(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 $D(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=HD({anchor:i,floating:e}),{x:s,y:n}=KD(r,t);return{x:s,y:n}}function HD({anchor:i,floating:e}){return{anchor:GD(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function GD(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 KD({anchor:i,floating:e},t){let r=VD(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 VD(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,Qo,Qp,Zy,Ic,xc,Zp,Jp,Jy,eg,e_,tg,t_,na,aa,oa,Zo,Lc,dg,ig,i_,ug,r_,rg,s_,cg,n_,sg,a_,ng,o_,zo,kc,ag,l_,Xo,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 WD(i){return`
|
|
1423
1427
|
<style>
|
|
1424
1428
|
:host {
|
|
1425
1429
|
font: var(--media-font,
|
|
@@ -1593,7 +1597,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1593
1597
|
<slot></slot>
|
|
1594
1598
|
</div>
|
|
1595
1599
|
<slot name="checked-indicator" hidden></slot>
|
|
1596
|
-
`}var zs={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},bt=class extends S.HTMLElement{constructor(){if(super(),Be(this,zp),Be(this,Ac),Be(this,Qp),Be(this,Zp),Be(this,Jp),Be(this,oa),Be(this,Rc),Be(this,eg),Be(this,lg),Be(this,tg),Be(this,dg),Be(this,ig),Be(this,rg),Be(this,jo),Be(this,sg),Be(this,zo),Be(this,Sc),Be(this,$i,null),Be(this,Xs,null),Be(this,es,null),Be(this,yc,new Set),Be(this,_c,void 0),Be(this,Qs,!1),Be(this,Xo,null),Be(this,xc,()=>{let e=Re(this,yc),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,yc,t)}),Be(this,na,()=>{Ge(this,oa,Qo).call(this),Ge(this,Rc,og).call(this,!1)}),Be(this,aa,()=>{Ge(this,oa,Qo).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,_c,new MutationObserver(Re(this,xc))),Re(this,_c).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,zp,zy).call(this,e);break;case"invoke":Ge(this,Qp,Xy).call(this,e);break;case"click":Ge(this,eg,Jy).call(this,e);break;case"toggle":Ge(this,tg,t_).call(this,e);break;case"focusout":Ge(this,ig,r_).call(this,e);break;case"keydown":Ge(this,rg,s_).call(this,e);break}}connectedCallback(){var e,t;Bi(this,Xo,Gm(this.shadowRoot,":host")),Ge(this,Ac,Xp).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Bi(this,$i,Zd(this)),(t=(e=Re(this,$i))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(nr(Zo(this),Re(this,na)),nr(this,Re(this,aa)))}disconnectedCallback(){var e,t;ar(Zo(this),Re(this,na)),ar(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,Jp,Zy).call(this):Ge(this,Zp,Qy).call(this),this.dispatchEvent(new Tc({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,Zd(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,Ac,Xp).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(HD)}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,Sc,ng).call(this,t)}focus(){if(Bi(this,Xs,no()),this.items.length){Ge(this,zo,Lc).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,jo,Ic).call(this,e);r&&(Ge(this,Sc,ng).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,jo,Ic).call(this,e))!=null?t:Ge(this,sg,n_).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,zo,Lc).call(this,n[l]),n[l].focus()}};$i=new WeakMap;Xs=new WeakMap;es=new WeakMap;yc=new WeakMap;_c=new WeakMap;Qs=new WeakMap;Xo=new WeakMap;zp=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,xc).call(this)};xc=new WeakMap;Ac=new WeakSet;Xp=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")};Qp=new WeakSet;Xy=function(i){Bi(this,es,i.relatedTarget),Rt(this,i.relatedTarget)||(this.hidden=!this.hidden)};Zp=new WeakSet;Qy=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),nr(Zo(this),Re(this,na)),nr(this,Re(this,aa))};Jp=new WeakSet;Zy=function(){var i;(i=Re(this,es))==null||i.setAttribute("aria-expanded","false"),ar(Zo(this),Re(this,na)),ar(this,Re(this,aa))};na=new WeakMap;aa=new WeakMap;oa=new WeakSet;Qo=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:e,y:t}=qy({anchor:this.anchorElement,floating:this,placement:"top-start"});i!=null||(i=this.offsetWidth);let s=Zo(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=Re(this,Xo);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`)};Rc=new WeakSet;og=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,Xo);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,Qo).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),Ge(this,oa,Qo).call(this);r.removeProperty("--media-menu-transition-in")};eg=new WeakSet;Jy=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Re(this,lg,e_))){(e=Re(this,Xs))==null||e.focus(),this.hidden=!0;return}let t=Ge(this,jo,Ic).call(this,i);!t||t.hasAttribute("disabled")||(Ge(this,zo,Lc).call(this,t),this.handleSelect(i))};lg=new WeakSet;e_=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"]'))};tg=new WeakSet;t_=function(i){if(i.target===this)return;Ge(this,dg,i_).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,Rc,og).call(this,!0)};dg=new WeakSet;i_=function(){let e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};ig=new WeakSet;r_=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))};rg=new WeakSet;s_=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)};jo=new WeakSet;Ic=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};sg=new WeakSet;n_=function(){return this.items.find(i=>i.tabIndex===0)};zo=new WeakSet;Lc=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Sc=new WeakSet;ng=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}))};bt.shadowRootOptions={mode:"open"};bt.getTemplateHTML=$D;function HD(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Zo(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",bt);var pg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ki=(i,e,t)=>(pg(i,e,"read from private field"),t?t.call(i):e.get(i)),mr=(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)},ug=(i,e,t,r)=>(pg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Gi=(i,e,t)=>(pg(i,e,"access private method"),t),kc,el,cg,a_,gg,o_,vg,l_,Vi,la,tl,hg,d_,wc,fg;function GD(i){return`
|
|
1600
|
+
`}var zs={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},bt=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(YD)}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}))};bt.shadowRootOptions={mode:"open"};bt.getTemplateHTML=WD;function YD(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",bt);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_,bg,c_,Vi,la,il,mg,h_,Cc,pg;function qD(i){return`
|
|
1597
1601
|
<style>
|
|
1598
1602
|
:host {
|
|
1599
1603
|
transition: var(--media-menu-item-transition,
|
|
@@ -1711,7 +1715,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1711
1715
|
${this.getSuffixSlotInnerHTML(i)}
|
|
1712
1716
|
</slot>
|
|
1713
1717
|
<slot name="submenu"></slot>
|
|
1714
|
-
`}function
|
|
1718
|
+
`}function jD(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,bg),pr(this,la),pr(this,mg),pr(this,Cc),pr(this,Dc,!1),pr(this,tl,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"),el(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,il).call(this,e);break}}attributeChangedCallback(e,t,r){e===Jt.CHECKED&&el(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,tl,gg(this,this.parentNode)),Gi(this,Cc,pg).call(this)}disconnectedCallback(){this.disable(),Gi(this,Cc,pg).call(this),hg(this,tl,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(el(this))return this.getAttribute("aria-checked")==="true"}set checked(e){el(this)&&(hg(this,Dc,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){el(this)||this.invokeTargetElement&&Rt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Jr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};Dc=new WeakMap;tl=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,bg,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)};bg=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;il=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Gi(this,la,il));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,il));return}this.addEventListener("keyup",Gi(this,la,il),{once:!0})};Cc=new WeakSet;pg=function(){var i;let e=(i=Ki(this,tl))==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=qD;Wi.getSuffixSlotInnerHTML=jD;function el(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 zD(i){return`
|
|
1715
1719
|
${bt.getTemplateHTML(i)}
|
|
1716
1720
|
<style>
|
|
1717
1721
|
:host {
|
|
@@ -1746,7 +1750,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1746
1750
|
--media-settings-menu-item-opacity: 0;
|
|
1747
1751
|
}
|
|
1748
1752
|
</style>
|
|
1749
|
-
`}var
|
|
1753
|
+
`}var rl=class extends bt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:We(this).querySelector("media-settings-menu-button")}};rl.getTemplateHTML=zD;S.customElements.get("media-settings-menu")||S.customElements.define("media-settings-menu",rl);function XD(i){return`
|
|
1750
1754
|
${Wi.getTemplateHTML.call(this,i)}
|
|
1751
1755
|
<style>
|
|
1752
1756
|
slot:not([name="submenu"]) {
|
|
@@ -1757,11 +1761,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1757
1761
|
background: transparent;
|
|
1758
1762
|
}
|
|
1759
1763
|
</style>
|
|
1760
|
-
`}function
|
|
1764
|
+
`}function QD(i){return`
|
|
1761
1765
|
<svg aria-hidden="true" viewBox="0 0 20 24">
|
|
1762
1766
|
<path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
|
|
1763
1767
|
</svg>
|
|
1764
|
-
`}var Zs=class extends Wi{};Zs.shadowRootOptions={mode:"open"};Zs.getTemplateHTML=
|
|
1768
|
+
`}var Zs=class extends Wi{};Zs.shadowRootOptions={mode:"open"};Zs.getTemplateHTML=XD;Zs.getSuffixSlotInnerHTML=QD;S.customElements.get("media-settings-menu-item")||S.customElements.define("media-settings-menu-item",Zs);var Pt=class extends Le{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}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}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new Jr({relatedTarget:this}))}};S.customElements.get("media-chrome-menu-button")||S.customElements.define("media-chrome-menu-button",Pt);function ZD(){return`
|
|
1765
1769
|
<style>
|
|
1766
1770
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1767
1771
|
display: none;
|
|
@@ -1772,27 +1776,27 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1772
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"/>
|
|
1773
1777
|
</svg>
|
|
1774
1778
|
</slot>
|
|
1775
|
-
`}function
|
|
1779
|
+
`}function JD(){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=ZD;da.getTooltipContentHTML=JD;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)},Tg=(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),sl,Uc,Pc,yg,Nc,_g,Fc=class extends bt{constructor(){super(...arguments),Mc(this,Pc),Mc(this,Nc),Mc(this,sl,[]),Mc(this,Uc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(Tg(this,sl,oT(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,sl)}set mediaAudioTrackList(e){Tg(this,sl,e),Oc(this,Pc,yg).call(this)}get mediaAudioTrackEnabled(){var e;return(e=de(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ue(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}};sl=new WeakMap;Uc=new WeakMap;Pc=new WeakSet;yg=function(){if(f_(this,Uc)===JSON.stringify(this.mediaAudioTrackList))return;Tg(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 eC=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1776
1780
|
<path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
|
|
1777
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"/>
|
|
1778
|
-
</svg>`;function
|
|
1782
|
+
</svg>`;function tC(){return`
|
|
1779
1783
|
<style>
|
|
1780
1784
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1781
1785
|
display: none;
|
|
1782
1786
|
}
|
|
1783
1787
|
</style>
|
|
1784
|
-
<slot name="icon">${
|
|
1785
|
-
`}function
|
|
1788
|
+
<slot name="icon">${eC}</slot>
|
|
1789
|
+
`}function iC(){return B("Audio")}var ua=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",B("Audio"))}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=We(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return(e=de(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){ue(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}};ua.getSlotTemplateHTML=tC;ua.getTooltipContentHTML=iC;S.customElements.get("media-audio-track-menu-button")||S.customElements.define("media-audio-track-menu-button",ua);var Lg=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},rC=(i,e,t)=>(Lg(i,e,"read from private field"),t?t.call(i):e.get(i)),Sg=(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)},sC=(i,e,t,r)=>(Lg(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xg=(i,e,t)=>(Lg(i,e,"access private method"),t),$c,Rg,g_,Bc,Ig,nC=`
|
|
1786
1790
|
<svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
|
|
1787
1791
|
<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"/>
|
|
1788
|
-
</svg>`;function
|
|
1792
|
+
</svg>`;function aC(i){return`
|
|
1789
1793
|
${bt.getTemplateHTML(i)}
|
|
1790
|
-
<slot name="captions-indicator" hidden>${
|
|
1791
|
-
`}var
|
|
1794
|
+
<slot name="captions-indicator" hidden>${nC}</slot>
|
|
1795
|
+
`}var nl=class extends bt{constructor(){super(...arguments),Sg(this,Rg),Sg(this,Bc),Sg(this,$c,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_LIST&&t!==r?xg(this,Rg,g_).call(this):e===T.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,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){p_(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return m_(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){p_(this,T.MEDIA_SUBTITLES_SHOWING,e)}};$c=new WeakMap;Rg=new WeakSet;g_=function(){var i;if(rC(this,$c)===JSON.stringify(this.mediaSubtitlesList))return;sC(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(T.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)};nl.getTemplateHTML=aC;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",nl);var oC=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1792
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"/>
|
|
1793
|
-
</svg>`,
|
|
1797
|
+
</svg>`,lC=`<svg aria-hidden="true" viewBox="0 0 26 24">
|
|
1794
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"/>
|
|
1795
|
-
</svg>`;function
|
|
1799
|
+
</svg>`;function dC(){return`
|
|
1796
1800
|
<style>
|
|
1797
1801
|
:host([aria-checked="true"]) slot[name=off] {
|
|
1798
1802
|
display: none !important;
|
|
@@ -1809,10 +1813,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1809
1813
|
</style>
|
|
1810
1814
|
|
|
1811
1815
|
<slot name="icon">
|
|
1812
|
-
<slot name="on">${
|
|
1813
|
-
<slot name="off">${
|
|
1816
|
+
<slot name="on">${oC}</slot>
|
|
1817
|
+
<slot name="off">${lC}</slot>
|
|
1814
1818
|
</slot>
|
|
1815
|
-
`}function
|
|
1819
|
+
`}function uC(){return B("Captions")}var v_=i=>{i.setAttribute("aria-checked",mu(i).toString())},ca=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.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===T.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,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){b_(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return E_(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){b_(this,T.MEDIA_SUBTITLES_SHOWING,e)}};ca.getSlotTemplateHTML=dC;ca.getTooltipContentHTML=uC;var E_=(i,e)=>{let t=i.getAttribute(e);return t?Ds(t):[]},b_=(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 T_=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ha=(i,e,t)=>(T_(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)},al=(i,e,t)=>(T_(i,e,"access private method"),t),ts,ol,Hc,Gc,Dg,wg={RATES:"rates"},Kc=class extends bt{constructor(){super(),kg(this,ol),kg(this,Gc),kg(this,ts,new Gr(this,wg.RATES,{defaultValue:Ip})),al(this,ol,Hc).call(this)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,wg.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===wg.RATES&&t!=r&&(ha(this,ts).value=r,al(this,ol,Hc).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",al(this,Gc,Dg))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",al(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="",al(this,ol,Hc).call(this)}get mediaPlaybackRate(){return ge(this,T.MEDIA_PLAYBACK_RATE,Bs)}set mediaPlaybackRate(e){ye(this,T.MEDIA_PLAYBACK_RATE,e)}};ts=new WeakMap;ol=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 cC(i){return`
|
|
1816
1820
|
<style>
|
|
1817
1821
|
:host {
|
|
1818
1822
|
min-width: 5ch;
|
|
@@ -1823,18 +1827,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1823
1827
|
display: none;
|
|
1824
1828
|
}
|
|
1825
1829
|
</style>
|
|
1826
|
-
<slot name="icon">${i.mediaplaybackrate||
|
|
1827
|
-
`}function
|
|
1830
|
+
<slot name="icon">${i.mediaplaybackrate||Vc}x</slot>
|
|
1831
|
+
`}function hC(){return B("Playback rate")}var fa=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,T.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===T.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,T.MEDIA_PLAYBACK_RATE,Vc)}set mediaPlaybackRate(e){ye(this,T.MEDIA_PLAYBACK_RATE,e)}};fa.getSlotTemplateHTML=cC;fa.getTooltipContentHTML=hC;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)},ll=(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),dl,ga,pa,ul,Yc,Cg,qc=class extends bt{constructor(){super(...arguments),Wc(this,pa),Wc(this,Yc),Wc(this,dl,[]),Wc(this,ga,{})}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_RENDITION_SELECTED&&t!==r?(this.value=r!=null?r:"auto",ma(this,pa,ul).call(this)):e===T.MEDIA_RENDITION_LIST&&t!==r?(y_(this,dl,nT(r)),ma(this,pa,ul).call(this)):e===T.MEDIA_HEIGHT&&t!==r&&ma(this,pa,ul).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 ll(this,dl)}set mediaRenditionList(e){y_(this,dl,e),ma(this,pa,ul).call(this)}get mediaRenditionSelected(){return de(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ue(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return ge(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ye(this,T.MEDIA_HEIGHT,e)}};dl=new WeakMap;ga=new WeakMap;pa=new WeakSet;ul=function(){if(ll(this,ga).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&ll(this,ga).mediaHeight===this.mediaHeight)return;ll(this,ga).mediaRenditionList=JSON.stringify(this.mediaRenditionList),ll(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 fC=`<svg aria-hidden="true" viewBox="0 0 24 24">
|
|
1828
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" />
|
|
1829
|
-
</svg>`;function
|
|
1833
|
+
</svg>`;function mC(){return`
|
|
1830
1834
|
<style>
|
|
1831
1835
|
:host([aria-expanded="true"]) slot[name=tooltip] {
|
|
1832
1836
|
display: none;
|
|
1833
1837
|
}
|
|
1834
1838
|
</style>
|
|
1835
|
-
<slot name="icon">${
|
|
1836
|
-
`}function
|
|
1837
|
-
https://github.com/muxinc/elements/blob/main/errors/${i.file}`),
|
|
1839
|
+
<slot name="icon">${fC}</slot>
|
|
1840
|
+
`}function pC(){return B("Quality")}var va=class extends Pt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.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,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){ue(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return ge(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ye(this,T.MEDIA_HEIGHT,e)}};va.getSlotTemplateHTML=mC;va.getTooltipContentHTML=pC;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{},gC=class extends eh{},vC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve($g)}},jc,EC=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:vC,CustomEvent:EC,EventTarget:eh,HTMLElement:$g,HTMLVideoElement:gC},B_=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Yi=B_?F_:globalThis,Hg=B_?F_.document:globalThis.document;function TC(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=yC(i).toString();return e?"?"+e:""}function yC(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",_C=()=>{try{return"3.4.1"}catch{}return"UNKNOWN"},AC=_C(),V_=()=>AC,SC=(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})}`},xC=(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}},RC={crossorigin:"crossOrigin",playsinline:"playsInline"};function IC(i){var e;return(e=RC[i])!=null?e:$_(i)}var Ea,ba,Nt,LC=class{constructor(i,e){vi(this,Ea),vi(this,ba),vi(this,Nt,[]),qi(this,Ea,i),qi(this,ba,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,ba)}`)))&&((t=De(this,Ea))==null||t.setAttribute(`${De(this,ba)}`,`${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,ba)}`,`${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,ba=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"},x8={..._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}}),kC=Object.values(_t).filter(i=>_t.PLAYSINLINE!==i),wC=Object.values(rs),DC=[...kC,...wC],CC=class extends Yi.HTMLElement{static get observedAttributes(){return DC}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 cl(this,_t.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(_t.CROSSORIGIN,`${i}`)}get autoplay(){return cl(this,_t.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(_t.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(_t.AUTOPLAY)}get loop(){return cl(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 cl(this,_t.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(_t.MUTED,""):this.removeAttribute(_t.MUTED)}get playsInline(){return cl(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 cl(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var A_=CC,MC=`:host {
|
|
1838
1842
|
--media-control-display: var(--controls);
|
|
1839
1843
|
--media-loading-indicator-display: var(--loading-indicator);
|
|
1840
1844
|
--media-dialog-display: var(--dialog);
|
|
@@ -1984,23 +1988,23 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
1984
1988
|
:host([no-tooltips]) {
|
|
1985
1989
|
--media-tooltip-display: none;
|
|
1986
1990
|
}
|
|
1987
|
-
`,
|
|
1991
|
+
`,hl=new WeakMap,OC=class q_{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let r=hl.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=hl.get(this.element);t&&t.delete(this.type)}}static for(e){hl.has(e.element)||hl.set(e.element,new Map);let t=e.attributeName.slice(2),r=hl.get(e.element);return r&&r.has(t)?r.get(t):new q_(e.element,t)}};function PC(i,e){return i instanceof It&&i.attributeName.startsWith("on")?(OC.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function NC(i,e){return e instanceof j_&&i instanceof mr?(e.renderInto(i),!0):!1}function UC(i,e){return e instanceof DocumentFragment&&i instanceof mr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function FC(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 BC(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 $C(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 HC(i,e){return e===!1&&i instanceof mr?(i.replace(""),!0):!1}function GC(i,e){BC(i,e)||$C(i,e)||PC(i,e)||HC(i,e)||NC(i,e)||UC(i,e)||FC(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)}},KC={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:"";GC(n,a)}}}};function zc(i,...e){return new j_(i,e,KC)}function VC(i,e){i.renderInto(e)}var WC=i=>{let{tokens:e}=i;return e.drm?":host(:not([cast-receiver])) { --_cast-button-drm-display: none; }":""},YC=i=>zc`
|
|
1988
1992
|
<style>
|
|
1989
|
-
${
|
|
1990
|
-
${
|
|
1993
|
+
${WC(i)}
|
|
1994
|
+
${MC}
|
|
1991
1995
|
</style>
|
|
1992
|
-
${
|
|
1993
|
-
`,
|
|
1996
|
+
${XC(i)}
|
|
1997
|
+
`,qC=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Gg(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},jC={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",MENU_BUTTON:"menu-button",MENU:"menu",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},zC=Object.values(jC).join(", "),XC=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,v,y,b,_,A,k,R,x,O,w,C,P,U,X,z,q,ce,fe,W;return zc`
|
|
1994
1998
|
<media-theme
|
|
1995
1999
|
template="${i.themeTemplate||!1}"
|
|
1996
2000
|
defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
|
|
1997
|
-
hotkeys="${
|
|
2001
|
+
hotkeys="${qC(i)||!1}"
|
|
1998
2002
|
nohotkeys="${i.noHotKeys||!i.hasSrc||!1}"
|
|
1999
2003
|
noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(Se.LIVE))&&i.targetLiveWindow!==0}"
|
|
2000
2004
|
novolumepref="${i.novolumepref||!1}"
|
|
2001
2005
|
disabled="${!i.hasSrc||i.isDialogOpen}"
|
|
2002
2006
|
audio="${(r=i.audio)!=null?r:!1}"
|
|
2003
|
-
style="${(s=
|
|
2007
|
+
style="${(s=TC({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
|
|
2004
2008
|
defaultsubtitles="${!i.defaultHiddenCaptions}"
|
|
2005
2009
|
forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
|
|
2006
2010
|
backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
|
|
@@ -2011,14 +2015,14 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
2011
2015
|
title="${(c=i.title)!=null?c:!1}"
|
|
2012
2016
|
videotitle="${(h=i.videoTitle)!=null?h:!1}"
|
|
2013
2017
|
proudlydisplaymuxbadge="${(f=i.proudlyDisplayMuxBadge)!=null?f:!1}"
|
|
2014
|
-
exportparts="${
|
|
2018
|
+
exportparts="${zC}"
|
|
2015
2019
|
onclose="${i.onCloseErrorDialog}"
|
|
2016
2020
|
onfocusin="${i.onFocusInErrorDialog}"
|
|
2017
2021
|
>
|
|
2018
2022
|
<mux-video
|
|
2019
2023
|
slot="media"
|
|
2020
2024
|
target-live-window="${(m=i.targetLiveWindow)!=null?m:!1}"
|
|
2021
|
-
stream-type="${(p
|
|
2025
|
+
stream-type="${(p=Gg(i.streamType))!=null?p:!1}"
|
|
2022
2026
|
crossorigin="${(g=i.crossOrigin)!=null?g:""}"
|
|
2023
2027
|
playsinline
|
|
2024
2028
|
autoplay="${(v=i.autoplay)!=null?v:!1}"
|
|
@@ -2043,7 +2047,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
2043
2047
|
drm-token="${(fe=(ce=i.tokens)==null?void 0:ce.drm)!=null?fe:!1}"
|
|
2044
2048
|
exportparts="video"
|
|
2045
2049
|
>
|
|
2046
|
-
${i.storyboard?
|
|
2050
|
+
${i.storyboard?zc`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:zc``}
|
|
2047
2051
|
<slot></slot>
|
|
2048
2052
|
</mux-video>
|
|
2049
2053
|
<slot name="poster" slot="poster">
|
|
@@ -2055,7 +2059,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
2055
2059
|
></media-poster-image>
|
|
2056
2060
|
</slot>
|
|
2057
2061
|
</media-theme>
|
|
2058
|
-
`},
|
|
2062
|
+
`},z_=i=>i.charAt(0).toUpperCase()+i.slice(1),QC=(i,e=!1)=>{var t,r;if(i.muxCode){let s=z_((t=i.errorCategory)!=null?t:"video"),n=qa((r=i.errorCategory)!=null?r:Ne.VIDEO);if(i.muxCode===J.NETWORK_OFFLINE)return Q("Your device appears to be offline",e);if(i.muxCode===J.NETWORK_TOKEN_EXPIRED)return Q("{category} URL has expired",e).format({category:s});if([J.NETWORK_TOKEN_SUB_MISMATCH,J.NETWORK_TOKEN_AUD_MISMATCH,J.NETWORK_TOKEN_AUD_MISSING,J.NETWORK_TOKEN_MALFORMED].includes(i.muxCode))return Q("{category} URL is formatted incorrectly",e).format({category:s});if(i.muxCode===J.NETWORK_TOKEN_MISSING)return Q("Invalid {categoryName} URL",e).format({categoryName:n});if(i.muxCode===J.NETWORK_NOT_FOUND)return Q("{category} does not exist",e).format({category:s});if(i.muxCode===J.NETWORK_NOT_READY){let a=i.streamType==="live"?"Live stream":"Video";return Q("{mediaType} is not currently available",e).format({mediaType:a})}}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return Q("Network Error",e);if(i.code===K.MEDIA_ERR_DECODE)return Q("Media Error",e);if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return Q("Source Not Supported",e)}return Q("Error",e)},ZC=(i,e=!1)=>{var t,r;if(i.muxCode){let s=z_((t=i.errorCategory)!=null?t:"video"),n=qa((r=i.errorCategory)!=null?r:Ne.VIDEO);return i.muxCode===J.NETWORK_OFFLINE?Q("Check your internet connection and try reloading this video.",e):i.muxCode===J.NETWORK_TOKEN_EXPIRED?Q("The video\u2019s secured {tokenNamePrefix}-token has expired.",e).format({tokenNamePrefix:n}):i.muxCode===J.NETWORK_TOKEN_SUB_MISMATCH?Q("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",e).format({tokenNamePrefix:n}):i.muxCode===J.NETWORK_TOKEN_MALFORMED?Q("{category} URL is formatted incorrectly",e).format({category:s}):[J.NETWORK_TOKEN_AUD_MISMATCH,J.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode)?Q("The {tokenNamePrefix}-token is formatted with incorrect information.",e).format({tokenNamePrefix:n}):[J.NETWORK_TOKEN_MISSING,J.NETWORK_INVALID_URL].includes(i.muxCode)?Q("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.",e).format({tokenNamePrefix:n}):i.muxCode===J.NETWORK_NOT_FOUND?"":i.message}return i.code&&(i.code===K.MEDIA_ERR_NETWORK||i.code===K.MEDIA_ERR_DECODE||(i.code,K.MEDIA_ERR_SRC_NOT_SUPPORTED)),i.message},JC=(i,e=!1)=>{let t=QC(i,e).toString(),r=ZC(i,e).toString();return{title:t,message:r}},eM=i=>{if(i.muxCode){if(i.muxCode===J.NETWORK_TOKEN_EXPIRED)return"403-expired-token.md";if(i.muxCode===J.NETWORK_TOKEN_MALFORMED)return"403-malformatted-token.md";if([J.NETWORK_TOKEN_AUD_MISMATCH,J.NETWORK_TOKEN_AUD_MISSING].includes(i.muxCode))return"403-incorrect-aud-value.md";if(i.muxCode===J.NETWORK_TOKEN_SUB_MISMATCH)return"403-playback-id-mismatch.md";if(i.muxCode===J.NETWORK_TOKEN_MISSING)return"missing-signed-tokens.md";if(i.muxCode===J.NETWORK_NOT_FOUND)return"404-not-found.md";if(i.muxCode===J.NETWORK_NOT_READY)return"412-not-playable.md"}if(i.code){if(i.code===K.MEDIA_ERR_NETWORK)return"";if(i.code===K.MEDIA_ERR_DECODE)return"media-decode-error.md";if(i.code===K.MEDIA_ERR_SRC_NOT_SUPPORTED)return"media-src-not-supported.md"}return""},R_=(i,e)=>{let t=eM(i);return{message:i.message,context:i.context,file:t}},tM=`<template id="media-theme-gerwig">
|
|
2059
2063
|
<style>
|
|
2060
2064
|
@keyframes pre-play-hide {
|
|
2061
2065
|
0% {
|
|
@@ -3183,7 +3187,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
3183
3187
|
<slot></slot>
|
|
3184
3188
|
</media-controller>
|
|
3185
3189
|
</template>
|
|
3186
|
-
`,
|
|
3190
|
+
`,Ng=Hg.createElement("template");"innerHTML"in Ng&&(Ng.innerHTML=tM);var I_,L_,X_=class extends js{};X_.template=(L_=(I_=Ng.content)==null?void 0:I_.children)==null?void 0:L_[0];Yi.customElements.get("media-theme-gerwig")||Yi.customElements.define("media-theme-gerwig",X_);var iM="gerwig",gr={SRC:"src",POSTER:"poster"},F={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",VIDEO_TITLE:"video-title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips",PROUDLY_DISPLAY_MUX_BADGE:"proudly-display-mux-badge"},Ug=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","videotitle","novolumepref","proudlydisplaymuxbadge"];function rM(i,e){var t,r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src||!!i.currentSrc,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(F.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:nM(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(F.NOHOTKEYS),hotKeys:i.getAttribute(F.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,assetStartTime:i.assetStartTime,assetEndTime:i.assetEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerInitTime:i.playerInitTime,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(D.TARGET_LIVE_WINDOW),streamType:Gg(i.getAttribute(D.STREAM_TYPE)),primaryColor:i.getAttribute(F.PRIMARY_COLOR),secondaryColor:i.getAttribute(F.SECONDARY_COLOR),accentColor:i.getAttribute(F.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:aM(i),playbackRates:i.getAttribute(F.PLAYBACK_RATES),customDomain:(t=i.getAttribute(D.CUSTOM_DOMAIN))!=null?t:void 0,title:i.getAttribute(F.TITLE),videoTitle:(r=i.getAttribute(F.VIDEO_TITLE))!=null?r:i.getAttribute(F.TITLE),novolumepref:i.hasAttribute(F.NO_VOLUME_PREF),proudlyDisplayMuxBadge:i.hasAttribute(F.PROUDLY_DISPLAY_MUX_BADGE),castReceiver:i.castReceiver,...e,extraSourceParams:i.extraSourceParams}}var sM=Vu.formatErrorMessage;Vu.formatErrorMessage=i=>{var e,t;if(i instanceof K){let r=JC(i,!1);return`
|
|
3187
3191
|
${r!=null&&r.title?`<h3>${r.title}</h3>`:""}
|
|
3188
3192
|
${r!=null&&r.message||r!=null&&r.linkUrl?`<p>
|
|
3189
3193
|
${r==null?void 0:r.message}
|
|
@@ -3195,8 +3199,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
|
|
|
3195
3199
|
>${(t=r.linkText)!=null?t:r.linkUrl}</a
|
|
3196
3200
|
>`:""}
|
|
3197
3201
|
</p>`:""}
|
|
3198
|
-
`}return JC(i)};function eM(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 tM(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 R_(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 iM=Object.values(D),rM=Object.values(pr),sM=Object.values(F),I_=H_(),L_="mux-player",k_={isDialogOpen:!1},nM={redundant_streams:!0},jc,zc,Xc,en,Qc,Ta,Xe,is,j_,Ng,tn,w_,D_,C_,M_,aM=class extends T_{constructor(){super(),gi(this,Xe),gi(this,jc),gi(this,zc,!1),gi(this,Xc,{}),gi(this,en,!0),gi(this,Qc,new AC(this,"hotkeys")),gi(this,Ta,{...k_,onCloseErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&nt(this,Xe,Ng).call(this,{isDialogOpen:!1})},onFocusInErrorDialog:i=>{var e;((e=i.composedPath()[0])==null?void 0:e.localName)==="media-error-dialog"&&(B_(this,Bg.activeElement)||i.preventDefault())}}),qi(this,jc,_d()),this.attachShadow({mode:"open"}),nt(this,Xe,j_).call(this),this.isConnected&&nt(this,Xe,is).call(this)}static get NAME(){return L_}static get VERSION(){return I_}static get observedAttributes(){var i;return[...(i=T_.observedAttributes)!=null?i:[],...rM,...iM,...sM]}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=R_(this))}attributeChangedCallback(i,e,t){switch(nt(this,Xe,is).call(this),super.attributeChangedCallback(i,e,t),i){case F.HOTKEYS:De(this,Qc).value=t;break;case F.THUMBNAIL_TIME:{t!=null&&this.tokens.thumbnail&&gr(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&&gr(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&&gr(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&&gr(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")&&Jt(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:K_({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,pr.SRC,F.PLAYBACK_TOKEN].includes(i)&&e!==t&&qi(this,Ta,{...De(this,Ta),...k_}),nt(this,Xe,tn).call(this,{[_C(i)]:t})}async requestFullscreen(i){var e;if(!(!this.mediaController||this.mediaController.hasAttribute(T.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(Xt.MEDIA_IS_FULLSCREEN,()=>t(),{once:!0})})}async exitFullscreen(){var i;if(!(!this.mediaController||!this.mediaController.hasAttribute(T.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(Xt.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):gr(`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(T.MEDIA_HAS_PLAYED))!=null?e:!1}get inLiveWindow(){var i;return(i=this.mediaController)==null?void 0:i.hasAttribute(T.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:QC}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(Pg.includes(t))continue;let r=i.getAttribute(t);e[U_(t)]=r===""?!0:r}return e}set themeProps(i){var e,t;nt(this,Xe,is).call(this);let r={...this.themeProps,...i};for(let s in r){if(Pg.includes(s))continue;let n=i==null?void 0:i[s];typeof n=="boolean"||n==null?(e=this.mediaTheme)==null||e.toggleAttribute(Mg(s),!!n):(t=this.mediaTheme)==null||t.setAttribute(Mg(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,pr.SRC))!=null?i:void 0:(e=this.getAttribute(pr.SRC))!=null?e:void 0}set src(i){i?this.setAttribute(pr.SRC,i):this.removeAttribute(pr.SRC)}get poster(){var i;let e=this.getAttribute(pr.POSTER);if(e!=null)return e;let{tokens:t}=this;if(t.playback&&!t.thumbnail){gr("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return bC(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(pr.POSTER,i):this.removeAttribute(pr.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 TC(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,Qc)}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,jc)}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:L_}get playerSoftwareVersion(){var i;return(i=this.getAttribute(D.PLAYER_SOFTWARE_VERSION))!=null?i:I_}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),{}):nM}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,Xe,is).call(this),!this.media){Jt("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...R_(this),...i}}get _hlsConfig(){var i;return(i=this.media)==null?void 0:i._hlsConfig}set _hlsConfig(i){if(nt(this,Xe,is).call(this),!this.media){Jt("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,Xe,is).call(this),!this.media){Jt("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,Xe,is).call(this),!this.media){Jt("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,Xc),...i!=null?{playback:i}:{},...e!=null?{drm:e}:{},...t!=null?{thumbnail:t}:{},...r!=null?{storyboard:r}:{}}}set tokens(i){qi(this,Xc,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 yd(n,i,e,t,r)}removeTextTrack(i){var e;let t=(e=this.media)==null?void 0:e.nativeEl;if(t)return UE(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){Jt("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)}};jc=new WeakMap,zc=new WeakMap,Xc=new WeakMap,en=new WeakMap,Qc=new WeakMap,Ta=new WeakMap,Xe=new WeakSet,is=function(){var i,e,t,r;if(!De(this,zc)){qi(this,zc,!0),nt(this,Xe,tn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof Yi.HTMLElement))throw""}catch{Jt("<media-theme> failed to upgrade!")}try{customElements.upgrade(this.media)}catch{Jt("underlying media element failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof rp))throw""}catch{Jt("<media-controller> failed to upgrade!")}nt(this,Xe,w_).call(this),nt(this,Xe,D_).call(this),nt(this,Xe,C_).call(this),qi(this,en,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(ee.USER_INACTIVE))!=null?e:!0),nt(this,Xe,M_).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>nt(this,Xe,tn).call(this)),(r=this.media)==null||r.addEventListener("loadstart",()=>nt(this,Xe,tn).call(this))}},j_=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{}},Ng=function(i){Object.assign(De(this,Ta),i),nt(this,Xe,tn).call(this)},tn=function(i={}){BC(HC(ZC(this,{...De(this,Ta),...i})),this.shadowRoot)},w_=function(){let i=e=>{var t,r;if(!(e!=null&&e.startsWith("theme-")))return;let s=e.replace(/^theme-/,"");if(Pg.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)},D_=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)){gr(r),r.data&&gr(`${r.name} data:`,r.data);return}let s=A_(r,!1);s.message&&K_(s),Jt(r),r.data&&Jt(`${r.name} data:`,r.data),nt(this,Xe,Ng).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=A_((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}})},C_=function(){var i,e,t,r;let s=()=>nt(this,Xe,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)},M_=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(`
|
|
3199
|
-
`).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
|
|
3202
|
+
`}return sM(i)};function nM(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 aM(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 oM=Object.values(D),lM=Object.values(gr),dM=Object.values(F),w_=V_(),D_="mux-player",C_={isDialogOpen:!1},uM={redundant_streams:!0},Xc,Qc,Zc,en,Jc,Ta,Qe,is,Q_,Fg,tn,M_,O_,P_,N_,cM=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 LC(this,"hotkeys")),vi(this,Ta,{...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:[],...lM,...oM,...dM]}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,Ta,{...De(this,Ta),...C_}),nt(this,Qe,tn).call(this,{[IC(i)]:t})}async requestFullscreen(i){var e;if(!(!this.mediaController||this.mediaController.hasAttribute(T.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(T.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(T.MEDIA_HAS_PLAYED))!=null?e:!1}get inLiveWindow(){var i;return(i=this.mediaController)==null?void 0:i.hasAttribute(T.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:iM}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 SC(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 xC(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),{}):uM}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,Ta=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,Ta),i),nt(this,Qe,tn).call(this)},tn=function(i={}){VC(YC(rM(this,{...De(this,Ta),...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=cM;ml.customElements.get("mux-player")||(ml.customElements.define("mux-player",th),ml.MuxPlayerElement=th);var W8=th;})();
|
|
3200
3204
|
/*! Bundled license information:
|
|
3201
3205
|
|
|
3202
3206
|
mux-embed/dist/mux.mjs:
|