PageSourceSearch

https://www.w-e.studio/_nuxt/7Emj7iXf.js

js w-e.studio collected 2026-10-05 02:50:01 UTC 687,924 bytes, 146 lines download raw bytes

vendor: 9,570 bytes, line 1
1var Vd=Object.create,al=Object.defineProperty,Hd=Object.getOwnPropertyDescriptor,qd=Object.getOwnPropertyNames,Yd=Object.getPrototypeOf,Wd=Object.prototype.hasOwnProperty,ol=function(s,e){return function(){return s&&(e=s(s=0)),e}},Ge=function(s,e){return function(){return e||s((e={exports:{}}).exports,e),e.exports}},jd=function(s,e,t,i){if(e&&typeof e=="object"||typeof e=="function")for(var r=qd(e),n=0,a=r.length,o;n<a;n++)o=r[n],!Wd.call(s,o)&&o!==t&&al(s,o,{get:(function(u){return e[u]}).bind(null,o),enumerable:!(i=Hd(e,o))||i.enumerable});return s},We=function(s,e,t){return t=s!=null?Vd(Yd(s)):{},jd(!s||!s.__esModule?al(t,"default",{value:s,enumerable:!0}):t,s)},ot=Ge(function(s,e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={},e.exports=t});function Qt(s,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](s):Qt(s,e)}var Jt=ol(function(){Jt()});function ll(s){"@swc/helpers - typeof";return s&&typeof Symbol<"u"&&s.constructor===Symbol?"symbol":typeof s}var ul=ol(function(){}),dl=Ge(function(s,e){var t=Array.prototype.slice;e.exports=i;function i(r,n){for(("length"in r)||(r=[r]),r=t.call(r);r.length;){var a=r.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(r=t.call(a.childNodes).concat(r))}}}),zd=Ge(function(s,e){Jt(),e.exports=t;function t(i,r){if(!Qt(this,t))return new t(i,r);this.data=i,this.nodeValue=i,this.length=i.length,this.ownerDocument=r||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),Xd=Ge(function(s,e){Jt(),e.exports=t;function t(i,r){if(!Qt(this,t))return new t(i);this.data=i||"",this.length=this.data.length,this.ownerDocument=r||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(i,r,n){var a=this.data,o=a.substring(0,i),u=a.substring(i+r,a.length);this.data=o+n+u,this.length=this.data.length}}),cl=Ge(function(s,e){e.exports=t;function t(i){var r=this,n=i.type;i.target||(i.target=r),r.listeners||(r.listeners={});var a=r.listeners[n];if(a)return a.forEach(function(o){i.currentTarget=r,typeof o=="function"?o(i):o.handleEvent(i)});r.parentNode&&r.parentNode.dispatchEvent(i)}}),hl=Ge(function(s,e){e.exports=t;function t(i,r){var n=this;n.listeners||(n.listeners={}),n.listeners[i]||(n.listeners[i]=[]),n.listeners[i].indexOf(r)===-1&&n.listeners[i].push(r)}}),fl=Ge(function(s,e){e.exports=t;function t(i,r){var n=this;if(n.listeners&&n.listeners[i]){var a=n.listeners[i],o=a.indexOf(r);o!==-1&&a.splice(o,1)}}}),Qd=Ge(function(s,e){ul(),e.exports=i;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function i(h){switch(h.nodeType){case 3:return d(h.data);case 8:return"<!--"+h.data+"-->";default:return r(h)}}function r(h){var f=[],g=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(g=g.toLowerCase()),f.push("<"+g+l(h)+o(h)),t.indexOf(g)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(i)):h.textContent||h.innerText?f.push(d(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+g+">")),f.join("")}function n(h,f){var g=ll(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(g==="string"||g==="boolean"||g==="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(g){var p=h[g];g=g.replace(/[A-Z]/g,function(m){return"-"+m.toLowerCase()}),f+=g+":"+p+";"}),f}function o(h){var f=h.dataset,g=[];for(var p in f)g.push({name:"data-"+p,value:f[p]});return g.length?u(g):""}function u(h){var f=[];return h.forEach(function(g){var p=g.name,m=g.value;p==="style"&&(m=a(m)),f.push(p+'="'+c(m)+'"')}),f.length?" "+f.join(" "):""}function l(h){var f=[];for(var g in h)n(h,g)&&f.push({name:g,value:h[g]});for(var p in h._attributes)for(var m in h._attributes[p]){var y=h._attributes[p][m],T=(y.prefix?y.prefix+":":"")+m;f.push({name:T,value:y.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?u(f):""}function d(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return d(h).replace(/"/g,"&quot;")}}),gl=Ge(function(s,e){Jt();var t=dl(),i=cl(),r=hl(),n=fl(),a=Qd(),o="http://www.w3.org/1999/xhtml";e.exports=u;function u(l,d,c){if(!Qt(this,u))return new u(l);var h=c===void 0?o:c||null;this.tagName=h===o?String(l).toUpperCase():l,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=d||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}u.prototype.type="DOMElement",u.prototype.nodeType=1,u.prototype.appendChild=function(l){return l.parentNode&&l.parentNode.removeChild(l),this.childNodes.push(l),l.parentNode=this,l},u.prototype.replaceChild=function(l,d){l.parentNode&&l.parentNode.removeChild(l);var c=this.childNodes.indexOf(d);return d.parentNode=null,this.childNodes[c]=l,l.parentNode=this,d},u.prototype.removeChild=function(l){var d=this.childNodes.indexOf(l);return this.childNodes.splice(d,1),l.parentNode=null,l},u.prototype.insertBefore=function(l,d){l.parentNode&&l.parentNode.removeChild(l);var c=d==null?-1:this.childNodes.indexOf(d);return c>-1?this.childNodes.splice(c,0,l):this.childNodes.push(l),l.parentNode=this,l},u.prototype.setAttributeNS=function(l,d,c){var h=null,f=d,g=d.indexOf(":");if(g>-1&&(h=d.substr(0,g),f=d.substr(g+1)),this.tagName==="INPUT"&&d==="type")this.type=c;else{var p=this._attributes[l]||(this._attributes[l]={});p[f]={value:c,prefix:h}}},u.prototype.getAttributeNS=function(l,d){var c=this._attributes[l],h=c&&c[d]&&c[d].value;return this.tagName==="INPUT"&&d==="type"?this.type:typeof h!="string"?null:h},u.prototype.removeAttributeNS=function(l,d){var c=this._attributes[l];c&&delete c[d]},u.prototype.hasAttributeNS=function(l,d){var c=this._attributes[l];return!!c&&d in c},u.prototype.setAttribute=function(l,d){return this.setAttributeNS(null,l,d)},u.prototype.getAttribute=function(l){return this.getAttributeNS(null,l)},u.prototype.removeAttribute=function(l){return this.removeAttributeNS(null,l)},u.prototype.hasAttribute=function(l){return this.hasAttributeNS(null,l)},u.prototype.removeEventListener=n,u.prototype.addEventListener=r,u.prototype.dispatchEvent=i,u.prototype.focus=function(){},u.prototype.toString=function(){return a(this)},u.prototype.getElementsByClassName=function(l){var d=l.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",g=f.split(" ");d.every(function(p){return g.indexOf(p)!==-1})&&c.push(h)}}),c},u.prototype.getElementsByTagName=function(l){l=l.toLowerCase();var d=[];return t(this.childNodes,function(c){c.nodeType===1&&(l==="*"||c.tagName.toLowerCase()===l)&&d.push(c)}),d},u.prototype.contains=function(l){return t(this,function(d){return l===d})||!1}}),Jd=Ge(function(s,e){Jt();var t=gl();e.exports=i;function i(r){if(!Qt(this,i))return new i;this.childNodes=[],this.parentNode=null,this.ownerDocument=r||null}i.prototype.type="DocumentFragment",i.prototype.nodeType=11,i.prototype.nodeName="#document-fragment",i.prototype.appendChild=t.prototype.appendChild,i.prototype.replaceChild=t.prototype.replaceChild,i.prototype.removeChild=t.prototype.removeChild,i.prototype.toString=function(){return this.childNodes.map(function(r){return String(r)}).join("")}}),Zd=Ge(function(s,e){e.exports=t;function t(i){}t.prototype.initEvent=function(i,r,n){this.type=i,this.bubbles=r,this.cancelable=n},t.prototype.preventDefault=function(){}}),ec=Ge(function(s,e){Jt();var t=dl(),i=zd(),r=Xd(),n=gl(),a=Jd(),o=Zd(),u=cl(),l=hl(),d=fl();e.exports=c;function c(){if(!Qt(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 r(f,this)},h.createElementNS=function(f,g){var p=f===null?null:String(f);return new n(g,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 i(f,this)},h.getElementById=function(f){f=String(f);var g=t(this.childNodes,function(p){if(String(p.id)===f)return p});return g||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=d,h.addEventListener=l,h.dispatchEvent=u}),tc=Ge(function(s,e){var t=ec();e.exports=new t}),ml=Ge(function(s,e){var t=typeof global<"u"?global:typeof window<"u"?window:{},i=tc(),r;typeof document<"u"?r=document:(r=t["__GLOBAL_DOCUMENT_CACHE@4"],r||(r=t["__GLOBAL_DOCUMENT_CACHE@4"]=i)),e.exports=r});function ic(s){if(Array.isArray(s))return s}function sc(s,e){var t=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(t!=null){var i=[],r=!0,n=!1,a,o;try{for(t=t.call(s);!(r=(a=t.next()).done)&&(i.push(a.value),!(e&&i.length===e));r=!0);}catch(u){n=!0,o=u}finally{try{!r&&t.return!=null&&t.return()}finally{if(n)throw o}}return i}}
1function rc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nr(s,e){(e==null||e>s.length)&&(e=s.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=s[t];return i}function pl(s,e){if(s){if(typeof s=="string")return Nr(s,e);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Nr(s,e)}}function xt(s,e){return ic(s)||sc(s,e)||pl(s,e)||rc()}var Di=We(ot()),ha=We(ot()),nc=We(ot()),ac={now:function(){var s=nc.default.performance,e=s&&s.timing,t=e&&e.navigationStart,i=typeof t=="number"&&typeof s.now=="function"?t+s.now():Date.now();return Math.round(i)}},be=ac,Oi=function(){var s,e,t;if(typeof((s=ha.default.crypto)===null||s===void 0?void 0:s.getRandomValues)=="function"){t=new Uint8Array(32),ha.default.crypto.getRandomValues(t);for(var i=0;i<32;i++)t[i]=t[i]%16}else{t=[];for(var r=0;r<32;r++)t[r]=Math.random()*16|0}var n=0;e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(u){var l=u==="x"?t[n]:t[n]&3|8;return n++,l.toString(16)});var a=be.now(),o=a?.toString(16).substring(3);return o?e.substring(0,28)+o:e},vl=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},st=function(s){if(s&&typeof s.nodeName<"u")return s.muxId||(s.muxId=vl()),s.muxId;var e;try{e=document.querySelector(s)}catch{}return e&&!e.muxId&&(e.muxId=s),e?.muxId||s},Ds=function(s){var e;s&&typeof s.nodeName<"u"?(e=s,s=st(e)):e=document.querySelector(s);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,s,t]};function oc(s){if(Array.isArray(s))return Nr(s)}function lc(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function uc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rt(s){return oc(s)||lc(s)||pl(s)||uc()}var qt={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4},dc=function(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,i,r,n,a,o=[console,s],u=(t=console.trace).bind.apply(t,rt(o)),l=(i=console.info).bind.apply(i,rt(o)),d=(r=console.debug).bind.apply(r,rt(o)),c=(n=console.warn).bind.apply(n,rt(o)),h=(a=console.error).bind.apply(a,rt(o)),f=e;return{trace:function(){for(var g=arguments.length,p=new Array(g),m=0;m<g;m++)p[m]=arguments[m];if(!(f>qt.TRACE))return u.apply(void 0,rt(p))},debug:function(){for(var g=arguments.length,p=new Array(g),m=0;m<g;m++)p[m]=arguments[m];if(!(f>qt.DEBUG))return d.apply(void 0,rt(p))},info:function(){for(var g=arguments.length,p=new Array(g),m=0;m<g;m++)p[m]=arguments[m];if(!(f>qt.INFO))return l.apply(void 0,rt(p))},warn:function(){for(var g=arguments.length,p=new Array(g),m=0;m<g;m++)p[m]=arguments[m];if(!(f>qt.WARN))return c.apply(void 0,rt(p))},error:function(){for(var g=arguments.length,p=new Array(g),m=0;m<g;m++)p[m]=arguments[m];if(!(f>qt.ERROR))return h.apply(void 0,rt(p))},get level(){return f},set level(g){g!==this.level&&(f=g??e)}}},he=dc("[mux]"),ir=We(ot());function Fr(){var s=ir.default.doNotTrack||ir.default.navigator&&ir.default.navigator.doNotTrack;return s==="1"}function X(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}Jt();function De(s,e){if(!Qt(s,e))throw new TypeError("Cannot call a class as a function")}function cc(s,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(s,i.key,i)}}function yt(s,e,t){return e&&cc(s.prototype,e),s}function F(s,e,t){return e in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function gi(s){return gi=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},gi(s)}function hc(s,e){for(;!Object.prototype.hasOwnProperty.call(s,e)&&(s=gi(s),s!==null););return s}function us(s,e,t){return typeof Reflect<"u"&&Reflect.get?us=Reflect.get:us=function(i,r,n){var a=hc(i,r);if(a){var o=Object.getOwnPropertyDescriptor(a,r);return o.get?o.get.call(n||i):o.value}},us(s,e,t||s)}function Ur(s,e){return Ur=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},Ur(s,e)}function fc(s,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(e&&e.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),e&&Ur(s,e)}function gc(){if(typeof Reflect>"u"||!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}}ul();function mc(s,e){return e&&(ll(e)==="object"||typeof e=="function")?e:X(s)}function pc(s){var e=gc();return function(){var t=gi(s),i;if(e){var r=gi(this).constructor;i=Reflect.construct(t,arguments,r)}else i=t.apply(this,arguments);return mc(this,i)}}var at=function(s){return Mi(s)[0]}
vendor: 1,204 bytes, line 3
3,Mi=function(s){if(typeof s!="string"||s==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=s.match(e)||[],i=t[4],r;return i&&(r=(i.match(/[^\.]+\.[^\.]+$/)||[])[0]),[i,r]},sr=We(ot()),vc={exists:function(){var s=sr.default.performance,e=s&&s.timing;return e!==void 0},domContentLoadedEventEnd:function(){var s=sr.default.performance,e=s&&s.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var s=sr.default.performance,e=s&&s.timing;return e&&e.navigationStart}},ks=vc;function _e(s,e,t){t=t===void 0?1:t,s[e]=s[e]||0,s[e]+=t}function Cs(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){F(s,r,t[r])})}return s}function yc(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t.push.apply(t,i)}return t}function _n(s,e){return e=e??{},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):yc(Object(e)).forEac
vendor: 13,154 bytes, lines 3-14
3h(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(e,t))}),s}var Ec=["x-cdn","content-type"],yl=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],Tc=Ec.concat(yl);function An(s){s=s||"";var e={},t=s.trim().split(/[\r\n]+/);return t.forEach(function(i){if(i){var r=i.split(": "),n=r.shift();n&&(Tc.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=r.join(": "))}}),e}function ws(s){if(s){var e=yl.find(function(t){return s[t]!==void 0});return e?s[e]:void 0}}var Sc=function(s){var e={};for(var t in s){var i=s[t],r=i["DATA-ID"].search("io.litix.data.");if(r!==-1){var n=i["DATA-ID"].replace("io.litix.data.","");e[n]=i.VALUE}}return e},El=Sc,qi=function(s){if(!s)return{};var e=ks.navigationStart(),t=s.loading,i=t?t.start:s.trequest,r=t?t.first:s.tfirst,n=t?t.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+i),responseStart:Math.round(e+r),responseEnd:Math.round(e+n)}},Ei=function(s){if(!(!s||typeof s.getAllResponseHeaders!="function"))return An(s.getAllResponseHeaders())},_c=function(s,e,t){var i=arguments.length>4?arguments[4]:void 0,r=s.log,n=s.utils.secondsToMs,a=function(m){var y=parseInt(i.version),T;return y===1&&m.programDateTime!==null&&(T=m.programDateTime),y===0&&m.pdt!==null&&(T=m.pdt),T};if(!ks.exists()){r.warn("performance timing not supported. Not tracking HLS.js.");return}var o=function(m,y){return s.emit(e,m,y)},u=function(m,y){var T=y.levels,E=y.audioTracks,S=y.url,_=y.stats,x=y.networkDetails,A=y.sessionData,I={},R={};T.forEach(function(U,P){I[P]={width:U.width,height:U.height,bitrate:U.bitrate,attrs:U.attrs}}),E.forEach(function(U,P){R[P]={name:U.name,language:U.lang,bitrate:U.bitrate}});var b=qi(_),k=b.bytesLoaded,M=b.requestStart,G=b.responseStart,q=b.responseEnd;o("requestcompleted",_n(Cs({},El(A)),{request_event_type:m,request_bytes_loaded:k,request_start:M,request_response_start:G,request_response_end:q,request_type:"manifest",request_hostname:at(S),request_response_headers:Ei(x),request_rendition_lists:{media:I,audio:R,video:{}}}))};t.on(i.Events.MANIFEST_LOADED,u);var l=function(m,y){var T=y.details,E=y.level,S=y.networkDetails,_=y.stats,x=qi(_),A=x.bytesLoaded,I=x.requestStart,R=x.responseStart,b=x.responseEnd,k=T.fragments[T.fragments.length-1],M=a(k)+n(k.duration);o("requestcompleted",{request_event_type:m,request_bytes_loaded:A,request_start:I,request_response_start:R,request_response_end:b,request_current_level:E,request_type:"manifest",request_hostname:at(T.url),request_response_headers:Ei(S),video_holdback:T.holdBack&&n(T.holdBack),video_part_holdback:T.partHoldBack&&n(T.partHoldBack),video_part_target_duration:T.partTarget&&n(T.partTarget),video_target_duration:T.targetduration&&n(T.targetduration),video_source_is_live:T.live,player_manifest_newest_program_time:isNaN(M)?void 0:M})};t.on(i.Events.LEVEL_LOADED,l);var d=function(m,y){var T=y.details,E=y.networkDetails,S=y.stats,_=qi(S),x=_.bytesLoaded,A=_.requestStart,I=_.responseStart,R=_.responseEnd;o("requestcompleted",{request_event_type:m,request_bytes_loaded:x,request_start:A,request_response_start:I,request_response_end:R,request_type:"manifest",request_hostname:at(T.url),request_response_headers:Ei(E)})};t.on(i.Events.AUDIO_TRACK_LOADED,d);var c=function(m,y){var T=y.stats,E=y.networkDetails,S=y.frag;T=T||S.stats;var _=qi(T),x=_.bytesLoaded,A=_.requestStart,I=_.responseStart,R=_.responseEnd,b=E?Ei(E):void 0,k={request_event_type:m,request_bytes_loaded:x,request_start:A,request_response_start:I,request_response_end:R,request_hostname:E?at(E.responseURL):void 0,request_id:b?ws(b):void 0,request_response_headers:b,request_media_duration:S.duration,request_url:E?.responseURL};S.type==="main"?(k.request_type="media",k.request_current_level=S.level,k.request_video_width=(t.levels[S.level]||{}).width,k.request_video_height=(t.levels[S.level]||{}).height,k.request_labeled_bitrate=(t.levels[S.level]||{}).bitrate):k.request_type=S.type,o("requestcompleted",k)};t.on(i.Events.FRAG_LOADED,c);var h=function(m,y){var T=y.frag,E=T.start,S=a(T),_={currentFragmentPDT:S,currentFragmentStart:n(E)};o("fragmentchange",_)};t.on(i.Events.FRAG_CHANGED,h);var f=function(m,y){var T=y.type,E=y.details,S=y.response,_=y.fatal,x=y.frag,A=y.networkDetails,I=x?.url||y.url||"",R=A?Ei(A):void 0;if((E===i.ErrorDetails.MANIFEST_LOAD_ERROR||E===i.ErrorDetails.MANIFEST_LOAD_TIMEOUT||E===i.ErrorDetails.FRAG_LOAD_ERROR||E===i.ErrorDetails.FRAG_LOAD_TIMEOUT||E===i.ErrorDetails.LEVEL_LOAD_ERROR||E===i.ErrorDetails.LEVEL_LOAD_TIMEOUT||E===i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||E===i.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||E===i.ErrorDetails.SUBTITLE_LOAD_ERROR||E===i.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||E===i.ErrorDetails.KEY_LOAD_ERROR||E===i.ErrorDetails.KEY_LOAD_TIMEOUT)&&o("requestfailed",{request_error:E,request_url:I,request_hostname:at(I),request_id:R?ws(R):void 0,request_type:E===i.ErrorDetails.FRAG_LOAD_ERROR||E===i.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":E===i.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||E===i.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":E===i.ErrorDetails.SUBTITLE_LOAD_ERROR||E===i.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":E===i.ErrorDetails.KEY_LOAD_ERROR||E===i.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:S?.code,request_error_text:S?.text}),_){var b,k="".concat(I?"url: ".concat(I,`
4`):"")+"".concat(S&&(S.code||S.text)?"response: ".concat(S.code,", ").concat(S.text,`
5`):"")+"".concat(y.reason?"failure reason: ".concat(y.reason,`
6`):"")+"".concat(y.level?"level: ".concat(y.level,`
7`):"")+"".concat(y.parent?"parent stream controller: ".concat(y.parent,`
8`):"")+"".concat(y.buffer?"buffer length: ".concat(y.buffer,`
9`):"")+"".concat(y.error?"error: ".concat(y.error,`
10`):"")+"".concat(y.event?"event: ".concat(y.event,`
11`):"")+"".concat(y.err?"error message: ".concat((b=y.err)===null||b===void 0?void 0:b.message,`
12`):"");o("error",{player_error_code:T,player_error_message:E,player_error_context:k})}};t.on(i.Events.ERROR,f);var g=function(m,y){var T=y.frag,E=T&&T._url||"";o("requestcanceled",{request_event_type:m,request_url:E,request_type:"media",request_hostname:at(E)})};t.on(i.Events.FRAG_LOAD_EMERGENCY_ABORTED,g);var p=function(m,y){var T=y.level,E=t.levels[T];if(E&&E.attrs&&E.attrs.BANDWIDTH){var S=E.attrs.BANDWIDTH,_,x=parseFloat(E.attrs["FRAME-RATE"]);isNaN(x)||(_=x),S?o("renditionchange",{video_source_fps:_,video_source_bitrate:S,video_source_width:E.width,video_source_height:E.height,video_source_rendition_name:E.name,video_source_codec:E?.videoCodec}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(i.Events.LEVEL_SWITCHED,p),t._stopMuxMonitor=function(){t.off(i.Events.MANIFEST_LOADED,u),t.off(i.Events.LEVEL_LOADED,l),t.off(i.Events.AUDIO_TRACK_LOADED,d),t.off(i.Events.FRAG_LOADED,c),t.off(i.Events.FRAG_CHANGED,h),t.off(i.Events.ERROR,f),t.off(i.Events.FRAG_LOAD_EMERGENCY_ABORTED,g),t.off(i.Events.LEVEL_SWITCHED,p),t.off(i.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(i.Events.DESTROYING,t._stopMuxMonitor)},Ac=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()},fa=function(s,e){if(!s||!s.requestEndDate)return{};var t=at(s.url),i=s.url,r=s.bytesLoaded,n=new Date(s.requestStartDate).getTime(),a=new Date(s.firstByteDate).getTime(),o=new Date(s.requestEndDate).getTime(),u=isNaN(s.duration)?0:s.duration,l=typeof e.getMetricsFor=="function"?e.getMetricsFor(s.mediaType).HttpList:e.getDashMetrics().getHttpRequests(s.mediaType),d;l.length>0&&(d=An(l[l.length-1]._responseHeaders||""));var c=d?ws(d):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:r,requestResponseHeaders:d,requestMediaDuration:u,requestHostname:t,requestUrl:i,requestId:c}},bc=function(s,e){var t=e.getQualityFor(s),i=e.getCurrentTrackFor(s).bitrateList;return i?{currentLevel:t,renditionWidth:i[t].width||null,renditionHeight:i[t].height||null,renditionBitrate:i[t].bandwidth}:{}},xc=function(s){var e;return(e=s.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},Ic=function(s){try{var e,t,i=(t=s.getVersion)===null||t===void 0||(e=t.call(s))===null||e===void 0?void 0:e.split(".").map(function(r){return parseInt(r)})[0];return i}catch{return!1}},Rc=function(s,e,t){var i=s.log;if(!t||!t.on){i.warn("Invalid dash.js player reference. Monitoring blocked.");return}var r=Ic(t),n=function(T,E){return s.emit(e,T,E)},a=function(T){var E=T.type,S=T.data,_=(S||{}).url;n("requestcompleted",{request_event_type:E,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:at(_),request_url:_})};t.on("manifestLoaded",a);var o={},u=function(T){if(typeof T.getRequests!="function")return null;var E=T.getRequests({state:"executed"});return E.length===0?null:E[E.length-1]},l=function(T){var E=T.type,S=T.fragmentModel,_=T.chunk,x=u(S);d({type:E,request:x,chunk:_})},d=function(T){var E=T.type,S=T.chunk,_=T.request,x=(S||{}).mediaInfo,A=x||{},I=A.type,R=A.bitrateList;R=R||[];var b={};R.forEach(function(z,O){b[O]={},b[O].width=z.width,b[O].height=z.height,b[O].bitrate=z.bandwidth,b[O].attrs={}}),I==="video"?o.video=b:I==="audio"?o.audio=b:o.media=b;var k=fa(_,t),M=k.requestStart,G=k.requestResponseStart,q=k.requestResponseEnd,U=k.requestResponseHeaders,P=k.requestMediaDuration,K=k.requestHostname,B=k.requestUrl,Y=k.requestId;n("requestcompleted",{request_event_type:E,request_start:M,request_response_start:G,request_response_end:q,request_bytes_loaded:-1,request_type:I+"_init",request_response_headers:U,request_hostname:K,request_id:Y,request_url:B,request_media_duration:P,request_rendition_lists:o})};r>=4?t.on("initFragmentLoaded",d):t.on("initFragmentLoaded",l);var c=function(T){var E=T.type,S=T.fragmentModel,_=T.chunk,x=u(S);h({type:E,request:x,chunk:_})},h=function(T){var E=T.type,S=T.chunk,_=T.request,x=S||{},A=x.mediaInfo,I=x.start,R=A||{},b=R.type,k=fa(_,t),M=k.requestStart,G=k.requestResponseStart,q=k.requestResponseEnd,U=k.requestBytesLoaded,P=k.requestResponseHeaders,K=k.requestMediaDuration,B=k.requestHostname,Y=k.requestUrl,z=k.requestId,O=bc(b,t),N=O.currentLevel,Z=O.renditionWidth,ae=O.renditionHeight,ee=O.renditionBitrate;n("requestcompleted",{request_event_type:E,request_start:M,request_response_start:G,request_response_end:q,request_bytes_loaded:U,request_type:b,request_response_headers:P,request_hostname:B,request_id:z,request_url:Y,request_media_start_time:I,request_media_duration:K,request_current_level:N,request_labeled_bitrate:ee,request_video_width:Z,request_video_height:ae})};r>=4?t.on("mediaFragmentLoaded",h):t.on("mediaFragmentLoaded",c);var f={video:void 0,audio:void 0,totalBitrate:void 0},g=function(){if(f.video&&typeof f.video.bitrate=="number"){if(!(f.video.width&&f.video.height)){i.warn("have bitrate info for video but missing width/height");return}var T=f.video.bitrate;if(f.audio&&typeof f.audio.bitrate=="number"&&(T+=f.audio.bitrate),T!==f.totalBitrate)return f.totalBitrate=T,{video_source_bitrate:T,video_source_height:f.video.height,video_source_width:f.video.width,video_source_codec:xc(f.video.codec)}}},p=function(T,E,S){if(typeof T.newQuality!="number"){i.warn("missing evt.newQuality in qualityChangeRendered event",T);return}var _=T.mediaType;if(_==="audio"||_==="video"){var x=t.getBitrateInfoListFor(_).find(function(I){var R=I.qualityIndex;return R===T.newQuality});if(!(x&&typeof x.bitrate=="number")){i.warn("missing bitrate info for ".concat(_));return}f[_]=_n(Cs({},x),{codec:t.getCurrentTrackFor(_).codec});var A=g();A&&n("renditionchange",A)}};t.on("qualityChangeRendered",p);var m=function(T){var E=T.request,S=T.mediaType;E=E||{},n("requestcanceled",{request_event_type:E.type+"_"+E.action,request_url:E.url,request_type:S,request_hostname:at(E.url)})};t.on("fragmentLoadingAbandoned",m);var y=function(T){var E=T.error,S,_,x=(E==null||(S=E.data)===null||S===void 0?void 0:S.request)||{},A=(E==null||(_=E.data)===null||_===void 0?void 0:_.response)||{};E?.code===27&&n("requestfailed",{request_error:x.type+"_"+x.action,request_url:x.url,request_hostname:at(x.url),request_type:x.mediaType,request_error_code:A.status,request_error_text:A.statusText});var I="".concat(x!=null&&x.url?"url: ".concat(x.url,`
13`):"")+"".concat(A!=null&&A.status||A!=null&&A.statusText?"response: ".concat(A?.status,", ").concat(A?.statusText,`
14`):"");n("error",{player_error_code:E?.code,player_error_message:E?.message,player_error_context:I})};t.on("error",y),t._stopMuxMonitor=function(){t.off("manifestLoaded",a),t.off("initFragmentLoaded",d),t.off("mediaFragmentLoaded",h),t.off("qualityChangeRendered",p),t.off("error",y),t.off("fragmentLoadingAbandoned",m),delete t._stopMuxMonitor}},Lc=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()},ga=0,Dc=(function(){function s(){De(this,s),F(this,"_listeners",void 0)}return yt(s,[{key:"on",value:function(e,t,i){return t._eventEmitterGuid=t._eventEmitterGuid||++ga,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],i&&(t=t.bind(i)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var i=this._listeners&&this._listeners[e];
vendor: 17,437 bytes, line 14
14i&&i.forEach(function(r,n){r._eventEmitterGuid===t._eventEmitterGuid&&i.splice(n,1)})}},{key:"one",value:function(e,t,i){var r=this;t._eventEmitterGuid=t._eventEmitterGuid||++ga;var n=function(){r.off(e,n),t.apply(i||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var i=this;if(this._listeners){t=t||{};var r=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(u,l){u=u.slice(),u.forEach(function(d){d.call(i,{type:e},l)})};o(r,t),o(n,t),o(a,t)}}}]),s})(),kc=Dc,rr=We(ot()),Cc=(function(){function s(e){var t=this;De(this,s),F(this,"_playbackHeartbeatInterval",void 0),F(this,"_playheadShouldBeProgressing",void 0),F(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(i,r){t._playbackHeartbeatInterval!==null&&(rr.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),t._playbackHeartbeatInterval=null)})}return yt(s,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=rr.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(rr.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),s})(),wc=Cc,Pc=function s(e){var t=this;De(this,s),F(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(i,r){try{var n=e.errorTranslator({player_error_code:r.player_error_code,player_error_message:r.player_error_message,player_error_context:r.player_error_context,player_error_severity:r.player_error_severity,player_error_business_exception:r.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||r.player_error_code,e.data.player_error_message=n.player_error_message||r.player_error_message,e.data.player_error_context=n.player_error_context||r.player_error_context,e.data.player_error_severity=n.player_error_severity||r.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||r.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 i,r,n,a,o;(i=e.data)===null||i===void 0||delete i.player_error_code,(r=e.data)===null||r===void 0||delete r.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})},Oc=Pc,Mc=(function(){function s(e){De(this,s),F(this,"_watchTimeTrackerLastCheckedTime",void 0),F(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 yt(s,[{key:"_updateWatchTime",value:function(e,t){var i=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=i),_e(this.pm.data,"view_watch_time",i-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=i}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),s})(),Nc=Mc,Fc=(function(){function s(e){var t=this;De(this,s),F(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),F(this,"_lastTime",void 0),F(this,"_isAdPlaying",void 0),F(this,"_callbackUpdatePlaybackTime",void 0),F(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=be.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var i=this._startPlaybackTimeTracking.bind(this);e.on("playing",i),e.on("adplaying",i),e.on("seeked",i);var r=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",r),e.on("seeking",r),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=be.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return yt(s,[{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=be.now(),i=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?i=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(i=t-this._lastTime),i>0&&i<=1e3&&_e(this.pm.data,"view_content_playback_time",i),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),s})(),Uc=Fc,Bc=(function(){function s(e){De(this,s),F(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 yt(s,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position>"u"?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 i=this,r=function(){i.pm.currentFragmentPDT&&i.pm.currentFragmentStart&&(i.pm.data.player_program_time=i.pm.currentFragmentPDT+i.pm.data.player_playhead_time-i.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,r(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n<"u"&&(this.pm.data.player_playhead_time=n,r(),this._updateMaxPlayheadPosition())}}}]),s})(),$c=Bc,ma=300*1e3,Gc=function s(e){if(De(this,s),!e.disableRebufferTracking){var t,i=function(n,a){r(a),t=void 0},r=function(n){if(t){var a=n.viewer_time-t;_e(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>ma&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(ma,"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 r(a)}),e.on("rebufferstart",function(n,a){t||(_e(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",i))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",i)})}},Kc=Gc,Vc=(function(){function s(e){var t=this;De(this,s),F(this,"_lastCheckedTime",void 0),F(this,"_lastPlayheadTime",void 0),F(this,"_lastPlayheadTimeUpdatedTime",void 0),F(this,"_rebuffering",void 0),F(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:be.now()})}))}return yt(s,[{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 i=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&i>=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 i=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 r=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&r>0&&n-r>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-r}))}i?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),s})(),Hc=Vc,qc=(function(){function s(e){var t=this;De(this,s),F(this,"NAVIGATION_START",void 0),F(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var i=e.data,r=i.view_id;if(!i.view_program_changed){var n=function(a,o){var u=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame>"u"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame>"u"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(u||be.now(),r)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return yt(s,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||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))}}]),s})(),Yc=qc,Wc=function s(e){var t=this;De(this,s),F(this,"_lastPlayerHeight",void 0),F(this,"_lastPlayerWidth",void 0),F(this,"_lastPlayheadPosition",void 0),F(this,"_lastSourceHeight",void 0),F(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var i=["pause","rebufferstart","seeking","error","adbreakstart","hb","renditionchange","orientationchange","viewend"],r=["playing","hb","renditionchange","orientationchange"];i.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),u=Math.max(0,o-1),l=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,u),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,l),_e(e.data,"view_total_content_playback_time",a),_e(e.data,"view_total_upscaling",u*a),_e(e.data,"view_total_downscaling",l*a)}t._lastPlayheadPosition=-1})}),r.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})})},jc=Wc,zc=2e3,Xc=function s(e){var t=this;De(this,s),F(this,"isSeeking",void 0),this.isSeeking=!1;var i=-1,r=function(){var n=be.now(),a=(e.data.viewer_time||n)-(i||n);_e(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,i=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-i<=zc){i=a.viewer_time;return}t.isSeeking&&r(),t.isSeeking=!0,i=a.viewer_time,_e(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){r()}),e.on("viewend",function(){t.isSeeking&&(r(),e.send("seeked")),t.isSeeking=!1,i=-1})},Qc=Xc,pa=function(s,e){s.push(e),s.sort(function(t,i){return t.viewer_time-i.viewer_time})},Jc=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],Zc=(function(){function s(e){var t=this;De(this,s),F(this,"_adHasPlayed",void 0),F(this,"_adRequests",void 0),F(this,"_adResponses",void 0),F(this,"_currentAdRequestNumber",void 0),F(this,"_currentAdResponseNumber",void 0),F(this,"_prerollPlayTime",void 0),F(this,"_wouldBeNewAdPlay",void 0),F(this,"isAdBreak",void 0),F(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}),Jc.forEach(function(r){return e.on(r,t._updateAdData.bind(t))});var i=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",i),e.on("playing",i),e.on("viewend",i),e.on("adrequest",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),pa(t._adRequests,n),_e(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||_e(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),pa(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&_e(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(r,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,_e(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(r,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time>"u"&&typeof t._prerollPlayTime<"u"&&(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(r,n){t._wouldBeNewAdPlay||_e(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(r,n){t._wouldBeNewAdPlay||_e(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return yt(s,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||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
14(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var i=xt(Mi(t.ad_tag_url),2),r=i[0],n=i[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=r}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=xt(Mi(t.ad_asset_url),2),o=a[0],u=a[1];this.pm.data.view_preroll_ad_asset_domain=u,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t?.ad_asset_url,this.pm.data.ad_tag_url=t?.ad_tag_url,this.pm.data.ad_creative_id=t?.ad_creative_id,this.pm.data.ad_id=t?.ad_id,this.pm.data.ad_universal_id=t?.ad_universal_id}}]),s})(),eh=Zc,va=We(ot()),th=function s(e){De(this,s);var t,i,r=function(){e.disableRebufferTracking||(_e(e.data,"view_waiting_rebuffer_count",1),t=be.now(),i=va.default.setInterval(function(){if(t){var l=be.now();_e(e.data,"view_waiting_rebuffer_duration",l-t),t=l}},250))},n=function(){e.disableRebufferTracking||t&&(_e(e.data,"view_waiting_rebuffer_duration",be.now()-t),t=!1,va.default.clearInterval(i))},a=!1,o=function(){a=!0},u=function(){a=!1,n()};e.on("waiting",function(){a&&r()}),e.on("playing",function(){n(),o()}),e.on("pause",u),e.on("seeking",u)},ih=th,sh=function s(e){var t=this;De(this,s),F(this,"lastWallClockTime",void 0);var i=function(){t.lastWallClockTime=be.now(),e.on("before*",r)},r=function(n){var a=be.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",i),e.on("playbackheartbeatend",function(){e.off("before*",r),e.one("playbackheartbeat",i)})},rh=sh,nr=We(ot()),Tl=(function(s){return s()})(function(){var s=function(){for(var t=0,i={};t<arguments.length;t++){var r=arguments[t];for(var n in r)i[n]=r[n]}return i};function e(t){function i(r,n,a){var o;if(typeof document<"u"){if(arguments.length>1){if(a=s({path:"/"},i.defaults,a),typeof a.expires=="number"){var u=new Date;u.setMilliseconds(u.getMilliseconds()+a.expires*864e5),a.expires=u}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,r):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),r=encodeURIComponent(String(r)),r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),r=r.replace(/[\(\)]/g,escape),document.cookie=[r,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}r||(o={});for(var l=document.cookie?document.cookie.split("; "):[],d=/(%[0-9A-Z]{2})+/g,c=0;c<l.length;c++){var h=l[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var g=h[0].replace(d,decodeURIComponent);if(f=t.read?t.read(f,g):t(f,g)||f.replace(d,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(r===g){o=f;break}r||(o[g]=f)}catch{}}return o}}return i.set=i,i.get=function(r){return i.call(i,r)},i.getJSON=function(){return i.apply({json:!0},[].slice.call(arguments))},i.defaults={},i.remove=function(r,n){i(r,"",s(n,{expires:-1}))},i.withConverter=e,i}return e(function(){})}),Sl="muxData",nh=function(s){return Object.entries(s).map(function(e){var t=xt(e,2),i=t[0],r=t[1];return"".concat(i,"=").concat(r)}).join("&")},ah=function(s){return s.split("&").reduce(function(e,t){var i=xt(t.split("="),2),r=i[0],n=i[1],a=+n,o=n&&a==n?a:n;return e[r]=o,e},{})},_l=function(){var s;try{s=ah(Tl.get(Sl)||"")}catch{s={}}return s},Al=function(s){try{Tl.set(Sl,nh(s),{expires:365})}catch{}},oh=function(){var s=_l();return s.mux_viewer_id=s.mux_viewer_id||Oi(),s.msn=s.msn||Math.random(),Al(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},lh=function(){var s=_l(),e=be.now();return s.session_start&&(s.sst=s.session_start,delete s.session_start),s.session_id&&(s.sid=s.session_id,delete s.session_id),s.session_expires&&(s.sex=s.session_expires,delete s.session_expires),(!s.sex||s.sex<e)&&(s.sid=Oi(),s.sst=e),s.sex=e+1500*1e3,Al(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};function uh(s,e){var t=e.beaconCollectionDomain,i=e.beaconDomain;if(t)return"https://"+t;s=s||"inferred";var r=i||"litix.io";return s.match(/^[a-z0-9]+$/)?"https://"+s+"."+r:"https://img.litix.io/a.gif"}var dh=We(ot()),bl=function(){var s;switch(xl()){case"cellular":s="cellular";break;case"ethernet":s="wired";break;case"wifi":s="wifi";break;case void 0:break;default:s="other"}return s},xl=function(){var s=dh.default.navigator,e=s&&(s.connection||s.moz
vendor: 6,077 bytes, line 14
14Connection||s.webkitConnection);return e&&e.type};bl.getConnectionFromAPI=xl;var ch=bl,hh={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"},fh=Il(hh),gh={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"},ya=Il(gh);function Il(s){var e={};for(var t in s)s.hasOwnProperty(t)&&(e[s[t]]=t);return e}function Br(s){var e={},t={};return Object.keys(s).forEach(function(i){var r=!1;if(s.hasOwnProperty(i)&&s[i]!==void 0){var n=i.split("_"),a=n[0],o=fh[a];o||(he.info("Data key word `"+n[0]+"` not expected in "+i),o=a+"_"),n.splice(1).forEach(function(u){u==="url"&&(r=!0),ya[u]?o+=ya[u]:Number.isInteger(Number(u))?o+=u:(he.info("Data key word `"+u+"` not expected in "+i),o+="_"+u+"_")}),r?t[o]=s[i]:e[o]=s[i]}}),Object.assign(e,t)}var Yt=We(ot()),mh=We(ml()),ph={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},vh=56*1024,yh=["hb","requestcompleted","requestfailed","requestcanceled"],Eh="https://img.litix.io",It=function(s){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=s||Eh,this._eventQueue=[],this._postInFlight=!1,this._resendAfterPost=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},ph,e)};It.prototype.queueEvent=function(s,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||s==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};It.prototype.flushEvents=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(s&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};It.prototype.destroy=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,s?this._clearBeaconQueue():this.flushEvents(),Yt.default.clearTimeout(this._sendTimeout)};It.prototype._clearBeaconQueue=function(){var s=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(s);s>0&&Object.assign(e[e.length-1],Br({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);Rl(this._beaconUrl,t,!0,function(){})};It.prototype._sendBeaconQueue=function(){var s=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),i=be.now();Rl(this._beaconUrl,t,!1,function(r,n){n?(s._eventQueue=e.concat(s._eventQueue),s._failureCount+=1,he.info("Error sending beacon: "+n)):s._failureCount=0,s._roundTripTime=be.now()-i,s._postInFlight=!1,s._resendAfterPost&&(s._resendAfterPost=!1,s._eventQueue.length>0&&s._sendBeaconQueue())})};It.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var s=Math.pow(2,this._failureCount-1);return s=s*Math.random(),(1+s)*this._options.baseTimeBetweenBeacons};It.prototype._startBeaconSending=function(){var s=this;Yt.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=Yt.default.setTimeout(function(){s._eventQueue.length&&s._sendBeaconQueue(),s._startBeaconSending()},this._getNextBeaconTime()))};It.prototype._createPayload=function(s){var e=this,t={transmission_timestamp:Math.round(be.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var i,r,n,a=function(){i=JSON.stringify({metadata:t,events:r||s}),n=i.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(he.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),r=s.filter(function(u){return yh.indexOf(u.e)===-1}),a()),o()||(he.info("Payload size still too big ("+n+" kb). Cropping fields.."),r.forEach(function(u){for(var l in u){var d=u[l],c=50*1024;
vendor: 6,269 bytes, line 14
14typeof d=="string"&&d.length>c&&(u[l]=d.substring(0,c))}}),a()),i};var Th=typeof mh.default.exitPictureInPicture=="function"?function(s){return s.length<=vh}:function(s){return!1},Rl=function(s,e,t,i){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(s,e)){i();return}if(Yt.default.fetch){Yt.default.fetch(s,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:Th(e)}).then(function(n){return i(null,n.ok?null:"Error")}).catch(function(n){return i(null,n)});return}if(Yt.default.XMLHttpRequest){var r=new Yt.default.XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===4)return i(null,r.status!==200?"error":void 0)},r.open("POST",s),r.setRequestHeader("Content-Type","text/plain"),r.send(e);return}i()},Sh=It,_h=["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"],Ah=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],bh=["ad_id","ad_creative_id","ad_universal_id"],xh=["viewstart","error","ended","viewend"],Ih=600*1e3,Rh=(function(){function s(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};De(this,s);var r,n,a,o,u,l,d,c,h,f,g,p;F(this,"mux",void 0),F(this,"envKey",void 0),F(this,"options",void 0),F(this,"eventQueue",void 0),F(this,"sampleRate",void 0),F(this,"disableCookies",void 0),F(this,"respectDoNotTrack",void 0),F(this,"previousBeaconData",void 0),F(this,"lastEventTime",void 0),F(this,"rateLimited",void 0),F(this,"pageLevelData",void 0),F(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=i,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new Sh(uh(this.envKey,this.options));var m;this.sampleRate=(m=this.options.sampleRate)!==null&&m!==void 0?m:1;var y;this.disableCookies=(y=this.options.disableCookies)!==null&&y!==void 0?y:!1;var T;this.respectDoNotTrack=(T=this.options.respectDoNotTrack)!==null&&T!==void 0?T:!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:(r=this.options.platform)===null||r===void 0?void 0:r.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:(u=this.options.platform)===null||u===void 0?void 0:u.manufacturer,viewer_os_family:(d=this.options.platform)===null||d===void 0||(l=d.os)===null||l===void 0?void 0:l.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:(g=this.options.platform)===null||g===void 0||(f=g.os)===null||f===void 0?void 0:f.version,viewer_connection_type:ch(),page_url:nr.default===null||nr.default===void 0||(p=nr.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:oh()}return yt(s,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Fr())return he.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return he.error("A data object was expected in send() but was not provided");var i=this.disableCookies?{}:lh(),r=_n(Cs({},this.pageLevelData,t,i,this.viewerData),{event:e,env_key:this.envKey});r.user_id&&(r.viewer_user_id=r.user_id,delete r.user_id);var n,a=((n=r.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,r),u=Br(o);if(this.lastEventTime=this.mux.utils.now(),a)return he.info("Not sending event due to sample rate restriction",e,r,u);if(this.envKey||he.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,u),!this.rateLimited){if(he.info("Sending event",e,r,u),this.rateLimited=!this.eventQueue.queueEvent(e,u),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):xh.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return r.event="eventrateexceeded",u=Br(r),this.eventQueue.queueEvent(r.event,u),he.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var i=this,r={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=Ih)r=Cs({},t),n&&(this.previousBeaconData=r),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var u=xt(o,2),l=u[0],d=u[1];i.previousBeaconData&&(d!==i.previousBeaconData[l]||_h.indexOf(l)>-1||i.objectHasChanged(a,l,d,i.previousBeaconData[l])||i.eventRequiresKey(e,l))&&(r[l]=d,i.previousBeaconData[l]=d)})}return r}},{key:"objectHasChanged",value:function(e,t,i,r){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof i!="object"||typeof r!="object"?!0:Object.keys(i||{}).length!==Object.keys(r||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||bh.includes(t)&&Ah.includes(e))}}]),s})(),Lh=function s(e){De(this,s);var t=0,i=0,r=0,n=0,a=0,o=0,u=0,l=function(h,f){var g=f.request_start,p=f.request_response_start,m=f.request_response_end,y=f.request_bytes_loaded;n++;var T,E;if(p?(T=p-(g??0),E=(m??0)-p):E=(m??0)-(g??0),E>0&&y&&y>0){var S=y/E*8e3;a++,i+=y,r+=E,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,S),e.data.view_average_request_throughput=i/r*8e3,e.data.view_request_count=n,T>0&&(t+=T,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,T),e.data.view_average_request_latency=t/a)}},d=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o}
14,c=function(h,f){n++,u++,e.data.view_request_count=n,e.data.view_request_canceled_count=u};e.on("requestcompleted",l),e.on("requestfailed",d),e.on("requestcanceled",c)},Dh=Lh,kh=3600*1e3,Ch=function s(e){var t=this;De(this,s),F(this,"_lastEventTime",void 0),e.on("before*",function(i,r){var n=r.viewer_time,a=be.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>kh){var u=Object.keys(e.data).reduce(function(d,c){return c.indexOf("video_")===0?Object.assign(d,F({},c,e.data[c])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view");var l=e.playbackHeartbeat._playheadShouldBeProgressing;e._resetView(Object.assign({viewer_time:n},u)),e.playbackHeartbeat._playheadShouldBeProgressing=l,e.playbackHeartbeat._playheadShouldBeProgressing&&i.type!=="play"&&i.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),i.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},wh=Ch,Ph=["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"],Oh=new Set(["requestcompleted","requestfailed","requestcanceled"]),Mh=(function(s){fc(t,s);var e=pc(t);function t(i,r,n){De(this,t);var a;a=e.call(this),F(X(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),F(X(a),"NAVIGATION_START",void 0),F(X(a),"_destroyed",void 0),F(X(a),"_heartBeatTimeout",void 0),F(X(a),"adTracker",void 0),F(X(a),"dashjs",void 0),F(X(a),"data",void 0),F(X(a),"disablePlayheadRebufferTracking",void 0),F(X(a),"disableRebufferTracking",void 0),F(X(a),"errorTracker",void 0),F(X(a),"errorTranslator",void 0),F(X(a),"emitTranslator",void 0),F(X(a),"getAdData",void 0),F(X(a),"getPlayheadTime",void 0),F(X(a),"getStateData",void 0),F(X(a),"stateDataTranslator",void 0),F(X(a),"hlsjs",void 0),F(X(a),"id",void 0),F(X(a),"longResumeTracker",void 0),F(X(a),"minimumRebufferDuration",void 0),F(X(a),"mux",void 0),F(X(a),"playbackEventDispatcher",void 0),F(X(a),"playbackHeartbeat",void 0),F(X(a),"playbackHeartbeatTime",void 0),F(X(a),"playheadTime",void 0),F(X(a),"seekingTracker",void 0),F(X(a),"sustainedRebufferThreshold",void 0),F(X(a),"watchTimeTracker",void 0),F(X(a),"currentFragmentPDT",void 0),F(X(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=ks.domContentLoadedEventEnd(),a.NAVIGATION_START=ks.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),g=0;g<h;g++)f[g]=arguments[g];return f},stateDataTranslator:function(h){return h}};a.mux=i,a.id=r,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),he.level=n.debug?qt.DEBUG:qt.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 Rh(i,n.data.env_key,n),a.data={player_instance_id:Oi(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1;var u=(function(){typeof this.data.view_start>
vendor: 10,800 bytes, line 14
14"u"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}).bind(X(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",u),this.one("adbreakstart",u)}),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})),u(),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<"u"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var l=function(){var h=typeof a.data.view_start<"u";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",h&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",l,!1);var d=function(h){h.persisted||a.destroy()};window.addEventListener("pagehide",d,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",l),window.removeEventListener("pagehide",d)})}a.on("playerready",function(h,f){Object.assign(this.data,f)}),Ph.forEach(function(h){a.on(h,function(f,g){h.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,g),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 wh(X(a)),a.errorTracker=new Oc(X(a)),new rh(X(a)),a.seekingTracker=new Qc(X(a)),a.playheadTime=new $c(X(a)),a.playbackHeartbeat=new wc(X(a)),new jc(X(a)),a.watchTimeTracker=new Nc(X(a)),new Uc(X(a)),a.adTracker=new eh(X(a)),new Hc(X(a)),new Kc(X(a)),new Yc(X(a)),new ih(X(a)),new Dh(X(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return yt(t,[{key:"emit",value:function(i,r){var n,a=Object.assign({viewer_time:this.mux.utils.now()},r),o=[i,a];if(this.emitTranslator)try{o=this.emitTranslator(i,a)}catch(u){this.mux.log.warn("Exception in emit translator callback.",u)}o!=null&&o.length&&(n=us(gi(t.prototype),"emit",this)).call.apply(n,[this].concat(rt(o)))}},{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start<"u"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(i){if(this.data.view_id){var r=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(r.video_source_is_live===void 0&&(r.player_source_duration===1/0||r.video_source_duration===1/0?r.video_source_is_live=!0:(r.player_source_duration>0||r.video_source_duration>0)&&(r.video_source_is_live=!1)),r.video_source_is_live||n.forEach(function(l){r[l]=void 0}),r.video_source_url=r.video_source_url||r.player_source_url,r.video_source_url){var a=xt(Mi(r.video_source_url),2),o=a[0],u=a[1];r.video_source_domain=u,r.video_source_hostname=o}delete r.ad_request_id,this.playbackEventDispatcher.send(i,r),this.data.view_sequence_number++,this.data.player_sequence_number++,Oh.has(i)||this._restartHeartBeat(),i==="viewend"&&delete this.data.view_id}}},{key:"_resetView",value:function(i){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",i)}},{key:"_updateStateData",value:function(){var i=this.getStateData();if(typeof this.stateDataTranslator=="function")try{i=this.stateDataTranslator(i)}catch(r){this.mux.log.warn("Exception in stateDataTranslator translator callback.",r)}Object.assign(this.data,i),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var i=this,r=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];r.forEach(function(a){var o=parseInt(i.data[a],10);i.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(i.data[a]){var o=i.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(i.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var i=this;Object.keys(this.data).forEach(function(r){r.indexOf("video_")===0&&delete i.data[r]})}},{key:"_resetViewData",value:function(){var i=this;Object.keys(this.data).forEach(function(r){r.indexOf("view_")===0&&delete i.data[r]}),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 i=this,r=this.data.view_id=Oi(),n=function(){r===i.data.view_id&&_e(i.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var i=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){i.data.player_is_paused||i.emit("hb")},1e4)}},{key:"addHLSJS",value:function(i){if(!i.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=i.hlsjs,_c(this.mux,this.id,i.hlsjs,{},i.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(Ac(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(i){if(!i.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=i.dashjs,Rc(this.mux,this.id,i.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(Lc(this.dashjs),this.dashjs=void 0)}}]),t})(kc),Nh=Mh,Ti=We(ml());function Fh(){return Ti.default&&!!(Ti.default.fullscreenElement||Ti.default.webkitFullscreenElement||Ti.default.mozFullScreenElement||Ti.default.msFullscreenElement)}var Uh=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Bh={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function $h(s,e,t){var i=xt(Ds(e),3),r=i[0],n=i[1],a=i[2],o=s.log,u=s.utils.getComputedStyle,l=s.utils.secondsToMs,d={automaticErrorTracking:!0};if(r){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.");r.mux&&(r.mux.destroy(),delete r.mux,o.warn("Already monitoring this video element, replacing existing event listeners"));var c={getPlayheadTime:function(){return l(r.currentTime)},getStateData:function(){var f,g,p,m=((f=(g=this).getPlayheadTime)===null||f===void 0?void 0:f.call(g))||l(r.currentTime),y=this.hlsjs&&this.hlsjs.url,T=this.dashjs&&typeof this.dashjs.getSource=="function"&&this.dashjs.getSource(),E={player_is_paused:r.paused,player_width:parseInt(u(r,"width")),player_height:parseInt(u(r,"height")),player_autoplay_on:r.autoplay,player_preload_on:r.preload,player_language_code:r.lang,player_is_fullscreen:Fh(),video_poster_url:r.poster,video_source_url:y||T||r.currentSrc,video_source_duration:l(r.duration),video_source_height:r.videoHeight,video_source_width:r.videoWidth,view_dropped_frame_count:r==null||(p=r.getVideoPlaybackQuality)===null||p===void 0?void 0:p.call(r).droppedVideoFrames};if(r.getStartDate&&m>0){var S=r.getStartDate();if(S&&typeof S.getTime=="function"&&S.getTime()){var _=S.getTime();if(E.player_program_time=_+m,r.seekable.length>0){var x=_+r.seekable.end(r.seekable.length-1);E.player_live_edge_program_time=x}}}return E}};t=Object.assign(d,t,c),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:s.VERSION},t.data),r.mux=r.mux||{},r.mux.deleted=!1,r.mux.emit=function(f,g){s.emit(n,f,g)},r.mux.updateData=function(f){r.mux.emit("hb",f)};var h=function(){o.error("The monitor for this video element has already been destroyed.")};r.mux.destroy=function(){Object.keys(r.mux.listeners).forEach(function(f){r.removeEventListener(f,r.mux.listeners[f],!1)}),delete r.mux.listeners,r.mux.destroy=h,r.mux.swapElement=h,r.mux.emit=h,r.mux.addHLSJS=h,r.mux.addDashJS=h,r.mux.removeHLSJS=h,r.mux.removeDashJS=h,r.mux.updateData=h,r.mux.setEmitTranslator=h,r.mux.setStateDataTranslator=h,r.mux.setGetPlayheadTime=h,r.mux.deleted=!0,s.emit(n,"destroy")},r.mux.swapElement=function(f){var g=xt(Ds(f),3),p=g[0],m=g[1],y=g[2];if(p){if(y!=="video"&&y!=="audio")return s.log.error("The element of `"+m+"` was not a media element.")}else return s.log.error("No element was found with the `"+m+"` query selector.");p.muxId=r.muxId,delete r.muxId,p.mux=p.mux||{},p.mux.listeners=Object.assign({},r.mux.listeners),delete r.mux.listeners,Object.keys(p.mux.listeners).forEach(function(T){r.removeEventListener(T,p.mux.listeners[T],!1),p.addEventListener(T,p.mux.listeners[T],!1)}),p.mux.swapElement=r.mux.swapElement,p.mux.destroy=r.mux.destroy,delete r.mux,r=p},r.mux.addHLSJS=function(f){s.addHLSJS(n,f)},r.mux.addDashJS=function(f){s.addDashJS(n,f)},r.mux.removeHLSJS=function(){s.removeHLSJS(n)},r.mux.removeDashJS=function(){s.removeDashJS(n)},r.mux.setEmitTranslator=function(f){s.setEmitTranslator(n,f)},r.mux.setStateDataTranslator=function(f){s.setStateDataTranslator(n,f)},r.mux.setGetPlayheadTime=function(f){f||(f=t.getPlayheadTime),s.setGetPlayheadTime(n,f)},s.init(n,t),s.emit(n,"playerready"),r.paused||(s.emit(n,"play"),r.readyState>2&&s.emit(n,"playing")),r.mux.listeners={}
vendor: 1,347 bytes, lines 14-16
14,Uh.forEach(function(f){f==="error"&&!t.automaticErrorTracking||(r.mux.listeners[f]=function(){var g={};if(f==="error"){if(!r.error||r.error.code===1)return;g.player_error_code=r.error.code,g.player_error_message=Bh[r.error.code]||r.error.message}s.emit(n,f,g)},r.addEventListener(f,r.mux.listeners[f],!1))})}function Gh(s,e,t,i){var r=i;if(s&&typeof s[e]=="function")try{r=s[e].apply(s,t)}catch(n){he.info("safeCall error",n)}return r}var ki=We(ot()),ri;ki.default&&ki.default.WeakMap&&(ri=new WeakMap);function Kh(s,e){if(!s||!e||!ki.default||typeof ki.default.getComputedStyle!="function")return"";var t;return ri&&ri.has(s)&&(t=ri.get(s)),t||(t=ki.default.getComputedStyle(s,null),ri&&ri.set(s,t)),t.getPropertyValue(e)}function Vh(s){return Math.floor(s*1e3)}var Gt={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"},Ys=function(s){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(s),this.manifest};Ys.prototype.process=function(s){var e;for(this.buffer+=s,e=this.buffer.indexOf(`
15`);e>-1;e=this.buffer.indexOf(`
16`))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};
vendor: 8,576 bytes, lines 16-22
16Ys.prototype.processLine=function(s){var e=s.indexOf(":"),t=Wh(s,e),i=t[0],r=t.length===2?bn(t[1]):void 0;if(i[0]!=="#")this.currentUri.uri=i,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(i){case Gt.TARGET_DURATION:{if(!isFinite(r)||r<0)return;this.manifest.targetDuration=r,this.setHoldBack();break}case Gt.PART_INF:{ar(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case Gt.SERVER_CONTROL:{ar(this.manifest,t),this.setHoldBack();break}case Gt.INF:{r===0?this.currentUri.duration=.01:r>0&&(this.currentUri.duration=r);break}case Gt.PROGRAM_DATE_TIME:{var n=r,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 Gt.VERSION:{ar(this.manifest,t);break}case Gt.SESSION_DATA:{var o=jh(t[1]),u=El(o);Object.assign(this.manifest.sessionData,u)}}};Ys.prototype.setHoldBack=function(){var s=this.manifest,e=s.serverControl,t=s.targetDuration,i=s.partTargetDuration;if(e){var r="holdBack",n="partHoldBack",a=t&&t*3,o=i&&i*2;t&&!e.hasOwnProperty(r)&&(e[r]=a),a&&e[r]<a&&(e[r]=a),i&&!e.hasOwnProperty(n)&&(e[n]=i*3),i&&e[n]<o&&(e[n]=o)}};var ar=function(s,e){var t=Ll(e[0].replace("#EXT-X-","")),i;Yh(e[1])?(i={},i=Object.assign(qh(e[1]),i)):i=bn(e[1]),s[t]=i},Ll=function(s){return s.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},bn=function(s){if(s.toLowerCase()==="yes"||s.toLowerCase()==="no")return s.toLowerCase()==="yes";var e=s.indexOf(":")!==-1?s:parseFloat(s);return isNaN(e)?s:e},Hh=function(s){var e={},t=s.split("=");if(t.length>1){var i=Ll(t[0]);e[i]=bn(t[1])}return e},qh=function(s){for(var e=s.split(","),t={},i=0;e.length>i;i++){var r=e[i],n=Hh(r);t=Object.assign(n,t)}return t},Yh=function(s){return s.indexOf("=")>-1},Wh=function(s,e){return e===-1?[s]:[s.substring(0,e),s.substring(e+1)]},jh=function(s){var e={};if(s){var t=s.search(","),i=s.slice(0,t),r=s.slice(t+1),n=[i,r];return n.forEach(function(a,o){for(var u=a.replace(/['"]+/g,"").split("="),l=0;l<u.length;l++)u[l]==="DATA-ID"&&(e["DATA-ID"]=u[1-l]),u[l]==="VALUE"&&(e.VALUE=u[1-l])}),{data:e}}},zh=Ys,Xh={safeCall:Gh,safeIncrement:_e,getComputedStyle:Kh,secondsToMs:Vh,assign:Object.assign,headersStringToObject:An,cdnHeadersToRequestId:ws,extractHostnameAndDomain:Mi,extractHostname:at,manifestParser:zh,generateShortID:vl,generateUUID:Oi,now:be.now,findMediaElement:Ds},Qh=Xh,Jh={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"},Zh=Jh,ef="mux-embed",tf="5.9.0",sf="2.1",Te={},Mt=function(s){var e=arguments;typeof s=="string"?Mt.hasOwnProperty(s)?Di.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Mt[s].apply(null,e)},0):he.warn("`"+s+"` is an unknown task"):typeof s=="function"?Di.default.setTimeout(function(){s(Mt)},0):he.warn("`"+s+"` is invalid.")},rf={loaded:be.now(),NAME:ef,VERSION:tf,API_VERSION:sf,PLAYER_TRACKED:!1,monitor:function(s,e){return $h(Mt,s,e)},destroyMonitor:function(s){var e=xt(Ds(s),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():he.error("A video element monitor for `"+s+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(s,e){var t=st(s);Te[t]?Te[t].addHLSJS(e):he.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(s,e){var t=st(s);Te[t]?Te[t].addDashJS(e):he.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(s){var e=st(s);Te[e]?Te[e].removeHLSJS():he.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(s){var e=st(s);Te[e]?Te[e].removeDashJS():he.error("A monitor for `"+e+"` has not been initialized.")},init:function(s,e){Fr()&&e&&e.respectDoNotTrack&&he.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=st(s);Te[t]=new Nh(Mt,t,e)},emit:function(s,e,t){var i=st(s);Te[i]?(Te[i].emit(e,t),e==="destroy"&&delete Te[i]):he.error("A monitor for `"+i+"` has not been initialized.")},updateData:function(s,e){var t=st(s);Te[t]?Te[t].emit("hb",e):he.error("A monitor for `"+t+"` has not been initialized.")},setEmitTranslator:function(s,e){var t=st(s);Te[t]?Te[t].emitTranslator=e:he.error("A monitor for `"+t+"` has not been initialized.")},setStateDataTranslator:function(s,e){var t=st(s);Te[t]?Te[t].stateDataTranslator=e:he.error("A monitor for `"+t+"` has not been initialized.")},setGetPlayheadTime:function(s,e){var t=st(s);Te[t]?Te[t].getPlayheadTime=e:he.error("A monitor for `"+t+"` has not been initialized.")},checkDoNotTrack:Fr,log:he,utils:Qh,events:Zh,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Mt,rf);typeof Di.default<"u"&&typeof Di.default.addEventListener=="function"&&Di.default.addEventListener("pagehide",function(s){s.persisted||(Mt.WINDOW_UNLOADING=!0)},!1);var xn=Mt;/*!
17* JavaScript Cookie v2.1.3
18* https://github.com/js-cookie/js-cookie
19*
20* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
21* Released under the MIT license
22*/const $=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},nf=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=af},af=Number.MAX_SAFE_INTEGER||9007199254740991;let W=(function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s})({}),D=(function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ER
22ROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s})({}),v=(function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s})({});var ie={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},H={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class ei{constructor(e,t=0,i=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_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class of{constructor(e,t,i,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_
vendor: 3,811 bytes, line 22
22=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ei(e),this.fast_=new ei(t),this.defaultTTFB_=r,this.ttfb_=new ei(e)}update(e,t){const{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new ei(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new ei(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new ei(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,r=e/1e3,n=i/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,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_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function lf(s,e,t){return(e=df(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function ce(){return ce=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},ce.apply(null,arguments)}function Ea(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,i)}return t}function le(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ea(Object(t),!0).forEach(function(i){lf(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Ea(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function uf(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function df(s){var e=uf(s,"string");return typeof e=="symbol"?e:e+""}class Ze{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=Ct,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const Ct=function(){},cf={trace:Ct,debug:Ct,log:Ct,warn:Ct,info:Ct,error:Ct};function $r(){return ce({},cf)}function hf(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Ct}function Ta(s,e,t){return e[s]?e[s].bind(e):hf(s,t)}const Gr=$r();function ff(s,e,t){const i=$r();if(typeof console=="object"&&s===!0||typeof s=="object"){const r=["debug","log","info","warn","error"];r.forEach(n=>{i[n]=Ta(n,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.14`)}catch{return $r()}r.forEach(n=>{Gr[n]=Ta(n,s)})}else ce(Gr,i);return i}const ue=Gr;function Nt(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function gf(s){return typeof self<"u"&&s===self.ManagedMediaSource}function Dl(s,e){const t=Object.keys(s),i=Object.keys(e),r=t.length,n=i.length;return!r||!n||r===n&&!t.some(a=>i.indexOf(a)===-1)}function Ye(s,e=!1){if(typeof TextDecoder<"u"){const l=new TextDecoder("utf-8").decode(s);if(e){const d=l.indexOf("\0");return d!==-1?l.substring(0,d):l}return l.replace(/\0/g,"")}const t=s.length;let i,r,n,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;
vendor: 29,550 bytes, line 22
22if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=s[o++],a+=String.fromCharCode((i&31)<<6|r&63);break;case 14:r=s[o++],n=s[o++],a+=String.fromCharCode((i&15)<<12|(r&63)<<6|(n&63)<<0);break}}return a}function Fe(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function kl(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function mf(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var or={exports:{}},Sa;function pf(){return Sa||(Sa=1,(function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(u,l,d){if(d=d||{},u=u.trim(),l=l.trim(),!l){if(!d.alwaysNormalize)return u;var c=o.parseURL(u);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(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):l;var f=o.parseURL(u);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=r.exec(f.path);f.netLoc=g[1],f.path=g[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 m=f.path,y=m.substring(0,m.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(y)}return p.path===null&&(p.path=d.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(u){var l=i.exec(u);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(u){for(u=u.split("").reverse().join("").replace(n,"");u.length!==(u=u.replace(a,"")).length;);return u.split("").reverse().join("")},buildURLFromParts:function(u){return u.scheme+u.netLoc+u.path+u.params+u.query+u.fragment}};s.exports=o})()})(or)),or.exports}var In=pf();class Rn{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}}}var fe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Cl{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,yf(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[fe.AUDIO]:null,[fe.VIDEO]:null,[fe.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Rn),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=In.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[fe.AUDIO]=null,e[fe.VIDEO]=null,e[fe.AUDIOVIDEO]=null}}function Ae(s){return s.sn!=="initSegment"}class lr extends Cl{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,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 byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if($(e)&&$(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const r=this._decryptdata=t[i[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=$(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){var t;const i=Object.keys(this.levelkeys),r=i.length;if(r>1||r===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!$(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return Ae(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const r=t[e];r&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,r,n,a=!1){const{elementaryStreams:o}=this,u=o[e];if(!u){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:n,partial:a};return}u.startPTS=Math.min(u.startPTS,t),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,r),u.endDTS=Math.max(u.endDTS,n)}}class vf extends Cl{constructor(e,t,i,r,n){super(i),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.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;const 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(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function wl(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||wl(t,e)}}function yf(s,e){const t=wl(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const _a=Math.pow(2,32)-1,Ef=[].push,Pl={video:1,audio:2,id3:3,text:4};function Ie(s){return String.fromCharCode.apply(null,s)}function Ol(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function Q(s,e){const t=Ml(s,e);return t<0?4294967296+t:t}function Aa(s,e){let t=Q(s,e);return t*=Math.pow(2,32),t+=Q(s,e+4),t}function Ml(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function Tf(s){const e=s.byteLength;for(let t=0;t<e;){const i=Q(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return!0;t=i>1?t+i:e}return!1}function te(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let r=0;r<i;){const n=Q(s,r),a=Ie(s.subarray(r+4,r+8)),o=n>1?r+n:i;if(a===e[0])if(e.length===1)t.push(s.subarray(r+8,o));else{const u=te(s.subarray(r+8,o),e.slice(1));u.length&&Ef.apply(t,u)}r=o}return t}function Sf(s){const e=[],t=s[0];let i=8;const r=Q(s,i);i+=4;let n=0,a=0;t===0?(n=Q(s,i),a=Q(s,i+4),i+=8):(n=Aa(s,i),a=Aa(s,i+8),i+=16),i+=2;let o=s.length+a;const u=Ol(s,i);i+=2;for(let l=0;l<u;l++){let d=i;const c=Q(s,d);d+=4;const h=c&2147483647;if((c&2147483648)>>>31===1)return ue.warn("SIDX has hierarchical references (not supported)"),null;const g=Q(s,d);d+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/r,start:o,end:o+h-1}}),o+=h,d+=4,i=d}return{earliestPresentationTime:n,timescale:r,version:t,referencesCount:u,references:e}}function Nl(s){const e=[],t=te(s,["moov","trak"]);for(let r=0;r<t.length;r++){const n=t[r],a=te(n,["tkhd"])[0];if(a){let o=a[0];const u=Q(a,o===0?12:20),l=te(n,["mdia","mdhd"])[0];if(l){o=l[0];const d=Q(l,o===0?12:20),c=te(n,["mdia","hdlr"])[0];if(c){const h=Ie(c.subarray(8,12)),f={soun:fe.AUDIO,vide:fe.VIDEO}[h],g=te(n,["mdia","minf","stbl","stsd"])[0],p=_f(g);f?(e[u]={timescale:d,type:f,stsd:p},e[f]=le({timescale:d,id:u},p)):e[u]={timescale:d,type:h,stsd:p}}}}}return te(s,["moov","mvex","trex"]).forEach(r=>{const n=Q(r,4),a=e[n];a&&(a.default={duration:Q(r,12),flags:Q(r,20)})}),e}function _f(s){const e=s.subarray(8),t=e.subarray(86),i=Ie(e.subarray(4,8));let r=i,n;const a=i==="enca"||i==="encv";if(a){const l=te(e,[i])[0].subarray(i==="enca"?28:78);te(l,["sinf"]).forEach(c=>{const h=te(c,["schm"])[0];if(h){const f=Ie(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){const g=te(c,["frma"])[0];g&&(r=Ie(g))}}})}const o=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const u=te(t,["avcC"])[0];u&&u.length>3&&(r+="."+Wi(u[1])+Wi(u[2])+Wi(u[3]),n=Yi(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const u=te(e,[i])[0],l=te(u.subarray(28),["esds"])[0];if(l&&l.length>7){let d=4;if(l[d++]!==3)break;d=ur(l,d),d+=2;const c=l[d++];if(c&128&&(d+=2),c&64&&(d+=l[d++]),l[d++]!==4)break;d=ur(l,d);const h=l[d++];if(h===64)r+="."+Wi(h);else break;if(d+=12,l[d++]!==5)break;d=ur(l,d);const f=l[d++];let g=(f&248)>>3;g===31&&(g+=1+((f&7)<<3)+((l[d]&224)>>5)),r+="."+g}break}case"hvc1":case"hev1":{const u=te(t,["hvcC"])[0];if(u&&u.length>12){const l=u[1],d=["","A","B","C"][l>>6],c=l&31,h=Q(u,2),f=(l&32)>>5?"H":"L",g=u[12],p=u.subarray(6,12);r+="."+d+c,r+="."+Af(h).toString(16).toUpperCase(),r+="."+f+g;let m="";for(let y=p.length;y--;){const T=p[y];(T||m)&&(m="."+T.toString(16).toUpperCase()+m)}r+=m}n=Yi(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{r=Yi(r,t)||r;break}case"vp09":{const u=te(t,["vpcC"])[0];if(u&&u.length>6){const l=u[4],d=u[5],c=u[6]>>4&15;r+="."+ht(l)+"."+ht(d)+"."+ht(c)}break}case"av01":{const u=te(t,["av1C"])[0];if(u&&u.length>2){const l=u[1]>>>5,d=u[1]&31,c=u[2]>>>7?"H":"M",h=(u[2]&64)>>6,f=(u[2]&32)>>5,g=l===2&&h?f?12:10:h?10:8,p=(u[2]&16)>>4,m=(u[2]&8)>>3,y=(u[2]&4)>>2,T=u[2]&3;r+="."+l+"."+ht(d)+c+"."+ht(g)+"."+p+"."+m+y+T+"."+ht(1)+"."+ht(1)+"."+ht(1)+"."+0,n=Yi("dav1",t)}break}}return{codec:r,encrypted:a,supplemental:n}}function Yi(s,e){const t=te(e,["dvvC"]),i=t.length?t[0]:te(e,["dvcC"])[0];if(i){const r=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return s+"."+ht(r)+"."+ht(n)}}function Af(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function ur(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function Wi(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function ht(s){return(s<10?"0":"")+s}function bf(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Fl(s,(i,r)=>{const n=i.subarray(8,24);n.some(a=>a!==0)||(ue.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Fe(n)} -> ${Fe(t)}`),i.set(t,8))})}function xf(s){const e=[];return Fl(s,t=>e.push(t.subarray(8,24))),e}function Fl(s,e){te(s,["moov","trak"]).forEach(i=>{const r=te(i,["mdia","minf","stbl","stsd"])[0];if(!r)return;const n=r.subarray(8);let a=te(n,["enca"]);const o=a.length>0;o||(a=te(n,["encv"])),a.forEach(u=>{const l=o?u.subarray(28):u.subarray(78);te(l,["sinf"]).forEach(c=>{const h=Ul(c);h&&e(h,o)})})})}function Ul(s){const e=te(s,["schm"])[0];if(e){const t=Ie(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=te(s,["schi","tenc"])[0];if(i)return i}}}function If(s,e,t){const i={},r=te(s,["moof","traf"]);for(let n=0;n<r.length;n++){const a=r[n],o=te(a,["tfhd"])[0],u=Q(o,4),l=e[u];if(!l)continue;i[u]||(i[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const d=i[u],c=te(a,["tfdt"])[0];if(c){const E=c[0];let S=Q(c,4);E===1&&(S===_a?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(S*=_a+1,S+=Q(c,8))),$(S)&&(!$(d.start)||S<d.start)&&(d.start=S)}const h=l.default,f=Q(o,0)|h?.flags;let g=h?.duration||0;f&8&&(f&2?g=Q(o,12):g=Q(o,8));const p=te(a,["trun"]);let m=d.start||0,y=0,T=g;for(let E=0;E<p.length;E++){const S=p[E],_=Q(S,4),x=d.sampleCount;d.sampleCount+=_;const A=S[3]&1,I=S[3]&4,R=S[2]&1,b=S[2]&2,k=S[2]&4,M=S[2]&8;let G=8,q=_;for(A&&(G+=4),I&&_&&(!(S[G+1]&1)&&d.keyFrameIndex===void 0&&(d.keyFrameIndex=x),G+=4,R?(T=Q(S,G),G+=4):T=g,b&&(G+=4),M&&(G+=4),m+=T,y+=T,q--);q--;)R?(T=Q(S,G),G+=4):T=g,b&&(G+=4),k&&(S[G+1]&1||d.keyFrameIndex===void 0&&(d.keyFrameIndex=d.sampleCount-(q+1),d.keyFrameStart=m),G+=4),M&&(G+=4),m+=T,y+=T;!y&&g&&(y+=g*_)}d.duration+=y}if(!Object.keys(i).some(n=>i[n].duration)){let n=1/0,a=0;const o=te(s,["sidx"]);for(let u=0;u<o.length;u++){const l=Sf(o[u]);if(l!=null&&l.references){n=Math.min(n,l.earliestPresentationTime/l.timescale);const d=l.references.reduce((c,h)=>c+h.info.duration||0,0);a=Math.max(a,d+l.earliestPresentationTime/l.timescale)}}a&&$(a)&&Object.keys(i).forEach(u=>{i[u].duration||(i[u].duration=a*i[u].timescale-i[u].start)})}return i}function Rf(s){const e={valid:null,remainder:null},t=te(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function Je(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function ba(s,e){const t=[],i=e.samples,r=e.timescale,n=e.id;let a=!1;return te(i,["moof"]).map(u=>{const l=u.byteOffset-8;te(u,["traf"]).map(c=>{const h=te(c,["tfdt"]).map(f=>{const g=f[0];let p=Q(f,4);return g===1&&(p*=Math.pow(2,32),p+=Q(f,8)),p/r})[0];return h!==void 0&&(s=h),te(c,["tfhd"]).map(f=>{const g=Q(f,4),p=Q(f,0)&16777215,m=(p&1)!==0,y=(p&2)!==0,T=(p&8)!==0;let E=0;const S=(p&16)!==0;let _=0;const x=(p&32)!==0;let A=8;g===n&&(m&&(A+=8),y&&(A+=4),T&&(E=Q(f,A),A+=4),S&&(_=Q(f,A),A+=4),x&&(A+=4),e.type==="video"&&(a=Ws(e.codec)),te(c,["trun"]).map(I=>{const R=I[0],b=Q(I,0)&16777215,k=(b&1)!==0;let M=0;const G=(b&4)!==0,q=(b&256)!==0;let U=0;const P=(b&512)!==0;let K=0;const B=(b&1024)!==0,Y=(b&2048)!==0;let z=0;const O=Q(I,4);let N=8;k&&(M=Q(I,N),N+=4),G&&(N+=4);let Z=M+l;for(let ae=0;ae<O;ae++){if(q?(U=Q(I,N),N+=4):U=E,P?(K=Q(I,N),N+=4):K=_,B&&(N+=4),Y&&(R===0?z=Q(I,N):z=Ml(I,N),N+=4),e.type===fe.VIDEO){let ee=0;for(;ee<K;){const re=Q(i,Z);if(Z+=4,Lf(a,i[Z])){const Oe=i.subarray(Z,Z+re);Ln(Oe,a?2:1,s+z/r,t)}Z+=re,ee+=re+4}}s+=U/r}}))})})}),t}function Ws(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Lf(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Ln(s,e,t,i){const r=Bl(s);let n=0;n+=e;let a=0,o=0,u=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;u=r[n++],a+=u}while(u===255);o=0;do{if(n>=r.length)break;u=r[n++],o+=u}while(u===255);const l=r.length-n;let d=n;if(o<l)n+=o;else if(o>l){ue.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(a===4){if(r[d++]===181){const h=Ol(r,d);if(d+=2,h===49){const f=Q(r,d);if(d+=4,f===1195456820){const g=r[d++];if(g===3){const p=r[d++],m=31&p,y=64&p,T=y?2+m*3:0,E=new Uint8Array(T);if(y){E[0]=p;for(let S=1;S<T;S++)E[S]=r[d++]}i.push({type:g,payloadType:a,pts:t,bytes:E})}}}}}else if(a===5&&o>16){const c=[];for(let g=0;g<16;g++){const p=r[d++].toString(16);c.push(p.length==1?"0"+p:p),(g===3||g===5||g===7||g===9)&&c.push("-")}const h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=r[d++];i.push({payloadType:a,pts:t,uuid:c.join(""),userData:Ye(f),userDataBytes:f})}}}function Bl(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const r=e-t.length,n=new Uint8Array(r);let a=0;for(i=0;i<r;a++,i++)a===t[0]&&(a++,t.shift()),n[i]=s[a];return n}function Df(s){const e=s[0];let t="",i="",r=0,n=0,a=0,o=0,u=0,l=0;if(e===0){for(;Ie(s.subarray(l,l+1))!=="\0";)t+=Ie(s.subarray(l,l+1)),l+=1;for(t+=Ie(s.subarray(l,l+1)),l+=1;Ie(s.subarray(l,l+1))!=="\0";)i+=Ie(s.subarray(l,l+1)),l+=1;i+=Ie(s.subarray(l,l+1)),l+=1,r=Q(s,12),n=Q(s,16),o=Q(s,20),u=Q(s,24),l=28}else if(e===1){l+=4,r=Q(s,l),l+=4;const c=Q(s,l);l+=4;const h=Q(s,l);for(l+=4,a=2**32*c+h,nf(a)||(a=Number.MAX_SAFE_INTEGER,ue.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Q(s,l),l+=4,u=Q(s,l),l+=4;Ie(s.subarray(l,l+1))!=="\0";)t+=Ie(s.subarray(l,l+1)),l+=1;for(t+=Ie(s.subarray(l,l+1)),l+=1;Ie(s.subarray(l,l+1))!=="\0";)i+=Ie(s.subarray(l,l+1)),l+=1;i+=Ie(s.subarray(l,l+1)),l+=1}const d=s.subarray(l,s.byteLength);return{schemeIdUri:t,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:u,payload:d}}function kf(s,...e){const t=e.length;let i=8,r=t;for(;r--;)i+=e[r].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(s,4),r=0,i=8;r<t;r++)n.set(e[r],i),i+=e[r].byteLength;return n}function Cf(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,r;i=0,r=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),kf([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t)}function wf(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const r=new DataView(s,i),n=Pf(r);e.push(n),i+=n.size}}return e}function Pf(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const n=s.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const a=s.buffer,o=Fe(new Uint8Array(a,t+12,16));let u=null,l=null,d=0;if(n===0)d=28;else{const h=s.getUint32(28);if(!h||i<32+h*16)return{offset:t,size:e};u=[];for(let f=0;f<h;f++)u.push(new Uint8Array(a,t+32+f*16,16));d=32+h*16}if(!d)return{offset:t,size:e};const c=s.getUint32(d);return e-32<c?{offset:t,size:e}:(l=new Uint8Array(a,t+d+4,c),{version:n,systemId:o,kids:u,data:l,offset:t,size:e})}const $l=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),mi={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,dav1:.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 Dn(s,e){const t=mi[e];return!!t&&!!t[s.slice(0,4)]}function Ni(s,e,t=!0){return!s.split(",").some(i=>!kn(i,e,t))}function kn(s,e,t=!0){var i;const r=Nt(t);return(i=r?.isTypeSupported(Fi(s,e)))!=null?i:!1}function Fi(s,e){return`${e}/mp4;codecs=${s}`}function xa(s){if(s){const e=s.substring(0,4);return mi.video[e]}return 2}function Ps(s){const e=$l();return s.split(",").reduce((t,i)=>{const n=e&&Ws(i)?9:mi.video[i];return n?(n*2+t)/(t?3:2):(mi.audio[i]+t)/(t?2:1)},0)}const dr={};function Of(s,e=!0){if(dr[s])return dr[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let r=0;r<t.length;r++){var i;if(kn(t[r],"audio",e))return dr[s]=t[r],t[r];if(t[r]==="mp3"&&(i=Nt(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const Mf=/flac|opus|mp4a\.40\.34/i;function Os(s,e=!0){return s.replace(Mf,t=>Of(t.toLowerCase(),e))}function Nf(s,e){const t=[];if(s){const i=s.split(",");for(let r=0;r<i.length;r++)Dn(i[r],"video")||t.push(i[r])}return e&&t.push(e),t.join(",")}function ds(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Ia(s,"audio")||Ia(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Ia(s,e){return Dn(s,e)&&kn(s,e)}function Ff(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function Uf(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Ra(s){const e=Nt(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Kr(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Bf={supported:!0,powerEfficient:!0,smooth:!0},$f={supported:!1,smooth:!1,powerEfficient:!1},Gl={supported:!0,configurations:[],decodingInfoResults:[Bf]};function Kl(s,e){return{supported:!1,configurations:e,decodingInfoResults:[$f],error:s}}function Gf(s,e,t,i,r,n){const a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,u=n?.audioCodec,l=n?.channels,d=l?parseInt(l):u?1/0:2;let c=null;if(o!=null&&o.length)try{o.length===1&&o[0]?c=e.groups[o[0]].channels:c=o.reduce((h,f)=>{if(f){const g=e.groups[f];if(!g)throw new Error(`Audio track group ${f} not found`);Object.keys(g.channels).forEach(p=>{h[p]=(h[p]||0)+g.channels[p]})}return h},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(h=>Ws(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!c&&$(d)&&Object.keys(c).some(h=>parseInt(h)>d)}function Vl(s,e,t,i={}){const r=s.videoCodec;if(!r&&!s.audioCodec||!t)return Promise.resolve(Gl);const n=[],a=Kf(s),o=a.length,u=Vf(s,e,o>0),l=u.length;for(let d=o||1*l||1;d--;){const c={type:"media-source"};if(o&&(c.video=a[d%o]),l){c.audio=u[d%l];const h=c.audio.bitrate;c.video&&h&&(c.video.bitrate-=h)}n.push(c)}if(r){const d=navigator.userAgent;if(r.split(",").some(c=>Ws(c))&&$l())return Promise.resolve(Kl(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${d})`),n))}return Promise.all(n.map(d=>{const c=qf(d);return i[c]||(i[c]=t.decodingInfo(d))})).then(d=>({supported:!d.some(c=>!c.supported),configurations:n,decodingInfoResults:d})).catch(d=>({supported:!1,configurations:n,decodingInfoResults:[],error:d}))}function Kf(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=Hl(s),r=s.width||640,n=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(u=>{const l={contentType:Fi(Uf(u),"video"),width:r,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function Vf(s,e,t){var i;const r=(i=s.audioCodec)==null?void 0:i.split(","),n=Hl(s);return r&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var u;const l=o?(u=e.groups[o])==null?void 0:u.tracks:null;return l?l.reduce((d,c)=>{if(c.groupId===o){const h=parseFloat(c.channels||"");r.forEach(f=>{const g={contentType:Fi(f,"audio"),bitrate:t?Hf(f,n):n};h&&(g.channels=""+h),d.push(g)})}return d},a):a},[]):[]}function Hf(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function Hl(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function qf(s){let e="";const{audio:t,video:i}=s;if(i){const r=Kr(i.contentType);e+=`${r}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const r=Kr(t.contentType);e+=`${i?"_":""}${r}_c${t.channels}`}return e}const Vr=["NONE","TYPE-0","TYPE-1",null];function Yf(s){return Vr.indexOf(s)>-1}const Ms=["SDR","PQ","HLG"];function Wf(s){return!!s&&Ms.indexOf(s)>-1}var cs={No:"",Yes:"YES",v2:"v2"};function La(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?cs.v2:cs.Yes:cs.No}class Da{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const 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}}class Ui{constructor(e){if(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.supplemental=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(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}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 ka(this._audioGroups,e)}hasSubtitleGroup(e){return ka(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.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 ka(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function jf(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function zf(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||Ms.slice(0);const r=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&jf(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const Xf=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},ge=(s,e)=>JSON.stringify(s,Xf(e));function Qf(s,e,t,i,r){const n=Object.keys(s),a=i?.channels,o=i?.audioCodec,u=r?.videoCodec,l=a&&parseInt(a)===2;let d=!1,c=!1,h=1/0,f=1/0,g=1/0,p=1/0,m=0,y=[];const{preferHDR:T,allowedVideoRanges:E}=zf(e,r);for(let I=n.length;I--;){const R=s[n[I]];d||(d=R.channels[2]>0),h=Math.min(h,R.minHeight),f=Math.min(f,R.minFramerate),g=Math.min(g,R.minBitrate),E.filter(k=>R.videoRanges[k]>0).length>0&&(c=!0)}h=$(h)?h:0,f=$(f)?f:0;const S=Math.max(1080,h),_=Math.max(30,f);g=$(g)?g:t,t=Math.max(g,t),c||(e=void 0);const x=n.length>1;return{codecSet:n.reduce((I,R)=>{const b=s[R];if(R===I)return I;if(y=c?E.filter(k=>b.videoRanges[k]>0):[],x){if(b.minBitrate>t)return ut(R,`min bitrate of ${b.minBitrate} > current estimate of ${t}`),I;if(!b.hasDefaultAudio)return ut(R,"no renditions with default or auto-select sound found"),I;if(o&&R.indexOf(o.substring(0,4))%5!==0)return ut(R,`audio codec preference "${o}" not found`),I;if(a&&!l){if(!b.channels[a])return ut(R,`no renditions with ${a} channel sound found (channels options: ${Object.keys(b.channels)})`),I}else if((!o||l)&&d&&b.channels[2]===0)return ut(R,"no renditions with stereo sound found"),I;if(b.minHeight>S)return ut(R,`min resolution of ${b.minHeight} > maximum of ${S}`),I;if(b.minFramerate>_)return ut(R,`min framerate of ${b.minFramerate} > maximum of ${_}`),I;
vendor: 3,865 bytes, line 22
22if(!y.some(k=>b.videoRanges[k]>0))return ut(R,`no variants with VIDEO-RANGE of ${ge(y)} found`),I;if(u&&R.indexOf(u.substring(0,4))%5!==0)return ut(R,`video codec preference "${u}" not found`),I;if(b.maxScore<m)return ut(R,`max score of ${b.maxScore} < selected max of ${m}`),I}return I&&(Ps(R)>=Ps(I)||b.fragmentError>s[I].fragmentError)?I:(p=b.minIndex,m=b.maxScore,R)},void 0),videoRanges:y,preferHDR:T,minFramerate:f,minBitrate:g,minIndex:p}}function ut(s,e){ue.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function ql(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const r=t.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Jf(s,e,t,i){return s.slice(t,i+1).reduce((r,n,a)=>{if(!n.codecSet)return r;const o=n.audioGroups;let u=r[n.codecSet];u||(r[n.codecSet]=u={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),u.minBitrate=Math.min(u.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return u.minHeight=Math.min(u.minHeight,l),u.minFramerate=Math.min(u.minFramerate,n.frameRate),u.minIndex=Math.min(u.minIndex,a),u.maxScore=Math.max(u.maxScore,n.score),u.fragmentError+=n.fragmentError,u.videoRanges[n.videoRange]=(u.videoRanges[n.videoRange]||0)+1,o&&o.forEach(d=>{if(!d)return;const c=e.groups[d];c&&(u.hasDefaultAudio=u.hasDefaultAudio||e.hasDefaultAudio?c.hasDefault:c.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(c.channels).forEach(h=>{u.channels[h]=(u.channels[h]||0)+c.channels[h]}))}),r},{})}function Ca(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}=s;return{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}}function gt(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const r=e[i];if(Wt(s,r,t))return i}return-1}function Wt(s,e,t){const{groupId:i,name:r,lang:n,assocLang:a,default:o}=s,u=s.forced;return(i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||Zf(n,e.lang))&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(u===void 0||e.forced===u)&&(!("characteristics"in s)||eg(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function Zf(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function eg(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function Ht(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function tg(s,e,t,i,r){const n=e[i],o=e.reduce((h,f,g)=>{const p=f.uri;return(h[p]||(h[p]=[])).push(g),h},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const u=n.videoRange,l=n.frameRate,d=n.codecSet.substring(0,4),c=wa(e,i,h=>{if(h.videoRange!==u||h.frameRate!==l||h.codecSet.substring(0,4)!==d)return!1;const f=h.audioGroups,g=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return gt(s,g,r)>-1});return c>-1?c:wa(e,i,h=>{const f=h.audioGroups,g=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return gt(s,g,r)>-1})}function wa(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function Ns(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class ig extends Ze{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.co
vendor: 4,829 bytes, lines 22-32
22decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:r,partCurrent:n,hls:a}=this,{autoLevelEnabled:o,media:u}=a;if(!r||!u)return;const l=performance.now(),d=n?n.stats:r.stats,c=n?n.duration:r.duration,h=l-d.loading.start,f=a.minAutoLevel,g=r.level,p=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||g<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const m=p>-1&&p!==g,y=!!t||m;if(!y&&(u.paused||!u.playbackRate||!u.readyState))return;const T=a.mainForwardBufferInfo;if(!y&&T===null)return;const E=this.bwEstimator.getEstimateTTFB(),S=Math.abs(u.playbackRate);if(h<=Math.max(E,1e3*(c/(S*2))))return;const _=T?T.len/S:0,x=d.loading.first?d.loading.first-d.loading.start:-1,A=d.loaded&&x>-1,I=this.getBwEstimate(),R=a.levels,b=R[g],k=Math.max(d.loaded,Math.round(c*(r.bitrate||b.averageBitrate)/8));let M=A?h-x:h;M<1&&A&&(M=Math.min(h,d.loaded*8/I));const G=A?d.loaded*1e3/M:0,q=E/1e3,U=G?(k-d.loaded)/G:k*8/I+q;if(U<=_)return;const P=G?G*8:I,K=((i=t?.details||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,B=this.hls.config.abrBandWidthUpFactor;let Y=Number.POSITIVE_INFINITY,z;for(z=g-1;z>f;z--){const ae=R[z].maxBitrate,ee=!R[z].details||K;if(Y=this.getTimeToLoadFrag(q,P,c*ae,ee),Y<Math.min(_,c+q))break}if(Y>=U||Y>c*10)return;A?this.bwEstimator.sample(h-Math.min(E,x),d.loaded):this.bwEstimator.sampleTTFB(h);const O=R[z].maxBitrate;this.getBwEstimate()*B>O&&this.resetEstimator(O);const N=this.findBestLevel(O,f,z,0,_,1,1);N>-1&&(z=N),this.warn(`Fragment ${r.sn}${n?" part "+n.index:""} of level ${g} is loading too slowly;
23      Fragment duration: ${r.duration.toFixed(3)}
24      Time to underbuffer: ${_.toFixed(3)} s
25      Estimated load time for current fragment: ${U.toFixed(3)} s
26      Estimated load time for down switch fragment: ${Y.toFixed(3)} s
27      TTFB estimate: ${x|0} ms
28      Current BW estimate: ${$(I)?I|0:"Unknown"} bps
29      New BW estimate: ${this.getBwEstimate()|0} bps
30      Switching to level ${z} @ ${O|0} bps`),a.nextLoadLevel=a.nextAutoLevel=z,this.clearTimer();const Z=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===z&&z>0){const ae=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${z>0?"and switching down":""}
31      Fragment duration: ${r.duration.toFixed(3)} s
32      Time to underbuffer: ${ae.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,z>f){let ee=this.findBestLevel(this.hls.levels[f].bitrate,f,z,0,ae,1,1);ee===-1&&(ee=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=ee,this.resetEstimator(this.hls.levels[ee].bitrate)}}};m||U>Y*2?Z():this.timer=self.setInterval(Z,Y*1e3),a.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:d})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new of(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},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){const i=t.frag;
vendor: 3,234 bytes, line 32
32if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r: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 D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:r,partCurrent:n}=this;if(i&&r&&i.sn===r.sn&&i.level===r.level){const a=performance.now(),o=n?n.stats:i.stats,u=a-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(u-Math.min(c,l),o.loaded)}else this.bwEstimator.sampleTTFB(u)}break}}}getTimeToLoadFrag(e,t,i,r){const n=e+i/t,a=r?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const i=this.hls.config,{loading:r}=t.stats,n=r.end-r.first;$(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const r=i?i.stats:t.stats;if(t.type===H.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=i?i.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,u=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:u},a.realBitrate=Math.round(8*o/u)}if(t.bitrateTest){const n={stats:r,frag:t,part:i,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const 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(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==H.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,r,1,1);if(n>-1)return n;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return this.warn(`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(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const 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()}
32_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,u=this.getBwEstimate(),l=this.getStarvationDelay();let d=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(l){const m=this.findBestLevel(u,a,r,l,0,d,c);if(m>=0)return this.rebufferNotice=-1,m}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const m=this.bitrateTestDelay;m&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),d=c=1)}const f=this.findBestLevel(u,a,r,l,h,d,c);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;const g=i.levels[a],p=i.loadLevelObj;return p&&g?.bitrate<p.bitrate?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,r,n,a,o){var u;const l=r+n,d=this.lastLoadedFragLevel,c=d===-1?this.hls.firstLevel:d,{fragCurrent:h,partCurrent:f}=this,{levels:g,allAudioTracks:p,loadLevel:m,config:y}=this.hls;if(g.length===1)return 0;const T=g[c],E=!!((u=this.hls.latestLevelDetails)!=null&&u.live),S=m===-1||d===-1;let _,x="SDR",A=T?.frameRate||0;const{audioPreference:I,videoPreference:R}=y,b=this.audioTracksByGroup||(this.audioTracksByGroup=ql(p));let k=-1;if(S){if(this.firstSelection!==-1)return this.firstSelection;const P=this.codecTiers||(this.codecTiers=Jf(g,b,t,i)),K=Qf(P,x,e,I,R),{codecSet:B,videoRanges:Y,minFramerate:z,minBitrate:O,minIndex:N,preferHDR:Z}=K;k=N,_=B,x=Z?Y[Y.length-1]:Y[0],A=z,e=Math.max(e,O),this.log(`picked start tier ${ge(K)}`)}else _=T?.codecSet,x=T?.videoRange;const M=f?f.duration:h?h.duration:0,G=this.bwEstimator.getEstimateTTFB()/1e3,q=[];for(let P=i;P>=t;P--){var U;const K=g[P],B=P>c;if(!K)continue;if(y.useMediaCapabilities&&!K.supportedResult&&!K.supportedPromise){const ee=navigator.mediaCapabilities;typeof ee?.decodingInfo=="function"&&Gf(K,b,x,A,e,I)?(K.supportedPromise=Vl(K,b,ee,this.supportedCache),K.supportedPromise.then(re=>{if(!this.hls)return;K.supportedResult=re;const Oe=this.hls.levels,ke=Oe.indexOf(K);re.error?this.warn(`MediaCapabilities decodingInfo error: "${re.error}" for level ${ke} ${ge(re)}`):re.supported?re.decodingInfoResults.some(je=>je.smooth===!1||je.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${ke} not smooth or powerEfficient: ${ge(re)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${ke} ${ge(re)}`),ke>-1&&Oe.length>1&&(this.log(`Removing unsupported level ${ke}`),this.hls.removeLevel(ke),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(re=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${re}`)})):K.supportedResult=Gl}if((_&&K.codecSet!==_||x&&K.videoRange!==x||B&&A>K.frameRate||!B&&A>0&&A<K.frameRate||(U=K.supportedResult)!=null&&(U=U.decodingInfoResults)!=null&&U.some(ee=>ee.smooth===!1))&&(!S||P!==k)){q.push(P);continue}const Y=K.details,z=(f?Y?.partTarget:Y?.averagetargetduration)||M;let O;B?O=o*e:O=a*e;const N=M&&r>=M*2&&n===0?K.averageBitrate:K.maxBitrate,Z=this.getTimeToLoadFrag(G,O,N*z,Y===void 0);if(O>=N&&(P===d||K.loadError===0&&K.fragmentError===0)&&(Z<=G||!$(Z)||E&&!this.bitrateTestDelay||Z<l)){const ee=this.forcedAutoLevel;return P!==m&&(ee===-1||ee!==m)&&(q.length&&this.trace(`Skipped level(s) ${q.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${g[q[0]].codecs}" ${g[q[0]].videoRange}; not compatible with "${_}" ${x}`),this.info(`switch candidate:${c}->${P} adjustedbw(${Math.round(O)})-bitrate=${Math.round(O-N)} ttfb:${G.toFixed(1)} avgDuration:${z.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${Z.toFixed(1)} firstSelection:${S} codecSet:${K.codecSet} videoRange:${K.videoRange} hls.loadLevel:${m}`)),S&&(this.firstSelection=P),P}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const Yl={search:function(s,e){let t=0,i=s.length-1,r=null,n=null;for(;t<=i;){r=(t+i)/2|0,n=s[r];const a=e(n);if(a>0)t=r+1;else if(a<0)i=r-1;else return n}return null}};
vendor: 5,160 bytes, line 32
32function sg(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!$(e))return null;const i=s[0].programDateTime;if(e<(i||0))return null;const r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let n=0;n<s.length;++n){const a=s[n];if(ng(e,t,a))return a}return null}function Xt(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[1+s.sn-e[0].sn]||null;const o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&s.level!==n.level&&n.end<=s.end&&(n=e[2+s.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&Pa(t,i,n)===0||rg(n,s,Math.min(r,i))))return n;const a=Yl.search(e,Pa.bind(null,t,i));return a&&(a!==s||!n)?a:n}function rg(s,e,t){if(e&&e.start===0&&e.level<s.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return s.start<=i}return!1}function Pa(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function ng(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function Wl(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments;const{fragmentHint:r}=s;r&&(i=i.concat(r));let n;return Yl.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function Fs(s){switch(s.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function jl(s){return s.details.startsWith("key")}function zl(s){return jl(s)&&!!s.frag&&!s.frag.decryptdata}function Oa(s,e){const t=Fs(e);return s.default[`${t?"timeout":"error"}Retry`]}function Cn(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function Ma(s){return le(le({},s),{errorRetry:null,timeoutRetry:null})}function Us(s,e,t,i){if(!s)return!1;const r=i?.code,n=e<s.maxNumRetry&&(ag(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function ag(s){return Hr(s)||!!s&&(s<400||s>499)}function Hr(s){return s===0&&navigator.onLine===!1}var we={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Ve={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class og extends Ze{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===H.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(a=>r.indexOf(a.groupId)>=0).some(a=>{var o;return(o=a.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const r=this.hls,n=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=di();return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=we.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var a;const u=t.parent===H.MAIN?t.level:r.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const u=r.loadLevelObj;if(u&&(n.type===ie.AUDIO_TRACK&&u.hasAudioGroup(n.groupId)||n.type===ie.SUBTITLE_TRACK&&u.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=we.SendAlternateToPenaltyBox,t.errorAction.flags=Ve.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:we.SendAlternateToPenaltyBox,flags:Ve.MoveAllAlternatesMatchingHDCP};return;case D.KEY_SYSTEM_SESSION_UPDATE_FAILED:case D.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case D.KEY_SYSTEM_NO_SESSION:t.errorAction={action:we.SendAlternateToPenaltyBox,flags:Ve.MoveAllAlternatesMatchingKey};return;
vendor: 10,983 bytes, line 32
32case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:r.loadLevel)}return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction=di();return}t.type===W.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=di())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,r=Oa(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(Us(r,n,Fs(e),e.response))return{action:we.RetryRequest,flags:Ve.None,retryConfig:r,retryCount:n};const o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Oa(jl(e)?a:n,e),u=t.levels.reduce((d,c)=>d+c.fragmentError,0);if(r&&(e.details!==D.FRAG_GAP&&r.fragmentError++,!zl(e)&&Us(o,u,Fs(e),e.response)))return{action:we.RetryRequest,flags:Ve.None,retryConfig:o,retryCount:u};const l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=u),l}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const r=this.hls.levels[t];if(r){var n,a;const l=e.details;r.loadError++,l===D.BUFFER_APPEND_ERROR&&r.fragmentError++;let d=-1;const{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:g}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const p=(n=e.frag)==null?void 0:n.type,y=(p===H.AUDIO&&l===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===D.BUFFER_ADD_CODEC_ERROR||l===D.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:x})=>r.audioCodec!==x),E=e.sourceBufferName==="video"&&(l===D.BUFFER_ADD_CODEC_ERROR||l===D.BUFFER_APPEND_ERROR)&&c.some(({codecSet:x,audioCodec:A})=>r.codecSet!==x&&r.audioCodec===A),{type:S,groupId:_}=(a=e.context)!=null?a:{};for(let x=c.length;x--;){const A=(x+h)%c.length;if(A!==h&&A>=f&&A<=g&&c[A].loadError===0){var o,u;const I=c[A];if(l===D.FRAG_GAP&&p===H.MAIN&&e.frag){const R=c[A].details;if(R){const b=Xt(e.frag,R.fragments,e.frag.start);if(b!=null&&b.gap)continue}}else{if(S===ie.AUDIO_TRACK&&I.hasAudioGroup(_)||S===ie.SUBTITLE_TRACK&&I.hasSubtitleGroup(_))continue;if(p===H.AUDIO&&(o=r.audioGroups)!=null&&o.some(R=>I.hasAudioGroup(R))||p===H.SUBTITLE&&(u=r.subtitleGroups)!=null&&u.some(R=>I.hasSubtitleGroup(R))||y&&r.audioCodec===I.audioCodec||E&&r.codecSet===I.codecSet||!y&&r.codecSet!==I.codecSet)continue}d=A;break}}if(d>-1&&i.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:we.SendAlternateToPenaltyBox,flags:Ve.None,nextAutoLevel:d}}return{action:we.SendAlternateToPenaltyBox,flags:Ve.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case we.DoNothing:break;case we.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.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}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:r}=i,n=i.nextAutoLevel;switch(r){case Ve.None:this.switchLevel(e,n);break;case Ve.MoveAllAlternatesMatchingHDCP:{const u=this.getVariantLevelIndex(e.frag),l=t.levels[u],d=l?.attrs["HDCP-LEVEL"];if(i.hdcpLevel=d,d==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(d){t.maxHdcpLevel=Vr[Vr.indexOf(d)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Ve.MoveAllAlternatesMatchingKey:{const u=e.decryptdata;if(u){const l=this.hls.levels,d=l.length;for(let h=d;h--;)if(this.variantHasKey(l[h],u)){var a,o;this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${(a=l[h].audioGroups)==null?void 0:a.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${Fe(u.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}const c=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(c&&c.type!==H.MAIN){const h=c.decryptdata;h&&!u.matches(h)&&(i.resolved=!0)}}break}}i.resolved||this.switchLevel(e,n)}switchLevel(e,t){if(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,e.details===D.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Kr(e.mimeType),r=this.hls.levels;for(let n=r.length;n--;)r[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n))}}}function di(s){const e={action:we.DoNothing,flags:Ve.None};return s&&(e.resolved=!0),e}var Re={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class lg{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(){const{hls:e}=this;e&&(e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let r=i.length;r--;){const n=i[r];if(!n)break;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:r}=this,n=Object.keys(r);for(let a=n.length;a--;){const o=r[n[a]];if(o?.body.type===t&&(!i||o.buffered)){const u=o.body;if(u.start<=e&&e<=u.end)return u}}return null}detectEvictedFragments(e,t,i,r,n){this.timeRanges&&(this.timeRanges[e]=t);const a=r?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{const u=this.fragments[o];if(!u||a>=u.body.sn)return;if(!u.buffered&&(!u.loaded||n)){u.body.type===i&&this.removeFragment(u.body);return}const l=u.range[e];if(l){if(l.time.length===0){this.removeFragment(u.body);return}l.time.some(d=>{const c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(u.body),c})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,r=ti(i),n=this.fragments[r];if(!n||n.buffered&&i.gap)return;const a=!i.relurl;Object.keys(t).forEach(o=>{const u=i.elementaryStreams[o];if(!u)return;const l=t[o],d=a||u.partial===!0;n.range[o]=this.getBufferedTimes(i,e.part,d,l)}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),ji(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Na(i,r=>r.fragment.sn>=e))}fragBuffered(e,t){const i=ti(e);let r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,i,r){const n={time:[],partial:i},a=e.start,o=e.end,u=e.minEndPTS||o,l=e.maxStartPTS||a;for(let d=0;d<r.length;d++){const c=r.start(d)-this.bufferPadding,h=r.end(d)+this.bufferPadding;if(l>=c&&u<=h){n.time.push({startPTS:Math.max(a,r.start(d)),endPTS:Math.min(o,r.end(d))});break}else if(a<h&&o>c){const f=Math.max(a,r.start(d)),g=Math.min(o,r.end(d));g>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:g}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0;const{bufferPadding:o,fragments:u}=this;return Object.keys(u).forEach(l=>{const d=u[l];d&&ji(d)&&(r=d.body.start-o,n=d.body.end+o,e>=r&&e<=n&&(i=Math.min(e-r,n-e),a<=i&&(t=d.body,a=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||ji(t))}getState(e){const t=ti(e),i=this.fragments[t];return i?i.buffered?ji(i)?Re.PARTIAL:Re.OK:Re.APPENDING:Re.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return!0;if(t<=r)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,r=t.part?null:t,n=ti(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:r,timeRanges:n,type:a}=t;if(i.sn==="initSegment")return;const o=i.type;if(r){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(r)}this.timeRanges=n;const u=n[a];this.detectEvictedFragments(a,u,o,r)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ti(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){const n=t[i[r]];if(n?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const u=o.body;u.type!==i||r&&!u.gap||u.start<t&&u.end>e&&(o.buffered||n)&&this.removeFragment(u)})}removeFragment(e){const t=ti(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const r=e.sn;this.activePartLists[e.type]=Na(i,n=>n.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function ji(s){var e,t,i;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial)}function ti(s){return`${s.type}_${s.level}_${s.sn}`}function Na(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Ft={cbc:0,ctr:1};class ug{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Ft.cbc:return this.subtle.decrypt({
vendor: 19,548 bytes, line 32
32name:"AES-CBC",iv:this.aesIV},t,e);case Ft.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function dg(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class cg{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){const t=new DataView(e),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],u=this.invSubMix,l=u[0],d=u[1],c=u[2],h=u[3],f=new Uint32Array(256);let g=0,p=0,m=0;for(m=0;m<256;m++)m<128?f[m]=m<<1:f[m]=m<<1^283;for(m=0;m<256;m++){let y=p^p<<1^p<<2^p<<3^p<<4;y=y>>>8^y&255^99,e[g]=y,t[y]=g;const T=f[g],E=f[T],S=f[E];let _=f[y]*257^y*16843008;r[g]=_<<24|_>>>8,n[g]=_<<16|_>>>16,a[g]=_<<8|_>>>24,o[g]=_,_=S*16843009^E*65537^T*257^g*16843008,l[y]=_<<24|_>>>8,d[y]=_<<16|_>>>16,c[y]=_<<8|_>>>24,h[y]=_,g?(g=T^f[f[f[S^T]]],p^=f[f[p]]):g=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,u;const l=this.keySchedule=new Uint32Array(a),d=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],p=f[1],m=f[2],y=f[3];let T,E;for(o=0;o<a;o++){if(o<n){T=l[o]=t[o];continue}E=T,o%n===0?(E=E<<8|E>>>24,E=c[E>>>24]<<24|c[E>>>16&255]<<16|c[E>>>8&255]<<8|c[E&255],E^=h[o/n|0]<<24):n>6&&o%n===4&&(E=c[E>>>24]<<24|c[E>>>16&255]<<16|c[E>>>8&255]<<8|c[E&255]),l[o]=T=(l[o-n]^E)>>>0}for(u=0;u<a;u++)o=a-u,u&3?E=l[o]:E=l[o-4],u<4||o<=4?d[u]=E:d[u]=g[c[E>>>24]]^p[c[E>>>16&255]]^m[c[E>>>8&255]]^y[c[E&255]],d[u]=d[u]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,u=o[0],l=o[1],d=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(i);let f=h[0],g=h[1],p=h[2],m=h[3];const y=new Int32Array(e),T=new Int32Array(y.length);let E,S,_,x,A,I,R,b,k,M,G,q,U,P;const K=this.networkToHostOrderSwap;for(;t<y.length;){for(k=K(y[t]),M=K(y[t+1]),G=K(y[t+2]),q=K(y[t+3]),A=k^n[0],I=q^n[1],R=G^n[2],b=M^n[3],U=4,P=1;P<r;P++)E=u[A>>>24]^l[I>>16&255]^d[R>>8&255]^c[b&255]^n[U],S=u[I>>>24]^l[R>>16&255]^d[b>>8&255]^c[A&255]^n[U+1],_=u[R>>>24]^l[b>>16&255]^d[A>>8&255]^c[I&255]^n[U+2],x=u[b>>>24]^l[A>>16&255]^d[I>>8&255]^c[R&255]^n[U+3],A=E,I=S,R=_,b=x,U=U+4;E=a[A>>>24]<<24^a[I>>16&255]<<16^a[R>>8&255]<<8^a[b&255]^n[U],S=a[I>>>24]<<24^a[R>>16&255]<<16^a[b>>8&255]<<8^a[A&255]^n[U+1],_=a[R>>>24]<<24^a[b>>16&255]<<16^a[A>>8&255]<<8^a[I&255]^n[U+2],x=a[b>>>24]<<24^a[A>>16&255]<<16^a[I>>8&255]<<8^a[R&255]^n[U+3],T[t]=K(E^f),T[t+1]=K(x^g),T[t+2]=K(_^p),T[t+3]=K(S^m),f=k,g=M,p=G,m=q,t=t+4}return T.buffer}}class hg{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=fg(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function fg(s){switch(s){case Ft.cbc:return"AES-CBC";case Ft.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const gg=16;class wn{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.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.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(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?dg(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,r){return this.useSoftware?new Promise((n,a)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,r);const u=this.flush();u?n(u.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){const{currentIV:n,currentResult:a,remainderData:o}=this;if(r!==Ft.cbc||t.byteLength!==16)return ue.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Je(o,e),this.remainderData=null);const u=this.getValidChunk(e);if(!u.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new cg),l.expandKey(t);const d=a;return this.currentResult=l.decrypt(u.buffer,0,i),this.currentIV=u.slice(-16).buffer,d||null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new hg(this.subtle,t,r)}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new ug(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(ue.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,r);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%gg;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(ue.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Fa=Math.pow(2,17);class mg{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){const i=e.url;if(!i)return Promise.reject(new St({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,u)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(g=>g[0]==="GAP")){u(Ba(e));return}else e.gap=!1;const l=this.loader=n?new n(r):new a(r),d=Ua(e);e.loader=l;const c=Ma(r.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Fa};e.stats=l.stats;const f={onSuccess:(g,p,m,y)=>{this.resetLoader(e,l);let T=g.data;m.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(T.slice(0,16)),T=T.slice(16)),o({frag:e,part:null,payload:T,networkDetails:y})},onError:(g,p,m,y)=>{this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:le({url:i,data:void 0},g),error:new Error(`HTTP Error ${g.code} ${g.text}`),networkDetails:m,stats:y}))},onAbort:(g,p,m)=>{this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:m,stats:g}))},onTimeout:(g,p,m)=>{this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:g}))}};t&&(f.onProgress=(g,p,m,y)=>t({frag:e,part:null,payload:m,networkDetails:y})),l.load(d,h,f)})}loadPart(e,t,i){this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,u)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){u(Ba(e,t));return}const l=this.loader=n?new n(r):new a(r),d=Ua(e,t);e.loader=l;const c=Ma(r.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Fa};t.stats=l.stats,l.load(d,h,{onSuccess:(f,g,p,m)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const y={frag:e,part:t,payload:f.data,networkDetails:m};i(y),o(y)},onError:(f,g,p,m)=>{this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:le({url:d.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:m}))},onAbort:(f,g,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,g,p)=>{this.resetLoader(e,l),u(new St({type:W.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const i=e.stats,r=t.stats,n=r.total;if(i.loaded+=r.loaded,n){const u=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/n),u),c=(u-l)*Math.round(i.loaded/l);i.total=i.loaded+c}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=r.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 Ua(s,e=null){const t=e||s,i={frag:s,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if($(r)&&$(n)){var a;let o=r,u=n;if(s.sn==="initSegment"&&pg((a=s.decryptdata)==null?void 0:a.method)){const l=n-r;l%16&&(u=n+(16-l%16)),r!==0&&(i.resetIV=!0,o=r-16)}i.rangeStart=o,i.rangeEnd=u}return i}function Ba(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:W.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new St(i)}function pg(s){return s==="AES-128"||s==="AES-256"}class St extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Xl extends Ze{constructor(e,t){super(e,t),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(){}}class Pn{constructor(e,t,i,r=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=zi(),this.buffering={audio:zi(),video:zi(),audiovideo:zi()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a}}function zi(){return{start:0,executeStart:0,executeEnd:0,end:0}}const $a={length:0,start:()=>0,end:()=>0};class J{static isBuffered(e,t){if(e){const i=J.getBuffered(e);for(let r=i.length;r--;)if(t>=i.start(r)&&t<=i.end(r))return!0}return!1}static bufferedRanges(e){if(e){const t=J.getBuffered(e);return J.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const r=J.bufferedRanges(e);if(r.length)return J.bufferedInfo(r,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((d,c)=>d.start-c.start||c.end-d.end);let r=-1,n=[];if(i)for(let d=0;d<e.length;d++){t>=e[d].start&&t<=e[d].end&&(r=d);const c=n.length;if(c){const h=n[c-1].end;e[d].start-h<i?e[d].end>h&&(n[c-1].end=e[d].end):n.push(e[d])}else n.push(e[d])}else n=e;let a=0,o,u=t,l=t;for(let d=0;d<n.length;d++){const c=n[d].start,h=n[d].end;if(r===-1&&t>=c&&t<=h&&(r=d),t+i>=c&&t<h)u=c,l=h,a=l-t;else if(t+i<c){o=c;break}}return{len:a,start:u||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||$a}catch(t){return ue.log("failed to get media.buffered",t),$a}}}const Ql=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ga(s){return Ql.test(s)}function qr(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(Ql,i=>{const r=i.substring(2,i.length-1),n=t?.[r];return n===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):n})}return e}function Ka(s,e,t){let i=s.variableList;i||(s.variableList=i={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,n=e.VALUE;r in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=n||""}function vg(s,e,t){const i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const yg=/^(\d+)x(\d+)$/,Va=/(.+?)=(".*?"|.*?)(?:,|$)/g;class pe{constructor(e,t){typeof e=="string"&&(e=pe.parseAttrList(e,t)),ce(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const 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;const i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((r,n)=>(r[n.toLowerCase()]=!0,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=yg.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const r={};for(Va.lastIndex=0;(i=Va.exec(e))!==null;){const a=i[1].trim();let o=i[2];const u=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let l=!1;if(u)o=o.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(u||l))o=qr(t,o);else if(!l&&!u)switch(a){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":ue.warn(`${e}: attribute ${a} is missing quotes`)}r[a]=o}return r}}const Eg="com.apple.hls.interstitial";function Tg(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function Sg(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class Jl{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:i,t){const n=t.attr;for(const a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){ue.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}e=ce(new pe({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const n=t?.endDate||new Date(this.attr["END-DATE"]);$(n.getTime())&&(this._endDate=n)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(ue.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if($(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 isInterstitial(){return this.class===Eg}get isValid(){return!!this.id&&!this._badValueForSameId&&$(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const _g=10;class Ag{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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.drift
vendor: 4,537 bytes, line 32
32StartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?$(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||_g}get drift(){const 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(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start: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 maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Bs(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function Ha(s,e){return!s&&!e?!0:!s||!e?!1:Bs(s,e)}function ci(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function On(s){switch(s){case"AES-128":case"AES-256":return Ft.cbc;case"AES-256-CTR":return Ft.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Mn(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Yr(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function bg(s){const e=Yr(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Zl(s){const e=function(i,r,n){const a=i[r];i[r]=i[n],i[n]=a};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function eu(s){const e=s.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){const n=r[0]==="base64",a=r[1];n?(i.splice(-1,1),t=Mn(a)):t=bg(a)}}return t}const $s=typeof self<"u"?self:void 0;var ve={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Pe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function hs(s){switch(s){case Pe.FAIRPLAY:return ve.FAIRPLAY;case Pe.PLAYREADY:return ve.PLAYREADY;case Pe.WIDEVINE:return ve.WIDEVINE;case Pe.CLEARKEY:return ve.CLEARKEY}}function cr(s){switch(s){case ve.FAIRPLAY:return Pe.FAIRPLAY;case ve.PLAYREADY:return Pe.PLAYREADY;case ve.WIDEVINE:return Pe.WIDEVINE;case ve.CLEARKEY:return Pe.CLEARKEY}}function _i(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[ve.FAIRPLAY,ve.WIDEVINE,ve.PLAYREADY,ve.CLEARKEY].filter(r=>!!e[r]):[];return!i[ve.WIDEVINE]&&t&&i.push(ve.WIDEVINE),i}const tu=(function(s){return $s!=null&&(s=$s.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function xg(s,e,t,i){let r;switch(s){case ve.FAIRPLAY:r=["cenc","sinf"];break;case ve.WIDEVINE:case ve.PLAYREADY:r=["cenc"];break;case ve.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Ig(r,e,t,i)}function Ig(s,e,t,i){return[{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}
32`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Rg(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function iu(s){const e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){const u=Mn(o).subarray(0,16);return Zl(u),u}}return null}let Xi={};class jt{static clearKeyUriToKeyIdMap(){Xi={}}static setKeyIdForUri(e,t){Xi[e]=t}constructor(e,t,i,r=[1],n=null,a){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=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!ci(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(kl(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Bs(e.keyFormatVersions,this.keyFormatVersions)&&Ha(e.iv,this.iv)&&Ha(e.keyId,this.keyId)}isSupported(){if(this.method){if(ci(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Pe.FAIRPLAY:case Pe.WIDEVINE:case Pe.PLAYREADY:case Pe.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(ci(this.method)){let n=this.iv;return n||(typeof e!="number"&&(ue.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),n=Dg(e)),new jt(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){const n=Xi[this.uri];if(n&&!Bs(this.keyId,n)&&jt.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=eu(this.uri);if(i)switch(this.keyFormat){case Pe.WIDEVINE:if(this.pssh=i,!this.keyId){const n=wf(i.buffer);if(n.length){var r;const a=n[0];this.keyId=(r=a.kids)!=null&&r.length?a.kids[0]:null}}this.keyId||(this.keyId=qa(t));break;case Pe.PLAYREADY:{const n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Cf(n,null,i),this.keyId=iu(i);break}default:{let n=i.subarray(0,16);if(n.length!==16){const a=new Uint8Array(16);a.set(n,16-n.length),n=a}this.keyId=n;break}}if(!this.keyId||this.keyId.byteLength!==16){let n;n=Lg(t),n||(n=qa(t),n||(n=Xi[this.uri])),n&&(this.keyId=n,jt.setKeyIdForUri(this.uri,n))}return this}}function Lg(s){const e=s?.[Pe.WIDEVINE];return e?e.keyId:null}function qa(s){const e=s?.[Pe.PLAYREADY];if(e){const t=eu(e.uri);if(t)return iu(t)}return null}function Dg(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const Ya=/#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,Wa=/#EXT-X-MEDIA:(.*)/g,kg=/^#EXT(?:INF|-X-TARGETDURATION):/m,hr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Cg=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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("|"));class mt{static findGroup(e,t){for(let i=0;i<e.length;i++){const r=e[i];if(r.id===t)return r}}static resolve(e,t){return In.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return kg.test(e)}static parseMasterPlaylist(e,t){const i=Ga(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(Ya.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let a;for(;(a=Ya.exec(e))!=null;)if(a[1]){var o;const l=new pe(a[1],r),d=qr(r,a[2]),c={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:mt.resolve(d,t)},h=l.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),Xa(l.CODECS,c);const f=l["SUPPLEMENTAL-CODECS"];f&&(c.supplemental={},Xa(f,c.supplemental)),(o=c.unknownCodecs)!=null&&o.length||n.push(c),r.levels.push(c)}else if(a[3]){const l=a[3],d=a[4];switch(l){case"SESSION-DATA":{const c=new pe(d,r),h=c["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=c);break}case"SESSION-KEY":{const c=ja(d,t,r);c.encrypted&&c.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(c)):ue.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const c=new pe(d,r);Ka(r,c,t)}break}case"CONTENT-STEERING":{const c=new pe(d,r);r.contentSteering={uri:mt.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=za(d);break}}}const u=n.length>0&&n.length<r.levels.length;return r.levels=u?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r;const n={},a=i.levels,o={AUDIO:a.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec}
vendor: 10,086 bytes, line 32
32)),SUBTITLES:a.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]};let u=0;for(Wa.lastIndex=0;(r=Wa.exec(e))!==null;){const l=new pe(r[1],i),d=l.TYPE;if(d){const c=o[d],h=n[d]||[];n[d]=h;const f=l.LANGUAGE,g=l["ASSOC-LANGUAGE"],p=l.CHANNELS,m=l.CHARACTERISTICS,y=l["INSTREAM-ID"],T={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?mt.resolve(l.URI,t):""};if(g&&(T.assocLang=g),p&&(T.channels=p),m&&(T.characteristics=m),y&&(T.instreamId=y),c!=null&&c.length){const E=mt.findGroup(c,T.groupId)||c[0];Qa(T,E,"audioCodec"),Qa(T,E,"textCodec")}h.push(T)}}return n}static parseLevelPlaylist(e,t,i,r,n,a){var o;const u={url:t},l=new Ag(t),d=l.fragments,c=[];let h=null,f=0,g=0,p=0,m=0,y=0,T=null,E=new lr(r,u),S,_,x,A=-1,I=!1,R=null,b;if(hr.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Ga(e),((o=hr.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(S=hr.exec(e))!==null;){I&&(I=!1,E=new lr(r,u),E.playlistOffset=p,E.setStart(p),E.sn=f,E.cc=m,y&&(E.bitrate=y),E.level=i,h&&(E.initSegment=h,h.rawProgramDateTime&&(E.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),R&&(E.setByteRange(R),R=null)));const q=S[1];if(q){E.duration=parseFloat(q);const U=(" "+S[2]).slice(1);E.title=U||null,E.tagList.push(U?["INF",q,U]:["INF",q])}else if(S[3]){if($(E.duration)){E.playlistOffset=p,E.setStart(p),x&&Za(E,x,l),E.sn=f,E.level=i,E.cc=m,d.push(E);const U=(" "+S[3]).slice(1);E.relurl=qr(l,U),Wr(E,T,c),T=E,p+=E.duration,f++,g=0,I=!0}}else{if(S=S[0].match(Cg),!S){ue.warn("No matches on slow regex match for level playlist!");continue}for(_=1;_<S.length&&S[_]===void 0;_++);const U=(" "+S[_]).slice(1),P=(" "+S[_+1]).slice(1),K=S[_+2]?(" "+S[_+2]).slice(1):null;switch(U){case"BYTERANGE":T?E.setByteRange(P,T):E.setByteRange(P);break;case"PROGRAM-DATE-TIME":E.rawProgramDateTime=P,E.tagList.push(["PROGRAM-DATE-TIME",P]),A===-1&&(A=d.length);break;case"PLAYLIST-TYPE":l.type&&Et(l,U,S),l.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":l.startSN!==0?Et(l,U,S):d.length>0&&eo(l,U,S),f=l.startSN=parseInt(P);break;case"SKIP":{l.skippedSegments&&Et(l,U,S);const B=new pe(P,l),Y=B.decimalInteger("SKIPPED-SEGMENTS");if($(Y)){l.skippedSegments+=Y;for(let O=Y;O--;)d.push(null);f+=Y}const z=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(z.split("	")));break}case"TARGETDURATION":l.targetduration!==0&&Et(l,U,S),l.targetduration=Math.max(parseInt(P),1);break;case"VERSION":l.version!==null&&Et(l,U,S),l.version=parseInt(P);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Et(l,U,S),l.live=!1;break;case"#":(P||K)&&E.tagList.push(K?[P,K]:[P]);break;case"DISCONTINUITY":m++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([U]);break;case"BITRATE":E.tagList.push([U,P]),y=parseInt(P)*1e3,$(y)?E.bitrate=y:y=0;break;case"DATERANGE":{const B=new pe(P,l),Y=new Jl(B,l.dateRanges[B.ID],l.dateRangeTagCount);l.dateRangeTagCount++,Y.isValid||l.skippedSegments?l.dateRanges[Y.id]=Y:ue.warn(`Ignoring invalid DATERANGE tag: "${P}"`),E.tagList.push(["EXT-X-DATERANGE",P]);break}case"DEFINE":{{const B=new pe(P,l);"IMPORT"in B?vg(l,B,a):Ka(l,B,t)}break}case"DISCONTINUITY-SEQUENCE":l.startCC!==0?Et(l,U,S):d.length>0&&eo(l,U,S),l.startCC=m=parseInt(P);break;case"KEY":{const B=ja(P,t,l);if(B.isSupported()){if(B.method==="NONE"){x=void 0;break}x||(x={});const Y=x[B.keyFormat];Y!=null&&Y.matches(B)||(Y&&(x=ce({},x)),x[B.keyFormat]=B)}else ue.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${P}"`);break}case"START":l.startTimeOffset=za(P);break;case"MAP":{const B=new pe(P,l);if(E.duration){const Y=new lr(r,u);Ja(Y,B,i,x),h=Y,E.initSegment=h,h.rawProgramDateTime&&!E.rawProgramDateTime&&(E.rawProgramDateTime=h.rawProgramDateTime)}else{const Y=E.byteRangeEndOffset;if(Y){const z=E.byteRangeStartOffset;R=`${Y-z}@${z}`}else R=null;Ja(E,B,i,x),h=E,I=!0}h.cc=m;break}case"SERVER-CONTROL":{b&&Et(l,U,S),b=new pe(P),l.canBlockReload=b.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=b.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&b.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=b.optionalFloat("PART-HOLD-BACK",0),l.holdBack=b.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{l.partTarget&&Et(l,U,S);const B=new pe(P);l.partTarget=B.decimalFloatingPoint("PART-TARGET");break}case"PART":{let B=l.partList;B||(B=l.partList=[]);const Y=g>0?B[B.length-1]:void 0,z=g++,O=new pe(P,l),N=new vf(O,E,u,z,Y);B.push(N),E.duration+=N.duration;break}case"PRELOAD-HINT":{const B=new pe(P,l);l.preloadHint=B;break}case"RENDITION-REPORT":{const B=new pe(P,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(B);break}default:ue.warn(`line parsed but not handled: ${S}`);break}}}T&&!T.relurl?(d.pop(),p-=T.duration,l.partList&&(l.fragmentHint=T)):l.partList&&(Wr(E,T,c),E.cc=m,l.fragmentHint=E,x&&Za(E,x,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=d.length,M=d[0],G=d[k-1];if(p+=l.skippedSegments*l.targetduration,p>0&&k&&G){l.averagetargetduration=p/k;const q=G.sn;l.endSN=q!=="initSegment"?q:0,l.live||(G.endList=!0),A>0&&(Pg(d,A),M&&c.unshift(M))}return l.fragmentHint&&(p+=l.fragmentHint.duration),l.totalduration=p,c.length&&l.dateRangeTagCount&&M&&su(c,l),l.endCC=m,l}}function su(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];s.push(o),t++}else return;const i=s[t-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){const u=e.dateRanges[n[o]],l=u.startDate.getTime();u.tagAnchor=i.ref;for(let d=t;d--;){var a;if(((a=s[d])==null?void 0:a.sn)<e.startSN)break;const c=wg(e,l,s,d,r);if(c!==-1){u.tagAnchor=e.fragments[c].ref;break}}}}function wg(s,e,t,i,r){const n=t[i];if(n){const o=n.programDateTime;if(e>=o||i===0){var a;const u=(((a=t[i+1])==null?void 0:a.start)||r)-n.start;if(e<=o+u*1e3){const l=t[i].sn-s.startSN;if(l<0)return-1;const d=s.fragments;if(d.length>t.length){const h=(t[i+1]||d[d.length-1]).sn-s.startSN;for(let f=h;f>l;f--){const g=d[f].programDateTime;if(e>=g&&e<g+d[f].duration*1e3)return f}}return l}}}return-1}function ja(s,e,t){var i,r;const n=new pe(s,t),a=(i=n.METHOD)!=null?i:"",o=n.URI,u=n.hexadecimalInteger("IV"),l=n.KEYFORMATVERSIONS,d=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!u&&ue.error(`Invalid IV: ${n.IV}`);const c=o?mt.resolve(o,e):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new jt(a,c,d,h,u,n.KEYID)}function za(s){const t=new pe(s).decimalFloatingPoint("TIME-OFFSET");return $(t)?t:null}function Xa(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const r=t.filter(n=>Dn(n,i));r.length&&(e[`${i}Codec`]=r.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>r.indexOf(n)===-1))}),e.unknownCodecs=t}function Qa(s,e,t){const i=e[t];i&&(s[t]=i)}function Pg(s,e){let t=s[e];for(let i=e;i--;){const r=s[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function Wr(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function Ja(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function Za(s,e,t){s.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s)}function Et(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function eo(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function fr(s,e){const t=e.startPTS;if($(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&r.setDuration(i)}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0))}function ru(s,e,t,i,r,n,a){i-t<=0&&(a.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let u=t,l=i;const d=e.startPTS,c=e.endPTS;if($(d)){const y=Math.abs(d-t);s&&y>s.totalduration?a.warn(`media timestamps and playlist times differ by ${y}s for level ${e.level} ${s.url}`):$(e.deltaPTS)?e.deltaPTS=Math.max(y,e.deltaPTS):e.deltaPTS=y,u=Math.max(t,d),t=Math.min(t,d),r=e.startDTS!==void 0?Math.min(r,e.startDTS):r,l=Math.min(i,c),i=Math.max(i,c),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n}const h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=u,e.startDTS=r,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;const f=e.sn;if(!s||f<s.startSN||f>s.endSN)return 0;let g;const p=f-s.startSN,m=s.fragments;for(m[p]=e,g=p;g>0;g--)fr(m[g],m[g-1]);for(g=p;g<m.length-1;g++)fr(m[g],m[g+1]);return s.fragmentHint&&fr(m[m.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,h}function Og(s,e,t){if(s===e)return;let i=null;const r=s.fragments;for(let d=r.length-1;d>=0;d--){const c=r[d].initSegment;if(c){i=c;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n;Fg(s,e,(d,c,h,f)=>{if((!e.startCC||e.skippedSegments)&&c.cc!==d.cc){const g=d.cc-c.cc;for(let p=h;p<f.length;p++)f[p].cc+=g;e.endCC=f[f.length-1].cc}$(d.startPTS)&&$(d.endPTS)&&(c.setStart(c.startPTS=d.startPTS),c.startDTS=d.startDTS,c.maxStartPTS=d.maxStartPTS,c.endPTS=d.endPTS,c.endDTS=d.endDTS,c.minEndPTS=d.minEndPTS,c.setDuration(d.endPTS-d.startPTS),c.duration&&(n=c),e.PTSKnown=e.alignedSliding=!0),d.hasStreams&&(c.elementaryStreams=d.elementaryStreams),c.loader=d.loader,d.hasStats&&(c.stats=d.stats),d.initSegment&&(c.initSegment=d.initSegment,i=d.initSegment)});const a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(d=>{var c;d&&(!d.initSegment||d.initSegment.relurl===((c=i)==null?void 0:c.relurl))&&(d.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(d=>!d),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments ski
32pped in delta playlist");for(let d=e.skippedSegments;d--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=Mg(s.dateRanges,e,t));const d=s.fragments.filter(c=>c.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let c=1;c<o.length;c++)o[c].programDateTime===null&&Wr(o[c],o[c-1],d);su(d,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var u;const d=ou(s,e.startSN-1);e.startCC=(u=d?.cc)!=null?u:a[0].cc}Ng(s.partList,e.partList,(d,c)=>{c.elementaryStreams=d.elementaryStreams,c.stats=d.stats}),n?ru(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,t):nu(s,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const l=e.advancedDateTime;if(e.advanced&&l){const d=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=d),e.driftEndTime=l,e.driftEnd=d}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled)}function Mg(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:r}=e,n=ce({},s);r&&r.forEach(u=>{delete n[u]});const o=Object.keys(n).length;
vendor: 33,515 bytes, lines 32-37
32return o?(Object.keys(i).forEach(u=>{const l=n[u],d=new Jl(i[u].attr,l);d.isValid?(n[u]=d,l||(d.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${ge(i[u].attr)}"`)}),n):i}function Ng(s,e,t){if(s&&e){let i=0;for(let r=0,n=s.length;r<=n;r++){const a=s[r],o=e[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function Fg(s,e,t){const i=e.skippedSegments,r=Math.max(s.startSN,e.startSN)-e.startSN,n=(s.fragmentHint?1:0)+(i?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,a=e.startSN-s.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let l=r;l<=n;l++){const d=u[a+l];let c=o[l];if(i&&!c&&d&&(c=e.fragments[l]=d),d&&c){t(d,c,l,o);const h=d.relurl,f=c.relurl;if(h&&Ug(h,f)){e.playlistParsingError=to(`media sequence mismatch ${c.sn}:`,s,e,d,c);return}else if(d.cc!==c.cc){e.playlistParsingError=to(`discontinuity sequence mismatch (${d.cc}!=${c.cc})`,s,e,d,c);return}}}}function to(s,e,t,i,r){return new Error(`${s} ${r.url}
33Playlist starting @${e.startSN}
34${e.m3u8}
35
36Playlist starting @${t.startSN}
37${t.m3u8}`)}function nu(s,e,t=!0){const i=e.startSN+e.skippedSegments-s.startSN,r=s.fragments,n=i>=0;let a=0;if(n&&i<r.length)a=r[i].start;else if(n&&e.startSN===s.endSN+1)a=s.fragmentEnd;else if(n&&t)a=s.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)a=s.fragmentStart;else return;jr(e,a)}function jr(s,e){if(e){const t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e)}}function au(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){const i=s.fragments;if(i.length&&t*4>e){const n=i[i.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function ou(s,e,t){if(!s)return null;let i=s.fragments[e-s.startSN];return i||(i=s.fragmentHint,i&&i.sn===e)?i:e<s.startSN&&t&&t.sn===e?t:null}function io(s,e,t){return s?lu(s.partList,e,t):null}function lu(s,e,t){if(s)for(let i=s.length;i--;){const r=s[i];if(r.index===t&&r.fragment.sn===e)return r}return null}function uu(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t)})})}function Ug(s,e){return s!==e&&e?so(s)!==so(e):!1}function so(s){return s.replace(/\?[^?]*$/,"")}function Ci(s,e){for(let i=0,r=s.length;i<r;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function Bg(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function ro(s,e){const t=s.start+e;s.startPTS=t,s.setStart(t),s.endPTS=t+s.duration}function du(s,e){const t=e.fragments;for(let i=0,r=t.length;i<r;i++)ro(t[i],s);e.fragmentHint&&ro(e.fragmentHint,s),e.alignedSliding=!0}function $g(s,e){s&&(cu(e,s),e.alignedSliding||Gs(e,s),!e.alignedSliding&&!e.skippedSegments&&nu(s,e,!1))}function cu(s,e){if(!Bg(e,s))return;const t=Math.min(e.endCC,s.endCC),i=Ci(e.fragments,t),r=Ci(s.fragments,t);if(!i||!r)return;ue.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const n=i.start-r.start;du(n,s)}function Gs(s,e){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;const t=s.fragments,i=e.fragments;if(!t.length||!i.length)return;let r,n;const a=Math.min(e.endCC,s.endCC);e.startCC<a&&s.startCC<a&&(r=Ci(i,a),n=Ci(t,a)),(!r||!n)&&(r=i[Math.floor(i.length/2)],n=Ci(t,r.cc)||t[Math.floor(t.length/2)]);const o=r.programDateTime,u=n.programDateTime;if(!o||!u)return;const l=(u-o)/1e3-(n.start-r.start);du(l,s)}function Ue(s,e,t){$e(s,e,t),s.addEventListener(e,t)}function $e(s,e,t){s.removeEventListener(e,t)}const Gg={toString:function(s){let e="";const t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}},C={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"};class Nn extends Xl{constructor(e,t,i,r,n){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=C.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.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.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:a,fragCurrent:o,media:u,mediaBuffer:l,state:d}=this,c=u?u.currentTime:0,h=J.bufferInfo(l||u,c,a.maxBufferHole),f=!h.len;if(this.log(`Media seeking to ${$(c)?c.toFixed(3):c}, state: ${d}, ${f?"out of":"in"} buffer`),this.state===C.ENDED)this.resetLoadingState();else if(o){const g=a.maxFragLookUpTolerance,p=o.start-g,m=o.start+o.duration+g;if(f||m<h.start||p>h.end){const y=c>m;(c<p||y)&&(y&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(u){this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0);const g=this.lastCurrentTime;if(c>g&&(this.lastCurrentTime=c),!this.loadingParts){const p=Math.max(h.end,c),m=this.shouldLoadParts(this.getLevelDetails(),p);m&&(this.log(`LL-Part loading ON after seeking to ${c.toFixed(2)} with buffer @${p.toFixed(2)}`),this.loadingParts=m)}}this.hls.hasEnoughToStart||(this.log(`Setting ${f?"startPosition":"nextLoadPosition"} to ${c} for seek without enough to start`),this.nextLoadPosition=c,f&&(this.startPosition=c)),f&&this.state===C.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new mg(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new wn(e.config)}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===C.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const 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=C.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=J.bufferedInfo(n,e.start,0));const a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return!1;const u=t.partList;if(u!=null&&u.length){const d=u[u.length-1];return J.isBuffered(this.media,d.start+d.duration/2)}const l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;Ue(i,"seeking",this.onMediaSeeking),Ue(i,"ended",this.onMediaEnded);const r=this.config;this.levels&&r.autoStartLoad&&this.state===C.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),$e(r,"seeking",this.onMediaSeeking),$e(r,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=C.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,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const r=n=>{const a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,!1,n.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(a);return}a.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;const a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===C.FRAG_LOADING||!this.fragCurrent&&a===C.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=C.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(`Frag error: ${n?.message||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Re.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),u=this.backtrackFragment;((u?e.sn-u.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Re.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const 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)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:i};this.hls.trigger(v.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const r=i?.frag;if(!r||this.fragContextChanged(r)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:r}=this,{frag:n,payload:a}=i,o=n.decryptdata;if(a&&a.byteLength>0&&o!=null&&o.key&&o.iv&&ci(o.method)){const u=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer,On(o.method)).catch(l=>{throw r.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:n}),l}).then(l=>{const d=self.performance.now();return r.trigger(v.FRAG_DECRYPTED,{frag:n,payload:l,stats:{tstart:u,tdecrypt:d}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==C.STOPPED&&(this.state=C.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,r;const n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(r=n.video)!=null&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?!1:(this.hls.trigger(v.ERROR,{type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?Gg.toString(J.getBuffered(i)):"(detached)"})`),Ae(e)){var r;if(e.type!==H.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=C.IDLE;return}}const n=(r=this.levels)==null?void 0:r[e.level];n!=null&&n.fragmentError&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0)}this.state=C.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(u=>!u),o=new Pn(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,r){var n;this.fragCurrent=e;const a=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)){if(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=C.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(v.KEY_LOADED,h),this.state===C.KEY_LOADING&&(this.state=C.IDLE),h}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const u=this.fragPrevious;if(Ae(e)&&(!u||e.sn!==u.sn)){const h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log(`LL-Part loading ${h?"ON":"OFF"} loading sn ${u?.sn}->${e.sn}`),this.loadingParts=h)}if(i=Math.max(e.start,i||0),this.loadingParts&&Ae(e)){const h=a.partList;if(h&&r){i>a.fragmentEnd&&a.fragmentHint&&(e=a.fragmentHint);const f=this.getNextPart(h,e,i);if(f>-1){const g=h[f];e=this.fragCurrent=g.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${g.index} (${f}/${h.length-1}) of ${this.fragInfo(e,!1,g)}) cc: ${e.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=g.start+g.duration,this.state=C.FRAG_LOADING;let p;return o?p=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,g,t,r)).catch(m=>this.handleFragLoadError(m)):p=this.doFragPartsLoad(e,g,t,r).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:g,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):p}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if(Ae(e)&&this.loadingParts){var l;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(l=a.partList)==null?void 0:l.filter(h=>h.loaded).map(h=>`[${h.start}-${h.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),$(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=C.FRAG_LOADING;const d=this.config.progressive;let c;return d&&o?c=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.fragmentLoader.load(e,r)).catch(h=>this.handleFragLoadError(h)):c=Promise.all([this.fragmentLoader.load(e,d?r:void 0),o]).then(([h])=>(!d&&r&&r(h),h)).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;const u=[],l=(o=i.details)==null?void 0:o.partList,d=c=>{this.fragmentLoader.loadPart(e,c,r).then(h=>{u[c.index]=h;const f=h.part;this.hls.trigger(v.FRAG_LOADED,h);const g=io(i.details,e.sn,c.index+1)||lu(l,e.sn,c.index+1);if(g)d(g);else return n({frag:e,part:f,partsLoaded:u})}).catch(a)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===W.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==C.PARSING){!this.fragCurrent&&this.state!==C.STOPPED&&this.state!==C.ERROR&&(this.state=C.IDLE);return}const{frag:i,part:r,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);const o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,r,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const n=e.partList[0];if(n.fragment.type===H.SUBTITLE)return!1;const a=n.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=a){var r;if((this.hls.hasEnoughToStart?((r=this.media)==null?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;const o=t[r],u=o.details,l=a>-1?io(u,n,a):null,d=l?l.fragment:ou(u,n,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,r,n){if(this.state!==C.PARSING)return;const{data1:a,data2:o}=e;let u=a;if(o&&(u=Je(a,o)),!u.length)return;const l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,c={type:e.type,frag:t,part:i,chunkMeta:r,offset:d,parent:t.type,data:u};if(this.hls.trigger(v.BUFFER_APPENDING,c),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!J.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,r=J.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const r=this.getLoadPosition();if(!$(r))return null;const a=this.lastCurrentTime>r||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){const n=J.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){const o=Math.max(Math.min(n.nextStart,a.end)-t,r);return J.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=H.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,r=i.length;if(!r)return null;const{config:n}=this,a=i[0].start,o=n.lowLatencyMode&&!!t.partList;let u=null;if(t.live){const c=n.initialLiveManifestSize;if(r<c)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${c})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),u=this.getInitialLiveFragment(t);const h=this.hls.startPosition,f=this.hls.liveSyncPosition,g=u?(h!==-1&&h>=a?h:f)||u.start:e;this.log(`Setting startPosition to ${g} to match start frag at live edge. mainStart: ${h} liveSyncPosition: ${f} frag.start: ${(l=u)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=g}}else e<=a&&(u=i[0]);if(!u){const c=this.loadingParts?t.partEnd:t.fragmentEnd;u=this.getFragmentAtPosition(e,c,t)}let d=this.filterReplacedPrimary(u,t);if(!d&&u){const c=u.sn-t.startSN;d=this.filterReplacedPrimary(i[c+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===Re.OK||i===Re.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,r,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(o!==null&&i.len+o.len>=n){const u=a.sn;return this.loopSn!==u&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${u}`),this.loopSn=u),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(no(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(no(this.config)&&e.type!==H.SUBTITLE){const i=this.hls.interstitialsManager,r=i?.bufferingItem;if(r){const a=r.event;if(a){if(a.appendInPlace||Math.abs(e.start-r.start)>1||r.start===0)return null}else if(e.end<=r.start&&t?.live===!1||e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}const n=i?.playerQueue;if(n)for(let a=n.length;a--;){const o=n[a].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let r=-1,n=!1,a=!0;for(let o=0,u=e.length;o<u;o++){const l=e[o];if(a=a&&!l.independent,r>-1&&i<l.start)break;const d=l.loaded;d?r=-1:(n||(l.independent||a)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),r=o),n=d}return r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--;){if(i=e[r],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let r=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),r=sg(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=Wl(e,i.cc,i.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,i){const{config:r}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=i;const{fragmentHint:u}=i,{maxFragLookUpTolerance:l}=r,d=i.partList,c=!!(this.loadingParts&&d!=null&&d.length&&u);c&&!this.bitrateTest&&d[d.length-1].fragment.sn===u.sn&&(a=a.concat(u),o=u.sn);let h;if(e<t){var f;const p=e<this.lastCurrentTime||e>t-l||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:l;h=Xt(n,a,e,p)}else h=a[a.length-1];if(h){const g=h.sn-i.startSN,p=this.fragmentTracker.getState(h);if((p===Re.OK||p===Re.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||d[0].fragment.sn>h.sn||!i.live)&&h.level===n.level){const y=a[g+1];h.sn<o&&this.fragmentTracker.getState(y)!==Re.OK?h=y:h=null}}return h}alignPlaylists(e,t,i){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,a=!t,o=e.alignedSliding&&$(n);if(a||!o&&!n){$g(i,e);const u=e.fragmentStart;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),u}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const r=this.timelineOffset;if(i===-1){const n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&$(a)?(i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+r}this.nextLoadPosition=i+r}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Ae(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==C.FRAG_LOADING_WAITING_RETRY)&&(this.state=C.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const y=this.getCurrentContext(t.chunkMeta);y&&(t.frag=y.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var n;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const a=t.details===D.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,!0);const o=t.errorAction;if(!o){this.state=C.ERROR;return}const{action:u,flags:l,retryCount:d=0,retryConfig:c}=o,h=!!c,f=h&&u===we.RetryRequest,g=h&&!o.resolved&&l===Ve.MoveAllAlternatesMatchingHost,p=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!f&&g&&Ae(r)&&!r.endList&&p&&!zl(t))this.resetFragmentErrors(e),this.treatAsGap(r),o.resolved=!0;else if((f||g)&&d<c.maxNumRetry){var m;const y=Hr((m=t.response)==null?void 0:m.code),T=Cn(c,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+T,this.state=C.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,y){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${d+1}/${c.maxNumRetry} in ${T}ms`)}else if(c)if(this.resetFragmentErrors(e),d<c.maxNumRetry)!a&&u!==we.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${d})`);return}else u===we.SendAlternateToPenaltyBox?this.state=C.WAITING_LEVEL:this.state=C.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!Hr(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=C.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===C.PARSING||this.state===C.PARSED){const t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len,t?.duration||10);const a=!n;return a&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===H.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==C.STOPPED&&(this.state=C.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const r=J.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===C.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==C.STOPPED&&(this.state=C.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,r){const n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((u,l)=>{const d=e.elementaryStreams[l];if(d){const c=d.endPTS-d.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${c})`),u||!1;const h=r?0:ru(n,e,d.startPTS,d.endPTS,d.startDTS,d.endDTS,this);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:n,level:i,drift:h,type:l,frag:e,start:d.startPTS,end:d.endPTS}),!0}return u},!1)){var o;if(i.fragmentError===0&&this.treatAsGap(e,i),((o=this.transmuxer)==null?void 0:o.error)===null){const u=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(u.message),this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=C.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===H.MAIN?"level":"track"}fragInfo(e,t=!0,i){var r,n;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((r=t&&!i?e.startPTS:(i||e).start)!=null?r:NaN).toFixed(3)}-${((n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function no(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class hu{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=Kg(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Kg(s,e){const t=new Uint8Array(e);let i=0;for(let r=0;r<s.length;r++){const n=s[r];t.set(n,i),i+=n.length}return t}var gr={exports:{}},ao;function Vg(){return ao||(ao=1,(function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(u,l,d){this.fn=u,this.context=l,this.once=d||!1}function n(u,l,d,c,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new r(d,c||u,h),g=t?t+l:l;return u._events[g]?u._events[g].fn?u._events[g]=[u._events[g],f]:u._events[g].push(f):(u._events[g]=f,u._eventsCount++),u}function a(u,l){--u._eventsCount===0?u._events=new i:delete u._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],d,c;if(this._eventsCount===0)return l;for(c in d=this._events)e.call(d,c)&&l.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=t?t+l:l,c=this._events[d];if(!c)return[];
vendor: 4,844 bytes, line 37
37if(c.fn)return[c.fn];for(var h=0,f=c.length,g=new Array(f);h<f;h++)g[h]=c[h].fn;return g},o.prototype.listenerCount=function(l){var d=t?t+l:l,c=this._events[d];return c?c.fn?1:c.length:0},o.prototype.emit=function(l,d,c,h,f,g){var p=t?t+l:l;if(!this._events[p])return!1;var m=this._events[p],y=arguments.length,T,E;if(m.fn){switch(m.once&&this.removeListener(l,m.fn,void 0,!0),y){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,d),!0;case 3:return m.fn.call(m.context,d,c),!0;case 4:return m.fn.call(m.context,d,c,h),!0;case 5:return m.fn.call(m.context,d,c,h,f),!0;case 6:return m.fn.call(m.context,d,c,h,f,g),!0}for(E=1,T=new Array(y-1);E<y;E++)T[E-1]=arguments[E];m.fn.apply(m.context,T)}else{var S=m.length,_;for(E=0;E<S;E++)switch(m[E].once&&this.removeListener(l,m[E].fn,void 0,!0),y){case 1:m[E].fn.call(m[E].context);break;case 2:m[E].fn.call(m[E].context,d);break;case 3:m[E].fn.call(m[E].context,d,c);break;case 4:m[E].fn.call(m[E].context,d,c,h);break;default:if(!T)for(_=1,T=new Array(y-1);_<y;_++)T[_-1]=arguments[_];m[E].fn.apply(m[E].context,T)}}return!0},o.prototype.on=function(l,d,c){return n(this,l,d,c,!1)},o.prototype.once=function(l,d,c){return n(this,l,d,c,!0)},o.prototype.removeListener=function(l,d,c,h){var f=t?t+l:l;if(!this._events[f])return this;if(!d)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===d&&(!h||g.once)&&(!c||g.context===c)&&a(this,f);else{for(var p=0,m=[],y=g.length;p<y;p++)(g[p].fn!==d||h&&!g[p].once||c&&g[p].context!==c)&&m.push(g[p]);m.length?this._events[f]=m.length===1?m[0]:m:a(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&a(this,d)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o})(gr)),gr.exports}var Hg=Vg(),Fn=mf(Hg);const Bi="1.6.14",pi={};function qg(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Yg(){const s=pi[Bi];if(s)return s.clientCount++,s;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return pi[Bi]=r,r}function Wg(s){const e=pi[s];if(e)return e.clientCount++,e;const t=new self.URL(s,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return pi[s]=r,r}function jg(s){const e=pi[s||Bi];if(e&&e.clientCount--===1){const{worker:i,objectURL:r}=e;delete pi[s||Bi],r&&self.URL.revokeObjectURL(r),i.terminate()}}function fu(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function Un(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function js(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function $i(s,e){const t=e;let i=0;for(;Un(s,e);){i+=10;const r=js(s,e+6);i+=r,fu(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function zg(s,e,t,i){const r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){const f=new Error(`invalid ADTS sampling index:${a}`);s.emit(v.ERROR,v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message});return}const o=(n>>6&3)+1,u=e[t+3]>>6&3|(n&1)<<2,l="mp4a.40."+o,d=r[a];let c=a;(o===5||o===29)&&(c-=3);const h=[o<<3|(c&14)>>1,(c&1)<<7|u<<3];return ue.log(`manifest codec:${i}, parsed codec:${l}, channels:${u}, rate:${d} (ADTS object type:${o} sampling index:${a})`),{config:h,samplerate:d,channelCount:u,codec:l,parsedCodec:l,manifestCodec:i}}function gu(s,e){return s[e]===255&&(s[e+1]&246)===240}function mu(s,e){return s[e+1]&1?7:9}function Bn(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function Xg(s,e){return e+5<s.length}function Ks(s,e){return e+1<s.length&&gu(s,e)}function Qg(s,e){return Xg(s,e)&&gu(s,e)&&Bn(s,e)<=s.length-e}function Jg(s,e){if(Ks(s,e)){const t=mu(s,e);if(e+t>=s.length)return!1;const i=Bn(s,e);if(i<=t)return!1;const r=e+i;return r===s.length||Ks(s,r)}return!1}function pu(s,e,t,i,r){if(!s.samplerate){const n=zg(e,t,i,r);if(!n)return;ce(s,n)}}function vu(s){return 1024*9e4/s}function Zg(s,e){const t=mu(s,e);if(e+t<=s.length){const i=Bn(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function yu(s,e,t,i,r){const n=vu(s.samplerate),a=i+r*n,o=Zg(e,t);let u;if(o){const{frameLength:c,headerLength:h}=o,f=h+c,g=Math.max(0,t+f-e.length);g?(u=new Uint8Array(f-h),u.set(e.subarray(t+h,e.length),0)):u=e.subarray(t+h,t+f);const p={unit:u,pts:a};return g||s.samples.push(p),{sample:p,length:f,missing:g}}const l=e.length-t;
vendor: 15,174 bytes, line 37
37return u=new Uint8Array(l),u.set(e.subarray(t,e.length),0),{sample:{unit:u,pts:a},length:l,missing:-1}}function em(s,e){return Un(s,e)&&js(s,e+6)+10<=s.length-e}function tm(s){return s instanceof ArrayBuffer?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function mr(s,e=0,t=1/0){return im(s,e,t,Uint8Array)}function im(s,e,t,i){const r=sm(s);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const a=rm(s)?s.byteOffset:0,o=(a+s.byteLength)/n,u=(a+e)/n,l=Math.floor(Math.max(0,Math.min(u,o))),d=Math.floor(Math.min(l+Math.max(t,0),o));return new i(r,l,d-l)}function sm(s){return s instanceof ArrayBuffer?s:s.buffer}function rm(s){return s&&s.buffer instanceof ArrayBuffer&&s.byteLength!==void 0&&s.byteOffset!==void 0}function nm(s){const e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2)return;if(s.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=s.data.subarray(1).indexOf(0);if(i===-1)return;const r=Ye(mr(s.data,1,i)),n=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;const o=Ye(mr(s.data,3+i,a));let u;return r==="-->"?u=Ye(mr(s.data,4+i+a)):u=tm(s.data.subarray(4+i+a)),e.mimeType=r,e.pictureType=n,e.description=o,e.data=u,e}function am(s){if(s.size<2)return;const e=Ye(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function om(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const i=Ye(s.data.subarray(t),!0);t+=i.length+1;const r=Ye(s.data.subarray(t));return{key:s.type,info:i,data:r}}const e=Ye(s.data.subarray(1));return{key:s.type,info:"",data:e}}function lm(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=Ye(s.data.subarray(t),!0);t+=i.length+1;const r=Ye(s.data.subarray(t));return{key:s.type,info:i,data:r}}const e=Ye(s.data);return{key:s.type,info:"",data:e}}function um(s){return s.type==="PRIV"?am(s):s.type[0]==="W"?lm(s):s.type==="APIC"?nm(s):om(s)}function dm(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=js(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const Qi=10,cm=10;function Eu(s){let e=0;const t=[];for(;Un(s,e);){const i=js(s,e+6);s[e+5]>>6&1&&(e+=Qi),e+=Qi;const r=e+i;for(;e+cm<r;){const n=dm(s.subarray(e)),a=um(n);a&&t.push(a),e+=n.size+Qi}fu(s,e)&&(e+=Qi)}return t}function Tu(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function hm(s){if(s.data.byteLength===8){const e=new Uint8Array(s.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function $n(s){const e=Eu(s);for(let t=0;t<e.length;t++){const i=e[t];if(Tu(i))return hm(i)}}let qe=(function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s})({});function ft(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Gn{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,i,r){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,i){}demux(e,t){this.cachedData&&(e=Je(this.cachedData,e),this.cachedData=null);let i=$i(e,0),r=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,u=i?$n(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&$(u))&&(this.basePTS=fm(u,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:qe.audioId3,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(e,r)){const d=this.appendFrame(a,e,r);d?(this.frameIndex++,this.lastPTS=d.sample.pts,r+=d.length,n=r):r=l}else em(e,r)?(i=$i(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:qe.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===l&&n!==l){const d=e.slice(n);this.cachedData?this.cachedData=Je(this.cachedData,d):this.cachedData=d}}return{audioTrack:a,videoTrack:ft(),id3Track:o,textTrack:ft()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ft(),id3Track:this._id3Track,textTrack:ft()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const fm=(s,e,t)=>{if($(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Ji=null;const gm=[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],mm=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],pm=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],vm=[0,1,1,4];function Su(s,e,t,i,r){if(t+24>e.length)return;const n=_u(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,u={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=n.channelCount,s.samplerate=n.sampleRate,s.samples.push(u),{sample:u,length:n.frameLength,missing:0}}}function _u(s,e){const t=s[e+1]>>3&3,i=s[e+1]>>1&3,r=s[e+2]>>4&15,n=s[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){const a=s[e+2]>>1&1,o=s[e+3]>>6,u=t===3?3-i:i===3?3:4,l=gm[u*14+r-1]*1e3,c=mm[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=pm[t][i],g=vm[i],p=f*8*g,m=Math.floor(f*l/c+a)*g;if(Ji===null){const E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ji=E?parseInt(E[1]):0}return!!Ji&&Ji<=87&&i===2&&l>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:c,channelCount:h,frameLength:m,samplesPerFrame:p}}}function Kn(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Au(s,e){return e+1<s.length&&Kn(s,e)}function ym(s,e){return Kn(s,e)&&4<=s.length-e}function bu(s,e){if(e+1<s.length&&Kn(s,e)){const i=_u(s,e);let r=4;i!=null&&i.frameLength&&(r=i.frameLength);const n=e+r;return n===s.length||Au(s,n)}return!1}class Em extends Gn{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=$i(e,0);let r=i?.length||0;if(bu(e,r))return!1;for(let n=e.length;r<n;r++)if(Jg(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Qg(e,t)}appendFrame(e,t,i){pu(e,this.observer,t,i,e.manifestCodec);const r=yu(e,t,i,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const xu=(s,e)=>{let t=0,i=5;e+=i;const r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];const o=Math.min(i,8),u=8-o;n[0]=4278190080>>>24+u<<u,r[0]=(a[0]&n[0])>>u,t=t?t<<o|r[0]:r[0],e+=1,i-=o}return t};class Tm extends Gn{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const r=Iu(e,t,i,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=$i(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&$n(t)!==void 0&&xu(e,i)<16}}function Iu(s,e,t,i,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],u=e[t+4]&63,d=[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][u*3+n]*2;if(t+d>e.length)return-1;const c=e[t+6]>>5;let h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,m=e[t+5]>>3,y=e[t+5]&7,T=new Uint8Array([n<<6|m<<1|y>>2,(y&3)<<6|c<<3|f<<2|u>>4,u<<4&224]),E=1536/o*9e4,S=i+r*E,_=e.subarray(t,t+d);return s.config=T,s.channelCount=p,s.samplerate=o,s.samples.push({unit:_,pts:S}),d}class Sm extends Gn{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=$i(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&$n(t)!==void 0&&xu(e,i)<=16)return!1;for(let r=e.length;i<r;i++)if(bu(e,i))return ue.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return ym(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return Su(e,t,i,this.basePTS,this.frameIndex)}}const _m=/\/emsg[-/]ID3/i;class Am{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,i,r){const n=this.videoTrack=ft("video",1),a=this.audioTrack=ft("audio",1),o=this.txtTrack=ft("text",1);if(this.id3Track=ft("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const u=Nl(e);if(u.video){const{id:l,timescale:d,codec:c,supplemental:h}=u.video;n.id=l,n.timescale=o.timescale=d,n.codec=c,n.supplemental=h}if(u.audio){const{id:l,timescale:d,codec:c}=u.audio;a.id=l,a.timescale=d,a.codec=c}o.id=Pl.text,n.sampleDuration=0,n.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return Tf(e)}demux(e,t){this.timeOffset=t;let i=e;const r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Je(this.remainderData,e));const o=Rf(i);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=i;const a=this.extractID3Track(r,t);return n.samples=ba(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return i.samples=ba(e,t),{videoTrack:t,audioTrack:ft(),id3Track:r,textTrack:ft()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const r=te(e.samples,["emsg"]);r&&r.forEach(n=>{const a=Df(n);if(_m.test(a.schemeIdUri)){const o=oo(a,t);let u=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);const l=a.payload;i.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:qe.emsg,duration:u})}else if(this.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=oo(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:o,pts:o,type:qe.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function oo(s,e){return $(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}class bm{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new wn(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Ft.cbc)}decryptAacSample(e,t,i){const r=e[t].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const u=new Uint8Array(o);r.set(u,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)i.set(e.subarray(n,n+16),r);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(i.subarray(r,r+16),n);return e}decryptAvcSample(e,t,i,r,n){const a=Bl(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(u=>{n.data=this.getAvcDecryptedUnit(a,u),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,r)}).catch(r)}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){r();return}const n=e[t].units;for(;!(i>=n.length);i++){const a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,r,a),!this.decrypter.isSync()))return}}}}class Ru{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const n=i.units;r=n[n.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,r=i.length;if(r){const n=i[r-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const r=t.byteLength;let n=e.naluState||0;const a=n,o=[];let u=0,l,d,c,h=-1,f=0;for(n===-1&&(h=0,f=this.getNALuType(t,0),n=0,u=1);u<r;){if(l=t[u++],!n){n=l?0:1;continue}if(n===1){n=l?0:2;continue}if(!l)n=3;else if(l===1){if(d=u-n-1,h>=0){const g={data:t.subarray(h,d),type:f};o.push(g)}else{const g=this.getLastNalUnit(e.samples);g&&(a&&u<=4-a&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-a)),d>0&&(g.data=Je(g.data,t.subarray(0,d)),g.state=0))}u<r?(c=this.getNALuType(t,u),h=u,f=c,n=0):n=-1}else n=0}if(h>=0&&n>=0){const g={data:t.subarray(h,r),type:f,state:n};o.push(g)}if(o.length===0){const g=this.getLastNalUnit(e.samples);g&&(g.data=Je(g.data,t))}return e.naluState=n,o}}class wi{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(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(i,i+n)),this.word=new DataView(r.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>
vendor: 4,191 bytes, line 37
37e?(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);const i=this.word>>>32-t;if(e>32&&ue.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?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const 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)}}class xm extends Ru{parsePES(e,t,i,r){const n=this.parseNALu(e,i.data,r);let a=this.VideoSample,o,u=!1;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.forEach(l=>{var d,c;switch(l.type){case 1:{let p=!1;o=!0;const m=l.data;if(u&&m.length>4){const y=this.readSliceType(m);(y===2||y===4||y===7||y===9)&&(p=!0)}if(p){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.frame=!0,a.key=p;break}case 5:o=!0,(d=a)!=null&&d.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 6:{o=!0,Ln(l.data,1,i.pts,t.samples);break}case 7:{var f,g;o=!0,u=!0;const p=l.data,m=this.readSPS(p);if(!e.sps||e.width!==m.width||e.height!==m.height||((f=e.pixelRatio)==null?void 0:f[0])!==m.pixelRatio[0]||((g=e.pixelRatio)==null?void 0:g[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[p];const y=p.subarray(1,4);let T="avc1.";for(let E=0;E<3;E++){let S=y[E].toString(16);S.length<2&&(S="0"+S),T+=S}e.codec=T}break}case 8:o=!0,e.pps=[l.data];break;case 9:o=!0,e.audFound=!0,(c=a)!=null&&c.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1;break}a&&o&&a.units.push(l)}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new wi(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8,n;for(let a=0;a<e;a++)r!==0&&(n=t.readEG(),r=(i+n+256)%256),i=r===0?i:r}readSPS(e){const t=new wi(e);let i=0,r=0,n=0,a=0,o,u,l;const d=t.readUByte.bind(t),c=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),g=t.skipBits.bind(t),p=t.skipEG.bind(t),m=t.skipUEG.bind(t),y=this.skipScalingList.bind(this);d();const T=d();if(c(5),g(3),d(),m(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){const I=h();if(I===3&&g(1),m(),m(),g(1),f())for(u=I!==3?8:12,l=0;l<u;l++)f()&&(l<6?y(16,t):y(64,t))}m();const E=h();if(E===0)h();else if(E===1)for(g(1),p(),p(),o=h(),l=0;l<o;l++)p();m(),g(1);const S=h(),_=h(),x=c(1);x===0&&g(1),g(1),f()&&(i=h(),r=h(),n=h(),a=h());let A=[1,1];if(f()&&f())switch(d()){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=[d()<<8|d(),d()<<8|d()];break}}return{width:Math.ceil((S+1)*16-i*2-r*2),height:(2-x)*(_+1)*16-(x?2:4)*(n+a),pixelRatio:A}}}class Im extends Ru{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,r){const n=this.parseNALu(e,i.data,r);let a=this.VideoSample,o,u=!1;i.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.forEac
vendor: 15,933 bytes, line 37
37h(l=>{var d,c;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),a.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,u){var h;(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:o=!0,(d=a)!=null&&d.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0,a.frame=!0;break;case 39:o=!0,Ln(l.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=ce(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=!0,u=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const f=this.readSPS(l.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const g in f.params)e.params[g]=f.params[g]}this.pushParameterSet(e.sps,l.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),a.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const f=this.readPPS(l.data);for(const g in f)e.params[g]=f[g]}this.pushParameterSet(e.pps,l.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(c=a)!=null&&c.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:o=!1;break}a&&o&&a.units.push(l)}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new wi(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),r=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:r}}readSPS(e){const t=new wi(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=t.readUByte(),h=t.readUByte(),f=t.readUByte(),g=t.readUByte(),p=t.readUByte(),m=t.readUByte(),y=t.readUByte(),T=[],E=[];for(let oe=0;oe<i;oe++)T.push(t.readBoolean()),E.push(t.readBoolean());if(i>0)for(let oe=i;oe<8;oe++)t.readBits(2);for(let oe=0;oe<i;oe++)T[oe]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),E[oe]&&t.readUByte();t.readUEG();const S=t.readUEG();S==3&&t.skipBits(1);const _=t.readUEG(),x=t.readUEG(),A=t.readBoolean();let I=0,R=0,b=0,k=0;A&&(I+=t.readUEG(),R+=t.readUEG(),b+=t.readUEG(),k+=t.readUEG());const M=t.readUEG(),G=t.readUEG(),q=t.readUEG(),U=t.readBoolean();for(let oe=U?0:i;oe<=i;oe++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let Me=0;Me<4;Me++)for(let ze=0;ze<(Me===3?2:6);ze++)if(!t.readBoolean())t.readUEG();else{const et=Math.min(64,1<<4+(Me<<1));Me>1&&t.readEG();for(let Zt=0;Zt<et;Zt++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const B=t.readUEG();let Y=0;for(let oe=0;oe<B;oe++){let Me=!1;if(oe!==0&&(Me=t.readBoolean()),Me){oe===B&&t.readUEG(),t.readBoolean(),t.readUEG();let ze=0;for(let Bt=0;Bt<=Y;Bt++){const et=t.readBoolean();let Zt=!1;et||(Zt=t.readBoolean()),(et||Zt)&&ze++}Y=ze}else{const ze=t.readUEG(),Bt=t.readUEG();Y=ze+Bt;for(let et=0;et<ze;et++)t.readUEG(),t.readBoolean();for(let et=0;et<Bt;et++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const oe=t.readUEG();for(let Me=0;Me<oe;Me++){for(let ze=0;ze<q+4;ze++)t.readBits(1);t.readBits(1)}}let O=0,N=1,Z=1,ae=!0,ee=1,re=0;t.readBoolean(),t.readBoolean();let Oe=!1;if(t.readBoolean()){if(t.readBoolean()){const $t=t.readUByte(),oa=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Hi=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];$t>0&&$t<16?(N=oa[$t-1],Z=Hi[$t-1]):$t===255&&(N=t.readBits(16),Z=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),Oe=t.readBoolean(),Oe&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(ee=t.readBits(32),re=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Hi=t.readBoolean(),la=t.readBoolean();let vi=!1;(Hi||la)&&(vi=t.readBoolean(),vi&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),vi&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let ua=0;ua<=i;ua++){ae=t.readBoolean();const Kd=ae||t.readBoolean();let da=!1;Kd?t.readEG():da=t.readBoolean();const ca=da?1:t.readUEG()+1;if(Hi)for(let yi=0;yi<ca;yi++)t.readUEG(),t.readUEG(),vi&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(la)for(let yi=0;yi<ca;yi++)t.readUEG(),t.readUEG(),vi&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),O=t.readUEG())}let je=_,lt=x;if(A){let oe=1,Me=1;S===1?oe=Me=2:S==2&&(oe=2),je=_-oe*R-oe*I,lt=x-Me*k-Me*b}const Ut=r?["A","B","C"][r]:"",Gd=o<<24|u<<16|l<<8|d;let er=0;for(let oe=0;oe<32;oe++)er=(er|(Gd>>oe&1)<<31-oe)>>>0;let tr=er.toString(16);return a===1&&tr==="2"&&(tr="6"),{codecString:`hvc1.${Ut}${a}.${tr}.${n?"H":"L"}${y}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[o,u,l,d],general_constraint_indicator_flags:[c,h,f,g,p,m],general_level_idc:y,bit_depth:M+8,bit_depth_luma_minus8:M,bit_depth_chroma_minus8:G,min_spatial_segmentation_idc:O,chroma_format_idc:S,frame_rate:{fixed:ae,fps:re/ee}},width:je,height:lt,pixelRatio:[N,Z]}}readPPS(e){const t=new wi(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),n=t.readBoolean();let a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const Le=188;class wt{constructor(e,t,i,r){this.logger=void 0,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._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=i,this.logger=r,this.videoParser=null}static probe(e,t){const i=wt.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(Le*5,t-Le)+1,r=0;for(;r<i;){let n=!1,a=-1,o=0;for(let u=r;u<t;u+=Le)if(e[u]===71&&(t-u===Le||e[u+Le]===71)){if(o++,a===-1&&(a=u,a!==0&&(i=Math.min(a+Le*99,e.length-Le)+1)),n||(n=zr(e,u)===0),n&&o>1&&(a===0&&o>2||u+Le>i))return a}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Pl[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=wt.createTrack("video"),this._videoTrack.duration=r,this._audioTrack=wt.createTrack("audio",r),this._id3Track=wt.createTrack("id3"),this._txtTrack=wt.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,r=!1){i||(this.sampleAes=null);let n;const a=this._videoTrack,o=this._audioTrack,u=this._id3Track,l=this._txtTrack;let d=a.pid,c=a.pesData,h=o.pid,f=u.pid,g=o.pesData,p=u.pesData,m=null,y=this.pmtParsed,T=this._pmtId,E=e.length;if(this.remainderData&&(e=Je(this.remainderData,e),E=e.length,this.remainderData=null),E<Le&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:u,textTrack:l};const S=Math.max(0,wt.syncOffset(e));E-=(E-S)%Le,E<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,E,e.buffer.byteLength-E));let _=0;for(let A=S;A<E;A+=Le)if(e[A]===71){const I=!!(e[A+1]&64),R=zr(e,A),b=(e[A+3]&48)>>4;let k;if(b>1){if(k=A+5+e[A+4],k===A+Le)continue}else k=A+4;switch(R){case d:I&&(c&&(n=ii(c,this.logger))&&(this.readyVideoParser(a.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(a,l,n,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(k,A+Le)),c.size+=A+Le-k);break;case h:if(I){if(g&&(n=ii(g,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(k,A+Le)),g.size+=A+Le-k);break;case f:I&&(p&&(n=ii(p,this.logger))&&this.parseID3PES(u,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(k,A+Le)),p.size+=A+Le-k);break;case 0:I&&(k+=e[k]+1),T=this._pmtId=Rm(e,k);break;case T:{I&&(k+=e[k]+1);const M=Lm(e,k,this.typeSupported,i,this.observer,this.logger);d=M.videoPid,d>0&&(a.pid=d,a.segmentCodec=M.segmentVideoCodec),h=M.audioPid,h>0&&(o.pid=h,o.segmentCodec=M.segmentAudioCodec),f=M.id3Pid,f>0&&(u.pid=f),m!==null&&!y&&(this.logger.warn(`MPEG-TS PMT found at ${A} after unknown PID '${m}'. Backtracking to sync byte @${S} to parse all TS packets.`),m=null,A=S-188),y=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=R;break}}else _++;_>0&&Xr(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`),void 0,this.logger),a.pesData=c,o.pesData=g,u.pesData=p;const x={audioTrack:o,videoTrack:a,id3Track:u,textTrack:l};return r&&this.extractRemainingSamples(x),x}flush(){const{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){const{audioTrack:t,videoTrack:i,id3Track:r,textTrack:n}=e,a=i.pesData,o=t.pesData,u=r.pesData;let l;if(a&&(l=ii(a,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,n,l,!0),i.pesData=null)):i.pesData=a,o&&(l=ii(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;u&&(l=ii(u,this.logger))?(this.parseID3PES(r,l),r.pesData=null):r.pesData=u}demuxSampleAes(e,t,i){const r=this.demux(e,i,!0,!this.config.progressive),n=this.sampleAes=new bm(this.observer,this.config,t);return this.decrypt(r,n)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new xm:e==="hevc"&&(this.videoParser=new Im))}decrypt(e,t){return new Promise(i=>{const{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let i=0;const r=this.aacOverFlow;let n=t.data;if(r){this.aacOverFlow=null;const c=r.missing,h=r.sample.unit.byteLength;if(c===-1)n=Je(r.sample.unit,n);else{const f=h-c;r.sample.unit.set(n.subarray(0,c),f),e.samples.push(r.sample),i=r.missing}}let a,o;for(a=i,o=n.length;a<o-1&&!Ks(n,a);a++);if(a!==i){let c;const 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",Xr(this.observer,new Error(c),h,this.logger),!h)return}pu(e,this.observer,n,a,this.audioCodec);let u;if(t.pts!==void 0)u=t.pts;else if(r){const c=vu(e.samplerate);u=r.sample.pts+c}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,d;for(;a<o;)if(d=yu(e,n,a,u,l),a+=d.length,d.missing){this.aacOverFlow=d;break}else for(l++;a<o-1&&!Ks(n,a);a++);}parseMPEGPES(e,t){const i=t.data,r=i.length;let n=0,a=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Au(i,a)){const u=Su(e,i,a,o,n);if(u)a+=u.length,n++;else break}else a++}parseAC3PES(e,t){{const i=t.data,r=t.pts;if(r===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=i.length;let a=0,o=0,u;for(;o<n&&(u=Iu(e,i,o,r,a++))>0;)o+=u}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ce({},t,{type:this._videoTrack?qe.emsg:qe.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function zr(s,e){return((s[e+1]&31)<<8)+s[e+2]}function Rm(s,e){return(s[e+10]&31)<<8|s[e+11]}function Lm(s,e,t,i,r,n){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(s[e+1]&15)<<8|s[e+2],u=e+3+o-4,l=(s[e+10]&15)<<8|s[e+11];for(e+=12+l;e<u;){const d=zr(s,e),c=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){pr("ADTS AAC",n);break}case 15:a.audioPid===-1&&(a.audioPid=d);break;case 21:a.id3Pid===-1&&(a.id3Pid=d);break;case 219:if(!i){pr("H.264",n);break}case 27:a.videoPid===-1&&(a.videoPid=d);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):a.audioPid===-1&&(a.audioPid=d,a.segmentAudioCodec="mp3");break;case 193:if(!i){pr("AC-3",n);break}case 129:t.ac3?a.audioPid===-1&&(a.audioPid=d,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(a.audioPid===-1&&c>0){let h=e+5,f=c;for(;f>2;){switch(s[h]){case 106:t.ac3!==!0?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=d,a.segmentAudioCodec="ac3");break}const p=s[h+1]+2;h+=p,f-=p}}break;case 194:case 135:return Xr(r,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:a.videoPid===-1&&(a.videoPid=d,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=c+5}return a}function Xr(s,e,t,i){i.warn(`parsing error: ${e.message}`),s.emit(v.ERROR,v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function pr(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function ii(s,e){let t=0,i,r,n,a,o;const u=s.data;if(!s||s.size===0)return null;for(;u[0].length<19&&u.length>1;)u[0]=Je(u[0],u[1]),u.splice(1,1);if(i=u[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>s.size-6)return null;const d=i[7];d&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,d&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let c=n+9;if(s.size<=c)return null;s.size-=c;const h=new Uint8Array(s.size);for(let f=0,g=u.length;f<g;
vendor: 6,594 bytes, line 37
37f++){i=u[f];let p=i.byteLength;if(c)if(c>p){c-=p;continue}else i=i.subarray(c),p-=c,c=0;h.set(i,t),t+=p}return r&&(r-=n+3),{data:h,pts:a,dts:o,len:r}}return null}class Dm{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}}}const Rt=Math.pow(2,32)-1;class L{static init(){L.types={avc1:[],avcC:[],hvc1:[],hvcC:[],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 L.types)L.types.hasOwnProperty(e)&&(L.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const 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]),i=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]);L.HDLR_TYPES={video:t,audio:i};const r=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]);L.STTS=L.STSC=L.STCO=n,L.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),L.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),L.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),L.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);L.FTYP=L.box(L.types.ftyp,a,u,a,o),L.DINF=L.box(L.types.dinf,L.box(L.types.dref,r))}static box(e,...t){let i=8,r=t.length;const n=r;for(;r--;)i+=t[r].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(e,4),r=0,i=8;r<n;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return L.box(L.types.hdlr,L.HDLR_TYPES[e])}static mdat(e){return L.box(L.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Rt+1)),r=Math.floor(t%(Rt+1));return L.box(L.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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return L.box(L.types.mdia,L.mdhd(e.timescale||0,e.duration||0),L.hdlr(e.type),L.minf(e))}static mfhd(e){return L.box(L.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"?L.box(L.types.minf,L.box(L.types.smhd,L.SMHD),L.DINF,L.stbl(e)):L.box(L.types.minf,L.box(L.types.vmhd,L.VMHD),L.DINF,L.stbl(e))}static moof(e,t,i){return L.box(L.types.moof,L.mfhd(e),L.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=L.trak(e[t]);return L.box.apply(null,[L.types.moov,L.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(L.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=L.trex(e[t]);return L.box.apply(null,[L.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Rt+1)),r=Math.floor(t%(Rt+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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&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 L.box(L.types.mvhd,n)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return L.box(L.types.sdtp,i)}static stbl(e){return L.box(L.types.stbl,L.stsd(e),L.box(L.types.stts,L.STTS),L.box(L.types.stsc,L.STSC),L.box(L.types.stsz,L.STSZ),L.box(L.types.stco,L.STCO))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));const o=L.box(L.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),u=e.width,l=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return L.box(L.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,u>>8&255,u&255,l>>8&255,l&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,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return L.box(L.types.mp4a,L.audioStsd(e),L.box(L.types.esds,L.esds(e)))}static mp3(e){return L.box(L.types[".mp3"],L.audioStsd(e))}static ac3(e){return L.box(L.types["ac-3"],L.audioStsd(e),L.box(L.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return L.box(L.types.stsd,L.STSD,L.mp4a(e));if(t==="ac3"&&e.config)return L.box(L.types.stsd,L.STSD,L.ac3(e));if(t==="mp3"&&e.codec==="mp3")return L.box(L.types.stsd,L.STSD,L.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return L.box(L.types.stsd,L.STSD,L.avc1(e));if(t==="hevc"&&e.vps)return L.box(L.types.stsd,L.STSD,L.hvc1(e))}
vendor: 23,982 bytes, line 37
37else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,n=e.height||0,a=Math.floor(i/(Rt+1)),o=Math.floor(i%(Rt+1));return L.box(L.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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const i=L.sdtp(e),r=e.id,n=Math.floor(t/(Rt+1)),a=Math.floor(t%(Rt+1));return L.box(L.types.traf,L.box(L.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),L.box(L.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])),L.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,L.box(L.types.trak,L.tkhd(e),L.mdia(e))}static trex(e){const t=e.id;return L.box(L.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){const i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n);let o,u,l,d,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)u=i[o],l=u.duration,d=u.size,c=u.flags,h=u.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,d>>>24&255,d>>>16&255,d>>>8&255,d&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 L.box(L.types.trun,a)}static initSegment(e){L.types||L.init();const t=L.moov(e);return Je(L.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],r=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let a=n.length;for(let g=0;g<i.length;g+=1){a+=3;for(let p=0;p<i[g].length;p+=1)a+=2+i[g][p].length}const o=new Uint8Array(a);o.set(n,0),a=n.length;const u=i.length-1;for(let g=0;g<i.length;g+=1){o.set(new Uint8Array([32+g|(g===u?128:0),0,i[g].length]),a),a+=3;for(let p=0;p<i[g].length;p+=1)o.set(new Uint8Array([i[g][p].length>>8,i[g][p].length&255]),a),a+=2,o.set(i[g][p],a),a+=i[g][p].length}const l=L.box(L.types.hvcC,o),d=e.width,c=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return L.box(L.types.hvc1,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,d>>8&255,d&255,c>>8&255,c&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]),l,L.box(L.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),L.box(L.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}}L.types=void 0;L.HDLR_TYPES=void 0;L.STTS=void 0;L.STSC=void 0;L.STCO=void 0;L.STSZ=void 0;L.VMHD=void 0;L.SMHD=void 0;L.STSD=void 0;L.FTYP=void 0;L.DINF=void 0;const Lu=9e4;function Vn(s,e,t=1,i=!1){const r=s*e*t;return i?Math.round(r):r}function km(s,e,t=1,i=!1){return Vn(s,e,1/t,i)}function Si(s,e=!1){return Vn(s,1e3,1/Lu,e)}function Cm(s,e=1){return Vn(s,Lu,1/e)}function lo(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const wm=10*1e3,Pm=1024,Om=1152,Mm=1536;let si=null,vr=null;function uo(s,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1}}}class fs extends Ze{constructor(e,t,i,r){if(super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,si===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);si=a?parseInt(a[1]):0}if(vr===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);vr=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&lo(t)} > ${e&&lo(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,r=e.reduce((n,a)=>{let o=a.pts,u=o-n;return u<-4294967296&&(t=!0,o=He(o,i),u=o-n),u>0?n:o},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,n,a,o,u){let l,d,c,h,f,g,p=n,m=n;const y=e.pid>-1,T=t.pid>-1,E=t.samples.length,S=e.samples.length>0,_=o&&E>0||E>1;if((!y||S)&&(!T||_)||this.ISGenerated||o){if(this.ISGenerated){var A,I,R,b;const q=this.videoTrackConfig;(q&&(t.width!==q.width||t.height!==q.height||((A=t.pixelRatio)==null?void 0:A[0])!==((I=q.pixelRatio)==null?void 0:I[0])||((R=t.pixelRatio)==null?void 0:R[1])!==((b=q.pixelRatio)==null?void 0:b[1]))||!q&&_||this.nextAudioTs===null&&S)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,n,a));const k=this.isVideoContiguous;let M=-1,G;if(_&&(M=Nm(t.samples),!k&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,M>0){this.warn(`Dropped ${M} out of ${E} video samples due to a missing keyframe`);const q=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(M),t.dropped+=M,m+=(t.samples[0].pts-q)/t.inputTimeScale,G=m}else M===-1&&(this.warn(`No keyframe found out of ${E} video samples`),g=!1);if(this.ISGenerated){if(S&&_){const q=this.getVideoStartPts(t.samples),P=(He(e.samples[0].pts,q)-q)/t.inputTimeScale;p+=Math.max(0,P),m+=Math.max(0,-P)}if(S){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),d=this.remuxAudio(e,p,this.isAudioContiguous,a,T||_||u===H.AUDIO?m:void 0),_){const q=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,m,k,q)}}else _&&(l=this.remuxVideo(t,m,k,0));l&&(l.firstKeyFrame=M,l.independent=M!==-1,l.firstKeyFramePTS=G)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Du(i,n,this._initPTS,this._initDTS)),r.samples.length&&(h=ku(r,n,this._initPTS))),{audio:d,video:l,initSegment:c,independent:g,text:h,id3:f}}computeInitPts(e,t,i,r){const n=Math.round(i*t);let a=He(e,n);if(a<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-a)/t} ${r}`);a<n+t;)a+=8589934592;return a-n}generateIS(e,t,i,r){const n=e.samples,a=t.samples,o=this.typeSupported,u={},l=this._initPTS;let d=!l||r,c="audio/mp4",h,f,g,p=-1;if(d&&(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}u.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):L.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(p=e.id,g=e.inputTimeScale,!l||g!==l.timescale?h=f=this.computeInitPts(n[0].pts,g,i,"audio"):d=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:L.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(p=t.id,g=t.inputTimeScale,!l||g!==l.timescale){const m=this.getVideoStartPts(a),y=He(a[0].dts,m),T=this.computeInitPts(y,g,i,"video"),E=this.computeInitPts(m,g,i,"video");f=Math.min(f,T),h=Math.min(h,E)}else d=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(u).length)return this.ISGenerated=!0,d?(l&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${h/g} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${h/g} (${h}/${g}) trackId: ${p}`),this._initPTS={baseTime:h,timescale:g,trackId:p},this._initDTS={baseTime:f,timescale:g,trackId:p}):h=g=void 0,{tracks:u,initPTS:h,timescale:g,trackId:p}}remuxVideo(e,t,i,r){const n=e.inputTimeScale,a=e.samples,o=[],u=a.length,l=this._initPTS,d=l.baseTime*n/l.timescale;let c=this.nextVideoTs,h=8,f=this.videoSampleDuration,g,p,m=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,T=!1;if(!i||c===null){const O=d+t*n,N=a[0].pts-He(a[0].dts,a[0].pts);si&&c!==null&&Math.abs(O-N-(c+d))<15e3?i=!0:c=O-N-d}const E=c+d;for(let O=0;O<u;O++){const N=a[O];N.pts=He(N.pts,E),N.dts=He(N.dts,E),N.dts<a[O>0?O-1:O].dts&&(T=!0)}T&&a.sort(function(O,N){const Z=O.dts-N.dts,ae=O.pts-N.pts;return Z||ae}),g=a[0].dts,p=a[a.length-1].dts;const S=p-g,_=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(i){const O=g-E,N=O>_,Z=O<-1;if((N||Z)&&(N?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Si(O,!0)} ms (${O}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Si(-O,!0)} ms (${O}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!Z||E>=a[0].pts||si)){g=E;const ae=a[0].pts-O;if(N)a[0].dts=g,a[0].pts=ae;else{let ee=!0;for(let re=0;re<a.length&&!(a[re].dts>ae&&ee);re++){const Oe=a[re].pts;if(a[re].dts-=O,a[re].pts-=O,re<a.length-1){const ke=a[re+1].pts,je=a[re].pts,lt=ke<=je,Ut=ke<=Oe;ee=lt==Ut}}}this.log(`Video: Initial PTS/DTS adjusted: ${Si(ae,!0)}/${Si(g,!0)}, delta: ${Si(O,!0)} ms`)}}g=Math.max(0,g);let x=0,A=0,I=g;for(let O=0;O<u;O++){const N=a[O],Z=N.units,ae=Z.length;let ee=0;for(let re=0;re<ae;re++)ee+=Z[re].data.length;A+=ee,x+=ae,N.length=ee,N.dts<I?(N.dts=I,I+=_/4|0||1):I=N.dts,m=Math.min(N.pts,m),y=Math.max(N.pts,y)}p=a[u-1].dts;const R=A+4*x+8;let b;try{b=new Uint8Array(R)}catch(O){this.observer.emit(v.ERROR,v.ERROR,{type:W.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:O,bytes:R,reason:`fail allocating video mdat ${R}`});return}const k=new DataView(b.buffer);k.setUint32(0,R),b.set(L.types.mdat,4);let M=!1,G=Number.POSITIVE_INFINITY,q=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,P=Number.NEGATIVE_INFINITY;for(let O=0;O<u;O++){const N=a[O],Z=N.units;let ae=0;for(let Oe=0,ke=Z.length;Oe<ke;Oe++){const je=Z[Oe],lt=je.data,Ut=je.data.byteLength;k.setUint32(h,Ut),h+=4,b.set(lt,h),h+=Ut,ae+=4+Ut}let ee;if(O<u-1)f=a[O+1].dts-N.dts,ee=a[O+1].pts-N.pts;else{const Oe=this.config,ke=O>0?N.dts-a[O-1].dts:_;if(ee=O>0?N.pts-a[O-1].pts:_,Oe.stretchShortVideoTrack&&this.nextAudioTs!==null){const je=Math.floor(Oe.maxBufferHole*n),lt=(r?m+r*n:this.nextAudioTs+d)-N.pts;lt>je?(f=lt-ke,f<0?f=ke:M=!0,this.log(`It is approximately ${lt/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=ke}else f=ke}const re=Math.round(N.pts-N.dts);G=Math.min(G,f),U=Math.max(U,f),q=Math.min(q,ee),P=Math.max(P,ee),o.push(uo(N.key,f,ae,re))}if(o.length){if(si){if(si<70){const O=o[0].flags;O.dependsOn=2,O.isNonSync=0}}else if(vr&&P-q<U-G&&_/U<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let O=g;for(let N=0,Z=o.length;N<Z;N++){const ae=O+o[N].duration,ee=O+o[N].cts;if(N<Z-1){const re=ae+o[N+1].cts;o[N].duration=re-ee}else o[N].duration=N?o[N-1].duration:_;o[N].cts=0,O=ae}}}f=M||!f?_:f;const K=p+f;this.nextVideoTs=c=K-d,this.videoSampleDuration=f,this.isVideoContiguous=!0;const z={data1:L.moof(e.sequenceNumber++,g,ce(e,{samples:o})),data2:b,startPTS:(m-d)/n,endPTS:(y+f-d)/n,startDTS:(g-d)/n,endDTS:c/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,z}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Om;case"ac3":return Mm;default:return Pm}}remuxAudio(e,t,i,r,n){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,u=a/o,l=this.getSamplesPerFrame(e),d=l*u,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=n!==void 0;let p=e.samples,m=h?0:8,y=this.nextAudioTs||-1;const T=c.baseTime*a/c.timescale,E=T+t*a;if(this.isAudioContiguous=i=i||p.length&&y>0&&(r&&Math.abs(E-(y+T))<9e3||Math.abs(He(p[0].pts,E)-(y+T))<20*d),p.forEach(function(P){P.pts=He(P.pts,E)}),!i||y<0){const P=p.length;if(p=p.filter(K=>K.pts>=0),P!==p.length&&this.warn(`Removed ${p.length-P} of ${P} samples (initPTS ${T} / ${a})`),!p.length)return;n===0?y=0:r&&!g?y=Math.max(0,E-T):y=p[0].pts-T}if(e.segmentCodec==="aac"){const P=this.config.maxAudioFramesDrift;for(let K=0,B=y+T;K<p.length;K++){const Y=p[K],z=Y.pts,O=z-B,N=Math.abs(1e3*O/a);if(O<=-P*d&&g)K===0&&(this.warn(`Audio frame @ ${(z/a).toFixed(3)}s overlaps marker by ${Math.round(1e3*O/a)} ms.`),this.nextAudioTs=y=z-T,B=z);else if(O>=P*d&&N<wm&&g){let Z=Math.round(O/d);for(B=z-Z*d;B<0&&Z&&d;)Z--,B+=d;K===0&&(this.nextAudioTs=y=B-T),this.warn(`Injecting ${Z} audio frames @ ${((B-T)/a).toFixed(3)}s due to ${Math.round(1e3*O/a)} ms gap.`);for(let ae=0;ae<Z;ae++){let ee=Dm.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);ee||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),ee=Y.unit.subarray()),p.splice(K,0,{unit:ee,pts:B}),B+=d,K++}}Y.pts=B,B+=d}}let S=null,_=null,x,A=0,I=p.length;for(;I--;)A+=p[I].unit.byteLength;for(let P=0,K=p.length;P<K;P++){const B=p[P],Y=B.unit;let z=B.pts;if(_!==null){const N=f[P-1];N.duration=Math.round((z-_)/u)}else if(i&&e.segmentCodec==="aac"&&(z=y+T),S=z,A>0){A+=m;try{x=new Uint8Array(A)}catch(N){this.observer.emit(v.ERROR,v.ERROR,{type:W.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:N,bytes:A,reason:`fail allocating audio mdat ${A}`});return}h||(new DataView(x.buffer).setUint32(0,A),x.set(L.types.mdat,4))}else return;x.set(Y,m);const O=Y.byteLength;m+=O,f.push(uo(!0,l,O,0)),_=z}const R=f.length;if(!R)return;const b=f[f.length-1];y=_-T,this.nextAudioTs=y+u*b.duration;const k=h?new Uint8Array(0):L.moof(e.sequenceNumber++,S/u,ce({},e,{samples:f}));e.samples=[];const M=(S-T)/a,G=y/a,U={data1:k,data2:x,startPTS:M,endPTS:G,startDTS:M,endDTS:G,type:"audio",hasAudio:!0,hasVideo:!1,nb:R};return this.isAudioContiguous=!0,U}}function He(s,e){let t;if(e===null)return s;for(e<s?t=-8589934592:t=8589934592;Math.abs(s-e)>4294967296;)s+=t;return s}function Nm(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function Du(s,e,t,i){const r=s.samples.length;if(!r)return;const n=s.inputTimeScale;for(let o=0;o<r;o++){const u=s.samples[o];u.pts=He(u.pts-t.baseTime*n/t.timescale,e*n)/n,u.dts=He(u.dts-i.baseTime*n/i.timescale,e*n)/n}const a=s.samples;return s.samples=[],{samples:a}}function ku(s,e,t){const i=s.samples.length;if(!i)return;const r=s.inputTimeScale;for(let a=0;a<i;a++){const o=s.samples[a];o.pts=He(o.pts-t.baseTime*r/t.timescale,e*r)/r}s.samples.sort((a,o)=>a.pts-o.pts);const n=s.samples;return s.samples=[],{samples:n}}class Fm extends Ze{constructor(e,t,i,r){super("passthrough-remuxer",r),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,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,r),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:n,video:a}=this.initData=Nl(e);if(t)bf(e,t);else{const u=n||a;u!=null&&u.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${u.codec}")!`)}n&&(i=co(n,fe.AUDIO,this)),a&&(r=co(a,fe.VIDEO,this));const o={};n&&a?o.audiovideo={container:"video/mp4",codec:i+","+r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:n?o.audio={container:"audio/mp4",codec:i,encrypted:n.encrypted,initSegment:e,id:"audio"}:a?o.video={container:"video/mp4",codec:r,supplemental:a.supplemental,encrypted:a.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,r,n,a){var o,u;let{initPTS:l,lastEndTime:d}=this;const c={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};$(d)||(d=this.lastEndTime=n||0);const h=t.samples;if(!h.length)return c;const f={initPTS:void 0,timescale:void 0,trackId:void 0};let g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((u=g)!=null&&u.length))return this.warn("Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=If(h,g,this),m=g.audio?p[g.audio.id]:null,y=g.video?p[g.video.id]:null,T=Zi(y,1/0),E=Zi(m,1/0),S=Zi(y,0,!0),_=Zi(m,0,!0);let x=n,A=0;const I=m&&(!y||!l&&E<T||l&&l.trackId===g.audio.id),R=I?m:y;if(R){const B=R.timescale,Y=R.start-n*B,z=I?g.audio.id:g.video.id;x=R.start/B,A=I?_-E:S-T,(a||!l)&&(Um(l,x,n,A)||B!==l.timescale)&&(l&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${n} ${Y/B} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${x-n} (${Y}/${B}) trackId: ${z}`),l=null,f.initPTS=Y,f.timescale=B,f.trackId=z)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);l?(f.initPTS=l.baseTime,f.timescale=l.timescale,f.trackId=l.trackId):((!f.timescale||f.trackId===void 0||f.initPTS===void 0)&&(this.warn("Could not set initPTS"),f.initPTS=x,f.timescale=1,f.trackId=-1),this.initPTS=l={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});const b=x-l.baseTime/l.timescale,k=b+A;A>0?this.lastEndTime=k:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const M=!!g.audio,G=!!g.video;let q="";M&&(q+="audio"),G&&(q+="video");const U=(g.audio?g.audio.encrypted:!1)||(g.video?g.video.encrypted:!1),P={data1:h,startPTS:b,startDTS:b,endPTS:k,endDTS:k,type:q,hasAudio:M,hasVideo:G,nb:1,dropped:0,encrypted:U};c.audio=M&&!G?P:void 0,c.video=G?P:void 0;const K=y?.sampleCount;if(K){const B=y.keyFrameIndex,Y=B!==-1;P.nb=K,P.dropped=B===0||this.isVideoContiguous?0:Y?B:K,P.independent=Y,P.firstKeyFrame=B,Y&&y.keyFrameStart&&(P.firstKeyFramePTS=(y.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(c.independent=Y),this.isVideoContiguous||(this.isVideoContiguous=Y),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${B}/${K} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return c.initSegment=f,c.id3=Du(i,n,l,l),r.samples.length&&(c.text=ku(r,n,l)),c}}function Zi(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function Um(s,e,t,i){if(s===null)return!0;const r=Math.max(i,1),n=e-s.baseTime/s.timescale;return Math.abs(n-t)>r}function co(s,e,t){const i=s.codec;return i&&i.length>4?i:e===fe.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Os(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let _t;try{_t=self.performance.now.bind(self.performance)}catch{_t=Date.now}const gs=[{demux:Am,remux:Fm},{demux:wt,remux:fs},{demux:Em,remux:fs},{demux:Sm,remux:fs}];gs.splice(2,0,{demux:Tm,remux:fs});class ho{constructor(e,t,i,r,n,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=i,this.id=n,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,r){const n=i.transmuxing;n.executeStart=_t();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:u}=this;r&&(this.currentTransmuxState=r);const{contiguous:l,discontinuity:d,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=r||o,{audioCodec:p,videoCodec:m,defaultInitPts:y,duration:T,initSegmentData:E}=u,S=Bm(a,t);if(S&&ci(S.method)){const I=this.getDecrypter(),R=On(S.method);if(I.isSync()){let b=I.softwareDecrypt(a,S.key.buffer,S.iv.buffer,R);if(i.part>-1){const M=I.flush();b=M&&M.buffer}if(!b)return n.executeEnd=_t(),yr(i);a=new Uint8Array(b)}else return this.asyncResult=!0,this.decryptionPromise=I.webCryptoDecrypt(a,S.key.buffer,S.iv.buffer,R).then(b=>{const k=this.push(b,null,i);return this.decryptionPromise=null,k}),this.decryptionPromise}const _=this.needsProbing(d,c);if(_){const I=this.configureTransmuxer(a);if(I)return this.logger.warn(`[transmuxer] ${I.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),n.executeEnd=_t(),yr(i)}(d||c||g||_)&&this.resetInitSegment(E,p,m,T,t),(d||g||_)&&this.resetInitialTimestamp(y),l||this.resetContiguity();const x=this.transmux(a,S,f,h,i);this.asyncResult=Gi(x);const A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,n.executeEnd=_t(),x}flush(e){const t=e.transmuxing;t.executeStart=_t();const{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const a=[],{timeOffset:o}=r;if(i){const c=i.flush();c&&a.push(this.push(c.buffer,null,e))}const{demuxer:u,remuxer:l}=this;if(!u||!l){t.executeEnd=_t();const c=[yr(e)];return this.asyncResult?Promise.resolve(c):c}const d=u.flush(o);return Gi(d)?(this.asyncResult=!0,d.then(c=>(this.flushRemux(a,c,e),a))):(this.flushRemux(a,d,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:u,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===H.MAIN?"level":"track"} ${i.level}`);const d=this.remuxer.remux(r,n,a,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=_t()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,r,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,i,r),o.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,r,n):a=this.transmuxUnencrypted(e,i,r,n),a}transmuxUnencrypted(e,t,i,r){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:u}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,u,t,i,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,i,r,n){return this.demuxer.demuxSampleAes(e,t,i).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,!1,this.id),chunkMeta:n}))}
vendor: 3,934 bytes, line 37
37configureTransmuxer(e){const{config:t,observer:i,typeSupported:r}=this;let n;for(let c=0,h=gs.length;c<h;c++){var a;if((a=gs[c].demux)!=null&&a.probe(e,this.logger)){n=gs[c];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,u=this.remuxer,l=n.remux,d=n.demux;(!u||!(u instanceof l))&&(this.remuxer=new l(i,t,r,this.logger)),(!o||!(o instanceof d))&&(this.demuxer=new d(i,t,r,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new wn(this.config)),e}}function Bm(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const yr=s=>({remuxResult:{},chunkMeta:s});function Gi(s){return"then"in s&&s.then instanceof Function}class $m{constructor(e,t,i,r,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=i,this.duration=r,this.defaultInitPts=n||null}}class Gm{constructor(e,t,i,r,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=i,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=a}}let fo=0;class Cu{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=fo++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=u=>{const l=u.data,d=this.hls;if(!(!d||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case"init":{var c;const h=(c=this.workerContext)==null?void 0:c.objectURL;h&&self.URL.revokeObjectURL(h);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}case"workerLog":{d.logger[l.data.logType]&&d.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,d.trigger(l.event,l.data);break}}},this.onWorkerError=u=>{if(!this.hls)return;const l=new Error(`${u.message}  (${u.filename}:${u.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:l})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;const a=(u,l)=>{l=l||{},l.frag=this.frag||void 0,u===v.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(u,l)};this.observer=new Fn,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o=Ra(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const u=this.hls.logger;if(n.workerPath||qg()){try{n.workerPath?(u.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=Wg(n.workerPath)):(u.log(`injecting Web Worker for "${t}"`),this.workerContext=Yg());const{worker:d}=this.workerContext;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:ge(n)})}catch(d){u.warn(`Error setting up "${t}" Web Worker, fallback to inline`,d),this.terminateWorker(),this.error=null,this.transmuxer=new ho(this.observer,o,n,"",t,e.logger)}return}}this.transmuxer=new ho(this.observer,o,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=fo++;const t=this.hls.config,i=Ra(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,c
vendor: 19,894 bytes, lines 37-43
37onfig:ge(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),jg(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,r,n,a,o,u,l,d){var c,h;l.transmuxing.start=self.performance.now();const{instanceNo:f,transmuxer:g}=this,p=a?a.start:n.start,m=n.decryptdata,y=this.frag,T=!(y&&n.cc===y.cc),E=!(y&&l.level===y.level),S=y?l.sn-y.sn:-1,_=this.part?l.part-this.part.index:-1,x=S===0&&l.id>1&&l.id===y?.stats.chunkCount,A=!E&&(S===1||S===0&&(_===1||x&&_<=0)),I=self.performance.now();(E||S||n.stats.parsing.start===0)&&(n.stats.parsing.start=I),a&&(_||!A)&&(a.stats.parsing.start=I);const R=!(y&&((c=n.initSegment)==null?void 0:c.url)===((h=y.initSegment)==null?void 0:h.url)),b=new Gm(T,A,u,E,p,R);if(!A||T||R){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===H.MAIN?"level":"track"}: ${l.level} id: ${l.id}
38        discontinuity: ${T}
39        trackSwitch: ${E}
40        contiguous: ${A}
41        accurateTimeOffset: ${u}
42        timeOffset: ${p}
43        initSegmentChange: ${R}`);const k=new $m(i,r,t,o,d);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(g){const k=g.push(e,m,l,b);Gi(k)?k.then(M=>{this.handleTransmuxComplete(M)}).catch(M=>{this.transmuxerError(M,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(k)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const r=i.flush(e);Gi(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,i){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const go=100;class Km extends Nn{constructor(e,t,i){super(e,t,i,"audio-stream-controller",H.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!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.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){if(i===H.MAIN){const o=t.cc,u=this.fragCurrent;if(this.initPTS[o]={baseTime:r,timescale:n,trackId:a},this.log(`InitPTS for cc: ${o} found from main: ${r/n} (${r}/${n}) trackId: ${a}`),this.mainAnchor=t,this.state===C.WAITING_INIT_PTS){const l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==o)&&this.syncWithAnchor(t,l?.frag)}else!this.hls.hasEnoughToStart&&u&&u.cc!==o?(u.abortRequests(),this.syncWithAnchor(t,u)):this.state===C.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const r=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&r?.cc===t.cc)return;const n=(r||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),u=Wl(a,n,o);u&&(this.log(`Syncing with main frag at ${u.start} cc ${u.cc}`),this.startFragRequested=!1,this.nextLoadPosition=u.start,this.resetLoadingState(),this.state===C.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=C.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(go),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=C.IDLE):this.state=C.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case C.IDLE:this.doTickIdle();break;case C.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],r=i?.details;if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=C.WAITING_INIT_PTS}break}case C.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case C.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:r,complete:n}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=C.FRAG_LOADING;const o=r.flush().buffer,u={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(u),n&&super._handleFragmentLoadComplete(u)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=C.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:r,trackId:n}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;const o=i[n],u=o.details;if(!u||this.waitForLive(o)||this.waitForCdnTuneIn(u)){this.state=C.WAITING_TRACK,this.startFragRequested=!1;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,fe.AUDIO,H.AUDIO));const d=this.getFwdBufferInfo(l,H.AUDIO);if(d===null)return;if(!this.switchingTrack&&this._streamEnded(d,u)){t.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=C.ENDED;return}const c=d.len,h=t.maxBufferLength,f=u.fragments,g=f[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&r){const E=p;u.PTSKnown&&E<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(c>=h&&!this.switchingTrack&&m<f[f.length-1].start)return;let y=this.getNextFragment(m,u);if(y&&this.isLoopLoading(y,m)&&(y=this.getNextFragmentLoopLoading(y,u,d,H.MAIN,h)),!y){this.bufferFlushed=!0;return}let T=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&T&&Ae(y)&&!y.endList&&(!u.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(T)===Re.OK&&(this.mainFragLoading=T=null),T&&Ae(T))){if(y.start>T.end){const S=this.fragmentTracker.getFragAtPos(m,H.MAIN);S&&S.end>T.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(y.start>T.end)return}this.loadFragment(y,o,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Ui(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==C.STOPPED&&(this.setInterval(go),this.state=C.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(v.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:r}=this,{details:n,id:a,groupId:o,track:u}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${u.name}" of "${o}"`);return}const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==C.STOPPED&&(this.state=C.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${u.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const d=r[a];let c=0;if(n.live||(i=d.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(d.details){var h;c=this.alignPlaylists(n,d.details,(h=this.levelLastLoaded)==null?void 0:h.details)}n.alignedSliding||(cu(n,l),n.alignedSliding||Gs(n,l),c=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger(v.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===C.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=C.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:r,payload:n}=e,{config:a,trackId:o,levels:u}=this;if(!u){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const l=u[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}const d=l.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const c=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new Cu(this.hls,H.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],g=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){const m=r?r.index:-1,y=m!==-1,T=new Pn(i.level,i.sn,i.stats.chunkCount,n.byteLength,m,y);h.push(n,g,c,"",i,r,d.totalduration,!1,T,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new hu,complete:!1};p.push(new Uint8Array(n)),this.state!==C.STOPPED&&(this.state=C.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===H.MAIN&&Ae(t.frag)&&(this.mainFragLoading=t,this.state===C.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:r}=t;if(i.type!==H.AUDIO){!this.audioOnly&&i.type===H.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(Ae(i)){this.fragPrevious=i;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,le({},n)))}this.fragBufferedComplete(i,r),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ie.AUDIO_TRACK&&(this.state=C.IDLE);break;case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case D.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==fe.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==fe.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===C.ENDED&&(this.state=C.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,H.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:u,part:l,level:d}=o,{details:c}=d,{audio:h,text:f,id3:g,initSegment:p}=n;if(this.fragContextChanged(u)||!c){this.fragmentTracker.removeFragment(u);return}if(this.state=C.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const m=u.initSegment||u;if(this.unhandledEncryptionError(p,u))return;this._bufferInitSegment(d,p.tracks,m,a),r.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:p.tracks})}if(h){const{startPTS:m,endPTS:y,startDTS:T,endDTS:E}=h;l&&(l.elementaryStreams[fe.AUDIO]={startPTS:m,endPTS:y,startDTS:T,endDTS:E}),u.setElementaryStreamInfo(fe.AUDIO,m,y,T,E),this.bufferFragmentData(h,u,l,a)}if(g!=null&&(t=g.samples)!=null&&t.length){const m=ce({id:i,frag:u,details:c},g);r.trigger(v.FRAG_PARSING_METADATA,m)}if(f){const m=ce({id:i,frag:u,details:c},f);r.trigger(v.FRAG_PARSING_USERDATA,m)}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const n=t.audio;n.id=H.AUDIO;const 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(v.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const u={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,u)}this.tickImmediate()}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===Re.NOT_LOADED||r===Re.PARTIAL){var n;if(!Ae(e))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=C.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&Gs(t.details,a)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;Wt({name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e,Ht)||(Ns(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,le({},e))}}class Hn extends Ze{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,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.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){const o=r[a];let u;try{u=new self.URL(o.URI,t.url).href}catch(l){this.warn(`Could not construct new URL for Rendition Report: ${l}`),u=o.URI||""}if(u===e){n=a;break}else u===e.substring(0,u.length)&&(n=a)}if(n!==-1){const a=r[n],o=parseInt(a["LAST-MSN"])||t.lastPartSn;let u=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const d=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&d>t.partTarget&&(u+=1)}const l=i&&La(i);return new Da(o,u>=0?u:void 0,l)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;r.advancedDateTime=Date.now()-o;const u=this.hls.config.timelineOffset;if(u!==r.appliedTimelineOffset){const d=Math.max(u||0,0);r.appliedTimelineOffset=d,r.fragments.forEach(c=>{c.setStart(c.playlistOffset+d)})}if(r.live||i!=null&&i.live){const d="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){Og(i,r,this);const T=r.playlistParsingError;if(T){this.warn(T);const E=this.hls;if(!E.config.ignorePlaylistParsingErrors){var l;const{networkDetails:S}=t;E.trigger(v.ERROR,{type:W.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:T,reason:T.message,level:t.level||void 0,parent:(l=r.fragments[0])==null?void 0:l.type,networkDetails:S,stats:n});return}r.playlistParsingError=null}}r.requestScheduled===-1&&(r.requestScheduled=n.loading.start);const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(r.edge-h)*1e3,g=au(r,f);if(r.requestScheduled+g<a?r.requestScheduled=a:r.requestScheduled+=g,this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let p,m,y;if(r.canBlockReload&&r.endSN&&r.advanced){const T=this.hls.config.lowLatencyMode,E=r.lastPartSn,S=r.endSN,_=r.lastPartIndex,x=_!==-1,A=E===S;x?A?(m=S+1,y=T?0:_):(m=E,y=T?_+1:r.maxPartIndex):m=S+1;const I=r.age,R=I+r.ageHeader;let b=Math.min(R-r.partTarget,r.targetduration*1.5);if(b>0){if(R>r.targetduration*3)this.log(`Playlist last advanced ${I.toFixed(2)}s ago. Omitting segment and part directives.`),m=void 0,y=void 0;else if(i!=null&&i.tuneInGoal&&R-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${b} with playlist age: ${r.age}`),b=0;
vendor: 12,339 bytes, lines 43-46
43else{const k=Math.floor(b/r.targetduration);if(m+=k,y!==void 0){const M=Math.round(b%r.targetduration/r.partTarget);y+=M}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${I.toFixed(2)}s goal: ${b} skip sn ${k} to part ${y}`)}r.tuneInGoal=b}if(p=this.getDeliveryDirectives(r,t.deliveryDirectives,m,y),T||!A){r.requestScheduled=a,this.loadingPlaylist(d,p);return}}else(r.canBlockReload||r.canSkipUntil)&&(p=this.getDeliveryDirectives(r,t.deliveryDirectives,m,y));p&&m!==void 0&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(g-o*2,g/2)),this.scheduleLoading(d,p,r)}else this.clearTimer()}scheduleLoading(e,t,i){const r=i||e.details;if(!r){this.loadingPlaylist(e,t);return}const n=self.performance.now(),a=r.requestScheduled;if(n>=a){this.loadingPlaylist(e,t);return}const o=a-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,r){let n=La(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=cs.No),new Da(i,r,n)}checkRetry(e){const t=e.details,i=Fs(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},u=!!r&&!!o&&(n===we.RetryRequest||!r.resolved&&n===we.SendAlternateToPenaltyBox);if(u){var l;if(a>=o.maxNumRetry)return!1;if(i&&(l=e.context)!=null&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const d=Cn(o,a);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${d}ms`)}e.levelRetry=!0,r.resolved=!0}return u}}function wu(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Ki(s[t].attrs,e[t].attrs))return!1;return!0}function Ki(s,e,t){const i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>s[r]!==e[r])}function Qr(s,e){return e.label.toLowerCase()===s.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(s.lang||"").toLowerCase())}class Vm extends Hn{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(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.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){const{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Audio track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,r=this.groupIds;let n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(o=>r?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>!i||i.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;const u=this.hls.config.audioPreference;if(!n&&u){const h=gt(u,o,Ht);if(h>-1)n=o[h];else{const f=gt(u,this.tracks);n=this.tracks[f]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,d);const c=this.trackId;if(l!==-1&&c===-1)this.setAudioTrack(l);else if(o.length&&c===-1){var a;const 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(v.ERROR,{type:W.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}}onError(e,t){t.fatal||!t.context||t.context.type===ie.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-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){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const r=this.currentTrack;if(r&&Wt(e,r,Ht))return r;const n=gt(e,this.tracksInGroup,Ht);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=tg(e,t.levels,i,a,Ht);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=gt(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===i&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,le({},r)),n))return;const a=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const r=t[i];if(!(this.selectDefaultTrack&&!r.default)&&(!e||Wt(e,r,Ht)))return i}if(e){const{name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:u}=e;for(let l=0;l<t.length;l++){const d=t[l];if(Wt({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:u},d,Ht))return l}for(let l=0;l<t.length;l++){const d=t[l];if(Ki(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const d=t[l];if(Ki(e.attrs,d.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&Ns(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e})}}class Hm{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(n){var i;if(r.onError(n),this.queues===null||this.tracks===null)return;const a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
44${this.list("video")}
45${this.list("audio")}
46${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],r=i?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const mo=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Pu="HlsJsTrackRemovedError";class qm extends Error{constructor(e){super(e),this.name=Pu}}class Ym extends Ze{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var r;this.hls&&((r=this.mediaSource)==null?void 0:r.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:r,mediaSource:n}=this;i&&this.log("Media source opened"),!(!r||!n)&&(n.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:r}=this;i!==r&&this.error(`Media element src was set while attaching MediaSource (${r} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=gf(Nt(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;
vendor: 20,844 bytes, lines 46-48
46e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this),e.off(v.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const n=this.isUpdating();n||this.operationQueue.removeBlockers();const a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?ce(i,r.tracks):this.sourceBuffers.forEach(n=>{const[a]=n;a&&(i[a]=ce({},this.tracks[a]),this.removeBuffer(a)),n[0]=n[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(`${r} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const r=Nt(this.appendSource);if(r){const n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");const u=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||u&&a instanceof u,po(i),Wm(i,o),i.load()}catch{i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,r=t.tracks,n=r?Object.keys(r):null,a=n?n.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&n&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
47required tracks: ${ge(i,(u,l)=>u==="initSegment"?void 0:l)};
48transfer tracks: ${ge(r,(u,l)=>u==="initSegment"?void 0:l)}}`),!Dl(r,i)){t.mediaSource=null,t.tracks=void 0;const u=e.currentTime,l=this.details,d=Math.max(u,l?.fragments[0].start||0);if(d-u>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${u} -> ${d}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${d} currentTime: ${u}`),this.onMediaDetaching(v.MEDIA_DETACHING,{}),this.onMediaAttaching(v.MEDIA_ATTACHING,t),e.currentTime=d;return}this.transferData=void 0,n.forEach(u=>{const l=u,d=r[l];if(d){const c=d.buffer;if(c){const h=this.fragmentTracker,f=d.id;if(h.hasFragments(f)||h.hasParts(f)){const m=J.getBuffered(c);h.detectEvictedFragments(l,m,f,null,!0)}const g=Er(l),p=[l,c];this.sourceBuffers[g]=p,c.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,d)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:r,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=n.readyState==="open";try{const u=n.sourceBuffers;for(let l=u.length;l--;)o&&u[l].abort(),n.removeSourceBuffer(u[l]);o&&n.endOfStream()}catch(u){this.warn(`onMediaDetaching: ${u.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(r.removeEventListener("emptied",this._onMediaEmptied),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&po(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(v.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(n){this.warn(`onBufferReset ${e}`,n)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Er(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Hm(this.tracks)}onBufferCodecs(e,t){var i;const r=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&n.some(u=>!r[u]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(r)}" and "${n}" SourceBuffers`);return}n.forEach(u=>{var l,d;const c=t[u],{id:h,codec:f,levelCodec:g,container:p,metadata:m,supplemental:y}=c;let T=r[u];const E=(l=this.transferData)==null||(l=l.tracks)==null?void 0:l[u],S=E!=null&&E.buffer?E:T,_=S?.pendingCodec||S?.codec,x=S?.levelCodec;T||(T=r[u]={buffer:void 0,listeners:[],codec:f,supplemental:y,container:p,levelCodec:g,metadata:m,id:h});const A=ds(_,x),I=A?.replace(mo,"$1");let R=ds(f,g);const b=(d=R)==null?void 0:d.replace(mo,"$1");R&&A&&I!==b&&(u.slice(0,5)==="audio"&&(R=Os(R,this.appendSource)),this.log(`switching codec ${_} to ${R}`),R!==(T.pendingCodec||T.codec)&&(T.pendingCodec=R),T.container=p,this.appendChangeType(u,p,R))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const r=`${t};codecs=${i}`,n={label:`change-type=${r}`,execute:()=>{const a=this.tracks[e];if(a){const o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),o.changeType(r),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,r=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,H.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var o;const u=this.tracks.video;(this.lastVideoAppendEnd>r||u!=null&&u.buffer&&J.isBuffered(u.buffer,r)||((o=this.fragmentTracker.getAppendedFrag(r,H.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:r,type:n,parent:a,frag:o,part:u,chunkMeta:l,offset:d}=t,c=l.buffering[n],{sn:h,cc:f}=o,g=self.performance.now();c.start=g;const p=o.stats.buffering,m=u?u.stats.buffering:null;p.start===0&&(p.start=g),m&&m.start===0&&(m.start=g);const y=i.audio;let T=!1;n==="audio"&&y?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const E=i.video,S=E?.buffer;if(S&&h!=="initSegment"){const A=u||o,I=this.blockedAudioAppend;if(n==="audio"&&a!=="main"&&!this.blockedAudioAppend&&!(E.ending||E.ended)){const b=A.start+A.duration*.05,k=S.buffered,M=this.currentOp("video");!k.length&&!M?this.blockAudio(A):!M&&!J.isBuffered(S,b)&&this.lastVideoAppendEnd<b&&this.blockAudio(A)}else if(n==="video"){const R=A.end;if(I){const b=I.frag.start;(R>b||R<this.lastVideoAppendEnd||J.isBuffered(S,b))&&this.unblockAudio()}this.lastVideoAppendEnd=R}}const _=(u||o).start,x={label:`append-${n}`,execute:()=>{var A;c.executeStart=self.performance.now();const I=(A=this.tracks[n])==null?void 0:A.buffer;I&&(T?this.updateTimestampOffset(I,_,.1,n,h,f):d!==void 0&&$(d)&&this.updateTimestampOffset(I,d,1e-6,n,h,f)),this.appendExecutor(r,n)},onStart:()=>{},onComplete:()=>{const A=self.performance.now();c.executeEnd=c.end=A,p.first===0&&(p.first=A),m&&m.first===0&&(m.first=A);const I={};this.sourceBuffers.forEach(([R,b])=>{R&&(I[R]=J.getBuffered(b))}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:n,frag:o,part:u,chunkMeta:l,parent:o.type,timeRanges:I})},onError:A=>{var I;const R={type:W.MEDIA_ERROR,parent:o.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:u,chunkMeta:l,error:A,err:A,fatal:!1},b=(I=this.media)==null?void 0:I.error;if(A.code===DOMException.QUOTA_EXCEEDED_ERR||A.name=="QuotaExceededError"||"quota"in A)R.details=D.BUFFER_FULL_ERROR;else if(A.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!b)R.errorAction=di(!0);else if(A.name===Pu&&this.sourceBufferCount===0)R.errorAction=di(!0);else{const k=++this.appendErrors[n];this.warn(`Failed ${k}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${b||"no media error"})`),(k>=this.hls.config.appendErrorMaxRetry||b)&&(R.fatal=!0)}this.hls.trigger(v.ERROR,R)}};this.log(`queuing "${n}" append sn: ${h}${u?" p: "+u.index:""} of ${o.type===H.MAIN?"level":"track"} ${o.level} cc: ${f}`),this.append(x,n,this.isPending(this.tracks[n]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:e})},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r)}}}onBufferFlushing(e,t){const{type:i,startOffset:r,endOffset:n}=t;i?this.append(this.getFlushOp(i,r,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,n),a)})}onFragParsed(e,t){const{frag:i,part:r}=t,n=[],a=r?r.elementaryStreams:i.elementaryStreams;a[fe.AUDIOVIDEO]?n.push("audiovideo"):(a[fe.AUDIO]&&n.push("audio"),a[fe.VIDEO]&&n.push("video"));const o=()=>{const u=self.performance.now();i.stats.buffering.end=u,r&&(r.stats.buffering.end=u);const l=r?r.stats:i.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:i,part:r,stats:l,id:i.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n).catch(u=>{this.warn(`Fragment buffered callback ${u}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([a])=>{if(a){const o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${a} buffer reached EOS`)))}});const r=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(!a||a.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(v.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(v.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===D.BUFFER_APPEND_ERROR&&t.frag){var i;const r=(i=t.errorAction)==null?void 0:i.nextAutoLevel;$(r)&&r!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const r=e.config,n=i.currentTime,a=t.levelTargetDuration,o=t.live&&r.liveBackBufferLength!==null?r.liveBackBufferLength:r.backBufferLength;if($(o)&&o>=0){const l=Math.max(o,a),d=Math.floor(n/a)*a-l;this.flushBackBuffer(n,a,d)}const u=r.frontBufferFlushThreshold;if($(u)&&u>0){const l=Math.max(r.maxBufferLength,u),d=Math.max(l,a),c=Math.floor(n/a)*a+d;this.flushFrontBuffer(n,a,c)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){const o=J.getBuffered(n);if(o.length>0&&i>o.start(0)){var a;this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:i});const u=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(u!=null&&u.ended){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:r})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){const a=J.getBuffered(n),o=a.length;if(o<2)return;const u=a.start(o-1),l=a.end(o-1);if(i>u||e>=u&&e<=l)return;this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:r})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const l=Math.max(0,t.fragmentStart),d=Math.max(l,r);return{duration:1/0,start:l,end:d}}return{duration:1/0}}const n=(e=this.overrides)==null?void 0:e.duration;if(n)return $(n)?{duration:n}:null;const a=this.media.duration,o=$(i.duration)?i.duration:0;return r>o&&r>a||!$(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){const r=this.mediaSource;!this.media||!r||r.readyState!=="open"||(r.duration!==e&&($(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${ge(i)}`),this.tracksReady){var r;const n=(r=this.transferData)==null?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata}}}),this.hls.trigger(v.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const a=n,o=e[a];if(this.isPending(o)){const u=this.getTrackCodec(o,a),l=`${o.container};codecs=${u}`;o.codec=u,this.log(`creating sourceBuffer(${l})${this.currentOp(a)?" Queued":""} ${ge(o)}`);try{const d=i.addSourceBuffer(l),c=Er(a),h=[a,d];t[c]=h,o.buffer=d}catch(d){var r;this.error(`error while trying to add sourceBuffer: ${d.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:a,mimeType:l,parent:o.id});return}this.trackSourceBuffer(a,o)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let r=e.codec;i&&(t==="video"||t==="audiovideo")&&Ni(i,"video")&&(r=Nf(r,i));const n=ds(r,e.levelCodec);return n?t.slice(0,5)==="audio"?Os(n,this.appendSource):n:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{const o=a.removedRanges;o!=null&&o.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${r}`,t),this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});const n=this.currentOp(e);n&&n.onError(r)}updateTimestampOffset(e,t,i,r,n,a){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:r,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!r||!n||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const u=$(r.duration)?r.duration:1/0,l=$(n.duration)?n.duration:1/0,d=Math.max(0,t),c=Math.min(i,u,l);c>d&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${d},${c}] from the ${e} SourceBuffer`),o.remove(d,c)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],r=i?.buffer;if(!r)throw new qm(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,r.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}
48`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,r=t.map(a=>this.appendBlocker(a));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(r).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const r=(i=this.tracks[t])==null?void 0:i.buffer;!r||r.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const r=this.tracks[e];if(!r)return;const n=r.buffer;if(!n)return;const a=i.bind(this,e);r.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(r=>{i.removeEventListener(r.event,r.listener)}),t.listeners.length=0)}}function po(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function Wm(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function Er(s){return s==="audio"?1:0}class qn{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(){const{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTA
vendor: 3,501 bytes, line 48
48CHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.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){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&$(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,qn.getMaxLevelByMediaSize(i,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;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.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 Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const r=(o,u)=>u?o.width!==u.width||o.height!==u.height:!0;let n=e.length-1;const a=Math.max(t,i);for(let o=0;o<e.length;o+=1){const u=e[o];if((u.width>=a||u.height>=a)&&r(u,e[o+1])){n=o;break}}return n}}const jm={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",
vendor: 4,253 bytes, line 48
48KEY:"k",OTHER:"o"},Be=jm,zm={HLS:"h"},Xm=zm;class pt{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof pt?i:new pt(i))),this.value=e,this.params=t}}const Qm="Dict";function Jm(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function Zm(s,e,t,i){return new Error(`failed to ${s} "${Jm(e)}" as ${t}`,{cause:i})}function vt(s,e,t){return Zm("serialize",s,e,t)}class Ou{constructor(e){this.description=e}}const vo="Bare Item",ep="Boolean";function tp(s){if(typeof s!="boolean")throw vt(s,ep);return s?"?1":"?0"}function ip(s){return btoa(String.fromCharCode(...s))}const sp="Byte Sequence";function rp(s){if(ArrayBuffer.isView(s)===!1)throw vt(s,sp);return`:${ip(s)}:`}const np="Integer";function ap(s){return s<-999999999999999||999999999999999<s}function Mu(s){if(ap(s))throw vt(s,np);return s.toString()}function op(s){return`@${Mu(s.getTime()/1e3)}`}function Nu(s,e){if(s<0)return-Nu(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const r=Math.floor(s*t);return(r%2===0?r:r+1)/t}else return Math.round(s*t)/t}const lp="Decimal";function up(s){const e=Nu(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw vt(s,lp);const t=e.toString();return t.includes(".")?t:`${t}.0`}const dp="String",cp=/[\x00-\x1f\x7f]+/;function hp(s){if(cp.test(s))throw vt(s,dp);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function fp(s){return s.description||s.toString().slice(7,-1)}const gp="Token";function yo(s){const e=fp(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw vt(e,gp);return e}function Jr(s){switch(typeof s){case"number":if(!$(s))throw vt(s,vo);return Number.isInteger(s)?Mu(s):up(s);case"string":return hp(s);case"symbol":return yo(s);case"boolean":return tp(s);case"object":if(s instanceof Date)return op(s);if(s instanceof Uint8Array)return rp(s);if(s instanceof Ou)return yo(s);default:throw vt(s,vo)}}const mp="Key";function Zr(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw vt(s,mp);return s}function Yn(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${Zr(e)}`:`;${Zr(e)}=${Jr(t)}`).join("")}function Fu(s){return s instanceof pt?`${Jr(s.value)}${Yn(s.params)}`:Jr(s)}function pp(s){return`(${s.value.map(Fu).join(" ")})${Yn(s.params)}`}function vp(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw vt(s,Qm);const t=s instanceof Map?s.entries():Object.entries(s),i=e?.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof pt||(n=new pt(n));let a=Zr(r);return n.value===!0?a+=Yn(n.params):(a+="=",Array.isArray(n.value)?a+=pp(n):a+=Fu(n)),a}).join(`,${i}`)}function Uu(s,e){return vp(s,e)}const dt="CMCD-Object",ye="CMCD-Request",Kt="CMCD-Session",Lt="CMCD-Status",yp={br:dt,ab:dt,d:dt,ot:dt,tb:dt,tpb:dt,lb:dt,tab:dt,lab:dt,url:dt,pb:ye,bl:ye,tbl:ye,dl:ye,ltc:ye,mtp:ye,nor:ye,nrr:ye,rc:ye,sn:ye,sta:ye,su:ye,ttfb:ye,ttfbb:ye,ttlb:ye,cmsdd:ye,cmsds:ye,smrt:ye,df:ye,cs:ye,ts:ye,cid:Kt,pr:Kt,sf:Kt,sid:Kt,st:Kt,v:Kt,msd:Kt,bs:Lt,bsd:Lt,cdn:Lt,rtp:Lt,bg:Lt,pt:Lt,ec:Lt,e:Lt},Ep={REQUEST:ye};function Tp(s){return Object.keys(s).reduce((e,t)=>{var i;return(i=s[t])===null||i===void 0||i.forEach(r=>e[r]=t),e},{})}function Sp(s,e){const t={};if(!s)return t;const i=Object.keys(s),r=e?Tp(e):{};return i.reduce((n,a)=>{var o;const u=yp[a]||r[a]||Ep.REQUEST,l=(o=n[u])!==null&&o!==void 0?o:n[u]={};return l[a]=s[a],n},t)}function _p(s){return["ot","sf","st","e","sta"].includes(s)}function Ap(s){return typeof s=="number"?$(s):s!=null&&s!==""&&s!==!1}const Bu="event";function bp(s,e){const t=new URL(s),i=new URL(e);if(t.origin!==i.origin)return s;const r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")+t.search+t.hash}const ms=s=>Math.round(s),en=(s,e)=>Array.isArray(s)?s.map(t=>en(t,e)):s instanceof pt&&typeof s.value=="string"?new pt(en(s.value,e),s.params):(e.baseUrl&&(s=bp(s,e.baseUrl)),e.version===1?encodeURIComponent(s):s),es=s=>ms(s/100)*100,xp=(s,e)=>{let t=s;return e.version>=2&&(s instanceof pt&&typeof s.value=="string"?t=new pt([s]):typeof s=="string"&&(t=[s])),en(t,e)},Ip={br:ms,d:ms,bl:es,dl:es,mtp:es,nor:xp,rtp:es,tb:ms}
48,$u="request",Gu="response",Wn=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Rp=["e"],Lp=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function zs(s){return Lp.test(s)}function Dp(s){return Wn.includes(s)||Rp.includes(s)||zs(s)}const Ku=["d","dl","nor","ot","rtp","su"];function kp(s){return Wn.includes(s)||Ku.includes(s)||zs(s)}const Cp=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function wp(s){return Wn.includes(s)||Ku.includes(s)||Cp.includes(s)||zs(s)}const Pp=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Op(s){return Pp.includes(s)||zs(s)}const Mp={[Gu]:wp,[Bu]:Dp,[$u]:kp};function Vu(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||1,r=e.reportingMode||$u,n=i===1?Op:Mp[r];let a=Object.keys(s).filter(n);const o=e.filter;typeof o=="function"&&(a=a.filter(o));const u=r===Gu||r===Bu;u&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const l=ce({},Ip,e.formatters),d={version:i,reportingMode:r,baseUrl:e.baseUrl};return a.sort().forEach(c=>{let h=s[c];const f=l[c];if(typeof f=="function"&&(h=f(h,d)),c==="v"){if(i===1)return;h=i}c=="pr"&&h===1||(u&&c==="ts"&&!$(h)&&(h=Date.now()),Ap(h)&&(_p(c)&&typeof h=="string"&&(h=new Ou(h)),t[c]=h))}),t}function Np(s,e={}){const t={};if(!s)return t;const i=Vu(s,e),r=Sp(i,e?.customHeaderMap);return Object.entries(r).reduce((n,[a,o])=>{const u=Uu(o,{whitespace:!1});return u&&(n[a]=u),n},t)}function Fp(s,e,t){return ce(s,Np(e,t))}const Up="CMCD";function Bp(s,e={}){return s?Uu(Vu(s,e),{whitespace:!1}):""}function $p(s,e={}){if(!s)return"";const t=Bp(s,e);return encodeURIComponent(t)}function Gp(s,e={}){if(!s)return"";const t=$p(s,e);return`${Up}=${t}`}const Eo=/CMCD=[^&#]+/;function Kp(s,e,t){const i=Gp(e,t);if(!i)return s;if(Eo.test(s))return s.replace(Eo,i);const r=s.includes("?")?"&":"?";return`${s}${r}${i}`}class Vp{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=r=>{try{this.apply(r,{ot:Be.MANIFEST,su:!this.initialized})}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const{frag:n,part:a}=r,o=this.hls.levels[n.level],u=this.getObjectType(n),l={d:(a||n).duration*1e3,ot:u};(u===Be.VIDEO||u===Be.AUDIO||u==Be.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(u)/1e3,l.bl=this.getBufferLength(u));const d=a?this.getNextPart(a):this.getNextFrag(n);d!=null&&d.url&&d.url!==n.url&&(l.nor=d.url),this.apply(r,l)}catch(n){this.hls.logger.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;
48e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=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 i,r;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:Xm.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ce(t,this.createData());const i=t.ot===Be.INIT||t.ot===Be.VIDEO||t.ot===Be.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((a,o)=>(r.includes(o)&&(a[o]=t[o]),a),{}));const n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),Fp(e.headers,t,n)):e.url=Kp(e.url,t,n)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const r=e.sn-i.startSN;return i.fragments[r+1]}}getNextPart(e){var t;const{index:i,fragment:r}=e,n=(t=this.hls.levels[r.level])==null||(t=t.details)==null?void 0:t.partList;if(n){const{sn:a}=r;for(let o=n.length-1;o>=0;o--){const u=n[o];if(u.index===i&&u.fragment.sn===a)return n[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Be.TIMED_TEXT;if(e.sn==="initSegment")return Be.INIT;if(t==="audio")return Be.AUDIO;if(t==="main")return this.hls.audioTracks.length?Be.VIDEO:Be.MUXED}getTopBandwidth(e){let t=0,i;const r=this.hls;if(e===Be.AUDIO)i=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;i=r.levels.slice(0,a)}return i.forEach(n=>{n.bitrate>t&&(t=n.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===Be.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:J.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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)}}}}const Hp=3e5;class qp extends Ze{constructor(e){super("content-steering",e.logger),this.hls=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.registerListeners()}registerListeners(){const e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}
48startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const 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){const t=this.levels;t&&(this.levels=t.filter(i=>i!==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){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===we.SendAlternateToPenaltyBox&&i.flags===Ve.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:u,type:l}=t.context;o&&r?a=this.getPathwayForGroupId(o,l,a):u&&(a=u)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),t.details===D.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${ge(n)} penalized: ${ge(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}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;const i=this.penalizedPathways,r=performance.now();
vendor: 4,346 bytes, line 48
48Object.keys(i).forEach(n=>{r-i[n]>Hp&&delete i[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in i)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,u=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,uu(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});const l=this.hls.levels[o];u&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==u.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==u.bitrate&&this.log(`Unstable Pathways change from bitrate ${u.bitrate} to ${l.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ie.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ie.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":u}=n;if(t.some(d=>d.pathwayId===a))return;const l=this.getLevelsForPathway(o).map(d=>{const c=new pe(d.attrs);c["PATHWAY-ID"]=a;const h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(i[c.AUDIO]=h,c.AUDIO=h),f&&(r[c.SUBTITLES]=f,c.SUBTITLES=f);const g=Hu(d.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u),p=new Ui({attrs:c,audioCodec:d.audioCodec,bitrate:d.bitrate,height:d.height,name:d.name,url:g,videoCodec:d.videoCodec,width:d.width});if(d.audioGroups)for(let m=1;m<d.audioGroups.length;m++)p.addGroupId("audio",`${d.audioGroups[m]}_clone_${a}`);if(d.subtitleGroups)for(let m=1;m<d.subtitleGroups.length;m++)p.addGroupId("text",`${d.subtitleGroups[m]}_clone_${a}`);return p});t.push(...l),To(this.audioTracks,i,u,a),To(this.subtitleTracks,r,u,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+d)}const n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},u={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(d,c,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const g=d.data;if(g?.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":m,"PATHWAY-PRIORITY":y}=g;if(p)try{this.uri=new self.URL(p,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),m&&this.clonePathways(m);const T={steeringManifest:g,url:r.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,T),y&&this.updatePathwayPriority(y)},onError:(d,c,h,f)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${c.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let g=this.timeToLoad*1e3;if(d.code===429){const p=this.loader;if(typeof p?.getResponseHeader=="function"){const m=p.getResponseHeader("Retry-After");m&&(g=parseFloat(m)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,g)},onTimeout:(d,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,u,l)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function To(s,e,t,i){s&&Object.keys(e).forEach(r=>{const n=s.filter(a=>a.groupId===r).map(a=>{const o=ce({},a);return o.details=void 0,o.attrs=new pe(o.attrs),o.url=o.attrs.URI=Hu(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n)})}function Hu(s,e,t,i){const{HOST:r,PARAMS:n,[t]:a}=i;let o;e&&(o=a?.[e],o&&(s=o));const u=new self.URL(s);
48return r&&!o&&(u.host=r),n&&Object.keys(n).sort().forEach(l=>{l&&u.searchParams.set(l,n[l])}),u.href}class hi extends Ze{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=hi.CDMCleanupPromise?[hi.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:r}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.debug(n),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=_i(this.config));const o=a.map(cr).filter(u=>!!u);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{const o=hs(a);if(i!=="sinf"||o!==ve.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let u;try{const f=Ie(new Uint8Array(r)),g=Mn(JSON.parse(f).sinf),p=Ul(g);if(!p)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");u=new Uint8Array(p.subarray(8,24))}catch(f){this.warn(`${n} Failed to parse sinf: ${f}`);return}const l=Fe(u),{keyIdToKeySessionPromise:d,mediaKeySessions:c}=this;let h=d[l];for(let f=0;f<c.length;f++){const g=c[f],p=g.decryptdata;if(!p.keyId)continue;const m=Fe(p.keyId);if(Bs(u,p.keyId)||p.uri.replace(/-/g,"").indexOf(l)!==-1){if(h=d[m],!h)continue;if(p.pssh)break;delete d[m],p.pssh=new Uint8Array(r),p.keyId=u,h=d[l]=h.then(()=>this.generateRequestWithPreferredKeySession(g,i,r,"encrypted-event-key-match")),h.catch(y=>this.handleError(y));break}}h||this.handleError(new Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${c.length}.`))}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const 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}
48registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(v.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(v.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,r=t?.[e];if(r)return r.licenseUrl;if(e===ve.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t?.[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(a,o,u)=>!!a&&u.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const u=l=>{const d=l.shift();this.getMediaKeysPromise(d,r,n).then(c=>a({keySystem:d,mediaKeys:c})).catch(c=>{l.length?u(l):c instanceof Ke?o(c):o(new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};u(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return tu===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){var r;const n=xg(e,t,i,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],o=(r=a)==null?void 0:r.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${ge(n)}`),o=this.requestMediaKeySystemAccess(e,n);const u=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const d=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const c=u.mediaKeys=l.createMediaKeys().then(h=>(this.log(`Media-keys created for "${e}"`),u.hasMediaKeys=!0,d.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return c.catch(h=>{this.error(`Failed to create media-keys for "${e}"}: ${h}`)}),c})}return o.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Fe(e.keyId||[])} keyUri: ${e.uri}`);const r=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),r=ts(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(i,n,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${Fe(e.decryptdata.keyId||[])}
49      } (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>cr(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:r})=>{const n=cr(r);n?t(n):i(new Error(`Unable to find format for key-system "${r}"`))}).catch(i)})}selectKeySystemFormat(e){const 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){const t=_i(this.config),i=e.map(hs).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const r=Yp(e,t[i]);if(r)return r}}loadKey(e){const t=e.keyInfo.decryptdata,i=ts(t),r=this.bannedKeyIds[i];if(r||this.getKeyStatus(t)==="internal-error"){const o=So(r||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}const n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const a=this.keyIdToKeySessionPromise[i];if(!a){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:u,mediaKeys:l})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(u,l).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:u,mediaKeys:l,decryptdata:t}))))).then(u=>{const l="cenc",d=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(u,l,d,"playlist-key")});return o.catch(u=>this.handleError(u,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return a.catch(o=>{if(o instanceof Ke){const u=le({},o.data);this.getKeyStatus(t)==="internal-error"&&(u.decryptdata=t);const l=new Ke(u,o.message);this.handleError(l,e.frag)}}),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ke){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${Fe(i.keyId||[])})`:""}`),this.hls.trigger(v.ERROR,e.data)}else this.error(e.message),this.hls.trigger(v.ERROR,{type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
vendor: 13,051 bytes, line 49
49getKeySystemForKeyPromise(e){const t=ts(e),i=this.keyIdToKeySessionPromise[t];if(!i){const r=hs(e.keyFormat),n=r?[r]:_i(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=_i(this.config)),e.length===0)throw new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${ge({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,r){var n;const a=(n=this.config.drmSystems)==null||(n=n[e.keySystem])==null?void 0:n.generateRequest;if(a)try{const g=a.call(this.hls,t,i,e);if(!g)throw new Error("Invalid response from configured generateRequest filter");t=g.initDataType,i=g.initData?g.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(g){if(this.warn(g.message),this.hls&&this.hls.config.debug)throw g}if(i===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const o=ts(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${r}" keyId: ${o} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);const l=new Fn,d=e._onmessage=g=>{const p=e.mediaKeysSession;if(!p){l.emit("error",new Error("invalid state"));return}const{messageType:m,message:y}=g;this.log(`"${m}" message event for session "${p.sessionId}" message size: ${y.byteLength}`),m==="license-request"||m==="license-renewal"?this.renewLicense(e,y).catch(T=>{l.eventNames().length?l.emit("error",T):this.handleError(T)}):m==="license-release"?e.keySystem===ve.FAIRPLAY&&this.updateKeySession(e,Yr("acknowledged")).then(()=>this.removeSession(e)).catch(T=>this.handleError(T)):this.warn(`unhandled media key message type "${m}"`)},c=(g,p)=>{p.keyStatus=g;let m;g.startsWith("usable")?l.emit("resolved"):g==="internal-error"||g==="output-restricted"||g==="output-downscaled"?m=So(g,p.decryptdata):g==="expired"?m=new Error(`key expired (keyId: ${o})`):g==="released"?m=new Error("key released"):g==="status-pending"||this.warn(`unhandled key status change "${g}" (keyId: ${o})`),m&&(l.eventNames().length?l.emit("error",m):this.handleError(m))},h=e._onkeystatuseschange=g=>{if(!e.mediaKeysSession){l.emit("error",new Error("invalid state"));return}const m=this.getKeyStatuses(e);if(!Object.keys(m).some(S=>m[S]!=="status-pending"))return;if(m[o]==="expired"){this.log(`Expired key ${ge(m)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let T=m[o];if(T)c(T,e);else{var E;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(E=e.keyStatusTimeouts)[o]||(E[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const _=this.getKeyStatus(e.decryptdata);if(_&&_!=="status-pending")return this.log(`No status for keyId ${o} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${_} from other session.`),c(_,e);this.log(`key status for ${o} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),T="internal-error",c(T,e)},1e3)),this.log(`No status for keyId ${o} (${ge(m)}).`)}};Ue(e.mediaKeysSession,"message",d),Ue(e.mediaKeysSession,"keystatuseschange",h);const f=new Promise((g,p)=>{l.on("error",p),l.on("resolved",g)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o} URI: ${u}`)}).catch(g=>{throw new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:g,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${g}`)}).then(()=>f).catch(g=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw g}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((i,r)=>{if(typeof r=="string"&&typeof i=="object"){const o=r;r=i,i=o}const n="buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r);e.keySystem===ve.PLAYREADY&&n.length===16&&Zl(n);const a=Fe(n);i==="internal-error"&&(this.bannedKeyIds[a]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${a} key-session "${e.mediaKeysSession.sessionId}"`),t[a]=i}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,r=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const u={responseType:"arraybuffer",url:n},l=t.certLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,g,p)=>{a(h.data)},onError:(h,f,g,p)=>{o(new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:le({url:u.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:u.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};r.load(u,d,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(r=>{throw new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:r,fatal:!1},r.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let d;for(let c=0,h=n.length;c<h;c++){var a,o;d=n[c];const f=(a=d.querySelector("name"))==null?void 0:a.textContent,g=(o=d.querySelector("value"))==null?void 0:o.textContent;f&&g&&e.setRequestHeader(f,g)}}const u=r.querySelector("Challenge"),l=u?.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Yr(atob(l))}setupLicenseXHR(e,t,i,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,r)}).catch(a=>{if(!i.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,i,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const 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 u=o.response;this.log(`License received ${u instanceof ArrayBuffer?u.byteLength:u}`);const l=this.config.licenseResponseCallback;if(l)try{u=l.call(this.hls,o,a,e)}catch(d){this.error(d)}r(u)}else{const u=i.errorRetry,l=u?u.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)n(new Ke({type:W.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,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{const d=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:u,licenseChallenge:l})=>{e.keySystem==ve.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(u,l)),u.send(l)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,Ue(i,"encrypted",this.onMediaEncrypted),Ue(i,"waitingforkey",this.onWaitingForKey);const r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&($e(e,"encrypted",this.onMediaEncrypted),$e(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,jt.clearKeyUriToKeyIdMap();const n=r.length;hi.CDMCleanupPromise=Promise.all(r.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:r}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${Fe(r?.keyId||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:a}=e;a&&Object.keys(a).forEach(l=>self.clearTimeout(a[l]));const{drmSystemOptions:o}=this.config;return(Rg(o)?new Promise((l,d)=>{self.setTimeout(()=>d(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(l).catch(d)}):Promise.resolve()).catch(l=>{this.log(`Could not remove session: ${l}`),this.hls&&this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${l}`)})}).then(()=>t.close()).catch(l=>{this.log(`Could not close session: ${l}`),this.hls&&this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${l}`)})})}return Promise.resolve()}}hi.CDMCleanupPromise=void 0;function ts(s){if(!s)throw new Error("Could not read keyId of undefined decryptdata");if(s.keyId===null)throw new Error("keyId is null");return Fe(s.keyId)}function Yp(s,e){if(s.keyId&&e.mediaKeysSession.keyStatuses.has(s.keyId))return e.mediaKeysSession.keyStatuses.get(s.keyId);if(s.matches(e.decryptdata))return e.keyStatus}class Ke 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}}function So(s,e){const t=s==="output-restricted",i=t?D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ke({type:W.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}class Wp{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}
vendor: 11,183 bytes, line 49
49registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,u=1e3*a/n,l=this.hls;if(l.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),u>0&&a>l.config.fpsDroppedMonitoringThreshold*o){let d=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=d)&&(d=d-1,l.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function qu(s,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=s,e.dispatchEvent(t)}function Yu(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){ue.debug(`[texttrack-utils]: ${i}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,s.addCue(r)}catch(r){ue.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(s.mode=t)}function li(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let i=s.cues.length;i--;)e&&s.cues[i].removeEventListener("enter",e),s.removeCue(s.cues[i]);t==="disabled"&&(s.mode=t)}function tn(s,e,t,i){const r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const n=zp(s.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&s.removeCue(n[a])}r==="disabled"&&(s.mode=r)}function jp(s,e){if(e<=s[0].startTime)return 0;const t=s.length-1;if(e>s[t].endTime)return-1;let i=0,r=t,n;for(;i<=r;)if(n=Math.floor((r+i)/2),e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n;return s[i].startTime-e<e-s[r].startTime?i:r}function zp(s,e,t){const i=[],r=jp(s,e);if(r>-1)for(let n=r,a=s.length;n<a;n++){const o=s[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function ps(s){const e=[];for(let t=0;t<s.length;t++){const i=s[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(s[t])}return e}class Xp extends Hn{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.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=ps(this.media.textTracks);for(let n=0;n<i.length;n++)if(i[n].mode==="hidden")t=i[n];else if(i[n].mode==="showing"){t=i[n];break}const r=this.findTrackForTextTrack(t);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},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(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.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(e,t){const i=this.media;if(!i)return;const r=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r)return;ps(i.textTracks).forEach(a=>{li(a)})}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){const{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,r=this.groupIds;let n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(d=>!i||i.indexOf(d.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(d=>d.default)&&(this.selectDefaultTrack=!1),a.forEach((d,c)=>{d.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const d=gt(o,a);if(d>-1)n=a[d];else{const c=gt(o,this.tracks);n=this.tracks[c]}}let u=this.findTrackId(n);u===-1&&n&&(u=this.findTrackId(null));const l={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,l),u!==-1&&this.trackId===-1&&this.setSubtitleTrack(u)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const n=t[r];if(!(i&&!n.default||!i&&!e)&&(!e||Wt(n,e)))return r}if(e){for(let r=0;r<t.length;r++){const n=t[r];if(Ki(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const n=t[r];if(Ki(e.attrs,n.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const r=t[i];if(Qr(r,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ie.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){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&Wt(e,i))return i;const r=gt(e,this.tracksInGroup);if(r>-1){const n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else{if(i)return null;{const n=gt(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=ps(e.textTracks),i=this.currentTrack;let r;if(i&&(r=t.filter(n=>Qr(i,n))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==r&&(n.mode="disabled")}),r){const n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!$(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!r.details&&!r.details.live;if(e===this.trackId&&r===i&&n)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:u,type:l,url:d}=r;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:u,type:l,url:d});const c=this.switchParams(r.url,i?.details,r.details);this.loadPlaylist(c)}}function Qp(){try{return crypto.randomUUID()}catch{try{const 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,r=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}function Pi(s){let e=5381,t=s.length;for(;t;
vendor: 4,230 bytes, line 49
49)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const fi=.025;let Vs=(function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s})({});function Jp(s,e,t){return`${s.identifier}-${t+1}-${Pi(e)}`}class Zp{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Tr(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=Tr(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=$(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Tr(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<fi))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Vs.Range:Vs.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return e0(this)}}function Tr(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<fi)?e.start:e.start+e.duration}function Wu(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Sr(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function e0(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function ni(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class t0{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetail
vendor: 4,232 bytes, line 49
49s=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(v.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=i,this.assetItem=r;const a=()=>{this.hasDetails=!0};n.once(v.LEVEL_LOADED,a),n.once(v.AUDIO_TRACK_LOADED,a),n.once(v.SUBTITLE_TRACK_LOADED,a),n.on(v.MEDIA_ATTACHING,(o,{media:u})=>{this.removeMediaListeners(),this.mediaAttached=u,this.interstitial.playoutLimit&&(u.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(v.BUFFER_APPENDED,()=>{const d=this.bufferedEnd;this.reachedPlayout(d)&&(this._bufferedEosTime=d,n.trigger(v.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Wu(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),r=this.timelineOffset,n=J.bufferInfo(e,r,0);return this.getAssetTime(n.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=J.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var r;(r=this.hls)==null||r.on(e,t)}once(e,t,i){var r;(r=this.hls)==null||r.once(e,t)}off(e,t,i){var r;(r=this.hls)==null||r.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${ni(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const _o=.033;class i0 extends Ze{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={}
vendor: 12,585 bytes, lines 49-50
49,this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const r=this.items;if(r)for(r[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=r[i])!=null&&n.event;){var n;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let r=0;r<i.length;r++){let n=i[r];if(t&&t!=="primary"&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return r}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){const n=i[r].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return r}return-1}findEventIndex(e){const t=this.items;if(t)for(let r=t.length;r--;){var i;if(((i=t[r].event)==null?void 0:i.identifier)===e)return r}return-1}findAssetIndex(e,t){const i=e.assetList,r=i.length;if(r>1)for(let n=0;n<r;n++){const a=i[n];if(!a.error){const o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||n===r-1))return n}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,r=i[i.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:r}=i,n=this.events,a=this.parseDateRanges(r,{url:i.url},t),o=Object.keys(r),u=n?n.filter(l=>!o.includes(l.identifier)):[];a.length&&a.sort((l,d)=>{const c=l.cue.pre,h=l.cue.post,f=d.cue.pre,g=d.cue.post;if(c&&!f)return-1;if(f&&!c||h&&!g)return 1;if(g&&!h)return-1;if(!c&&!f&&!h&&!g){const p=l.startTime,m=d.startTime;if(p!==m)return p-m}return l.dateRange.tagOrder-d.dateRange.tagOrder}),this.events=a,u.forEach(l=>{this.removeEvent(l)}),this.updateSchedule(e,u)}updateSchedule(e,t=[],i=!1){const r=this.events||[];if(r.length||t.length||this.length<2){const n=this.items,a=this.parseSchedule(r,e);(i||t.length||n?.length!==a.length||a.some((u,l)=>Math.abs(u.playout.start-n[l].playout.start)>.005||Math.abs(u.playout.end-n[l].playout.end)>.005))&&(this.items=a,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,i){const r=[],n=Object.keys(e);for(let a=0;a<n.length;a++){const o=n[a],u=e[o];if(u.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(u):(l=new Zp(u,t),this.eventMap[o]=l,i===!1&&(l.appendInPlace=i)),r.push(l)}}return r}parseSchedule(e,t){const i=[],r=t.main.details,n=r.live?1/0:r.edge;let a=0;if(e=e.filter(u=>!u.error&&!(u.cue.once&&u.hasPlayed)),e.length){this.resolveOffsets(e,t);let u=0,l=0;if(e.forEach((d,c)=>{const h=d.cue.pre,f=d.cue.post,g=e[c-1]||null,p=d.appendInPlace,m=f?n:d.startOffset,y=d.duration,T=d.timelineOccupancy===Vs.Range?y:0,E=d.resumptionOffset,S=g?.startTime===m,_=m+d.cumulativeDuration;let x=p?_+y:m+E;if(h||!f&&m<=0){const I=l;l+=T,d.timelineStart=_;const R=a;a+=y,i.push({event:d,start:_,end:x,playout:{start:R,end:a},integrated:{start:I,end:l}})}else if(m<=n){if(!S){const b=m-u;if(b>_o){const k=u,M=l;l+=b;const G=a;a+=b;const q={previousEvent:e[c-1]||null,nextEvent:d,start:k,end:k+b,playout:{start:G,end:a},integrated:{start:M,end:l}};i.push(q)}else b>0&&g&&(g.cumulativeDuration+=b,i[i.length-1].end=m)}f&&(x=_),d.timelineStart=_;const I=l;l+=T;const R=a;a+=y,i.push({event:d,start:_,end:x,playout:{start:R,end:a},integrated:{start:I,end:l}})}else return;const A=d.resumeTime;f||A>n?u=n:u=A}),u<n){var o;const d=u,c=l,h=n-u;l+=h;const f=a;a+=h,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:u,end:d+h,playout:{start:f,end:a},integrated:{start:c,end:l}})}this.setDurations(n,a,l)}else i.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n);return i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,r=i.live?1/0:i.edge;let n=0,a=-1;e.forEach((o,u)=>{const l=o.cue.pre,d=o.cue.post,c=l?0:d?r:o.startTime;this.updateAssetDurations(o),a===c?o.cumulativeDuration=n:(n=0,a=c),!d&&o.snapOptions.in&&(o.resumeAnchor=Xt(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&u+1<e.length&&e[u+1].startTime-e[u].resumeTime<_o&&(e[u+1].appendInPlace=!1,e[u+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const f=$(o.resumeOffset)?o.resumeOffset:o.duration;n+=f})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>fi?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(a=>{const o=t[a].details,u=o.edge;if(i>=u)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${u}`),!1;const l=Xt(null,o.fragments,i);if(!l)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const d=a==="audio"?.175:0;return Math.abs(l.start-i)<fi+d||Math.abs(l.end-i)<fi+d?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,r=!1,n=!1;for(let a=0;a<e.assetList.length;a++){const o=e.assetList[a],u=t+i;o.startOffset=i,o.timelineStart=u,r||(r=o.duration===null),n||(n=!!o.error);const l=o.error?0:o.duration||0;i+=l}r&&!n?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function tt(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class s0{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let r;try{r=Wu(i,this.hls.sessionId,e.baseUrl)}catch(h){const f=this.assignAssetListError(e,D.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(v.ERROR,f);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,a=n.loader,o=new a(n),u={responseType:"json",url:r.href},l=n.interstitialAssetListLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,g,p)=>{const m=h.data,y=m?.ASSETS;if(!Array.isArray(y)){const T=this.assignAssetListError(e,D.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),g.url,f,p);this.hls.trigger(v.ERROR,T);return}e.assetListResponse=m,this.hls.trigger(v.ASSET_LIST_LOADED,{event:e,assetListResponse:m,networkDetails:p})},onError:(h,f,g,p)=>{const m=this.assignAssetListError(e,D.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,p,g);this.hls.trigger(v.ERROR,m)},onTimeout:(h,f,g)=>{const p=this.assignAssetListError(e,D.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,g);this.hls.trigger(v.ERROR,p)}};return o.load(u,d,c),this.hls.trigger(v.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,r,n,a){return e.error=i,{type:W.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:r,error:i,networkDetails:a,stats:n}}}function Ao(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function is(s,e){return`[${s}] Advancing timeline position to ${e}`}class r0 extends Ze{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;const a=r<=-.01;this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<o.start||i>=o.end){var u;const f=this.findItemIndex(o);let g=this.schedule.findItemIndexAtTime(i);if(g===-1&&(g=f+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${f} to ${g})`)),!this.isInterstitial(o)&&(u=this.media)!=null&&u.paused&&(this.shouldPlay=!1),!a&&g>f){const p=this.schedule.findJumpRestrictedIndex(f+1,g);if(p>f){this.setSchedulePosition(p);return}}this.setSchedulePosition(g);return}const l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){const f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,f))}return}const d=l.timelineStart,c=l.duration||0;if(a&&i<d||i>=d+c){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearInterstitial(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,l)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const r=this.playingItem;if(!r||this.playingLastItem)return;if(i>=r.end){this.timelinePos=r.end;const o=this.findItemIndex(r);this.setSchedulePosition(o+1)}const n=this.playingAsset;if(!n)return;const a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n)},this.onScheduleUpdate=(i,r)=>{const n=this.schedule;if(!n)return;const a=this.playingItem,o=n.events||[],u=n.items||[],l=n.durations,d=i.map(p=>p.identifier),c=!!(o.length||d.length);(c||r)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
50Schedule: ${u.map(p=>tt(p))} pos: ${this.timelinePos}`),d.length&&this.log(`Removed events ${d}`);let h=null,f=null;a&&(h=this.updateItem(a,this.timelinePos),this.itemsMatch(a,h)?this.playingItem=h:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const g=this.bufferingItem;if(g&&(f=this.updateItem(g,this.bufferedPos),this.itemsMatch(g,f)?this.bufferingItem=f:g.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(g.event,null))),i.forEach(p=>{p.assetList.forEach(m=>{this.clearAssetPlayer(m.identifier,null)})}),this.playerQueue.forEach(p=>{if(p.interstitial.appendInPlace){const m=p.assetItem.timelineStart,y=p.timelineOffset-m;if(y)try{p.timelineOffset=m}catch(T){Math.abs(y)>fi&&this.warn(`${T} ("${p.assetId}" ${p.timelineOffset}->${m})`)}}}),c||r){if(this.hls.trigger(v.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:u.slice(0),durations:l,removedIds:d}),this.isInterstitial(a)&&d.includes(a.event.identifier)){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(h,a),g&&f!==h&&this.trimInPlace(f,g),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new s0(e),this.schedule=new i0(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(v.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(v.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(v.MEDIA_ENDED,this.onMediaEnded,this),e.on(v.ERROR,this.onError,this),e.on(v.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;
vendor: 4,618 bytes, line 50
50e&&(e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(v.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(v.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(v.MEDIA_ENDED,this.onMediaEnded,this),e.off(v.ERROR,this.onError,this),e.off(v.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){$e(e,"play",this.onPlay),$e(e,"pause",this.onPause),$e(e,"seeking",this.onSeeking),$e(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;Ue(i,"seeking",this.onSeeking),Ue(i,"timeupdate",this.onTimeupdate),Ue(i,"play",this.onPlay),Ue(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!r){this.clearScheduleState();const n=this.findItemIndex(i);this.setSchedulePosition(n)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){const n=this.getBufferingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=c=>c&&e.getAssetPlayer(c.identifier),r=(c,h,f,g,p)=>{if(c){let m=c[h].start;const y=c.event;if(y){if(h==="playout"||y.timelineOccupancy!==Vs.Point){const T=i(f);T?.interstitial===y&&(m+=T.assetItem.startOffset+T[p])}}else{const T=g==="bufferedPos"?a():e[g];m+=T-c.start}return m}return 0},n=(c,h)=>{var f;if(c!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var g;const p=e.schedule.findItemIndexAtTime(c),m=(g=e.schedule.items)==null?void 0:g[p];if(m){const y=m[h].start-m.start;return c+y}}return c},a=()=>{const c=e.bufferedPos;return c===Number.MAX_VALUE?o("primary"):Math.max(c,0)},o=c=>{var h,f;return(h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[c])||0},u=(c,h)=>{var f,g;const p=e.effectivePlayingItem;if(p!=null&&(f=p.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log(`seek to ${c} "${h}"`);const m=e.effectivePlayingItem,y=e.schedule.findItemIndexAtTime(c,h),T=(g=e.schedule.items)==null?void 0:g[y],E=e.getBufferingPlayer(),S=E?.interstitial,_=S?.appendInPlace,x=m&&e.itemsMatch(m,T);if(m&&(_||x)){const A=i(e.playingAsset),I=A?.media||e.primaryMedia;if(I){const R=h==="primary"?I.currentTime:r(m,h,e.playingAsset,"timelinePos","currentTime"),b=c-R,k=(_?R:I.currentTime)+b;if(k>=0&&(!A||_||k<=A.duration)){I.currentTime=k;return}}}if(T){let A=c;if(h!=="primary"){const R=T[h].start,b=c-R;A=T.start+b}const I=!e.isInterstitial(T);if((!e.isInterstitial(m)||m.event.appendInPlace)&&(I||T.event.appendInPlace)){const R=e.media||(_?E?.media:null);R&&(R.currentTime=A)}else if(m){const R=e.findItemIndex(m);if(y>R){const k=e.schedule.findJumpRestrictedIndex(R+1,y);if(k>
vendor: 33,557 bytes, line 50
50R){e.setSchedulePosition(k);return}}let b=0;if(I)e.timelinePos=A,e.checkBuffer();else{const k=T.event.assetList,M=c-(T[h]||T).start;for(let G=k.length;G--;){const q=k[G];if(q.duration&&M>=q.startOffset&&M<q.startOffset+q.duration){b=G;break}}}e.setSchedulePosition(y,b)}}},l=()=>{const c=e.effectivePlayingItem;if(e.isInterstitial(c))return c;const h=t();return e.isInterstitial(h)?h:null},d={get bufferedEnd(){const c=t(),h=e.bufferingItem;if(h&&h===c){var f;return r(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){const c=l(),h=e.effectivePlayingItem;return h&&h===c?r(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(c){const h=l(),f=e.effectivePlayingItem;f&&f===h&&u(c+f.playout.start,"playout")},get duration(){const c=l();return c?c.playout.end-c.playout.start:0},get assetPlayers(){var c;const h=(c=l())==null?void 0:c.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var c;const h=(c=l())==null?void 0:c.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};return this.manager={get events(){var c;return((c=e.schedule)==null||(c=c.events)==null?void 0:c.slice(0))||[]},get schedule(){var c;return((c=e.schedule)==null||(c=c.items)==null?void 0:c.slice(0))||[]},get interstitialPlayer(){return l()?d:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const c=t();return e.findItemIndex(c)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const c=e.effectivePlayingItem;return e.findItemIndex(c)},primary:{get bufferedEnd(){return a()},get currentTime(){const c=e.timelinePos;return c>0?c:0},set currentTime(c){u(c,"primary")},get duration(){return o("primary")},get seekableStart(){var c;return((c=e.primaryDetails)==null?void 0:c.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(c){u(c,"integrated")},get duration(){return o("integrated")},get seekableStart(){var c;return n(((c=e.primaryDetails)==null?void 0:c.fragmentStart)||0,"integrated")}},skip:()=>{const c=e.effectivePlayingItem,h=c?.event;if(h&&!h.restrictions.skip){const f=e.findItemIndex(c);if(h.appendInPlace){const g=c.playout.start+c.event.duration;u(g+.001,"playout")}else e.advanceAfterAssetEnded(h,f,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(r=this.primaryMedia);const n=(t=r)==null?void 0:t.currentTime;if(!(n===void 0||!$(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}const n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${ge(n)}`),this.detachedData=n}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var i,r;if(e.media===t)return;let n=null;const a=this.hls,o=e!==a,u=o&&e.interstitial.appendInPlace,l=(i=this.detachedData)==null?void 0:i.mediaSource;let d;if(a.media)u&&(n=a.transferMedia(),this.detachedData=n),d="Primary";else if(l){const g=this.getBufferingPlayer();g?(n=g.transferMedia(),d=`${g}`):d="detached MediaSource"}else d="detached media";if(!n){if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${ge(n)}`);else if(!this.detachedData||a.media===t){const g=this.playerQueue;g.length>1&&g.forEach(p=>{if(o&&p.interstitial.appendInPlace!==u){const m=p.interstitial;this.clearInterstitial(p.interstitial,null),m.appendInPlace=!1,m.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${m}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const c=n&&"mediaSource"in n&&((r=n.mediaSource)==null?void 0:r.readyState)!=="closed",h=c&&n?n:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${d} (media.currentTime: ${t.currentTime})`);const f=this.schedule;if(h===n&&f){const g=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||g,cueRemoval:!o}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,r=this.effectivePlayingItem;if(i===-1){const n=this.hls.startPosition;if(this.log(is("checkStart",n)),this.timelinePos=n,t.length&&t[0].cue.pre){const a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){const a=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(a);this.setSchedulePosition(o)}}else if(r&&!this.playingItem){const n=e.findItemIndex(r);this.setSchedulePosition(n)}}advanceAssetBuffering(e,t){const i=e.event,r=i.findAssetIndex(t),n=Sr(i,r);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var a;const o=(a=this.schedule.items)==null?void 0:a[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,i){const r=Sr(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){const n=this.schedule.items;if(n){const a=t+1,o=n.length;if(a>=o){this.setSchedulePosition(-1);return}const u=e.resumeTime;this.timelinePos<u&&(this.log(is("advanceAfterAssetEnded",u)),this.timelinePos=u,e.appendInPlace&&this.advanceInPlace(u),this.checkBuffer(this.bufferedPos<u)),this.setSchedulePosition(a)}}}else{if(e.appendInPlace){const n=e.assetList[r];n&&this.advanceInPlace(n.timelineStart)}this.setSchedulePosition(t,r)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const r=t.parentIdentifier,n=i.getEvent(r);if(n){const a=i.findEventIndex(r),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1)}}setSchedulePosition(e,t){var i;const r=(i=this.schedule)==null?void 0:i.items;if(!r||this.playbackDisabled)return;const n=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&tt(n)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){const d=a.event,c=this.playingAsset,h=c?.identifier,f=h?this.getAssetPlayer(h):null;if(f&&h&&(!this.eventItemsMatch(a,n)||t!==void 0&&h!==d.assetList[t].identifier)){var u;const g=d.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${g+1}/${d.assetList.length} ${ni(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(v.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:g,event:d,schedule:r.slice(0),scheduleIndex:e,player:f}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(d,this.findItemIndex(this.playingItem),g);return}this.retreiveMediaSource(h,n),f.media&&!((u=this.detachedData)!=null&&u.mediaSource)&&f.detachMedia()}if(!this.eventItemsMatch(a,n)&&(this.endedItem=a,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${d} ${tt(a)}`),d.hasPlayed=!0,this.hls.trigger(v.INTERSTITIAL_ENDED,{event:d,schedule:r.slice(0),scheduleIndex:e}),d.cue.once)){var l;this.updateSchedule();const g=(l=this.schedule)==null?void 0:l.items;if(n&&g){const p=this.findItemIndex(n);this.advanceSchedule(p,g,t,a,o)}return}}this.advanceSchedule(e,r,t,a,o)}advanceSchedule(e,t,i,r,n){const a=this.schedule;if(!a)return;const o=t[e]||null,u=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(d=>{const c=d.interstitial,h=a.findEventIndex(c.identifier);(h<e||h>e+1)&&this.clearInterstitial(c,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const d=o.event;if(i===void 0){i=a.findAssetIndex(d,this.timelinePos);const g=Sr(d,i-1);if(d.isAssetPastPlayoutLimit(g)||d.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(d,e,i);return}i=g}const c=this.waitingItem;this.assetsBuffered(o,u)||this.setBufferingItem(o);let h=this.preloadAssets(d,i);if(this.eventItemsMatch(o,c||r)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${tt(o)} ${d.appendInPlace?"append in place":""}`),this.hls.trigger(v.INTERSTITIAL_STARTED,{event:d,schedule:t.slice(0),scheduleIndex:e})),!d.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${d}`);return}if(d.assetListLoader&&(d.assetListLoader.destroy(),d.assetListLoader=void 0),!u){this.log(`Waiting for attachMedia to start Interstitial ${d}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const f=d.assetList[i];if(!f){this.advanceAfterAssetEnded(d,e,i||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){const g=d.assetList.length;this.warn(`asset ${i+1}/${g} player destroyed ${d}`),h=this.createAssetPlayer(d,f,i),h.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&d.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,i,t,e,u),this.shouldPlay&&Ao(h.media)}else o?(this.resumePrimary(o,e,r),this.shouldPlay&&Ao(this.hls.media)):n&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var r,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${tt(e)}`),!((r=this.detachedData)!=null&&r.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log(is("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!i)return;const a=(n=this.schedule)==null?void 0:n.items;a&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${tt(e)}`),this.hls.trigger(v.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const r=this.primaryDetails;if(t===0)return this.hls.startPosition;if(r&&(i<r.fragmentStart||i>r.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:J.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const r=this.primaryMedia;if(!r)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(is("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const r=this.hls;!r.loadingEnabled||!r.media||Math.abs((((i=r.mainForwardBufferInfo)==null?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(v.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(v.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const r=le(le({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=le(le({},this.altSelection),{},{audio:i});return}const n=le(le({},r),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=le(le({},this.altSelection),{},{subtitles:i});return}const n=le(le({},r),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(e,t){const i=Ca(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setAudioOption(t)||r.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Ca(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setSubtitleOption(t)||t.id!==-1&&r.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const r=this.timelinePos;this.bufferedPos=r,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let r=0;r<t.length;r++){const n=t[r];if(n.cue.post){var i;const a=this.schedule.findEventIndex(n.identifier),o=(i=this.schedule.items)==null?void 0:i[a];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const r=(i=this.schedule)==null?void 0:i.items;if(e&&r){const n=this.findItemIndex(e,t);return r[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null)});const i=e.end+.25,r=J.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${tt(e)} (was ${tt(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const r=J.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,i,e)}updateBufferedPos(e,t,i){const r=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}const a=this.playingItem,o=this.findItemIndex(a);let u=r.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const d=this.findItemIndex(n),c=Math.min(d+1,t.length-1),h=t[c];if((u===-1&&n&&e>=n.end||(l=h.event)!=null&&l.appendInPlace&&e+.01>=h.start)&&(u=c),this.isInterstitial(n)){const f=n.event;if(c-o>1&&f.appendInPlace===!1||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,u>d&&u>o)this.bufferedToItem(h);else{const f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&a&&!this.itemsMatch(a,n)&&(u===o?this.bufferedToItem(a):u===o+1&&this.bufferedToItem(t[u]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(r=>{const n=this.getAssetPlayer(r.identifier);return!(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:r,events:n}=i;if(!r||!n)return t;const a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const u=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${tt(e)}`+(t?` (${u.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const l=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((d,c)=>{const h=this.getAssetPlayer(d.identifier);h&&(c===l&&h.loadSource(),h.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering());this.hls.trigger(v.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const r=this.detachedData;r?r.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,r=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(r||!n){const a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o)}}}preloadAssets(e,t){const i=e.assetUrl,r=e.assetList.length,n=r===0&&!e.assetListLoader,a=e.cue.once;if(n){const u=e.timelineStart;if(e.appendInPlace){var o;const h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(u+.25)}let l,d=0;if(!this.playingItem&&this.primaryLive&&(d=this.hls.startPosition,d===-1&&(d=this.hls.liveSyncPosition||0)),d&&!(e.cue.pre||e.cue.post)){const h=d-u;h>0&&(l=Math.round(h*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${l?` live-start: ${d} start-offset: ${l}`:""}`),i)return this.createAsset(e,0,0,u,e.duration,i);const c=this.assetListLoader.loadAssetList(e,l);c&&(e.assetListLoader=c)}else if(!a&&r){for(let l=t;l<r;l++){const d=e.assetList[l],c=this.getAssetPlayerQueueIndex(d.identifier);(c===-1||this.playerQueue[c].destroyed)&&!d.error&&this.createAssetPlayer(e,d,l)}const u=e.assetList[t];if(u){const l=this.getAssetPlayer(u.identifier);return l&&l.loadSource(),l}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(r=>{this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,n,a){const o={parentIdentifier:e.identifier,identifier:Jp(e,a,t),duration:n,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const r=this.hls,n=r.userConfig;let a=n.videoPreference;const o=r.loadLevelObj||r.levels[r.currentLevel];(a||o)&&(a=ce({},a),o.videoCodec&&(a.videoCodec=o.videoCodec),o.videoRange&&(a.allowedVideoRanges=[o.videoRange]));const u=r.audioTracks[r.audioTrack],l=r.subtitleTracks[r.subtitleTrack];let d=0;if(this.primaryLive||e.appendInPlace){const S=this.timelinePos-t.timelineStart;if(S>1){const _=t.duration;_&&S<_&&(d=S)}}const c=t.identifier,h=le(le({},n),{},{maxMaxBufferLength:Math.min(180,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:a,audioPreference:u||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));const f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=ce({},f,{contentId:Pi(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);const g=new t0(this.HlsPlayerClass,h,e,t);this.playerQueue.push(g),e.assetList[i]=t;let p=!0;const m=S=>{if(S.live){var _;const I=new Error(`Interstitials MUST be VOD assets ${e}`),R={fatal:!0,type:W.OTHER_ERROR,details:D.INTERSTITIAL_ASSET_ITEM_ERROR,error:I},b=((_=this.schedule)==null?void 0:_.findEventIndex(e.identifier))||-1;this.handleAssetItemError(R,e,b,i,I.message);return}const x=S.edge-S.fragmentStart,A=t.duration;(p||A===null||x>A)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${A} > ${x}`),t.duration=x,this.updateSchedule())};g.on(v.LEVEL_UPDATED,(S,{details:_})=>m(_)),g.on(v.LEVEL_PTS_UPDATED,(S,{details:_})=>m(_)),g.on(v.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const y=(S,_)=>{const x=this.getAssetPlayer(c);if(x&&_.tracks){x.off(v.BUFFER_CODECS,y),x.tracks=_.tracks;const A=this.primaryMedia;this.bufferingAsset===x.assetItem&&A&&!x.media&&this.bufferAssetPlayer(x,A)}};g.on(v.BUFFER_CODECS,y);const T=()=>{var S;const _=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${_}`),!_||!this.schedule)return;const x=this.schedule.findEventIndex(e.identifier),A=(S=this.schedule.items)==null?void 0:S[x];this.isInterstitial(A)&&this.advanceAssetBuffering(A,t)};g.on(v.BUFFERED_TO_END,T);const E=S=>()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;this.shouldPlay=!0;const x=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,x,S)};return g.once(v.MEDIA_ENDED,E(i)),g.once(v.PLAYOUT_LIMIT_REACHED,E(1/0)),g.on(v.ERROR,(S,_)=>{if(!this.schedule)return;const x=this.getAssetPlayer(c);if(_.details===D.BUFFER_STALLED_ERROR){if(x!=null&&x.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(_,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${_.error} ${e}`)}),g.on(v.DESTROYING,()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;const _=new Error(`Asset player destroyed unexpectedly ${c}`),x={fatal:!0,type:W.OTHER_ERROR,details:D.INTERSTITIAL_ASSET_ITEM_ERROR,error:_};this.handleAssetItemError(x,e,this.schedule.findEventIndex(e.identifier),i,_.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${ni(t)}`),this.hls.trigger(v.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:g}),g}clearInterstitial(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)}),e.reset()}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const r=this.playerQueue[i];this.log(`clear ${r} toSegment: ${t&&tt(t)}`),this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,r,n){const{interstitial:a,assetItem:o,assetId:u}=e,l=a.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!d||d.identifier!==u)&&(d&&(this.clearAssetPlayer(d.identifier,i[r]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${ni(o)}`),this.hls.trigger(v.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var i,r;if(!this.schedule)return;const{interstitial:n,assetItem:a}=e,o=this.schedule.findEventIndex(n.identifier),u=(i=this.schedule.items)==null?void 0:i[o];if(!u)return;e.loadSource(),this.setBufferingItem(u),this.bufferingAsset=a;const l=this.getBufferingPlayer();if(l===e)return;const d=n.appendInPlace;if(d&&l?.interstitial.appendInPlace===!1)return;const c=l?.tracks||((r=this.detachedData)==null?void 0:r.tracks)||this.requiredTracks;if(d&&a!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(c&&!Dl(c,e.tracks)){const h=new Error(`Asset ${ni(a)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(c)}')`),f={fatal:!0,type:W.OTHER_ERROR,details:D.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},g=n.findAssetIndex(a);this.handleAssetItemError(f,n,o,g,h.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const r=i.currentTime,n=t.findAssetIndex(e,r),a=e.assetList[n];if(a){const o=this.getAssetPlayer(a.identifier);if(o){const u=o.currentTime||r-a.timelineStart,l=o.duration-u;if(this.warn(`Stalled at ${u} of ${u+l} in ${o} ${e} (media.currentTime: ${r})`),u&&(l/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){const d=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,d,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,r,n){if(e.details===D.BUFFER_STALLED_ERROR)return;const a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&ni(a)} ${e.error}`),!this.schedule)return;const o=a?.identifier||"",u=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[u]||null,d=this.schedule.items,c=ce({},e,{fatal:!1,errorAction:di(!0),asset:a,assetListIndex:r,event:t,schedule:d,scheduleIndex:i,player:l});if(this.hls.trigger(v.INTERSTITIAL_ASSET_ERROR,c),!e.fatal)return;const h=this.playingAsset,f=this.bufferingAsset,g=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=g),!t.assetList.some(p=>!p.error))t.error=g;else for(let p=r;p<t.assetList.length;p++)this.resetAssetPlayer(t.assetList[p].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,r):f&&f.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${tt(i)} error: ${e.error}`);let r=this.timelinePos;r===-1&&(r=this.hls.startPosition);const n=this.updateItem(i,r);if(this.itemsMatch(i,n)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t)),!this.schedule)return;const a=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(a)}else this.checkStart()}onAssetListLoaded(e,t){var i,r;const n=t.event,a=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;const u=n.timelineStart,l=n.duration;let d=0;o.forEach((p,m)=>{const y=parseFloat(p.DURATION);this.createAsset(n,m,d,u+d,y,p.URI),d+=y}),n.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${n}`);const c=this.waitingItem,h=c?.event.identifier===a;this.updateSchedule();const f=(r=this.bufferingItem)==null?void 0:r.event;if(h){var g;const p=this.schedule.findEventIndex(a),m=(g=this.schedule.items)==null?void 0:g[p];if(m){if(!this.playingItem&&this.timelinePos>m.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==p){n.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${n}`),this.updateSchedule(!0),this.primaryFallback(n);return}this.setBufferingItem(m)}this.setSchedulePosition(p)}else if(f?.identifier===a){const p=n.assetList[0];if(p){const m=this.getAssetPlayer(p.identifier);if(f.appendInPlace){const y=this.primaryMedia;m&&y&&this.bufferAssetPlayer(m,y)}else m&&m.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case D.ASSET_LIST_PARSING_ERROR:case D.ASSET_LIST_LOAD_ERROR:case D.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case D.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const bo=500;class n0 extends Nn{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",H.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=C.IDLE,this.setInterval(bo),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:r}=t;if(this.fragContextChanged(i)||(Ae(i)&&(this.fragPrevious=i),this.state=C.IDLE),!r)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=i.start;for(let l=0;l<n.length;l++)if(o>=n[l].start&&o<=n[l].end){a=n[l];break}const u=i.start+i.duration;a?a.end=u:(a={start:o,end:u},n.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){const n=r-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(i,n,H.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===H.SUBTITLE&&(t.details===D.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==C.STOPPED&&(this.state=C.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&wu(this.levels,t)){this.levels=t.map(i=>new Ui(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const r=new Ui(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.state!==C.STOPPED&&this.setInterval(bo)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const u=n[o];if(o>=n.length||!u)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 l=0;if(a.live||(i=u.details)!=null&&i.live){if(a.deltaUpdateFailed)return;const c=this.mainDetails;if(!c){this.startFragRequested=!1;return}const h=c.fragments[0];if(!u.details)a.hasProgramDateTime&&c.hasProgramDateTime?(Gs(a,c),l=a.fragmentStart):h&&(l=h.start,jr(a,l));else{var d;l=this.alignPlaylists(a,u.details,(d=this.levelLastLoaded)==null?void 0:d.details),l===0&&h&&(l=h.start,jr(a,l))}c&&!this.startFragRequested&&this.setStartPosition(c,l)}u.details=a,this.levelLastLoaded=u,o===r&&(this.hls.trigger(v.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===C.IDLE&&(Xt(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&r!=null&&r.key&&r.iv&&ci(r.method)){const a=performance.now();
vendor: 28,983 bytes, lines 50-61
50this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,On(r.method)).catch(o=>{throw n.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const u=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:u}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=C.IDLE})}}doTick(){if(!this.media){this.state=C.IDLE;return}if(this.state===C.IDLE){const{currentTrackId:e,levels:t}=this,i=t?.[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:r}=this,n=this.getLoadPosition(),a=J.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:u}=a,l=i.details,d=this.hls.maxBufferLength+l.levelTargetDuration;if(u>d)return;const c=l.fragments,h=c.length,f=l.edge;let g=null;const p=this.fragPrevious;if(o<f){const T=r.maxFragLookUpTolerance,E=o>f-T?0:T;g=Xt(p,c,Math.max(c[0].start,o),E),!g&&p&&p.start<c[0].start&&(g=c[0])}else g=c[h-1];if(g=this.filterReplacedPrimary(g,i.details),!g)return;const m=g.sn-l.startSN,y=c[m-1];if(y&&y.cc===g.cc&&this.fragmentTracker.getState(y)===Re.NOT_LOADED&&(g=y),this.fragmentTracker.getState(g)===Re.NOT_LOADED){const T=this.mapToInitFragWhenRequired(g);T&&this.loadFragment(T,i,o)}}}loadFragment(e,t,i){Ae(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new a0(this.tracksBuffered[this.currentTrackId]||[])}}class a0{constructor(e){this.buffered=void 0;const t=(i,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const o0={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},ju=s=>String.fromCharCode(o0[s]||s),nt=15,Tt=100,l0={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},u0={17:2,18:4,21:6,22:8,23:10,19:13,20:15},d0={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},c0={25:2,26:4,29:6,30:8,31:10,27:13,28:15},h0=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class f0{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;ue.log(`${this.time} [${e}] ${i}`)}}}const Vt=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class zu{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){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const r=t[i];e.hasOwnProperty(r)&&(this[r]=e[r])}}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}}class g0{constructor(){this.uchar=" ",this.penState=new zu}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()}}class m0{constructor(e){this.chars=[],this.pos=0,this.currPenState=new zu,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Tt;t++)this.chars.push(new g0);this.logger=e}equals(e){for(let t=0;t<Tt;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Tt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Tt;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>Tt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Tt)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=ju(e);if(this.pos>=Tt){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<Tt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Tt;i++){const r=this.chars[i].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class _r{constructor(e){this.rows=[],this.currRow=nt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<nt;t++)this.rows.push(new m0(e));this.logger=e}reset(){for(let e=0;e<nt;e++)this.rows[e].clear();this.currRow=nt-1}equals(e){let t=!0;for(let i=0;i<nt;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<nt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<nt;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 = "+ge(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<nt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,u=this.logger.time;if(o!==null&&u!==null&&o<u)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+ge(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());const 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;const t=[];let i="",r=-1;for(let n=0;n<nt;n++){const a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
51`)),i}getTextAndFormat(){return this.rows}}class xo{constructor(e,t,i){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 _r(i),this.nonDisplayedMemory=new _r(i),this.lastOutputScreen=new _r(i),this.currRollUpRow=this.displayedMemory.rows[nt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[nt-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const 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"){const 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){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i]}this.logger.log(2,"MIDROW: "+ge(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const 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))}}class Io{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=v0(),this.logger=void 0;const r=this.logger=new f0;this.channels=[null,new xo(e,t,r),new xo(e+1,i,r)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const r=t[i]&127,n=t[i+1]&127;let a=!1,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+Vt([t[i],t[i+1]])+"] -> ("+Vt([r,n])+")");const u=this.cmdHistory;if(r>=16&&r<=31){if(p0(r,n,u)){ss(null,null,u),this.logger.log(3,()=>"Repeated command ("+Vt([r,n])+") is dropped");continue}ss(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n))}else ss(null,null,u);if(!a&&(o=this.parseChars(r,n),o)){const d=this.currentChannel;d&&d>0?this.channels[d].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Vt([r,n])+" orig: "+Vt([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(i||r))return!1;const 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 i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[i];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Vt([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return!1;const a=e<=23?1:2;t>=64&&t<=95?i=a===1?l0[e]:d0[e]:i=a===1?u0[e]:c0[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let i;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,r.underline=(i&1)===1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(e,t){let i,r=null,n=null;if(e>=25?(i=2,n=e-8):(i=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 '"+ju(a)+"' in channel "+i),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes =  "+Vt(r).join(",")),r}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(i||r))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=h0[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}ss(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function ss(s,e,t){t.a=s,t.b=e}function p0(s,e,t){return t.a===s&&t.b===e}function v0(){return{a:null,b:null}}var jn=(function(){if($s!=null&&$s.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,u){if(typeof u!="string"||!Array.isArray(o))return!1;const l=u.toLowerCase();return~o.indexOf(l)?l:!1}function i(o){return t(s,o)}function r(o){return t(e,o)}function n(o,...u){let l=1;for(;l<arguments.length;l++){const d=arguments[l];for(const c in d)o[c]=d[c]}return o}function a(o,u,l){const d=this,c={enumerable:!0};d.hasBeenReset=!1;let h="",f=!1,g=o,p=u,m=l,y=null,T="",E=!0,S="auto",_="start",x=50,A="middle",I=50,R="middle";Object.defineProperty(d,"id",n({},c,{get:function(){return h},set:function(b){h=""+b}})),Object.defineProperty(d,"pauseOnExit",n({},c,{get:function(){return f},set:function(b){f=!!b}})),Object.defineProperty(d,"startTime",n({},c,{get:function(){return g},set:function(b){if(typeof b!="number")throw new TypeError("Start time must be set to a number.");g=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",n({},c,{get:function(){return p},set:function(b){if(typeof b!="number")throw new TypeError("End time must be set to a number.");p=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",n({},c,{get:function(){return m},set:function(b){m=""+b,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",n({},c,{get:function(){return y},set:function(b){y=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",n({},c,{get:function(){return T},set:function(b){const k=i(b);if(k===!1)throw new SyntaxError("An invalid or illegal string was specified.");T=k,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",n({},c,{get:function(){return E},set:function(b){E=!!b,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",n({},c,{get:function(){return S},set:function(b){if(typeof b!="number"&&b!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",n({},c,{get:function(){return _},set:function(b){const k=r(b);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");_=k,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",n({},c,{get:function(){return x},set:function(b){if(b<0||b>100)throw new Error("Position must be between 0 and 100.");x=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",n({},c,{get:function(){return A},set:function(b){const k=r(b);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");A=k,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",n({},c,{get:function(){return I},set:function(b){if(b<0||b>100)throw new Error("Size must be between 0 and 100.");I=b,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",n({},c,{get:function(){return R},set:function(b){const k=r(b);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");R=k,this.hasBeenReset=!0}})),d.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a})();class y0{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Xu(s){function e(i,r,n,a){return(i|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}const t=s.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}class E0{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){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)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Qu(s,e,t,i){const r=i?s.split(i):[s];for(const n in r){if(typeof r[n]!="string")continue;const a=r[n].split(t);if(a.length!==2)continue;const o=a[0],u=a[1];e(o,u)}}const sn=new jn(0,0,""),rs=sn.align==="middle"?"middle":"center";function T0(s,e,t){const i=s;function r(){const o=Xu(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,u){const l=new E0;Qu(o,function(h,f){let g;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){l.set(h,t[p].region);break}break;case"vertical":l.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),l.integer(h,g[0]),l.percent(h,g[0])&&l.set("snapToLines",!1),l.alt(h,g[0],["auto"]),g.length===2&&l.alt("lineAlign",g[1],["start",rs,"end"]);break;case"position":g=f.split(","),l.percent(h,g[0]),g.length===2&&l.alt("positionAlign",g[1],["start",rs,"end","line-left","line-right","auto"]);break;case"size":l.percent(h,f);break;case"align":l.alt(h,f,["start",rs,"end","left","right"]);break}},/:/,/\s/),u.region=l.get("region",null),u.vertical=l.get("vertical","");let d=l.get("line","auto");d==="auto"&&sn.line===-1&&(d=-1),u.line=d,u.lineAlign=l.get("lineAlign","start"),u.snapToLines=l.get("snapToLines",!0),u.size=l.get("size",100),u.align=l.get("align",rs);let c=l.get("position","auto");c==="auto"&&sn.position===50&&(c=u.align==="start"||u.align==="left"?0:u.align==="end"||u.align==="right"?100:50),u.position=c}function a(){s=s.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e)}function Ju(s){return s.replace(/<br(?: \/)?>/gi,`
52`)}class S0{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new y0,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let n=t.buffer,a=0;for(n=Ju(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
53`;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
54`&&++a,t.buffer=n.slice(a),o}function r(n){Qu(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();const 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=i(),t.state){case"HEADER":/:/.test(n)?r(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 jn(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{T0(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const 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+=`
55`),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(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
56
57`,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}}const _0=/\r\n|\n\r|\n|\r/g,Ar=function(e,t,i=0){return e.slice(i,i+t.length)===t},A0=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!$(t)||!$(i)||!$(r)||!$(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=3600*1e3*n,t};function zn(s,e,t){return Pi(s.toString())+Pi(e.toString())+Pi(t)}const b0=function(e,t,i){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=r.start-n.start,r.new=!1,r=n,n=e[r.prevCC]}e.presentationOffset=i};function x0(s,e,t,i,r,n,a){const o=new S0,u=Ye(new Uint8Array(s)).trim().replace(_0,`
58`).split(`
59`),l=[],d=e?Cm(e.baseTime,e.timescale):0;let c="00:00.000",h=0,f=0,g,p=!0;o.oncue=function(m){const y=t[i];let T=t.ccOffset;const E=(h-d)/9e4;if(y!=null&&y.new&&(f!==void 0?T=t.ccOffset=y.start:b0(t,i,E)),E){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}T=E-t.presentationOffset}const S=m.endTime-m.startTime,_=He((m.startTime+T-f)*9e4,r*9e4)/9e4;m.startTime=Math.max(_,0),m.endTime=Math.max(_+S,0);const x=m.text.trim();m.text=decodeURIComponent(encodeURIComponent(x)),m.id||(m.id=zn(m.startTime,m.endTime,x)),m.endTime>0&&l.push(m)},o.onparsingerror=function(m){g=m},o.onflush=function(){if(g){a(g);return}n(l)},u.forEach(m=>{if(p)if(Ar(m,"X-TIMESTAMP-MAP=")){p=!1,m.slice(16).split(",").forEach(y=>{Ar(y,"LOCAL:")?c=y.slice(6):Ar(y,"MPEGTS:")&&(h=parseInt(y.slice(7)))});try{f=A0(c)/1e3}catch(y){g=y}return}else m===""&&(p=!1);o.parse(m+`
60`)}),o.flush()}const br="stpp.ttml.im1t",Zu=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ed=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,I0={left:"start",center:"center",right:"end",start:"start",end:"end"};function Ro(s,e,t,i){const r=te(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>Ye(o)),a=km(e.baseTime,1,e.timescale);try{n.forEach(o=>t(R0(o,a)))}catch(o){i(o)}}function R0(s,e){const r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=r.getAttribute(`ttp:${h}`)||n[h],c),{}),o=r.getAttribute("xml:space")!=="preserve",u=Lo(xr(r,"styling","style")),l=Lo(xr(r,"layout","region")),d=xr(r,"body","[begin]");return[].map.call(d,c=>{const h=td(c,o);if(!h||!c.hasAttribute("begin"))return null;const f=Rr(c.getAttribute("begin"),a),g=Rr(c.getAttribute("dur"),a);let p=Rr(c.getAttribute("end"),a);if(f===null)throw Do(c);if(p===null){if(g===null)throw Do(c);p=f+g}const m=new jn(f-e,p-e,h);m.id=zn(m.startTime,m.endTime,m.text);const y=l[c.getAttribute("region")],T=u[c.getAttribute("style")],E=L0(y,T,u),{textAlign:S}=E;if(S){const _=I0[S];_&&(m.lineAlign=_),m.align=S}return ce(m,E),m}).filter(c=>c!==null)}function xr(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Lo(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function td(s,e){return[].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
61`:(n=i.childNodes)!=null&&n.length?td(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function L0(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,u)=>{const l=Ir(e,i,u)||Ir(s,i,u)||Ir(r,i,u);return l&&(o[u]=l),o},{})}function Ir(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Do(s){return new Error(`Could not parse ttml timestamp ${s}`)}function Rr(s,e){if(!s)return null;let t=Xu(s);return t===null&&(Zu.test(s)?t=D0(s,e):ed.test(s)&&(t=k0(s,e))),t}function D0(s,e){const t=Zu.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function k0(s,e){const t=ed.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class ns{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class C0{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=Co(),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}}
vendor: 4,133 bytes, line 61
61,e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new ns(this,"textTrack1"),t=new ns(this,"textTrack2"),i=new ns(this,"textTrack3"),r=new ns(this,"textTrack4");this.cea608Parser1=new Io(1,e,t),this.cea608Parser2=new Io(3,i,r)}addCues(e,t,i,r,n){let a=!1;for(let o=n.length;o--;){const u=n[o],l=w0(u[0],u[1],t,i);if(l>=0&&(u[0]=Math.min(u[0],t),u[1]=Math.max(u[1],i),a=!0,l/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,r)}else{const o=this.Cues.newCue(null,t,i,r);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:r,timescale:n,trackId:a}){const{unparsedVttFrags:o}=this;i===H.MAIN&&(this.initPTS[t.cc]={baseTime:r,timescale:n,trackId:a}),o.length&&(this.unparsedVttFrags=[],o.forEach(u=>{this.initPTS[u.frag.cc]?this.onFragLoaded(v.FRAG_LOADED,u):this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let r=0;r<i.textTracks.length;r++){const n=i.textTracks[r];if(ko(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)i[e]=o,li(i[e]),qu(i[e],r);else{const u=this.createTextTrack("captions",n,a);u&&(u[e]=!0,i[e]=u)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,i){const r=this.media;if(r)return r.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:r}=this;Object.keys(r).forEach(n=>{li(r[n]),delete r[n]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Co(),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(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)li(t[i])}
vendor: 13,194 bytes, line 61
61onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],r=i.some(n=>n.textCodec===br);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(wu(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const a=this.media,o=a?ps(a.textTracks):null;if(this.tracks.forEach((u,l)=>{let d;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&ko(o[h],u)){c=o[h],o[h]=null;break}c&&(d=c)}if(d)li(d);else{const c=id(u);d=this.createTextTrack(c,u.name,u.lang),d&&(d.mode="disabled")}d&&this.textTracks.push(d)}),o!=null&&o.length){const u=o.filter(l=>l!==null).map(l=>l.label);u.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${u.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===H.MAIN){var i,r;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:u,sn:l}=t.frag,d=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}onFragLoaded(e,t){const{frag:i,payload:r}=t;if(i.type===H.SUBTITLE)if(r.byteLength){const n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[i.level],u=this.vttCCs;u[i.cc]||(u[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===br?this._parseIMSC1(i,r):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;Ro(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{i.logger.log(`Failed to parse IMSC1: ${r}`),i.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:i,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[i.cc]&&o===-1){a.push(e);return}const u=this.hls,l=(t=i.initSegment)!=null&&t.data?Je(i.initSegment.data,new Uint8Array(r)).buffer:r;x0(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,d=>{this._appendCues(d,i.level),u.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},d=>{const c=d.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(i,r),u.logger.log(`Failed to parse VTT cue: ${d}`),!(c&&o>i.cc)&&u.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:d})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||Ro(t,this.initPTS[e.cc],()=>{i.textCodec=br,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Yu(r,n))}else{const r=this.tracks[t];if(!r)return;const n=r.default?"default":"subtitles"+t;i.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===H.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:r}=t;if(!(i.type===H.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){const a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:r,type:n}){const{media:a}=this;if(!(!a||a.currentTime<i)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(u=>tn(o[u],t,i))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(u=>tn(o[u],t,r))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let r=2;for(let n=0;n<i;n++){const a=e[r++],o=127&e[r++],u=127&e[r++];if(o===0&&u===0)continue;if((4&a)!==0){const d=3&a;(d===0||d===1)&&(t[d].push(o),t[d].push(u))}}return t}}function id(s){return s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function ko(s,e){return!!s&&s.kind===id(e)&&Qr(e,s)}function w0(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Co(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const P0=/\s/,O0={newCue(s,e,t,i){const r=[];let n,a,o,u,l;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,u=0,l="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)P0.test(n.chars[p].uchar)&&o?u++:(l+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),u>=16?u--:u++;const f=Ju(l.trim()),g=zn(e,t,f);s!=null&&(c=s.cues)!=null&&c.getCueById(g)||(a=new d(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(u*8/32)*10),r.push(a))}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Yu(s,h))),r}};function M0(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const N0=/(\d+)-(\d+)\/(\d+)/;class wo{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||$0,this.controller=new self.AbortController,this.stats=new Rn}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,i){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=F0(e,this.controller.signal),a=e.responseType==="arraybuffer",o=a?"byteLength":"length",{maxTimeToFirstByteMs:u,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=u&&$(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))},t.timeout),(Gi(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(c=>{var h;this.response=this.loader=c;const f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,e,this.response))},l-(f-r.loading.start)),!c.ok){const{status:p,statusText:m}=c;throw new G0(m||"fetch, bad network response",p,c)}r.loading.first=f,r.total=B0(c.headers)||r.total;const g=(h=this.callbacks)==null?void 0:h.onProgress;return g&&$(t.highWaterMark)?this.loadProgressively(c,r,e,t.highWaterMark,g):a?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{var h,f;const g=this.response;if(!g)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const p=c[o];p&&(r.loaded=r.total=p);const m={url:g.url,data:c,code:g.status},y=(h=this.callbacks)==null?void 0:h.onProgress;y&&!$(t.highWaterMark)&&y(r,e,c,g),(f=this.callbacks)==null||f.onSuccess(m,r,e,g)}).catch(c=>{var h;if(self.clearTimeout(this.requestTimeout),r.aborted)return;const f=c&&c.code||0,g=c?c.message:null;(h=this.callbacks)==null||h.onError({code:f,text:g},e,c?c.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,r=0,n){const a=new hu,o=e.body.getReader(),u=()=>o.read().then(l=>{if(l.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const d=l.value,c=d.length;return t.loaded+=c,c<r||a.dataLength?(a.push(d),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,d.buffer,e),u()}).catch(()=>Promise.reject());return u()}}function F0(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ce({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function U0(s){const e=N0.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function B0(s){const e=s.get("Content-Range");if(e){const i=U0(e);if($(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function $0(s,e){return new self.Request(s.url,e)}class G0 extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const K0=/^age:\s*[\d.]+\s*$/im;class sd{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 Rn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const 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,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&$(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,d=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){const g=d??t.response;if(g!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const p=t.responseType==="arraybuffer"?g.byteLength:g.length;i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const m=(a=this.callbacks)==null?void 0:a.onProgress;m&&m(i,e,g,t);const y={url:t.responseURL,data:g,code:l};(o=this.callbacks)==null||o.onSuccess(y,i,e,t);return}}const c=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:l};if(Us(c,h,!1,f))this.retry(c);else{var u;ue.error(`${l} while loading ${e.url}`),(u=this.callbacks)==null||u.onError({code:l,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Us(e,t,!0))this.retry(e);else{var i;ue.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;
vendor: 4,601 bytes, line 61
61this.retryDelay=Cn(e,i.retry),i.retry++,ue.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&K0.test(this.loader.getAllResponseHeaders())){const 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}}const V0={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},H0=le(le({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:sd,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:ig,bufferController:Ym,capLevelController:qn,errorController:og,fpsController:Wp,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:tu,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:V0},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},q0()),{},{subtitleStreamController:n0,subtitleTrackController:Xp,timelineController:C0,audioStreamController:Km,audioTrackController:Vm,emeController:hi,cmcdController:V
vendor: 3,115 bytes, line 61
61p,contentSteeringController:qp,interstitialsController:r0});function q0(){return{cueHandler:O0,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 Y0(s,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=rn(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{const o=`${a==="level"?"playlist":a}LoadPolicy`,u=e[o]===void 0,l=[];n.forEach(d=>{const c=`${a}Loading${d}`,h=e[c];if(h!==void 0&&u){l.push(c);const f=i[o].default;switch(e[o]={default:f},d){case"TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case"MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${ge(e[o])}`)}),le(le({},i),e)}function rn(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(rn):Object.keys(s).reduce((e,t)=>(e[t]=rn(s[t]),e),{}):s}function W0(s,e){const t=s.loader;t!==wo&&t!==sd?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):M0()&&(s.loader=wo,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const vs=2,j0=.1,z0=.05,X0=100;class Q0 extends Xl{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;
vendor: 24,333 bytes, line 61
61e&&(e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(X0),this.mediaSource=t.mediaSource;const i=this.media=t.media;Ue(i,"playing",this.onMediaPlaying),Ue(i,"waiting",this.onMediaWaiting),Ue(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&($e(i,"playing",this.onMediaPlaying),$e(i,"waiting",this.onMediaWaiting),$e(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,r;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const a=this.media;if(!a)return;const{seeking:o}=a,u=this.seeking&&!o,l=!this.seeking&&o,d=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||u){u&&this.stallResolved(e);return}if(d){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!1}));return}if(!J.getBuffered(a).length){this.nudgeRetry=0;return}const c=J.bufferInfo(a,e,0),h=c.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){const x=Po(this.hls.inFlightFragments,e),A=c.len>vs,I=!h||x||h-e>vs&&!f.getPartialFragment(e);if(A||I)return;this.moved=!1}const g=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(c.len>0)&&!h)return;const A=Math.max(h,c.start||0)-e,R=!!(g!=null&&g.live)?g.targetduration*2:vs,b=as(e,f);if(A>0&&(A<=R||b)){a.paused||this._trySkipBufferHole(b);return}}const p=n.detectStallWithCurrentTimeMs,m=self.performance.now(),y=this.waiting;let T=this.stalled;if(T===null)if(y>0&&m-y<p)T=this.stalled=y;else{this.stalled=m;return}const E=m-T;if(!o&&(E>=p||y)&&this.hls){var S;if(((S=this.mediaSource)==null?void 0:S.readyState)==="ended"&&!(g!=null&&g.live)&&Math.abs(e-(g?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(v.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(c),!this.media||!this.hls)return}const _=J.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(_,E,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(v.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){const n=J.bufferedInfo(J.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const a=J.timeRangesToArray(r),o=J.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){const u=J.bufferedInfo(a,e,0).bufferedIndex,l=a[o].end,d=a[o+1].start;if((u===-1||u>o)&&d-l<1&&e-l<2){const c=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${d} buffered index: ${u}`);this.warn(c.message),this.media.currentTime+=1e-6;let h=as(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const f=J.bufferInfo(this.media,e,0);this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:c,reason:c.message,frag:h,buffer:f.len,bufferInfo:f})}}}}}_tryFixBufferStall(e,t,i){var r,n;const{fragmentTracker:a,media:o}=this,u=(r=this.hls)==null?void 0:r.config;if(!o||!a||!u)return;const l=(n=this.hls)==null?void 0:n.latestLevelDetails,d=as(i,a);if((d||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;const c=e.buffered,h=this.adjacentTraversal(e,i);(c&&c.length>1&&e.len>u.maxBufferHole||e.nextStart&&(e.nextStart-i<u.maxBufferHole||h))&&(t>u.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,r=e.nextStart;if(i&&r){const n=i.getFragAtPos(t,H.MAIN),a=i.getFragAtPos(r,H.MAIN);if(n&&a)return a.sn-n.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${ge(e)})`);this.warn(a.message),t.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:r}=this,n=(t=this.hls)==null?void 0:t.config;if(!r||!i||!n)return 0;const a=r.currentTime,o=J.bufferInfo(r,a,0),u=a<o.start?o.start:o.nextStart;if(u&&this.hls){const d=o.len<=n.maxBufferHole,c=o.len>0&&o.len<1&&r.readyState<3,h=u-a;if(h>0&&(d||c)){if(h>n.maxBufferHole){let g=!1;if(a===0){const p=i.getAppendedFrag(0,H.MAIN);p&&u<p.end&&(g=!0)}if(!g&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||Po(this.hls.inFlightFragments,u))return 0;let m=!1,y=e.end;for(;y<u;){const T=as(y,i);if(T)y+=T.duration;else{m=!0;break}}if(m)return 0}}const f=Math.max(u+z0,a+j0);if(this.warn(`skipping hole, adjusting currentTime from ${a} to ${f}`),this.moved=!0,r.currentTime=f,!(e!=null&&e.gap)){const g=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${f}`),p={type:W.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:g,reason:g.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?p.part=e:p.frag=e),this.hls.trigger(v.ERROR,p)}return f}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;const a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){const o=a+(r+1)*n.nudgeOffset,u=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(u.message),i.currentTime=o,t.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Po(s,e){const t=Oo(s.main);if(t&&t.start<=e)return t;const i=Oo(s.audio);return i&&i.start<=e?i:null}function Oo(s){if(!s)return null;switch(s.state){case C.IDLE:case C.STOPPED:case C.ENDED:case C.ERROR:return null}return s.frag}function as(s,e){return e.getAppendedFrag(s,H.MAIN)||e.getPartialFragment(s)}const J0=.25;function nn(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Lr(s,e,t,i,r){let n=new s(e,t,"");try{n.value=i,r&&(n.type=r)}catch{n=new s(e,t,ge(r?le({type:r},i):i))}return n}const os=(()=>{const s=nn();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class Z0{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(v.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&li(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return qu(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=nn();if(a)for(let o=0;o<n.length;o++){const u=n[o].type;if(u===qe.emsg&&!i||!r)continue;const l=Eu(n[o].data),d=n[o].pts;let c=d+n[o].duration;c>os&&(c=os),c-d<=0&&(c=d+J0);for(let f=0;f<l.length;f++){const g=l[f];if(!Tu(g)){this.updateId3CueEnds(d,u);const p=Lr(a,d,c,g,u);p&&this.id3Track.addCue(p)}}}}updateId3CueEnds(e,t){var i;const r=(i=this.id3Track)==null?void 0:i.cues;if(r)for(let n=r.length;n--;){const a=r[n];a.type===t&&a.startTime<e&&a.endTime===os&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:u}}=a;if(n&&(o||u)){let l;r==="audio"?l=d=>d.type===qe.audioId3&&u:r==="video"?l=d=>d.type===qe.emsg&&o:l=d=>d.type===qe.audioId3&&u||d.type===qe.emsg&&o,tn(n,t,i,l)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;const o=nn();if(i&&r&&!a){const{fragmentStart:p,fragmentEnd:m}=e;let y=this.assetCue;y?(y.startTime=p,y.endTime=m):o&&(y=this.assetCue=Lr(o,p,m,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),y&&(y.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(y),y.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:u}=this,{dateRanges:l}=e,d=Object.keys(l);let c=this.dateRangeCuesAppended;if(u&&t){var h;if((h=u.cues)!=null&&h.length){const p=Object.keys(c).filter(m=>!d.includes(m));for(let m=p.length;m--;){var f;const y=p[m],T=(f=c[y])==null?void 0:f.cues;delete c[y],T&&Object.keys(T).forEach(E=>{const S=T[E];if(S){S.removeEventListener("enter",this.onEventCueEnter);try{u.removeCue(S)}catch{}}})}}else c=this.dateRangeCuesAppended={}}const g=e.fragments[e.fragments.length-1];if(!(d.length===0||!$(g?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let p=0;p<d.length;p++){const m=d[p],y=l[m],T=y.startTime,E=c[m],S=E?.cues||{};let _=E?.durationKnown||!1,x=os;const{duration:A,endDate:I}=y;if(I&&A!==null)x=T+A,_=!0;else if(y.endOnNext&&!_){const b=d.reduce((k,M)=>{if(M!==y.id){const G=l[M];if(G.class===y.class&&G.startDate>y.startDate&&(!k||y.startDate<k.startDate))return G}return k},null);b&&(x=b.startTime,_=!0)}const R=Object.keys(y.attr);for(let b=0;b<R.length;b++){const k=R[b];if(!Tg(k))continue;const M=S[k];if(M)_&&!(E!=null&&E.durationKnown)?M.endTime=x:Math.abs(M.startTime-T)>.01&&(M.startTime=T,M.endTime=x);else if(o){let G=y.attr[k];Sg(k)&&(G=kl(G));const U=Lr(o,T,x,{key:k,data:G},qe.dateRange);U&&(U.id=m,this.id3Track.addCue(U),S[k]=U,a&&(k==="X-ASSET-LIST"||k==="X-ASSET-URL")&&U.addEventListener("enter",this.onEventCueEnter))}}c[m]={cues:S,dateRange:y,durationKnown:_}}}}}class ev{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const u=r-o,l=Math.min(this.maxLatency,o+i.targetduration);if(u<l&&u>.05&&this.forwardBufferLength>1){const c=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20,f=Math.min(c,Math.max(1,h));this.changeMediaPlaybackRate(t,f)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,u=this.hls.userConfig;let l=o&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:a*r);const d=r;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class tv extends Hn{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(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.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){const i=this.hls.config.preferManagedMediaSource,r=[],n={},a={};let o=!1,u=!1,l=!1;t.levels.forEach(d=>{const c=d.attrs;let{audioCodec:h,videoCodec:f}=d;h&&(d.audioCodec=h=Os(h,i)||void 0),f&&(f=d.videoCodec=Ff(f));const{width:g,height:p,unknownCodecs:m}=d,y=m?.length||0;if(o||(o=!!(g&&p)),u||(u=!!f),l||(l=!!h),y||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log(`Some or all CODECS not supported "${c.CODECS}"`);return}const{CODECS:T,"FRAME-RATE":E,"HDCP-LEVEL":S,"PATHWAY-ID":_,RESOLUTION:x,"VIDEO-RANGE":A}=c,R=`${`${_||"."}-`}${d.bitrate}-${x}-${E}-${T}-${A}-${S}`;if(n[R])if(n[R].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const b=a[R]+=1;d.attrs["PATHWAY-ID"]=new Array(b+1).join(".");const k=this.createLevel(d);n[R]=k,r.push(k)}else n[R].addGroupId("audio",c.AUDIO),n[R].addGroupId("text",c.SUBTITLES);else{const b=this.createLevel(d);n[R]=b,a[R]=1,r.push(b)}}),this.filterAndSortMediaOptions(r,t,o,u,l)}createLevel(e){const t=new Ui(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=Kl(r,[])}return t}isAudioSupported(e){return Ni(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Ni(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,r,n){var a;let o=[],u=[],l=e;const d=((a=t.stats)==null?void 0:a.parsing)||{};if((i||r)&&n&&(l=l.filter(({videoCodec:T,videoRange:E,width:S,height:_})=>(!!T||!!(S&&_))&&Wf(E))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let T="no level with compatible codecs found in manifest",E=T;t.levels.length&&(E=`one or more CODECS in variant not supported: ${ge(t.levels.map(_=>_.attrs.CODECS).filter((_,x,A)=>A.indexOf(_)===x))}`,this.warn(E),T+=` (${E})`);const S=new Error(T);this.hls.trigger(v.ERROR,{type:W.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:S,reason:E})}}),d.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(T=>!T.audioCodec||this.isAudioSupported(T.audioCodec)),Mo(o)),t.subtitles&&(u=t.subtitles,Mo(u));const c=l.slice(0);l.sort((T,E)=>{if(T.attrs["HDCP-LEVEL"]!==E.attrs["HDCP-LEVEL"])return(T.attrs["HDCP-LEVEL"]||"")>(E.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&T.height!==E.height)return T.height-E.height;if(T.frameRate!==E.frameRate)return T.frameRate-E.frameRate;if(T.videoRange!==E.videoRange)return Ms.indexOf(T.videoRange)-Ms.indexOf(E.videoRange);if(T.videoCodec!==E.videoCodec){const S=xa(T.videoCodec),_=xa(E.videoCodec);if(S!==_)return _-S}if(T.uri===E.uri&&T.codecSet!==E.codecSet){const S=Ps(T.codecSet),_=Ps(E.codecSet);if(S!==_)return _-S}return T.averageBitrate!==E.averageBitrate?T.averageBitrate-E.averageBitrate:0});let h=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let T=0;T<c.length;T++)if(c[T].pathwayId===l[0].pathwayId){h=c[T];break}}this._levels=l;for(let T=0;T<l.length;T++)if(l[T]===h){var f;this._firstLevel=T;const E=h.bitrate,S=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${E}`),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const _=Math.min(E,this.hls.config.abrEwmaDefaultEstimateMax);_>S&&S===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=_)}break}const g=n&&!r,p=this.hls.config,m=!!(p.audioStreamController&&p.audioTrackController),y={levels:l,audioTracks:o,subtitleTracks:u,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:m&&!g&&o.some(T=>!!T.url)};d.end=performance.now(),this.hls.trigger(v.MANIFEST_PARSED,y)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const d=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:d,reason:d.message}),c)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const u={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(v.LEVEL_SWITCHING,u);const l=a.details;if(!l||l.live){const d=this.switchParams(a.uri,r?.details,l);this.loadPlaylist(d)}}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){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===ie.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}
vendor: 5,171 bytes, line 61
61){if(t!==void 0&&t.type===H.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var i;const{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let u=a.details;u===t.details&&u.advanced&&(u=void 0),this.playlistLoaded(r,t,u)}else(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(v.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((n,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),!1));uu(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(v.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Mo(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function rd(){return self.SourceBuffer||self.WebKitSourceBuffer}function nd(){if(!Nt())return!1;const e=rd();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function iv(){if(!nd())return!1;const s=Nt();return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(Fi(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(Fi(e,"audio"))))}function sv(){var s;const e=rd();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}const rv=100;class nv extends Nn{constructor(e,t,i){super(e,t,i,"stream-controller",H.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const r=this.media,n=r?r.currentTime:null;if(n===null||!$(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;const a=this.getFwdBufferInfoAtPos(r,n,H.MAIN,0);if(a===null||a.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${a?a.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}
vendor: 36,206 bytes, line 61
61startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(rv),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=C.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=C.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case C.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=C.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=C.IDLE;break}break}case C.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===C.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;const a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const u=this.getLevelDetails();if(u&&this._streamEnded(o,u)){const p={};this.altAudio===2&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=C.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;const l=a.details;if(!l||this.state===C.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=C.WAITING_LEVEL,this.startFragRequested=!1;return}const d=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(d>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&Ae(f)&&this.fragmentTracker.getState(f)!==Re.OK){var g;const m=((g=this.backtrackFragment)!=null?g:f).sn-l.startSN,y=l.fragments[m-1];y&&f.cc===y.cc&&(f=y,this.fragmentTracker.removeFragment(y))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const m=this.audioOnly&&!this.altAudio?fe.AUDIO:fe.VIDEO,y=(m===fe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,m,H.MAIN)}f=this.getNextFragmentLoopLoading(f,l,o,H.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);r===Re.NOT_LOADED||r===Re.PARTIAL?Ae(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,H.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,u=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*u.maxBitrate/(1e3*l)+1:i=0}else i=0;const a=this.getBufferedFrag(t.currentTime+i);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const u=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,d=Math.max(a.end,u+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(d,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case C.KEY_LOADING:case C.FRAG_LOADING:case C.FRAG_LOADING_WAITING_RETRY:case C.PARSING:case C.PARSED:this.state=C.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;Ue(i,"playing",this.onMediaPlaying),Ue(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&($e(i,"playing",this.onMediaPlaying),$e(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,r=!1;for(let n=0;n<t.levels.length;n++){const a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&r&&!sv(),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){const{levels:i}=this;if(!i||this.state!==C.IDLE)return;const r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=C.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,u=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${u}`);const l=t.levelInfo,d=this.fragCurrent;d&&(this.state===C.FRAG_LOADING||this.state===C.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(o.live||(i=l.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,c),this.hls.trigger(v.LEVEL_UPDATED,{details:o,level:a}),this.state===C.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=C.IDLE}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,o=e.edge,u=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!u)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!u&&i.readyState<4||n<o-d)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;const c=J.bufferInfo(i,r,0);if(!((l=c.buffered)!=null&&l.length)){i.currentTime=r;return}if(c.start<=n){i.currentTime=r;return}const{nextStart:f}=J.bufferedInfo(c.buffered,n,0);f&&(i.currentTime=f)}else i.currentTime=r}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const u=o.details;if(!u){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const l=o.videoCodec,d=u.PTSKnown||!u.live,c=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new Cu(this.hls,H.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=r?r.index:-1,p=g!==-1,m=new Pn(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,p),y=this.initPTS[i.cc];f.push(n,c,h,l,i,r,u.totalduration,d,m,y)}onAudioTrackSwitching(e,t){const i=this.hls,r=this.altAudio===2;if(Ns(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(r){this.fragmentTracker.removeAllFragments(),i.once(v.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(v.AUDIO_TRACK_SWITCHED,t)}),i.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=Ns(t.url,this.hls);if(i){const r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let r,n,a=!1;for(const o in i){const u=i[o];if(u.id==="main"){if(n=o,r=u,o==="video"){const l=i[o];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:r}=t,n=i.type===H.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===C.PARSED&&(this.state=C.IDLE);return}const o=r?r.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Ae(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r)}const a=this.media;a&&(!this._hasEnoughToStart&&J.getBuffered(a).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ie.LEVEL&&(this.state=C.IDLE);break;case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case D.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=C.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==fe.AUDIO||!this.altAudio){const i=(t===fe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,H.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const r=this.timelineOffset;r&&i&&(i+=r);const n=this.getLevelDetails(),a=J.getBuffered(e),o=a.length?a.start(0):0,u=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||u>0&&(u<l||this.loadingParts&&u<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${u} to match buffer start`),i+=u,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=C.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(v.FRAG_LOADED,i),n.bitrateTest=!1}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}const{frag:o,part:u,level:l}=a,{video:d,text:c,id3:h,initSegment:f}=r,{details:g}=l,p=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=C.PARSING,f){const m=f.tracks;if(m){const S=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,m,S,n),i.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:t,tracks:m})}const y=f.initPTS,T=f.timescale,E=this.initPTS[o.cc];if($(y)&&(!E||E.baseTime!==y||E.timescale!==T)){const S=f.trackId;this.initPTS[o.cc]={baseTime:y,timescale:T,trackId:S},i.trigger(v.INIT_PTS_FOUND,{frag:o,id:t,initPTS:y,timescale:T,trackId:S})}}if(d&&g){p&&d.type==="audiovideo"&&this.logMuxedErr(o);const m=g.fragments[o.sn-1-g.startSN],y=o.sn===g.startSN,T=!m||o.cc>m.cc;if(r.independent!==!1){const{startPTS:E,endPTS:S,startDTS:_,endDTS:x}=d;if(u)u.elementaryStreams[d.type]={startPTS:E,endPTS:S,startDTS:_,endDTS:x};else if(d.firstKeyFrame&&d.independent&&n.id===1&&!T&&(this.couldBacktrack=!0),d.dropped&&d.independent){const A=this.getMainFwdBufferInfo(),I=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,R=d.firstKeyFramePTS?d.firstKeyFramePTS:E;if(!y&&I<R-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=!0);o.setElementaryStreamInfo(d.type,o.start,S,o.start,x,!0)}else y&&E-(g.appliedTimelineOffset||0)>vs&&(o.gap=!0);o.setElementaryStreamInfo(d.type,E,S,_,x),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,u,n,y||T)}else if(y||T)o.gap=!0;else{this.backtrack(o);return}}if(p){const{startPTS:m,endPTS:y,startDTS:T,endDTS:E}=p;u&&(u.elementaryStreams[fe.AUDIO]={startPTS:m,endPTS:y,startDTS:T,endDTS:E}),o.setElementaryStreamInfo(fe.AUDIO,m,y,T,E),this.bufferFragmentData(p,o,u,n)}if(g&&h!=null&&h.samples.length){const m={id:t,frag:o,details:g,samples:h.samples};i.trigger(v.FRAG_PARSING_METADATA,m)}if(g&&c){const m={id:t,frag:o,details:g,samples:c.samples};i.trigger(v.FRAG_PARSING_USERDATA,m)}}logMuxedErr(e){this.warn(`${Ae(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:n,video:a,audiovideo:o}=t;if(n){const l=e.audioCodec;let d=ds(n.codec,l);d==="mp4a"&&(d="mp4a.40.5");const c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){d&&(d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5");const h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(d="mp4a.40.5")}d&&d.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(d="mp4a.40.2",this.log(`Android: force audio codec to ${d}`)),l&&l!==d&&this.log(`Swapping manifest audio codec "${l}" for "${d}"`),n.levelCodec=d,n.id=H.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${d||""}/${l||""}/${n.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=H.MAIN;const l=a.codec;if(l?.length===4)switch(l){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${a.codec!==l?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const u=Object.keys(t);if(u.length){if(this.hls.trigger(v.BUFFER_CODECS,t),!this.hls)return;u.forEach(l=>{const c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:c,frag:i,part:null,chunkMeta:r,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,H.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}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=C.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(J.isBuffered(e,i)?t=this.getAppendedFrag(i):J.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return $(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if($(t)){const i=this.getLevelDetails(),r=this.currentFrag||(i?Xt(null,i.fragments,t):null);if(r){const n=r.programDateTime;if(n!==null){const a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class av extends Ze{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const r=this.keyIdToKeyInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,i,r,n){return new St({type:W.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:r})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){const a=t[r];if(e.cc<=a.cc&&(!Ae(e)||!Ae(a)||e.sn<a.sn)||!i&&r==n-1)return this.emeController.selectKeySystemFormat(a).then(o=>{if(!this.emeController)return;a.setKeyFormat(o);const u=hs(o);if(u)return this.emeController.getKeySystemAccess([u])})}if(this.config.requireKeySystemAccessOnStart){const r=_i(this.config);if(r.length)return this.emeController.getKeySystemAccess(r)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,l))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));const o=Dr(n);let u=this.keyIdToKeyInfo[o];if((i=u)!=null&&i.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&(r=u)!=null&&r.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(d=>{const{keyInfo:c}=d;return n.key=c.decryptdata.key,{frag:e,keyInfo:c}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+Fe(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r;if(!e.decryptdata.keyId&&(r=t.initSegment)!=null&&r.data){const a=xf(t.initSegment.data);if(a.length){const o=a[0];o.some(u=>u!==0)&&(this.log(`Using keyId found in init segment ${Fe(o)}`),e.decryptdata.keyId=o,jt.setKeyIdForUri(e.decryptdata.uri,o))}}const n=this.emeController.loadKey(i);return(e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,"data"in a&&(a.data.frag=t),a})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,r=i.loader,n=new r(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,g,p)=>{const{frag:m,keyInfo:y}=g,T=Dr(y.decryptdata);if(!m.decryptdata||y!==this.keyIdToKeyInfo[T])return o(this.createKeyLoadError(m,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));y.decryptdata.key=m.decryptdata.key=new Uint8Array(h.data),m.keyLoader=null,y.loader=null,a({frag:m,keyInfo:y})},onError:(h,f,g,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,le({url:u.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(u,d,c)})}resetLoader(e){const{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);const a=Dr(i.decryptdata)||r;delete this.keyIdToKeyInfo[a],n&&n.destroy()}}function Dr(s){if(s.keyFormat!==Pe.FAIRPLAY){const e=s.keyId;if(e)return Fe(e)}return s.uri}function No(s){const{type:e}=s;switch(e){case ie.AUDIO_TRACK:return H.AUDIO;case ie.SUBTITLE_TRACK:return H.SUBTITLE;default:return H.MAIN}}function kr(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class ov{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:u}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ie.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:u})}onAudioTrackLoading(e,t){const{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ie.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ie.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[ie.LEVEL];if(i){const r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ie.LEVEL])}}load(e){var t;const i=this.hls.config;let r=this.getInternalLoader(e);if(r){const l=this.hls.logger,d=r.context;if(d&&d.levelOrTrack===e.levelOrTrack&&(d.url===e.url||d.deliveryDirectives&&!e.deliveryDirectives)){d.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${d.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let n;if(e.type===ie.MANIFEST?n=i.manifestLoadPolicy.default:n=ce({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),$((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===ie.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===ie.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===ie.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){const d=l.partTarget,c=l.targetduration;if(d&&c){const h=Math.max(d*3,c*.8)*1e3;n=ce({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},u={onSuccess:(l,d,c,h)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const g=l.data;d.parsing.start=performance.now(),mt.isMediaPlaylist(g)||c.type!==ie.MANIFEST?this.handleTrackOrLevelPlaylist(l,d,c,h||null,f):this.handleMasterPlaylist(l,d,c,h)},onError:(l,d,c,h)=>{this.handleNetworkError(d,c,!1,l,h)},onTimeout:(l,d,c)=>{this.handleNetworkError(d,c,!0,void 0,l)}};r.load(e,o,u)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,r){const n=this.hls,a=e.data,o=kr(e,i),u=mt.parseMasterPlaylist(a,o);if(u.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,u.playlistParsingError,r,t);return}const{contentSteering:l,levels:d,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:g}=u;this.variableList=g,d.forEach(T=>{const{unknownCodecs:E}=T;if(E){const{preferManagedMediaSource:S}=this.hls.config;let{audioCodec:_,videoCodec:x}=T;for(let A=E.length;A--;){const I=E[A];Ni(I,"audio",S)?(T.audioCodec=_=_?`${_},${I}`:I,mi.audio[_.substring(0,4)]=2,E.splice(A,1)):Ni(I,"video",S)&&(T.videoCodec=x=x?`${x},${I}`:I,mi.video[x.substring(0,4)]=2,E.splice(A,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":y}=mt.parseMasterPlaylistMedia(a,o,u);p.length&&!p.some(E=>!E.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(this.hls.logger.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 pe({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:y,contentSteering:l,url:o,stats:t,networkDetails:r,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,i,r,n){const a=this.hls,{id:o,level:u,type:l}=i,d=kr(e,i),c=$(u)?u:$(o)?o:0,h=No(i),f=mt.parseLevelPlaylist(e.data,d,c,h,0,this.variableList);if(l===ie.MANIFEST){const g={attrs:new pe({}),bitrate:0,details:f,name:"",url:d};f.requestScheduled=t.loading.start+au(f,0),a.trigger(v.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:d,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n)}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(v.ERROR,{type:W.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===ie.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:n})}handleNetworkError(e,t,i=!1,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ie.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ie.AUDIO_TRACK||e.type===ie.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let u=D.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case ie.MANIFEST:u=i?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,l=!0;break;case ie.LEVEL:u=i?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,l=!1;break;case ie.AUDIO_TRACK:u=i?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case ie.SUBTITLE_TRACK:u=i?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,l=!1;break}d&&this.resetInternalLoader(e.type);const c={type:W.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:n};if(r){const h=t?.url||e.url;c.response=le({url:h,data:void 0},r)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,i,r,n,a){const o=this.hls,{type:u,level:l,levelOrTrack:d,id:c,groupId:h,deliveryDirectives:f}=r,g=kr(t,r),p=No(r);let m=typeof r.level=="number"&&p===H.MAIN?l:void 0;const y=e.playlistParsingError;if(y){if(this.hls.logger.warn(`${y} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(v.ERROR,{type:W.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:y,reason:y.message,response:t,context:r,level:m,parent:p,networkDetails:n,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:W.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:T,reason:T.message,response:t,context:r,level:m,parent:p,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),u){case ie.MANIFEST:case ie.LEVEL:if(m){if(!d)m=0;else if(d!==o.levels[m]){const T=o.levels.indexOf(d);T>-1&&(m=T)}}o.trigger(v.LEVEL_LOADED,{details:e,levelInfo:d||o.levels[0],level:m||0,id:c||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:u===ie.MANIFEST});break;case ie.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break;case ie.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f});break}}}class Pt{static get version(){return Bi}static isMSESupported(){return nd()}static isSupported(){return iv()}static getMediaSource(){return Nt()}static get Events(){return v}static get MetadataSchema(){return qe}static get ErrorTypes(){return W}static get ErrorDetails(){return D}static get DefaultConfig(){return Pt.defaultConfig?Pt.defaultConfig:H0}static set DefaultConfig(e){Pt.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Fn,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=ff(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=Y0(Pt.DefaultConfig,e,t);this.userConfig=e,i.progressive&&W0(i,t);const{abrController:r,bufferController:n,capLevelController:a,errorController:o,fpsController:u}=i,l=new o(this),d=this.abrController=new r(this),c=new lg(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,Pt):null,g=this.bufferController=new n(this,c),p=this.capLevelController=new a(this),m=new u(this),y=new ov(this),T=i.contentSteeringController,E=T?new T(this):null,S=this.levelController=new tv(this,E),_=new Z0(this),x=new av(this.config,this.logger),A=this.streamController=new nv(this,c,x),I=this.gapController=new Q0(this,c);p.setStreamController(A),m.setStreamController(A);const R=[y,S,A];f&&R.splice(1,0,f),E&&R.splice(1,0,E),this.networkControllers=R;const b=[d,g,I,p,m,_,c];this.audioTrackController=this.createController(i.audioTrackController,R);const k=i.audioStreamController;k&&R.push(this.audioStreamController=new k(this,c,x)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);const M=i.subtitleStreamController;M&&R.push(this.subtititleStreamController=new M(this,c,x)),this.createController(i.timelineController,b),x.emeController=this.emeController=this.createController(i.emeController,b),this.cmcdController=this.createController(i.cmcdController,b),this.latencyController=this.createController(ev,b),this.coreComponents=b,R.push(l);const G=l.onErrorOut;typeof G=="function"&&this.on(v.ERROR,G,l),this.on(v.MANIFEST_LOADED,y.onManifestLoaded,y)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}
vendor: 6,917 bytes, line 61
61trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const r=e===v.ERROR;this.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(v.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;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(v.ERROR,{type:W.OTHER_ERROR,details:D.ATTACH_MEDIA_ERROR,fatal:!0,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(v.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(v.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,r=this._url=In.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${r}`),t&&i&&(i!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[H.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[H.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[H.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Qp()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const 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(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Yf(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(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}
vendor: 6,744 bytes, line 61
61setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=ql(t);return Vl(e,i,navigator.mediaCapabilities)}}Pt.defaultConfig=void 0;var se=Pt,me={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},de={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},ad=s=>s===me.VIDEO?"playback":s,kt=class Ai extends Error{constructor(e,t=Ai.MEDIA_ERR_CUSTOM,i,r){var n;super(e),this.name="MediaError",this.code=t,this.context=r,this.fatal=i??(t>=Ai.MEDIA_ERR_NETWORK&&t<=Ai.MEDIA_ERR_ENCRYPTED),this.message||(this.message=(n=Ai.defaultMessages[this.code])!=null?n:"")}};kt.MEDIA_ERR_ABORTED=1,kt.MEDIA_ERR_NETWORK=2,kt.MEDIA_ERR_DECODE=3,kt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,kt.MEDIA_ERR_ENCRYPTED=5,kt.MEDIA_ERR_CUSTOM=100,kt.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 j=kt,lv=s=>s==null,Xn=(s,e)=>lv(e)?!1:s in e,an={ANY:"any",MUTED:"muted"},Ne={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ui={MSE:"mse",NATIVE:"native"},bi={HEADER:"header",QUERY:"query",NONE:"none"},Fo=Object.values(bi),At={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Uo={HLS:At.M3U8};[...Object.values(At)];var uv="en",on={code:uv},Se=(s,e,t,i,r=s)=>{r.addEventListener(e,t,i),s.addEventListener("teardown",()=>{r.removeEventListener(e,t)},{once:!0})};function dv(s,e,t){e&&t>e&&(t=e);for(let i=0;i<s.length;i++)if(s.start(i)<=t&&s.end(i)>=t)return!0;return!1}var Qn=s=>{let e=s.indexOf("?");if(e<0)return[s];let t=s.slice(0,e),i=s.slice(e);return[t,i]},Xs=s=>{let{type:e}=s;if(e){let t=e.toUpperCase();return Xn(t,Uo)?Uo[t]:e}return cv(s)},od=s=>s==="VOD"?Ne.ON_DEMAND:Ne.LIVE,ld=s=>s==="EVENT"?Number.POSITIVE_INFINITY:s==="VOD"?Number.NaN:0,cv=s=>{let{src:e}=s;if(!e)return"";let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let i=t.lastIndexOf(".");if(i<0)return fv(s)?At.M3U8:"";let r=t.slice(i+1).toUpperCase();return Xn(r,At)?At[r]:""},hv="mux.com",fv=({src:s,customDomain:e=hv})=>{let t;try{t=new URL(`${s}`)}catch{return!1}let i=t.protocol==="https:",r=t.hostname===`stream.${e}`.toLowerCase(),n=t.pathname.split("/"),a=n.length===2,o=!(n!=null&&n[1].includes("."));return i&&r&&a&&o},gv=s=>{let e=(s??"").split(".")[1];if(e)try{let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(i)}catch{return}},mv=({exp:s},e=Date.now())=>!s||s*1e3<e,pv=({sub:s},e)=>s!==e,vv=({aud:s},e)=>!s,yv=({aud:s},e)=>s!==e,ud="en";function ne(s,e=!0){var t,i;let r=e&&(i=(t=on)==null?void 0:t[s])!=null?i:s,n=e?on.code:ud;return new Ev(r,n)}var Ev=class{constructor(s,e=(t=>(t=on)!=null?t:ud)()){this.message=s,this.locale=e}format(s){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var i;return(i=s[t])!=null?i:""})}toString(){return this.message}},Tv=Object.values(an),Bo=s=>typeof s=="boolean"||typeof s=="string"&&Tv.includes(s),Sv=(s,e,t)=>{let{autoplay:i}=s,r=!1,n=!1,a=Bo(i)?i:!!i,o=()=>{r||Se(e,"playing",()=>{r=!0},{once:!0})};if(o(),Se(e,"loadstart",()=>{r=!1,o(),Cr(e,a)},{once:!0}),Se(e,"loadstart",()=>{t||(s.streamType&&s.streamType!==Ne.UNKNOWN?n=s.streamType===Ne.LIVE:n=!Number.isFinite(e.duration)),Cr(e,a)},{once:!0}),t&&t.once(se.Events.LEVEL_LOADED,(u,l)=>{var d;s.streamType&&s.streamType!==Ne.UNKNOWN?n=s.streamType===Ne.LIVE:n=(d=l.details.live)!=null?d:!1}),!a){let u=()=>{!n||Number.isFinite(s.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&Se(e,"play",()=>{e.preload==="metadata"?t.once(se.Events.LEVEL_UPDATED,u):u()},{once:!0})}return u=>{r||(a=Bo(u)?u:!!u,Cr(e,a))}},Cr=(s,e)=>{if(!e)return;let t=s.muted,i=()=>s.muted=t;switch(e){case an.ANY:s.play().catch(()=>{s.muted=!0,s.play().catch(i)});break;case an.MUTED:s.muted=!0,s.play().catch(i);break;default:s.play().catch(()=>{});break}},_v=({preload:s,src:e}
61,t,i)=>{let r=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!i)return r(s),r;let n=!1,a=!1,o=i.config.maxBufferLength,u=i.config.maxBufferSize,l=c=>{r(c);let h=c??t.preload;a||h==="none"||(h==="metadata"?(i.config.maxBufferLength=1,i.config.maxBufferSize=1):(i.config.maxBufferLength=o,i.config.maxBufferSize=u),d())},d=()=>{!n&&e&&(n=!0,i.loadSource(e))};return Se(t,"play",()=>{a=!0,i.config.maxBufferLength=o,i.config.maxBufferSize=u,d()},{once:!0}),l(s),l};function Av(s,e){var t;if(!("videoTracks"in s))return;let i=new WeakMap;e.on(se.Events.MANIFEST_PARSED,function(u,l){o();let d=s.addVideoTrack("main");d.selected=!0;for(let[c,h]of l.levels.entries()){let f=d.addRendition(h.url[0],h.width,h.height,h.videoCodec,h.bitrate);i.set(h,`${c}`),f.id=`${c}`}}),e.on(se.Events.AUDIO_TRACKS_UPDATED,function(u,l){a();for(let d of l.audioTracks){let c=d.default?"main":"alternative",h=s.addAudioTrack(c,d.name,d.lang);h.id=`${d.id}`,d.default&&(h.enabled=!0)}}),s.audioTracks.addEventListener("change",()=>{var u;let l=+((u=[...s.audioTracks].find(c=>c.enabled))==null?void 0:u.id),d=e.audioTracks.map(c=>c.id);l!=e.audioTrack&&d.includes(l)&&(e.audioTrack=l)}),e.on(se.Events.LEVELS_UPDATED,function(u,l){var d;let c=s.videoTracks[(d=s.videoTracks.selectedIndex)!=null?d:0];if(!c)return;let h=l.levels.map(f=>i.get(f));for(let f of s.videoRenditions)f.id&&!h.includes(f.id)&&c.removeRendition(f)});let r=u=>{let l=u.target.selectedIndex;l!=e.nextLevel&&(e.nextLevel=l)};(t=s.videoRenditions)==null||t.addEventListener("change",r);let n=()=>{for(let u of s.videoTracks)s.removeVideoTrack(u)},a=()=>{for(let u of s.audioTracks)s.removeAudioTrack(u)},o=()=>{n(),a()};e.once(se.Events.DESTROYING,o)}var wr=s=>"time"in s?s.time:s.startTime;function bv(s,e){e.on(se.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:n})=>{n.forEach(a=>{var o,u;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:h,name:f,type:g})=>h==l?.lang&&f===a.label&&g.toLowerCase()===a.kind),c=((u=a._id)!=null?u:a.default)?"default":`${a.kind}${d}`;dd(s,a.kind,a.label,l?.lang,c,a.default)})});let t=()=>{if(!e.subtitleTracks.length)return;let r=Array.from(s.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind));if(!r)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||r?.id!==a){let o=e.subtitleTracks.findIndex(({lang:u,name:l,type:d,default:c})=>r.id==="default"&&c||u==r.language&&l===r.label&&d.toLowerCase()===r.kind);e.subtitleTrack=o}r?.id===a&&r.cues&&Array.from(r.cues).forEach(o=>{r.addCue(o)})};s.textTracks.addEventListener("change",t),e.on(se.Events.CUES_PARSED,(r,{track:n,cues:a})=>{let o=s.textTracks.getTrackById(n);if(!o)return;let u=o.mode==="disabled";u&&(o.mode="hidden"),a.forEach(l=>{var d;(d=o.cues)!=null&&d.getCueById(l.id)||o.addCue(l)}),u&&(o.mode="disabled")}),e.once(se.Events.DESTROYING,()=>{s.textTracks.removeEventListener("change",t),s.querySelectorAll("track[data-removeondestroy]").forEach(r=>{r.remove()})});let i=()=>
vendor: 4,403 bytes, line 61
61{Array.from(s.textTracks).forEach(r=>{var n,a;if(!["subtitles","caption"].includes(r.kind)&&(r.label==="thumbnails"||r.kind==="chapters")){if(!((n=r.cues)!=null&&n.length)){let o="track";r.kind&&(o+=`[kind="${r.kind}"]`),r.label&&(o+=`[label="${r.label}"]`);let u=s.querySelector(o),l=(a=u?.getAttribute("src"))!=null?a:"";u?.removeAttribute("src"),setTimeout(()=>{u?.setAttribute("src",l)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};e.once(se.Events.MANIFEST_LOADED,i),e.once(se.Events.MEDIA_ATTACHED,i)}function dd(s,e,t,i,r,n){let a=document.createElement("track");return a.kind=e,a.label=t,i&&(a.srclang=i),r&&(a.id=r),n&&(a.default=!0),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),s.append(a),a.track}function Vi(s,e,t){var i;return(i=Array.from(s.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind===t))==null?void 0:i.track}async function cd(s,e,t,i){let r=Vi(s,t,i);return r||(r=dd(s,i,t),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort((n,a)=>wr(a)-wr(n)).forEach(n=>{var a,o;let u=n.value,l=wr(n);if("endTime"in n&&n.endTime!=null)r?.addCue(new VTTCue(l,n.endTime,i==="chapters"?u:JSON.stringify(u??null)));else{let d=Array.prototype.findIndex.call(r?.cues,g=>g.startTime>=l),c=(a=r?.cues)==null?void 0:a[d],h=c?c.startTime:Number.isFinite(s.duration)?s.duration:Number.MAX_SAFE_INTEGER,f=(o=r?.cues)==null?void 0:o[d-1];f&&(f.endTime=l),r?.addCue(new VTTCue(l,h,i==="chapters"?u:JSON.stringify(u??null)))}}),s.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var Jn="cuepoints",hd=Object.freeze({label:Jn});async function fd(s,e,t=hd){return cd(s,e,t.label,"metadata")}var ln=s=>({time:s.startTime,value:JSON.parse(s.text)});function xv(s,e={label:Jn}){let t=Vi(s,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,i=>ln(i)):[]}function gd(s,e={label:Jn}){var t,i;let r=Vi(s,e.label,"metadata");if(!((t=r?.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return ln(r.activeCues[0]);let{currentTime:n}=s,a=Array.prototype.find.call((i=r.activeCues)!=null?i:[],({startTime:o,endTime:u})=>o<=n&&u>n);return ln(a||r.activeCues[0])}async function Iv(s,e=hd){return new Promise(t=>{Se(s,"loadstart",async()=>{let i=await fd(s,[],e);Se(s,"cuechange",()=>{let r=gd(s);if(r){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});s.dispatchEvent(n)}},{},i),t(i)})})}var Zn="chapters",md=Object.freeze({label:Zn}),un=s=>({startTime:s.startTime,endTime:s.endTime,value:s.text});async function pd(s,e,t=md){return cd(s,e,t.label,"chapters")}function Rv(s,e={label:Zn}){var t;let i=Vi(s,e.label,"chapters");return(t=i?.cues)!=null&&t.length?Array.from(i.cues,r=>un(r)):[]}function vd(s,e={label:Zn}){var t,i;let r=Vi(s,e.label,"chapters");if(!((t=r?.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return un(r.activeCues[0]);let{currentTime:n}=s,a=Array.prototype.find.call((i=r.activeCues)!=null?i:[],({startTime:o,endTime:u})=>o<=n&&u>n);return un(a||r.activeCues[0])}async function Lv(s,e=md){return new Promise(t=>{Se(s,"loadstart",async()=>{let i=await pd(s,[],e);Se(s,"cuechange",()=>{let r=vd(s);if(r){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});s.dispatchEvent(n)}},{},i),t(i)})})}function Dv(s,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-s.currentTime*1e3)}return typeof s.getStartDate=="function"?s.getStartDate():new Date(NaN)}function kv(s,e){if(e&&e.playingDate)return e.playingDate;if(typeof s.getStartDate=="function"){let t=s.getStartDate();return new Date(t.getTime()+s.currentTime*1e3)}return new Date(NaN)}var $o={VIDEO:"v",DRM:"d"},Cv=s=>{if(s===me.VIDEO)return $o.VIDEO;if(s===me.DRM)return $o.DRM},wv=(s,e)=>{var t,i;let r=ad(s),n=`${r}Token`;return(t=e.tokens)!=null&&t[r]?(i=e.tokens)==null?void 0:i[r]:Xn(n,e)?e[n]:void 0},Hs=(s,e,t,i,r=!1,n=!(a=>(a=globalThis.navigator)==null?void 0:a.onLine)())=>{var a,o;if(n){let y=ne("Your device appears to be offline",r),T,E=j.MEDIA_ERR_NETWORK,S=new j(y,E,!1,T);return S.errorCategory=e,S.muxCode=de.NETWORK_OFFLINE,S.data=s,S}let u="status"in s?s.status:s.code,l=Date.now(),d=j.MEDIA_ERR_NETWORK;if(u===200)return;let c=ad(e),h=wv(e,t),f=Cv(e),[g]=Qn((a=t.playbackId)!=null?a:"");if(!u||!g)return;let p=gv(h);if(h&&!p){let y=ne("The {tokenNamePrefix}
61-token provided is invalid or malformed.",r).format({tokenNamePrefix:c}),T=ne("Compact JWT string: {token}",r).format({token:h}),E=new j(y,d,!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_TOKEN_MALFORMED,E.data=s,E}if(u>=500){let y=new j("",d,i??!0);return y.errorCategory=e,y.muxCode=de.NETWORK_UNKNOWN_ERROR,y}if(u===403)if(p){if(mv(p,l)){let y={timeStyle:"medium",dateStyle:"medium"},T=ne("The video’s secured {tokenNamePrefix}-token has expired.",r).format({tokenNamePrefix:c}),E=ne("Expired at: {expiredDate}. Current time: {currentDate}.",r).format({expiredDate:new Intl.DateTimeFormat("en",y).format((o=p.exp)!=null?o:0*1e3),currentDate:new Intl.DateTimeFormat("en",y).format(l)}),S=new j(T,d,!0,E);return S.errorCategory=e,S.muxCode=de.NETWORK_TOKEN_EXPIRED,S.data=s,S}if(pv(p,g)){let y=ne("The video’s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",r).format({tokenNamePrefix:c}),T=ne("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",r).format({tokenNamePrefix:c,playbackId:g,tokenPlaybackId:p.sub}),E=new j(y,d,!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_TOKEN_SUB_MISMATCH,E.data=s,E}if(vv(p)){let y=ne("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:c}),T=ne("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",r).format({tokenNamePrefix:c,expectedAud:f}),E=new j(y,d,!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_TOKEN_AUD_MISSING,E.data=s,E}if(yv(p,f)){let y=ne("The {tokenNamePrefix}-token is formatted with incorrect information.",r).format({tokenNamePrefix:c}),T=ne("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",r).format({tokenNamePrefix:c,expectedAud:f,aud:p.aud}),E=new j(y,d,!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_TOKEN_AUD_MISMATCH,E.data=s,E}}else{let y=ne("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",r).format({tokenNamePrefix:c,category:e}),T=ne("Specified playback ID: {playbackId}",r).format({playbackId:g}),E=new j(y,d,i??!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_TOKEN_MISSING,E.data=s,E}if(u===412){let y=ne("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",r),T=ne("Specified playback ID: {playbackId}",r).format({playbackId:g}),E=new j(y,d,i??!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_NOT_READY,E.streamType=t.streamType===Ne.LIVE?"live":t.streamType===Ne.ON_DEMAND?"on-demand":"unknown",E.data=s,E}if(u===404){let y=ne("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",r),T=ne("Specified playback ID: {playbackId}",r).format({playbackId:g}),E=new j(y,d,i??!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_NOT_FOUND,E.data=s,E}if(u===400){let y=ne("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),T=ne("Specified playback ID: {playbackId}",r).format({playbackId:g}),E=new j(y,d,i??!0,T);return E.errorCategory=e,E.muxCode=de.NETWORK_INVALID_URL,E.data=s,E}let m=new j("",d,i??!0);return m.errorCategory=e,m.muxCode=de.NETWORK_UNKNOWN_ERROR,m.data=s,m},Go=se.DefaultConfig.capLevelController,yd=class Ed extends Go{constructor(e){super(e)}get levels(){var e;return(e=this.hls.levels)!=null?e:[]}getValidLevels(e){return this.levels.filter((t,i)=>this.isLevelAllowed(t)&&i<=e)}getMaxLevel(e){let t=super.getMaxLevel(e),i=this.getValidLevels(e);if(!i[t])return t;let r=Math.min(i[t].width,i[t].height),n=Ed.minMaxResolution;return r>=n?t:Go.getMaxLevelByMediaSize(i,n*(16/9),n)}};yd.minMaxResolution=720;var Pv=yd,Ov=Pv,ys={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},Mv=s=>{if(s.includes("fps"))return ys.FAIRPLAY;if(s.includes("playready"))return ys.PLAYREADY;if(s.includes("widevine"))return ys.WIDEVINE},Nv=s=>{let e=s.split(`
62`).find((t,i,r)=>i&&r[i-1].startsWith("#EXT-X-STREAM-INF"));return fetch(e).then(t=>t.status!==200?Promise.reject(t):t.text())},Fv=s=>{let e=s.split(`
63`).filter(i=>i.startsWith("#EXT-X-SESSION-DATA"));if(!e.length)return{};let t={};for(let i of e){let r=Bv(i),n=r["DATA-ID"];n&&(t[n]={...r})}return{sessionData:t}},Uv=/([A-Z0-9-]+)="?(.*?)"?(?:,|$)/g;function Bv(s){let e=[...s.matchAll(Uv)];return Object.fromEntries(e.map(([,t,i])=>[t,i]))}var $v=s=>{var e,t,i;let r=s.split(`
64`),n=(t=((e=r.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),a=od(n),o=ld(n),u;if(a===Ne.LIVE){let l=r.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)u=+l.split(":")[1].split("=")[1]*2;else{let d=r.find(h=>h.startsWith("#EXT-X-TARGETDURATION")),c=(i=d?.split(":"))==null?void 0:i[1];u=+(c??6)*3}}return{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:u}},Gv=async(s,e)=>{if(e===At.MP4)return{streamType:Ne.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0,sessionData:void 0};if(e===At.M3U8){let t=await fetch(s);if(!t.ok)return Promise.reject(t);let i=await t.text(),r=await Nv(i);return{...Fv(i),...$v(r)}}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${s}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0,sessionData:void 0}},Kv=async(s,e,t=Xs({src:s}))=>{var i,r,n,a;let{streamType:o,targetLiveWindow:u,liveEdgeStartOffset:l,sessionData:d}=await Gv(s,t),c=d?.["com.apple.hls.chapters"];(c!=null&&c.URI||c!=null&&c.VALUE.toLocaleLowerCase().startsWith("http"))&&ea((i=c.URI)!=null?i:c.VALUE,e),((r=Ee.get(e))!=null?r:{}).liveEdgeStartOffset=l,((n=Ee.get(e))!=null?n:{}).targetLiveWindow=u,e.dispatchEvent(new CustomEvent("targetlivewindowch
64ange",{composed:!0,bubbles:!0})),((a=Ee.get(e))!=null?a:{}).streamType=o,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ea=async(s,e)=>{var t,i;try{let r=await fetch(s);if(!r.ok)throw new Error(`Failed to fetch Mux metadata: ${r.status} ${r.statusText}`);let n=await r.json(),a={};if(!((t=n?.[0])!=null&&t.metadata))return;for(let u of n[0].metadata)u.key&&u.value&&(a[u.key]=u.value);((i=Ee.get(e))!=null?i:{}).metadata=a;let o=new CustomEvent("muxmetadata");e.dispatchEvent(o)}catch(r){console.error(r)}},Vv=s=>{var e;let t=s.type,i=od(t),r=ld(t),n,a=!!((e=s.partList)!=null&&e.length);return i===Ne.LIVE&&(n=a?s.partTarget*2:s.targetduration*3),{streamType:i,targetLiveWindow:r,liveEdgeStartOffset:n,lowLatency:a}},Hv=(s,e,t)=>{var i,r,n,a,o,u,l,d;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:g}=Vv(s);if(c===Ne.LIVE){g?(t.config.backBufferLength=(i=t.userConfig.backBufferLength)!=null?i:4,t.config.maxFragLookUpTolerance=(r=t.userConfig.maxFragLookUpTolerance)!=null?r:.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(m){return e.seekable.start(m)},end(m){var y;return m>this.length||m<0||Number.isFinite(e.duration)?e.seekable.end(m):(y=t.liveSyncPosition)!=null?y:e.seekable.end(m)}});((o=Ee.get(e))!=null?o:{}).seekable=p}((u=Ee.get(e))!=null?u:{}).liveEdgeStartOffset=f,((l=Ee.get(e))!=null?l:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((d=Ee.get(e))!=null?d:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Ko,Vo,qv=(Vo=(Ko=globalThis?.navigator)==null?void 0:Ko.userAgent)!=null?Vo:"",Ho,qo,Yo,Yv=(Yo=(qo=(Ho=globalThis?.navigator)==null?void 0:Ho.userAgentData)==null?void 0:qo.platform)!=null?Yo:"",Wo,jo,zo,Wv=(zo=(jo=(Wo=globalThis?.navigator)==null?void 0:Wo.userAgentData)==null?void 0:jo.brands)!=null?zo:[],jv=qv.toLowerCase().includes("android")||["x11","android"].some(s=>Yv.toLowerCase().includes(s)),Xo=Wv.find(s=>s.brand==="Google Chrome"),zv=s=>{var e;return Xo&&parseInt((e=Xo.version)!=null?e:"0")>=141&&!!s.canPlayType("application/vnd.apple.mpegurl")},Ee=new WeakMap,bt="mux.com",Qo,Jo,Td=(Jo=(Qo=se).isSupported)==null?void 0:Jo.call(Qo),Xv=s=>jv||zv(s),Qv=()=>xn.utils.now(),Jv=xn.utils.generateUUID,Zv=({playbackId:s,customDomain:e=bt,maxResolution:t,minResolution:i,renditionOrder:r,programStartTime:n,programEndTime:a,assetStartTime:o,assetEndTime:u,playbackToken:l,tokens:{playback:d=l}={},extraSourceParams:c={}}={})=>{if(!s)return;let[h,f=""]=Qn(s),g=new URL(`https://stream.${e}/${h}.m3u8${f}`);return d||g.searchParams.has("token")?(g.searchParams.forEach((p,m)=>{m!="token"&&g.searchParams.delete(m)}),d&&g.searchParams.set("token",d)):(t&&g.searchParams.set("max_resolution",t),i&&(g.searchParams.set("min_resolution",i),t&&+t.slice(0,-1)<+i.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",i,"maxResolution",t)),r&&g.searchParams.set("rendition_order",r),n&&g.searchParams.set("program_start_time",`${n}`),a&&g.searchParams.set("program_end_time",`${a}`),o&&g.searchParams.set("asset_start_time",`${o}`),u&&g.searchParams.set("asset_end_time",`${u}`),Object.entries(c).forEach(([p,m])=>{m!=null&&g.searchParams.set(p,m)})),g.toString()},Qs=s=>{if(!s)return;let[e]=s.split("?");return e||void 0},ta=s=>{if(!s||!s.startsWith("https://stream."))return;let[e]=new URL(s).pathname.slice(1).split(/\.m3u8|\//);return e||void 0},ey=s=>{var e,t,i;return(e=s?.metadata)!=null&&e.video_id?s.metadata.video_id:Ld(s)&&(i=(t=Qs(s.playbackId))!=null?t:ta(s.src))!=null?i:s.src},Sd=s=>{var e;return(e=Ee.get(s))==null?void 0:e.error},ty=s=>{var e;return(e=Ee.get(s))==null?void 0:e.metadata},dn=s=>{var e,t;return(t=(e=Ee.get(s))==null?void 0:e.streamType)!=null?t:Ne.UNKNOWN},iy=s=>{var e,t;return(t=(e=Ee.get(s))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},ia=s=>{var e,t;return(t=(e=Ee.get(s))==null?void 0:e.seekable)!=null?t:s.seekable},sy=s=>{var e;let t=(e=Ee.get(s))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let i=ia(s);return i.length?i.end(i.length-1)-t:Number.NaN},sa=.034,ry=(s,e,t=sa)=>Math.abs(s-e)<=t,_d=(s,e,t=sa)=>s>e||ry(s,e,t),ny=(s,e=sa)=>s.paused&&_d(s.currentTime,s.duration,e),Ad=(s,e)=>{var t,i,r;if(!e||!s.buffered.length)return;if(s.readyState>2)return!1;let n=e.currentLevel>=0?(i=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:i.details:(r=e.levels.find(c=>!!c.details))==null?void 0:r.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(s.currentTime<s.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(s.currentTime<=o.start)return!1;let u=o.start+o.duration/2,l=s.buffered.start(s.buffered.length-1),d=s.buffered.end(s.buffered.length-1);return u>l&&u<d},bd=(s,e)=>s.ended||s.loop?s.ended:e&&Ad(s,e)?!0:ny(s),ay=(s,e,t)=>{xd(e,t,s);let{metadata:i={}}=s,{view_session_id:r=Jv()}=i,n=ey(s);i.view_session_id=r,i.video_id=n,s.metadata=i;let a=d=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:d})};s.drmTypeCb=a,Ee.set(e,{retryCount:0});let o=oy(s,e),u=_v(s,e,o);s!=null&&s.muxDataKeepSession&&e!=null&&e.mux&&!e.mux.deleted?o&&e.mux.addHLSJS({hlsjs:o,Hls:o?se:void 0}):fy(s,e,o),gy(s,e,o),Iv(e),Lv(e);let l=Sv(s,e,o);return{engine:o,setAutoplay:l,setPreload:u}},xd=(s,e,t)=>{let i=e?.engine;
64s!=null&&s.mux&&!s.mux.deleted&&(t!=null&&t.muxDataKeepSession?i&&s.mux.removeHLSJS():(s.mux.destroy(),delete s.mux)),i&&(i.detachMedia(),i.destroy()),s&&(s.hasAttribute("src")&&(s.removeAttribute("src"),s.load()),s.removeEventListener("error",kd),s.removeEventListener("error",cn),s.removeEventListener("durationchange",Dd),Ee.delete(s),s.dispatchEvent(new Event("teardown")))};function Id(s,e){var t;let i=Xs(s);if(i!==At.M3U8)return!0;let r=!i||((t=e.canPlayType(i))!=null?t:!0),{preferPlayback:n}=s,a=n===ui.MSE,o=n===ui.NATIVE,u=Td&&(a||Xv(e));return r&&(o||!u)}var oy=(s,e)=>{let{debug:t,streamType:i,startTime:r=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=s,u=Xs(s)===At.M3U8,l=Id(s,e);if(u&&!l&&Td){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=ly(i),h=uy(s),f=[bi.QUERY,bi.HEADER].includes(a)?{useHeaders:a===bi.HEADER,sessionId:n?.view_session_id,contentId:n?.video_id}:void 0,g=o.capLevelToPlayerSize==null?{capLevelController:Ov}:{},p=new se({debug:t,startPosition:r,cmcd:f,xhrSetup:(m,y)=>{var T,E;if(a&&a!==bi.QUERY)return;let S=new URL(y);if(!S.searchParams.has("CMCD"))return;let _=((E=(T=S.searchParams.get("CMCD"))==null?void 0:T.split(","))!=null?E:[]).filter(x=>x.startsWith("sid")||x.startsWith("cid")).join(",");S.searchParams.set("CMCD",_),m.open("GET",S)},...g,...d,...c,...h,...o});return p.on(se.Events.MANIFEST_PARSED,async function(m,y){var T,E;let S=(T=y.sessionData)==null?void 0:T["com.apple.hls.chapters"];(S!=null&&S.URI||S!=null&&S.VALUE.toLocaleLowerCase().startsWith("http"))&&ea((E=S?.URI)!=null?E:S?.VALUE,e)}),p}},ly=s=>s===Ne.LIVE?{backBufferLength:8}:{},uy=s=>{let{tokens:{drm:e}={},playbackId:t,drmTypeCb:i}=s,r=Qs(t);return!e||!r?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Es(s,"fairplay"),serverCertificateUrl:Rd(s,"fairplay")},"com.widevine.alpha":{licenseUrl:Es(s,"widevine")},"com.microsoft.playready":{licenseUrl:Es(s,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var u;let l=(u=o.videoCapabilities)==null?void 0:u.map(d=>({...d,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:l}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let u=Mv(n);return i?.(u),o}))}},dy=async s=>{let e=await fetch(s);return e.status!==200?Promise.reject(e):await e.arrayBuffer()},cy=async(s,e)=>{let t=await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:s});if(t.status!==200)return Promise.reject(t);let i=await t.arrayBuffer();return new Uint8Array(i)},hy=(s,e)=>{Se(e,"encrypted",async t=>{try{let i=t.initDataType;if(i!=="skd"){console.error(`Received unexpected initialization data type "${i}"`);return}if(!e.mediaKeys){let u=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[i],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(d=>{var c;return(c=s.drmTypeCb)==null||c.call(s,ys.FAIRPLAY),d}).catch(()=>{let d=ne("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),c=new j(d,j.MEDIA_ERR_ENCRYPTED,!0);c.errorCategory=me.DRM,c.muxCode=de.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,Qe(e,c)});if(!u)return;let l=await u.createMediaKeys();try{let d=await dy(Rd(s,"fairplay")).catch(c=>{if(c instanceof Response){let h=Hs(c,me.DRM,s);return console.error("mediaError",h?.message,h?.context),h?Promise.reject(h):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(c)});await l.setServerCertificate(d).catch(()=>{let c=ne("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),h=new j(c,j.MEDIA_ERR_ENCRYPTED,!0);return h.errorCategory=me.DRM,h.muxCode=de.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(h)})}catch(d){Qe(e,d);return}await e.setMediaKeys(l)}let r=t.initData;if(r==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",()=>
64{n.keyStatuses.forEach(u=>{let l;if(u==="internal-error"){let d=ne("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");l=new j(d,j.MEDIA_ERR_ENCRYPTED,!0),l.errorCategory=me.DRM,l.muxCode=de.ENCRYPTED_CDM_ERROR}else if(u==="output-restricted"||u==="output-downscaled"){let d=ne("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");l=new j(d,j.MEDIA_ERR_ENCRYPTED,!1),l.errorCategory=me.DRM,l.muxCode=de.ENCRYPTED_OUTPUT_RESTRICTED}l&&Qe(e,l)})});let a=await Promise.all([n.generateRequest(i,r).catch(()=>{let u=ne("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),l=new j(u,j.MEDIA_ERR_ENCRYPTED,!0);l.errorCategory=me.DRM,l.muxCode=de.ENCRYPTED_GENERATE_REQUEST_FAILED,Qe(e,l)}),new Promise(u=>{n.addEventListener("message",l=>{u(l.message)},{once:!0})})]).then(([,u])=>u),o=await cy(a,Es(s,"fairplay")).catch(u=>{if(u instanceof Response){let l=Hs(u,me.DRM,s);return console.error("mediaError",l?.message,l?.context),l?Promise.reject(l):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(u)});await n.update(o).catch(()=>{let u=ne("Failed to update DRM license. This may be an issue with the player or your protected content."),l=new j(u,j.MEDIA_ERR_ENCRYPTED,!0);return l.errorCategory=me.DRM,l.muxCode=de.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(l)})}catch(i){Qe(e,i);return}})},Es=({playbackId:s,tokens:{drm:e}={},customDomain:t=bt},i)=>{let r=Qs(s);return`https://license.${t.toLocaleLowerCase().endsWith(bt)?t:bt}/license/${i}/${r}?token=${e}`},Rd=({playbackId:s,tokens:{drm:e}={},customDomain:t=bt},i)=>{let r=Qs(s);return`https://license.${t.toLocaleLowerCase().endsWith(bt)?t:bt}/appcert/${i}/${r}?token=${e}`},Ld=({playbackId:s,src:e,customDomain:t})=>{if(s)return!0;if(typeof e!="string")return!1;let i=window?.location.href,r=new URL(e,i).hostname.toLocaleLowerCase();return r.includes(bt)||!!t&&r.includes(t.toLocaleLowerCase())},fy=(s,e,t)=>{var i;let{envKey:r,disableTracking:n,muxDataSDK:a=xn,muxDataSDKOptions:o={}}=s,u=Ld(s);if(!n&&(r||u)){let{playerInitTime:l,playerSoftwareName:d,playerSoftwareVersion:c,beaconCollectionDomain:h,debug:f,disableCookies:g}=s,p={...s.metadata,video_title:((i=s?.metadata)==null?void 0:i.video_title)||void 0},m=y=>typeof y.player_error_code=="string"?!1:typeof s.errorTranslator=="function"?s.errorTranslator(y):y;a.monitor(e,{debug:f,beaconCollectionDomain:h,hlsjs:t,Hls:t?se:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:g,...o,data:{...r?{env_key:r}:{},player_software_name:d,player_software:d,player_software_version:c,player_init_time:l,...p}})}},gy=(s,e,t)=>{var i,r;let n=Id(s,e),{src:a,customDomain:o=bt}=s,u=()=>{e.ended||s.disablePseudoEnded||!bd(e,t)||(Ad(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},l,d,c=()=>{let h=ia(e),f,g;h.length>0&&(f=h.start(0),g=h.end(0)),(d!==g||l!==f)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),l=f,d=g};if(Se(e,"durationchange",c),e&&n){let h=Xs(s);if(typeof a=="string"){if(a.endsWith(".mp4")&&a.includes(o)){let p=ta(a),m=new URL(`https://stream.${o}/${p}/metadata.json`);ea(m.toString(),e)}let f=()=>{if(dn(e)!==Ne.LIVE||Number.isFinite(e.duration))return;let p=setInterval(c,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),Se(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})},g=async()=>Kv(a,e,h).then(f).catch(p=>{if(p instanceof Response){let m=Hs(p,me.VIDEO,s);if(m){Qe(e,m);return}}});if(e.preload==="none"){let p=()=>{g(),e.removeEventListener("loadedmetadata",m)},m=()=>{g(),e.removeEventListener("play",p)};Se(e,"play",p,{once:!0}),Se(e,"loadedmetadata",m,{once:!0})}else g();(i=s.tokens)!=null&&i.drm?hy(s,e):Se(e,"encrypted",()=>{let p=ne("Attempting to play DRM-protected content without providing a DRM token."),m=new j(p,j.MEDIA_ERR_ENCRYPTED,!0);m.errorCategory=me.DRM,m.muxCode=de.ENCRYPTED_MISSING_TOKEN,Qe(e,m)},{once:!0}),e.setAttribute("src",a),s.startTime&&(((r=Ee.get(e))!=null?r:{}).startTime=s.startTime,e.addEventListener("durationchange",Dd,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",kd),e.addEventListener("error",cn),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(f=>{f.remove()})},{once:!0}),Se(e,"pause",u),Se(e,"seeked",u),Se(e,"play",()=>{e.ended||_d(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&a?(t.once(se.Events.LEVEL_LOADED,(h,f)=>{Hv(f.details,e,t),c(),dn(e)===Ne.LIVE&&!Number.isFinite(e.duration)&&(t.on(se.Events.LEVEL_UPDATED,c),Se(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(se.Events.LEVELS_UPDATED,c)}))}),t.on(se.Events.ERROR,(h,f)=>{var g,p;let m=my(f,s);if(m.muxCode===de.NETWORK_NOT_READY){let y=(g=Ee.get(e))!=null?g:{},T=(p=y.retryCount)!=null?p:0;
vendor: 4,422 bytes, line 64
64if(T<6){let E=T===0?5e3:6e4,S=new j(`Retrying in ${E/1e3} seconds...`,m.code,m.fatal);Object.assign(S,m),Qe(e,S),setTimeout(()=>{y.retryCount=T+1,f.details==="manifestLoadError"&&f.url&&t.loadSource(f.url)},E);return}else{y.retryCount=0;let E=new j('Try again later or <a href="#" onclick="window.location.reload(); return false;" style="color: #4a90e2;">click here to retry</a>',m.code,m.fatal);Object.assign(E,m),Qe(e,E);return}}Qe(e,m)}),t.on(se.Events.MANIFEST_LOADED,()=>{let h=Ee.get(e);h&&h.error&&(h.error=null,h.retryCount=0,e.dispatchEvent(new Event("emptied")),e.dispatchEvent(new Event("loadstart")))}),e.addEventListener("error",cn),Se(e,"waiting",u),Av(s,t),bv(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 Dd(s){var e;let t=s.target,i=(e=Ee.get(t))==null?void 0:e.startTime;if(i&&dv(t.seekable,t.duration,i)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=i,r&&(t.preload="auto")}}async function kd(s){if(!s.isTrusted)return;s.stopImmediatePropagation();let e=s.target;if(!(e!=null&&e.error))return;let{message:t,code:i}=e.error,r=new j(t,i);if(e.src&&i===j.MEDIA_ERR_SRC_NOT_SUPPORTED&&e.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var n;let a=(n=Sd(e))!=null?n:e.error;a?.code===j.MEDIA_ERR_SRC_NOT_SUPPORTED&&Qe(e,r)},500);return}if(e.src&&(i!==j.MEDIA_ERR_DECODE||i!==void 0))try{let{status:n}=await fetch(e.src);r.data={response:{code:n}}}catch{}Qe(e,r)}function Qe(s,e){var t;e.fatal&&(((t=Ee.get(s))!=null?t:{}).error=e,s.dispatchEvent(new CustomEvent("error",{detail:e})))}function cn(s){var e,t;if(!(s instanceof CustomEvent)||!(s.detail instanceof j))return;let i=s.target,r=s.detail;!r||!r.fatal||(((e=Ee.get(i))!=null?e:{}).error=r,(t=i.mux)==null||t.emit("error",{player_error_code:r.code,player_error_message:r.message,player_error_context:r.context}))}var my=(s,e)=>{var t,i,r;console.error("getErrorFromHlsErrorData()",s);let n={[se.ErrorTypes.NETWORK_ERROR]:j.MEDIA_ERR_NETWORK,[se.ErrorTypes.MEDIA_ERROR]:j.MEDIA_ERR_DECODE,[se.ErrorTypes.KEY_SYSTEM_ERROR]:j.MEDIA_ERR_ENCRYPTED},a=d=>[se.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,se.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(d.details)?j.MEDIA_ERR_NETWORK:n[d.type],o=d=>{if(d.type===se.ErrorTypes.KEY_SYSTEM_ERROR)return me.DRM;if(d.type===se.ErrorTypes.NETWORK_ERROR)return me.VIDEO},u,l=a(s);if(l===j.MEDIA_ERR_NETWORK&&s.response){let d=(t=o(s))!=null?t:me.VIDEO;u=(i=Hs(s.response,d,e,s.fatal))!=null?i:new j("",l,s.fatal)}else if(l===j.MEDIA_ERR_ENCRYPTED)if(s.details===se.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let d=ne("Attempting to play DRM-protected content without providing a DRM token.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_MISSING_TOKEN}else if(s.details===se.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let d=ne("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(s.details===se.ErrorDetails.KEY_SYSTEM_NO_SESSION){let d=ne("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,!0),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(s.details===se.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let d=ne("Failed to update DRM license. This may be an issue with the player or your protected content.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(s.details===se.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let d=ne("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(s.details===se.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let d=ne("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_CDM_ER
64ROR}else if(s.details===se.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let d=ne("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");u=new j(d,j.MEDIA_ERR_ENCRYPTED,!1),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_OUTPUT_RESTRICTED}else u=new j(s.error.message,j.MEDIA_ERR_ENCRYPTED,s.fatal),u.errorCategory=me.DRM,u.muxCode=de.ENCRYPTED_ERROR;else u=new j("",l,s.fatal);return u.context||(u.context=`${s.url?`url: ${s.url}
65`:""}${s.response&&(s.response.code||s.response.text)?`response: ${s.response.code}, ${s.response.text}
66`:""}${s.reason?`failure reason: ${s.reason}
67`:""}${s.level?`level: ${s.level}
68`:""}${s.parent?`parent stream controller: ${s.parent}
69`:""}${s.buffer?`buffer length: ${s.buffer}
70`:""}${s.error?`error: ${s.error}
71`:""}${s.event?`event: ${s.event}
72`:""}${s.err?`error message: ${(r=s.err)==null?void 0:r.message}
73`:""}`),u.data=s,u};const py=["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"],Cd=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function vy(s){return`
74    <style>
75      :host {
76        display: inline-flex;
77        line-height: 0;
78        flex-direction: column;
79        justify-content: end;
80      }
81
82      audio {
83        width: 100%;
84      }
85    </style>
86    <slot name="media">
87      <audio${Pd(s)}></audio>
88    </slot>
89    <slot></slot>
90  `}function yy(s){return`
91    <style>
92      :host {
93        display: inline-block;
94        line-height: 0;
95      }
96
97      video {
98        max-width: 100%;
99        max-height: 100%;
100        min-width: 100%;
101        min-height: 100%;
102        object-fit: var(--media-object-fit, contain);
103        object-position: var(--media-object-position, 50% 50%);
104      }
105
106      video::-webkit-media-text-track-container {
107        transform: var(--media-webkit-text-track-transform);
108        transition: var(--media-webkit-text-track-transition);
109      }
110    </style>
111    <slot name="media">
112      <video${Pd(s)}></video>
113    </slot>
114    <slot></slot>
115  `}function wd(s,{tag:e,is:t}){const i=globalThis.document?.createElement?.(e,{is:t}),r=i?Ey(i):[];return class hn extends s{static getTemplateHTML=e.endsWith("audio")?vy:yy;static shadowRootOptions={mode:"open"};static Events=py;static#e=!1;static get observedAttributes(){return hn.#s(),[...i?.constructor?.observedAttributes??[],...Cd]}static#s(){if(this.#e)return;this.#e=!0;const a=new Set(this.observedAttributes);a.delete("muted");for(const o of r)if(!(o in this.prototype))if(typeof i[o]=="function")this.prototype[o]=function(...u){return this.#n(),this.call?this.call(o,...u):this.nativeEl?.[o]?.apply(this.nativeEl,u)};else{const u={get(){this.#n();const l=o.toLowerCase();if(a.has(l)){const d=this.getAttribute(l);return d===null?!1:d===""?!0:d}return this.get?.(o)??this.nativeEl?.[o]}};o!==o.toUpperCase()&&(u.set=function(l){this.#n();const d=o.toLowerCase();if(a.has(d)){l===!0||l===!1||l==null?this.toggleAttribute(d,!!l):this.setAttribute(d,l);return}if(this.set){this.set(o,l);return}this.nativeEl&&(this.nativeEl[o]=l)}),Object.defineProperty(this.prototype,o,u)}}#i=!1;#r=null;#t=new Map;#a;get;set;call;get nativeEl(){return this.#n(),this.#r??this.querySelector(":scope > [slot=media]")??this.querySelector(e)??this.shadowRoot?.querySelector(e)??null}set nativeEl(a){this.#r=a}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(a){this.toggleAttribute("muted",a)}get src(){return this.getAttribute("src")}set src(a){this.setAttribute("src",`${a}`)}get preload(){return this.getAttribute("preload")??this.nativeEl?.preload}set preload(a){this.setAttribute("preload",`${a}`)}#n(){this.#i||(this.#i=!0,this.init())}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const a=Ty(this.attributes);t&&(a.is=t),e&&(a.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(a)}this.nativeEl.muted=this.hasAttribute("muted");for(const a of r)this.#c(a);this.#a=new MutationObserver(this.#o.bind(this)),this.shadowRoot.addEventListener("slotchange",()=>this.#l()),this.#l();for(const a of this.constructor.Events)this.shadowRoot.addEventListener(a,this,!0)}handleEvent(a){a.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(a.type,{detail:a.detail}))}#l(){const a=new Map(this.#t);(this.shadowRoot?.querySelector("slot:not([name])")?.assignedElements({flatten:!0}).filter(l=>
115["track","source"].includes(l.localName))).forEach(l=>{a.delete(l);let d=this.#t.get(l);d||(d=l.cloneNode(),this.#t.set(l,d),this.#a?.observe(l,{attributes:!0})),this.nativeEl?.append(d),this.#u(d)}),a.forEach((l,d)=>{l.remove(),this.#t.delete(d)})}#o(a){for(const o of a)if(o.type==="attributes"){const{target:u,attributeName:l}=o,d=this.#t.get(u);d&&l&&(d.setAttribute(l,u.getAttribute(l)??""),this.#u(d))}}#u(a){a&&a.localName==="track"&&a.default&&(a.kind==="chapters"||a.kind==="metadata")&&a.track.mode==="disabled"&&(a.track.mode="hidden")}#c(a){if(Object.prototype.hasOwnProperty.call(this,a)){const o=this[a];delete this[a],this[a]=o}}attributeChangedCallback(a,o,u){this.#n(),this.#d(a,o,u)}#d(a,o,u){["id","class"].includes(a)||!hn.observedAttributes.includes(a)&&this.constructor.observedAttributes.includes(a)||(u===null?this.nativeEl?.removeAttribute(a):this.nativeEl?.getAttribute(a)!==u&&this.nativeEl?.setAttribute(a,u))}connectedCallback(){this.#n()}}}function Ey(s){const e=[];for(let t=Object.getPrototypeOf(s);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){const i=Object.getOwnPropertyNames(t);e.push(...i)}return e}function Pd(s){let e="";for(const t in s){if(!Cd.includes(t))continue;const i=s[t];i===""?e+=` ${t}`:e+=` ${t}="${i}"`}return e}function Ty(s){const e={};for(const t of s)e[t.name]=t.value;return e}const ls=wd(globalThis.HTMLElement??class{},{tag:"video"});wd(globalThis.HTMLElement??class{},{tag:"audio"});var Od=s=>{throw TypeError(s)},ra=(s,e,t)=>e.has(s)||Od("Cannot "+t),Ce=(s,e,t)=>(ra(s,e,"read from private field"),t?t.call(s):e.get(s)),it=(s,e,t)=>e.has(s)?Od("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),Xe=(s,e,t,i)=>(ra(s,e,"write to private field"),e.set(s,t),t),Pr=(s,e,t)=>(ra(s,e,"access private method"),t),Sy=()=>{try{return"0.27.2"}catch{}return"UNKNOWN"},_y=Sy(),Ay=()=>_y,by=`
116<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>`,w={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DISABLE_PSEUDO_ENDED:"disable-pseudo-ended",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"},xy=Object.values(w),Zo=Ay(),el="mux-video",ct,xi,Ts,Ii,Ss,_s,As,bs,xs,Ri,Li,Is,Iy=class extends ls{constructor(){super(),it(this,Li),it(this,ct),it(this,xi),it(this,Ts),it(this,Ii,{}),it(this,Ss,{}
vendor: 9,971 bytes, lines 116-144
116),it(this,_s),it(this,As),it(this,bs),it(this,xs),it(this,Ri,""),Xe(this,Ts,Qv()),this.nativeEl.addEventListener("muxmetadata",s=>{var e;let t=ty(this.nativeEl),i=(e=this.metadata)!=null?e:{};this.metadata={...t,...i},t?.["com.mux.video.branding"]==="mux-free-plan"&&(Xe(this,Ri,"default"),this.updateLogo())})}static get NAME(){return el}static get VERSION(){return Zo}static get observedAttributes(){var s;return[...xy,...(s=ls.observedAttributes)!=null?s:[]]}static getLogoHTML(s){return!s||s==="false"?"":s==="default"?by:`<img part="logo" src="${s}" />`}static getTemplateHTML(s={}){var e;return`
117      ${ls.getTemplateHTML(s)}
118      <style>
119        :host {
120          position: relative;
121        }
122        slot[name="logo"] {
123          display: flex;
124          justify-content: end;
125          position: absolute;
126          top: 1rem;
127          right: 1rem;
128          opacity: 0;
129          transition: opacity 0.25s ease-in-out;
130          z-index: 1;
131        }
132        slot[name="logo"]:has([part="logo"]) {
133          opacity: 1;
134        }
135        slot[name="logo"] [part="logo"] {
136          width: 5rem;
137          pointer-events: none;
138          user-select: none;
139        }
140      </style>
141      <slot name="logo">
142        ${this.getLogoHTML((e=s[w.LOGO])!=null?e:"")}
143      </slot>
144    `}get preferCmcd(){var s;return(s=this.getAttribute(w.PREFER_CMCD))!=null?s:void 0}set preferCmcd(s){s!==this.preferCmcd&&(s?Fo.includes(s)?this.setAttribute(w.PREFER_CMCD,s):console.warn(`Invalid value for preferCmcd. Must be one of ${Fo.join()}`):this.removeAttribute(w.PREFER_CMCD))}get playerInitTime(){return this.hasAttribute(w.PLAYER_INIT_TIME)?+this.getAttribute(w.PLAYER_INIT_TIME):Ce(this,Ts)}set playerInitTime(s){s!=this.playerInitTime&&(s==null?this.removeAttribute(w.PLAYER_INIT_TIME):this.setAttribute(w.PLAYER_INIT_TIME,`${+s}`))}get playerSoftwareName(){var s;return(s=Ce(this,bs))!=null?s:el}set playerSoftwareName(s){Xe(this,bs,s)}get playerSoftwareVersion(){var s;return(s=Ce(this,As))!=null?s:Zo}set playerSoftwareVersion(s){Xe(this,As,s)}get _hls(){var s;return(s=Ce(this,ct))==null?void 0:s.engine}get mux(){var s;return(s=this.nativeEl)==null?void 0:s.mux}get error(){var s;return(s=Sd(this.nativeEl))!=null?s:null}get errorTranslator(){return Ce(this,xs)}set errorTranslator(s){Xe(this,xs,s)}get src(){return this.getAttribute("src")}set src(s){s!==this.src&&(s==null?this.removeAttribute("src"):this.setAttribute("src",s))}get type(){var s;return(s=this.getAttribute(w.TYPE))!=null?s:void 0}set type(s){s!==this.type&&(s?this.setAttribute(w.TYPE,s):this.removeAttribute(w.TYPE))}get preload(){let s=this.getAttribute("preload");return s===""?"auto":["none","metadata","auto"].includes(s)?s:super.preload}set preload(s){s!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(s)?this.setAttribute("preload",s):this.removeAttribute("preload"))}get debug(){return this.getAttribute(w.DEBUG)!=null}set debug(s){s!==this.debug&&(s?this.setAttribute(w.DEBUG,""):this.removeAttribute(w.DEBUG))}get disableTracking(){return this.hasAttribute(w.DISABLE_TRACKING)}set disableTracking(s){s!==this.disableTracking&&this.toggleAttribute(w.DISABLE_TRACKING,!!s)}get disableCookies(){return this.hasAttribute(w.DISABLE_COOKIES)}set disableCookies(s){s!==this.disableCookies&&(s?this.setAttribute(w.DISABLE_COOKIES,""):this.removeAttribute(w.DISABLE_COOKIES))}get disablePseudoEnded(){return this.hasAttribute(w.DISABLE_PSEUDO_ENDED)}set disablePseudoEnded(s){s!==this.disablePseudoEnded&&(s?this.setAttribute(w.DISABLE_PSEUDO_ENDED,""):this.removeAttribute(w.DISABLE_PSEUDO_ENDED))}get startTime(){let s=this.getAttribute(w.START_TIME);if(s==null)return;let e=+s;return Number.isNaN(e)?void 0:e}set startTime(s){s!==this.startTime&&(s==null?this.removeAttribute(w.START_TIME):this.setAttribute(w.START_TIME,`${s}`))}get playbackId(){var s;return this.hasAttribute(w.PLAYBACK_ID)?this.getAttribute(w.PLAYBACK_ID):(s=ta(this.src))!=null?s:void 0}set playbackId(s){s!==this.playbackId&&(s?this.setAttribute(w.PLAYBACK_ID,s):this.removeAttribute(w.PLAYBACK_ID))}get maxResolution(){var s;return(s=this.getAttribute(w.MAX_RESOLUTION))!=null?s:void 0}set maxResolution(s){s!==this.maxResolution&&(s?this.setAttribute(w.MAX_RESOLUTION,s):this.removeAttribute(w.MAX_RESOLUTION))}get minResolution(){var s;return(s=this.getAttribute(w.MIN_RESOLUTION))!=null?s:void 0}set minResolution(s){s!==this.minResolution&&(s?this.setAttribute(w.MIN_RESOLUTION,s):this.removeAttribute(w.MIN_RESOLUTION))}get renditionOrder(){var s;return(s=this.getAttribute(w.RENDITION_ORDER))!=null?s:void 0}set renditionOrder(s){s!==this.renditionOrder&&(s?this.setAttribute(w.RENDITION_ORDER,s):this.removeAttribute(w.RENDITION_ORDER))}get programStartTime(){let s=this.getAttribute(w.PROGRAM_START_TIME);if(s==null)return;let e=+s;return Number.isNaN(e)?void 0:e}set programStartTime(s){s==null?this.removeAttribute(w.PROGRAM_START_TIME):this.setAttribute(w.PROGRAM_START_TIME,`${s}`)}get programEndTime(){let s=this.getAttribute(w.PROGRAM_END_TIME);if(s==null)return;let e=+s;return Number.isNaN(e)?void 0:e}set programEndTime(s){s==null?this.removeAttribute(w.PROGRAM_END_TIME):this.setAttribute(w.PROGRAM_END_TIME,`${s}`)}get assetStartTime(){let s=this.getAttribute(w.ASSET_START_TIME);if(s==null)return;let e=+s;return Number.isNaN(e)?void 0:e}set assetStartTime(s){s==null?this.removeAttribute(w.ASSET_START_TIME):this.setAttribute(w.ASSET_START_TIME,`${s}`)}get assetEndTime(){let s=this.getAttribute(w.ASSET_END_TIME);if(s==null)return;let e=+s;return Number.isNaN(e)?void 0:e}set assetEndTime(s){s==null?this.removeAttribute(w.ASSET_END_TIME):this.setAttribute(w.ASSET_END_TIME,`${s}`)}get customDomain(){var s;return(s=this.getAttribute(w.CUSTOM_DOMAIN))!=null?s:void 0}set customDomain(s){s!==this.customDomain&&(s?this.setAttribute(w.CUSTOM_DOMAIN,s):this.removeAttribute(w.CUSTOM_DOMAIN))}get drmToken(){var s;return(s=this.getAttribute(w.DRM_TOKEN))!=null?s:void 0}set drmToken(s){s!==this.drmToken&&(s?this.setAttribute(w.DRM_TOKEN,s):this.removeAttribute(w.DRM_TOKEN))}get playbackToken(){var s,e,t,i;if(this.hasAttribute(w.PLAYBACK_TOKEN))return(s=this.getAttribute(w.PLAYBACK_TOKEN))!=null?s:void 0;if(this.hasAttribute(w.PLAYBACK_ID)){let[,r]=Qn((e=this.playbackId)!=null?e:"");return(t=new URLSearchParams(r).get("token"))!=null?t:void 0}if(this.src)return(i=new URLSearchParams(this.src).get("token"))!=null?i:void 0}set playbackToken(s){s!==this.playbackToken&&(s?this.setAttribute(w.PLAYBACK_TOKEN,s):this.removeAttribute(w.PLAYBACK_TOKEN))}get tokens(){let s=this.getAttribute(w.PLAYBACK_TOKEN),e=this.getAttribute(w.DRM_TOKEN);return{...Ce(this,Ss),...s!=null?{playback:s}:{},...e!=null?{drm:e}:{}}}set tokens(s){Xe(this,Ss,s??{})}get ended(){return bd(this.nativeEl,this._hls)}get envKey(){var s;return(s=this.getAttribute(w.ENV_KEY))!=null?s:void 0}set envKey(s){s!==this.envKey&&(s?this.setAttribute(w.ENV_KEY,s):this.removeAttribute(w.ENV_KEY))}get beaconCollectionDomain(){var s;return(s=this.getAttribute(w.BEACON_COLLECTION_DOMAIN))!=null?s:void 0}set beaconCollectionDomain(s){s!==this.beaconCollectionDomain&&(s?this.setAttribute(w.BEACON_COLLECTION_DOMAIN,s):this.removeAttribute(w.BEACON_COLLECTION_DOMAIN))}get streamType(){var s;return(s=this.getAttribute(w.STREAM_TYPE))!=null?s:dn(this.nativeEl)}set streamType(s){s!==this.streamType&&(s?this.setAttribute(w.STREAM_TYPE,s):this.removeAttribute(w.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(w.TARGET_LIVE_WINDOW)?+this.getAttribute(w.TARGET_LIVE_WINDOW):iy(this.nativeEl)}set targetLiveWindow(s){s!=this.targetLiveWindow&&(s==null?this.removeAttribute(w.TARGET_LIVE_WINDOW):this.setAttribute(w.TARGET_LIVE_WINDOW,`${+s}`))}get liveEdgeStart(){var s,e;if(this.hasAttribute(w.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,i=(s=this.nativeEl.seekable.end(0))!=null?s:0,r=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(r,i-t)}return sy(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(w.LIVE_EDGE_OFFSET))return+this.getAttribute(w.LIVE_EDGE_OFFSET)}set liveEdgeOffset(s){s!=this.liveEdgeOffset&&(s==null?this.removeAttribute(w.LIVE_EDGE_OFFSET):this.setAttribute(w.LIVE_EDGE_OFFSET,`${+s}`))}get seekable(){return ia(this.nativeEl)}async addCuePoints(s){return fd(this.nativeEl,s)}get activeCuePoint(){return gd(this.nativeEl)}get cuePoints(){return xv(this.nativeEl)}async addChapters(s){return pd(this.nativeEl,s)}get activeChapter(){return vd(this.nativeEl)}get chapters(){return Rv(this.nativeEl)}getStartDate(){return Dv(this.nativeEl,this._hls)}get currentPdt(){return kv(this.nativeEl,this._hls)}get preferPlayback(){let s=this.getAttribute(w.PREFER_PLAYBACK);if(s===ui.MSE||s===ui.NATIVE)return s}set preferPlayback(s){s!==this.preferPlayback&&(s===ui.MSE||s===ui.NATIVE?this.setAttribute(w.PREFER_PLAYBACK,s):this.removeAttribute(w.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(s=>s.startsWith("metadata-")&&![w.METADATA_URL].includes(s)).reduce((s,e)=>{let t=this.getAttribute(e);return t!=null&&(s[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),s},{}),...Ce(this,Ii)}}set metadata(s){Xe(this,Ii,s??{}),this.mux&&this.mux.emit("hb",Ce(this,Ii))}get _hlsConfig(){return Ce(this,_s)}set _hlsConfig(s){Xe(this,_s,s)}get logo(){var s;return(s=this.getAttribute(w.LOGO))!=null?s:Ce(this,Ri)}set logo(s){s?this.setAttribute(w.LOGO,s):this.removeAttribute(w.LOGO)}load(){Xe(this,ct,ay(this,this.nativeEl,Ce(this,ct)))}unload(){xd(this.nativeEl,Ce(this,ct),this),Xe(this,ct,void 0)}attributeChangedCallback(s,e,t){var i,r;switch(ls.observedAttributes.includes(s)&&!["src","autoplay","preload"].includes(s)&&super.attributeChangedCallback(s,e,t),s){case w.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t??void 0;break;case w.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t??void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Pr(this,Li,Is).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Pr(this,Li,Is).call(this));break}
144case"autoplay":if(t===e)break;(i=Ce(this,ct))==null||i.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(r=Ce(this,ct))==null||r.setPreload(t);break;case w.PLAYBACK_ID:this.src=Zv(this);break;case w.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 w.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 w.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case w.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;case w.LOGO:(t==null||t!==e)&&this.updateLogo();break}}updateLogo(){if(!this.shadowRoot)return;let s=this.shadowRoot.querySelector('slot[name="logo"]');if(!s)return;let e=this.constructor.getLogoHTML(Ce(this,Ri)||this.logo);s.innerHTML=e}connectedCallback(){var s;(s=super.connectedCallback)==null||s.call(this),this.nativeEl&&this.src&&!Ce(this,ct)&&Pr(this,Li,Is).call(this)}disconnectedCallback(){this.unload()}handleEvent(s){s.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(s.type,{composed:!0,detail:s.detail}))}};ct=new WeakMap,xi=new WeakMap,Ts=new WeakMap,Ii=new WeakMap,Ss=new WeakMap,_s=new WeakMap,As=new WeakMap,bs=new WeakMap,xs=new WeakMap,Ri=new WeakMap,Li=new WeakSet,Is=async function(){Ce(this,xi)||(await Xe(this,xi,Promise.resolve()),Xe(this,xi,null),this.load())};const zt=new WeakMap;class Or extends Error{}class Ry extends Error{}const Ly=["application/x-mpegURL","application/vnd.apple.mpegurl","audio/mpegurl"],Dy=globalThis.WeakRef?class extends Set{add(s){super.add(new WeakRef(s))}forEach(s){super.forEach(e=>{const t=e.deref();t&&s(t)})}}:Set;function ky(s){globalThis.chrome?.cast?.isAvailable?globalThis.cast?.framework?s():customElements.whenDefined("google-cast-button").then(s):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(s)}}function Cy(){return globalThis.chrome}function wy(){const s="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome?.cast||document.querySelector(`script[src="${s}"]`))return;const e=document.createElement("script");e.src=s,document.head.append(e)}function Ot(){return globalThis.cast?.framework?.CastContext.getInstance()}function na(){return Ot()?.getCurrentSession()}function aa(){return na()?.getSessionObj().media[0]}function Py(s){return new Promise((e,t)=>{aa().editTracksInfo(s,e,t)})}function Oy(s){return new Promise((e,t)=>{aa().getStatus(s,e,t)})}function tl(s){return Ot().setOptions({...Md(),...s})}function Md(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}function My(s){if(!s)return;const e=/\.([a-zA-Z0-9]+)(?:\?.*)?$/,t=s.match(e);return t?t[1]:null}function Ny(s){const e=s.split(`
145`),t=[];for(let i=0;i<e.length;i++)if(e[i].trim().startsWith("#EXT-X-STREAM-INF")){const n=e[i+1]?e[i+1].trim():"";n&&!n.startsWith("#")&&t.push(n)}return t}function Fy(s){return s.split(`
146`).find(i=>!i.trim().startsWith("#")&&i.trim()!=="")}async function Uy(s){try{const t=(await fetch(s,{method:"HEAD"})).headers.get("Content-Type");return Ly.some(i=>t===i)}catch(e){return console.error("Error while trying to get the Content-Type of the manifest",e),!1}}async function By(s){try{const e=await(await fetch(s)).text();let t=e;const i=Ny(e);if(i.length>0){const a=new URL(i[0],s).toString();t=await(await fetch(a)).text()}const r=Fy(t);return My(r)}catch(e){console.error("Error while trying to parse the manifest playlist",e);return}}const Rs=new Dy,Dt=new WeakSet;let xe;ky(()=>{if(!globalThis.chrome?.cast?.isAvailable){console.debug("chrome.cast.isAvailable",globalThis.chrome?.cast?.isAvailable);return}xe||(xe=cast.framework,Ot().addEventListener(xe.CastContextEventType.CAST_STATE_CHANGED,s=>
146{Rs.forEach(e=>zt.get(e).onCastStateChanged?.(s))}),Ot().addEventListener(xe.CastContextEventType.SESSION_STATE_CHANGED,s=>{Rs.forEach(e=>zt.get(e).onSessionStateChanged?.(s))}),Rs.forEach(s=>zt.get(s).init?.()))});let il=0;class $y extends EventTarget{#e;#s;#i;#r;#t="disconnected";#a=!1;#n=new Set;#l=new WeakMap;constructor(e){super(),this.#e=e,Rs.add(this),zt.set(this,{init:()=>this.#h(),onCastStateChanged:()=>this.#d(),onSessionStateChanged:()=>this.#g(),getCastPlayer:()=>this.#o}),this.#h()}get#o(){if(Dt.has(this.#e))return this.#i}get state(){return this.#t}async watchAvailability(e){if(this.#e.disableRemotePlayback)throw new Or("disableRemotePlayback attribute is present.");return this.#l.set(e,++il),this.#n.add(e),queueMicrotask(()=>e(this.#c())),il}async cancelWatchAvailability(e){if(this.#e.disableRemotePlayback)throw new Or("disableRemotePlayback attribute is present.");e?this.#n.delete(e):this.#n.clear()}async prompt(){if(this.#e.disableRemotePlayback)throw new Or("disableRemotePlayback attribute is present.");if(!globalThis.chrome?.cast?.isAvailable)throw new Ry("The RemotePlayback API is disabled on this platform.");const e=Dt.has(this.#e);Dt.add(this.#e),tl(this.#e.castOptions),Object.entries(this.#r).forEach(([t,i])=>{this.#i.controller.addEventListener(t,i)});try{await Ot().requestSession()}catch(t){if(e||Dt.delete(this.#e),t==="cancel")return;throw new Error(t)}zt.get(this.#e)?.loadOnPrompt?.()}#u(){Dt.has(this.#e)&&(Object.entries(this.#r).forEach(([e,t])=>{this.#i.controller.removeEventListener(e,t)}),Dt.delete(this.#e),this.#e.muted=this.#i.isMuted,this.#e.currentTime=this.#i.savedPlayerState.currentTime,this.#i.savedPlayerState.isPau
146sed===!1&&this.#e.play())}#c(){const e=Ot()?.getCastState();return e&&e!=="NO_DEVICES_AVAILABLE"}#d(){const e=Ot().getCastState();if(Dt.has(this.#e)&&e==="CONNECTING"&&(this.#t="connecting",this.dispatchEvent(new Event("connecting"))),!this.#a&&e?.includes("CONNECT")){this.#a=!0;for(let t of this.#n)t(!0)}else if(this.#a&&(!e||e==="NO_DEVICES_AVAILABLE")){this.#a=!1;for(let t of this.#n)t(!1)}}async#g(){const{SESSION_RESUMED:e}=xe.SessionState;if(Ot().getSessionState()===e&&this.#e.castSrc===aa()?.media.contentId){Dt.add(this.#e),Object.entries(this.#r).forEach(([t,i])=>{this.#i.controller.addEventListener(t,i)});try{await Oy(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}this.#r[xe.RemotePlayerEventType.IS_PAUSED_CHANGED](),this.#r[xe.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}}#h(){!xe||this.#s||(this.#s=!0,tl(this.#e.castOptions),this.#e.textTracks.addEventListener("change",()=>this.#f()),this.#d(),this.#i=new xe.RemotePlayer,new xe.RemotePlayerController(this.#i),this.#r={[xe.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:e})=>{e===!0?(this.#t="connected",this.dispatchEvent(new Event("connect"))):(this.#u(),this.#t="disconnected",this.dispatchEvent(new Event("disconnect")))},[xe.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.#e.dispatchEvent(new Event("durationchange"))},[xe.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.#e.dispatchEvent(new Event("volumechange"))},[xe.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.#e.dispatchEvent(new Event("volumechange"))},[xe.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{this.#o?.isMediaLoaded&&this.#e.dispatchEvent(new Event("timeupdate"))},[xe.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.#e.dispatchEvent(new Event("resize"))},[xe.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.#e.dispatchEvent(new Event(this.paused?"pause":"play"))},[xe.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{this.#o?.playerState!==chrome.cast.media.PlayerState.PAUSED&&this.#e.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[this.#o?.playerState]))},[xe.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{this.#o?.isMediaLoaded&&(await Promise.resolve(),this.#m())}})}#m(){this.#f()}async#f(){if(!this.#o)return;const t=(this.#i.mediaInfo?.tracks??[]).filter(({type:c})=>c===chrome.cast.media.TrackType.TEXT),i=[...this.#e.textTracks].filter(({kind:c})=>c==="subtitles"||c==="captions"),r=t.map(({language:c,name:h,trackId:f})=>{const{mode:g}=i.find(p=>p.language===c&&p.label===h)??{};return g?{mode:g,trackId:f}:!1}).filter(Boolean),a=r.filter(({mode:c})=>c!=="showing").map(({trackId:c})=>c),o=r.find(({mode:c})=>c==="showing"),u=na()?.getSessionObj().media[0]?.activeTrackIds??[];let l=u;if(u.length&&(l=l.filter(c=>!a.includes(c))),o?.trackId&&(l=[...l,o.trackId]),l=[...new Set(l)],!((c,h)=>c.length===h.length&&c.every(f=>h.includes(f)))(u,l))try{const c=new chrome.cast.media.EditTracksInfoRequest(l);await Py(c)}catch(c){console.error(c)}}}const Gy=s=>class extends s{static observedAttributes=[...s.observedAttributes??[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"];#e={paused:!1};#s=Md();#i;#r;get remote(){return this.#r?this.#r:Cy()?(this.disableRemotePlayback||wy(),zt.set(this,{loadOnPrompt:()=>this.#a()}),this.#r=new $y(this)):super.remote}get#t(){return zt.get(this.remote)?.getCastPlayer?.()}attributeChangedCallback(t,i,r){if(super.attributeChangedCallback(t,i,r),t==="cast-receiver"&&r){this.#s.receiverApplicationId=r;return}if(this.#t)switch(t){case"cast-stream-type":case"cast-src":this.load();break}}async#a(){this.#e.paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(t){console.error(t)}}async load(){if(!this.#t)return super.load();const t=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);t.customData=this.castCustomData;const i=[...this.querySelectorAll("track")].filter(({kind:o,src:u})=>u&&(o==="subtitles"||o==="captions")),r=[];let n=0;if(i.length&&(t.tracks=i.map(o=>{const u=++n;r.length===0&&o.track.mode==="showing"&&r.push(u);const l=new chrome.cast.media.Track(u,chrome.cast.media.TrackType.TEXT);return l.trackContentId=o.src,l.trackContentType="text/vtt",l.subtype=o.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,l.name=o.label,l.language=o.srclang,l})),this.castStreamType==="live"?t.streamType=chrome.cast.media.StreamType.LIVE:t.streamType=chrome.cast.media.StreamType.BUFFERED,t.metadata=new chrome.cast.media.GenericMediaMetadata,t.metadata.title=this.title,t.metadata.images=[{url:this.poster}],Uy(this.castSrc)){const o=await By(this.castSrc);o?.includes("m4s")||o?.includes("mp4")?(t.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.FMP4,t.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.FMP4):o?.includes("ts")&&(t.hlsSegmentFormat=chrome.cast.media.HlsSegmentFormat.TS,t.hlsVideoSegmentFormat=chrome.cast.media.HlsVideoSegmentFormat.TS)}const a=new chrome.cast.media.LoadRequest(t);a.currentTime=super.currentTime??0,a.autoplay=!this.#e.paused,a.activeTrackIds=r,await na()?.loadMedia(a),this.dispatchEvent(new Event("volumechange"))}play(){if(this.#t){this.#t.isPaused&&this.#t.controller?.playOrPause();return}return super.play()}pause(){if(this.#t){this.#t.isPaused||this.#t.controller?.playOrPause();return}super.pause()}get castOptions(){return this.#s}get castReceiver(){return this.getAttribute("cast-receiver")??void 0}set castReceiver(t){this.castReceiver!=t&&this.setAttribute("cast-receiver",`${t}`)}get castSrc(){return this.getAttribute("cast-src")??this.querySelector("source")?.src??this.currentSrc}set castSrc(t){this.castSrc!=t&&this.setAttribute("cast-src",`${t}`)}get castContentType(){return this.getAttribute("cast-content-type")??void 0}set castContentType(t){this.setAttribute("cast-content-type",`${t}`)}get castStreamType(){return this.getAttribute("cast-stream-type")??this.streamType??void 0}set castStreamType(t){this.setAttribute("cast-stream-type",`${t}`)}get castCustomData(){return this.#i}set castCustomData(t){const i=typeof t;if(!["object","undefined"].includes(i)){console.error(`castCustomData must be nullish or an object but value was of type ${i}`);return}this.#i=t}get readyState(){if(this.#t)switch(this.#t.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 this.#t?this.#t.isPaused:super.paused}get muted(){return this.#t?this.#t?.isMuted:super.muted}set muted(t){if(this.#t){(t&&!this.#t.isMuted||!t&&this.#t.isMuted)&&this.#t.controller?.muteOr
146Unmute();return}super.muted=t}get volume(){return this.#t?this.#t?.volumeLevel??1:super.volume}set volume(t){if(this.#t){this.#t.volumeLevel=+t,this.#t.controller?.setVolumeLevel();return}super.volume=t}get duration(){return this.#t&&this.#t?.isMediaLoaded?this.#t?.duration??NaN:super.duration}get currentTime(){return this.#t&&this.#t?.isMediaLoaded?this.#t?.currentTime??0:super.currentTime}set currentTime(t){if(this.#t){this.#t.currentTime=t,this.#t.controller?.seek();return}super.currentTime=t}};class Js extends Event{track;constructor(e,t){super(e),this.track=t.track}}const fn=new WeakMap;function V(s){return fn.get(s)??Ky(s,{})}function Ky(s,e){let t=fn.get(s);return t||fn.set(s,t={}),Object.assign(t,e)}function gn(s,e){const t=s.videoTracks;V(e).media=s,V(e).renditionSet||(V(e).renditionSet=new Set);const i=V(t).trackSet;i.add(e);const r=i.size-1;r in pn.prototype||Object.defineProperty(pn.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Js("addtrack",{track:e}))})}function mn(s){const e=V(s).media?.videoTracks;if(!e)return;V(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new Js("removetrack",{track:s}))})}function Vy(s){const e=V(s).media.videoTracks??[];let t=!1;for(const i of e)i!==s&&(i.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"))})}}class pn extends EventTarget{#e;#s;#i;constructor(){super(),V(this).trackSet=new Set}get#r(){return V(this).trackSet}[Symbol.iterator](){return this.#r.values()}get length(){return this.#r.size}getTrackById(e){return[...this.#r].find(t=>t.id===e)??null}get selectedIndex(){return[...this.#r].findIndex(e=>e.selected)}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#s}set onremovetrack(e){this.#s&&(this.removeEventListener("removetrack",this.#s),this.#s=void 0),typeof e=="function"&&(this.#s=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Zs extends Event{rendition;constructor(e,t){super(e),this.rendition=t.rendition}}function Hy(s,e){const t=V(s).media.videoRenditions;V(e).media=V(s).media,V(e).track=s;const i=V(s).renditionSet;i.add(e);const r=i.size-1;r in vn.prototype||Object.defineProperty(vn.prototype,r,{get(){return ai(this)[r]}}),queueMicrotask(()=>{s.selected&&t.dispatchEvent(new Zs("addrendition",{rendition:e}))})}function qy(s){const e=V(s).media.videoRenditions,t=V(s).track;V(t).renditionSet.delete(s),queueMicrotask(()=>{V(s).track.selected&&e.dispatchEvent(new Zs("removerendition",{rendition:s}))})}function Yy(s){const e=V(s).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(s).track.selected&&e.dispatchEvent(new Event("change"))}))}function ai(s){return[...V(s).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...V(t).renditionSet])}class vn extends EventTarget{#e;#s;#i;[Symbol.iterator](){return ai(this).values()}get length(){return ai(this).length}getRenditionById(e){return ai(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return ai(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of ai(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#s}set onremoverendition(e){this.#s&&(this.removeEventListener("removerendition",this.#s),this.#s=void 0),typeof e=="function"&&(this.#s=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Wy{src;id;width;height;bitrate;frameRate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,Yy(this))}}class Nd{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i,r,n,a){const o=new Wy;return o.src=e,o.width=t,o.height=i,o.frameRate=a,o.bitrate=n,o.codec=r,Hy(this,o),o}removeRendition(e){qy(e)}get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,e===!0&&Vy(this))}}function jy(s,e){const t=V(s).media.audioRenditions;V(e).media=V(s).media,V(e).track=s;const i=V(s).renditionSet;i.add(e);const r=i.size-1;
146r in yn.prototype||Object.defineProperty(yn.prototype,r,{get(){return oi(this)[r]}}),queueMicrotask(()=>{s.enabled&&t.dispatchEvent(new Zs("addrendition",{rendition:e}))})}function zy(s){const e=V(s).media.audioRenditions,t=V(s).track;V(t).renditionSet.delete(s),queueMicrotask(()=>{V(s).track.enabled&&e.dispatchEvent(new Zs("removerendition",{rendition:s}))})}function Xy(s){const e=V(s).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(s).track.enabled&&e.dispatchEvent(new Event("change"))}))}function oi(s){return[...V(s).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...V(t).renditionSet])}class yn extends EventTarget{#e;#s;#i;[Symbol.iterator](){return oi(this).values()}get length(){return oi(this).length}getRenditionById(e){return oi(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return oi(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of oi(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#s}set onremoverendition(e){this.#s&&(this.removeEventListener("removerendition",this.#s),this.#s=void 0),typeof e=="function"&&(this.#s=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Qy{src;id;bitrate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,Xy(this))}}function En(s,e){const t=s.audioTracks;V(e).media=s,V(e).renditionSet||(V(e).renditionSet=new Set);const i=V(t).trackSet;i.add(e);const r=i.size-1;r in Sn.prototype||Object.defineProperty(Sn.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Js("addtrack",{track:e}))})}function Tn(s){const e=V(s).media?.audioTracks;
146if(!e)return;V(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new Js("removetrack",{track:s}))})}function Jy(s){const e=V(s).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}class Sn extends EventTarget{#e;#s;#i;constructor(){super(),V(this).trackSet=new Set}get#r(){return V(this).trackSet}[Symbol.iterator](){return this.#r.values()}get length(){return this.#r.size}getTrackById(e){return[...this.#r].find(t=>t.id===e)??null}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#s}set onremovetrack(e){this.#s&&(this.removeEventListener("removetrack",this.#s),this.#s=void 0),typeof e=="function"&&(this.#s=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Fd{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i){const r=new Qy;return r.src=e,r.codec=t,r.bitrate=i,jy(this,r),r}removeRendition(e){zy(e)}get enabled(){return this.#e}set enabled(e){this.#e!==e&&(this.#e=e,Jy(this))}}const sl=qs(globalThis.HTMLMediaElement,"video"),rl=qs(globalThis.HTMLMediaElement,"audio");function Zy(s){if(!s?.prototype)return s;const e=qs(s,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"videoTracks",{get(){return eE(this)}});const t=qs(s,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"audioTracks",{get(){return tE(this)}}),"addVideoTrack"in s.prototype||(s.prototype.addVideoTrack=function(n,a="",o=""){const u=new Nd;return u.kind=n,u.label=a,u.language=o,gn(this,u),u}),"removeVideoTrack"in s.prototype||(s.prototype.removeVideoTrack=mn),"addAudioTrack"in s.prototype||(s.prototype.addAudioTrack=function(n,a="",o=""){const u=new Fd;return u.kind=n,u.label=a,u.language=o,En(this,u),u}),"removeAudioTrack"in s.prototype||(s.prototype.removeAudioTrack=Tn),"videoRenditions"in s.prototype||Object.defineProperty(s.prototype,"videoRenditions",{get(){return i(this)}});const i=n=>{let a=V(n).videoRenditions;return a||(a=new vn,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in s.prototype||Object.defineProperty(s.prototype,"audioRenditions",{get(){return r(this)}});const r=n=>{let a=V(n).audioRenditions;return a||(a=new yn,V(a).media=n,V(n).audioRenditions=a),a};return s}function qs(s,e){if(s?.prototype)return Object.getOwnPropertyDescriptor(s.prototype,`${e}Tracks`)?.get}function eE(s){let e=V(s).videoTracks;if(!e&&(e=new pn,V(s).videoTracks=e,sl)){const t=sl.call(s.nativeEl??s);for(const i of t)gn(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(r=>r instanceof Nd)){for(const r of t)mn(r);return}gn(s,i.track)}),t.addEventListener("removetrack",i=>{mn(i.track)})}return e}function tE(s){let e=V(s).audioTracks;
146if(!e&&(e=new Sn,V(s).audioTracks=e,rl)){const t=rl.call(s.nativeEl??s);for(const i of t)En(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(r=>r instanceof Fd)){for(const r of t)Tn(r);return}En(s,i.track)}),t.addEventListener("removetrack",i=>{Tn(i.track)})}return e}var Ud=s=>{throw TypeError(s)},Bd=(s,e,t)=>e.has(s)||Ud("Cannot "+t),iE=(s,e,t)=>(Bd(s,e,"read from private field"),t?t.call(s):e.get(s)),sE=(s,e,t)=>e.has(s)?Ud("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),rE=(s,e,t,i)=>(Bd(s,e,"write to private field"),e.set(s,t),t),$d=class{addEventListener(){}removeEventListener(){}dispatchEvent(s){return!0}};if(typeof DocumentFragment>"u"){class s extends $d{}globalThis.DocumentFragment=s}var nE=class extends $d{},aE={get(s){},define(s,e,t){},getName(s){return null},upgrade(s){},whenDefined(s){return Promise.resolve(nE)}},oE={customElements:aE},lE=typeof window>"u"||typeof globalThis.customElements>"u",Mr=lE?oE:globalThis,Ls,nl=class extends Gy(Zy(Iy)){constructor(){super(...arguments),sE(this,Ls)}get autoplay(){let s=this.getAttribute("autoplay");return s===null?!1:s===""?!0:s}set autoplay(s){let e=this.autoplay;s!==e&&(s?this.setAttribute("autoplay",typeof s=="string"?s:""):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 s;return(s=iE(this,Ls))!=null?s:this.muxCastCustomData}set castCustomData(s){rE(this,Ls,s)}};Ls=new WeakMap;Mr.customElements.get("mux-video")||(Mr.customElements.define("mux-video",nl),Mr.MuxVideoElement=nl);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.