����JFIF��x�x����'403WebShell
403Webshell
Server IP : 66.29.137.217  /  Your IP : 3.145.125.13
Web Server : LiteSpeed
System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : gltevjme ( 1095)
PHP Version : 7.0.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/gltevjme/gle.gltechlimited.com/public/content/java/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gltevjme/gle.gltechlimited.com/public/content/java/hls.js
/* HLS JS */
(function e(t){(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"==typeof globalThis?e||self:globalThis,e.Hls=t())})(this,function(){'use strict';function a(a,e){var r=Object.keys(a);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(a);e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable})),r.push.apply(r,t)}return r}function r(n){for(var e=1,i;e<arguments.length;e++)i=null==arguments[e]?{}:arguments[e],e%2?a(Object(i),!0).forEach(function(e){l(n,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):a(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))});return n}function n(a,t){if("object"!=typeof a||!a)return a;var r=a[Symbol.toPrimitive];if(void 0!==r){var e=r.call(a,t||"default");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(a)}function d(e){var t=n(e,"string");return"symbol"==typeof t?t:t+""}function o(e,t){for(var a=0,r;a<t.length;a++)r=t[a],r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}function s(e,t,a){return t&&o(e.prototype,t),a&&o(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,a){return t=d(t),t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1,a;t<arguments.length;t++)for(var r in a=arguments[t],a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r]);return e},u.apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,g(e,t)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function m(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function p(){return p=m()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var a=Function.bind.apply(e,n),i=new a;return r&&g(i,r.prototype),i},p.apply(null,arguments)}function y(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(a){return"function"==typeof t}}function h(e){var t="function"==typeof Map?new Map:void 0;return h=function(e){function a(){return p(e,arguments,f(this).constructor)}if(null===e||!y(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof t){if(t.has(e))return t.get(e);t.set(e,a)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),g(a,e)},h(e)}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e,t){if(e){if("string"==typeof e)return S(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?S(e,t):void 0}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=Array(t);a<t;a++)r[a]=e[a];return r}function L(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(a)return(a=a.call(e)).next.bind(a);if(Array.isArray(e)||(a=E(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function R(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):Rn}function A(e){for(var t=arguments.length,a=Array(1<t?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];a.forEach(function(t){vn[t]=e[t]?e[t].bind(e):R(t)})}function v(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){A(e,"debug","log","info","warn","error");try{vn.log("Debug logs enabled for \""+t+"\" in hls.js version 1.5.1")}catch(t){vn=An}}else vn=An}function I(e){return"ID"!==e&&"CLASS"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function D(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}function k(e){return Uint8Array.from(atob(e),function(e){return e.charCodeAt(0)})}function _(e){var t=x(e).subarray(0,16),a=new Uint8Array(16);return a.set(t,16-t.length),a}function C(e){var t=function(e,t,a){var r=e[t];e[t]=e[a],e[a]=r};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function b(e){var t=e.split(":"),a=null;if("data"===t[0]&&2===t.length){var r=t[1].split(";"),n=r[r.length-1].split(",");if(2===n.length){var i="base64"===n[0],d=n[1];i?(r.splice(-1,1),a=k(d)):a=_(d)}}return a}function x(e){return Uint8Array.from(unescape(encodeURIComponent(e)),function(e){return e.charCodeAt(0)})}function P(e){return e===Mn.FAIRPLAY?wn.FAIRPLAY:e===Mn.PLAYREADY?wn.PLAYREADY:e===Mn.WIDEVINE?wn.WIDEVINE:e===Mn.CLEARKEY?wn.CLEARKEY:void 0}function F(e){if(e===Bn.WIDEVINE)return wn.WIDEVINE}function O(e){return e===wn.FAIRPLAY?Mn.FAIRPLAY:e===wn.PLAYREADY?Mn.PLAYREADY:e===wn.WIDEVINE?Mn.WIDEVINE:e===wn.CLEARKEY?Mn.CLEARKEY:void 0}function N(e){var t=e.drmSystems,a=e.widevineLicenseUrl,r=t?[wn.FAIRPLAY,wn.WIDEVINE,wn.PLAYREADY,wn.CLEARKEY].filter(function(e){return!!t[e]}):[];return!r[wn.WIDEVINE]&&a&&r.push(wn.WIDEVINE),r}function w(e,t,a,r){var n;switch(e){case wn.FAIRPLAY:n=["cenc","sinf"];break;case wn.WIDEVINE:case wn.PLAYREADY:n=["cenc"];break;case wn.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e);}return M(n,t,a,r)}function M(e,t,a,r){var n={initDataTypes:e,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:t.map(function(e){return{contentType:"audio/mp4; codecs=\""+e+"\"",robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null}}),videoCapabilities:a.map(function(e){return{contentType:"video/mp4; codecs=\""+e+"\"",robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}})};return[n]}function B(e,t,a){return Uint8Array.prototype.slice?e.slice(t,a):new Uint8Array(Array.prototype.slice.call(e,t,a))}function U(){if(!navigator.userAgent.includes("PlayStation 4"))return Rd||"undefined"==typeof self.TextDecoder||(Rd=new self.TextDecoder("utf-8")),Rd}function G(e){return String.fromCharCode.apply(null,e)}function K(e,t){var a=e[t]<<8|e[t+1];return 0>a?65536+a:a}function H(e,t){var a=V(e,t);return 0>a?4294967296+a:a}function V(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Y(e,t,a){e[t]=a>>24,e[t+1]=255&a>>16,e[t+2]=255&a>>8,e[t+3]=255&a}function W(e){for(var t=e.byteLength,a=0,r;a<t;){if(r=H(e,a),8<r&&109===e[a+4]&&111===e[a+5]&&111===e[a+6]&&102===e[a+7])return!0;a=1<r?a+r:t}return!1}function q(e,t){var a=[];if(!t.length)return a;for(var r=e.byteLength,n=0;n<r;){var d=H(e,n),o=G(e.subarray(n+4,n+8)),s=1<d?n+d:r;if(o===t[0])if(1===t.length)a.push(e.subarray(n+8,s));else{var l=q(e.subarray(n+8,s),t.slice(1));l.length&&ri.apply(a,l)}n=s}return a}function j(e){var t=[],a=e[0],r=8,n=H(e,r);r+=4;r+=0===a?8:16,r+=2;var d=e.length+0,o=K(e,r);r+=2;for(var s=0;s<o;s++){var l=r,u=H(e,l);l+=4;var c=2147483647&u;if(1===(2147483648&u)>>>31)return In.warn("SIDX has hierarchical references (not supported)"),null;var f=H(e,l);l+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:d,end:d+c-1}}),d+=c,l+=4,r=l}return{earliestPresentationTime:0,timescale:n,version:a,referencesCount:o,references:t}}function X(e){for(var t=[],a=q(e,["moov","trak"]),n=0;n<a.length;n++){var d=a[n],o=q(d,["tkhd"])[0];if(o){var s=o[0],l=H(o,0===s?12:20),u=q(d,["mdia","mdhd"])[0];if(u){s=u[0];var c=H(u,0===s?12:20),f=q(d,["mdia","hdlr"])[0];if(f){var g=G(f.subarray(8,12)),m={soun:bn.AUDIO,vide:bn.VIDEO}[g];if(m){var p=q(d,["mdia","minf","stbl","stsd"])[0],y=z(p);t[l]={timescale:c,type:m},t[m]=r({timescale:c,id:l},y)}}}}}var h=q(e,["moov","mvex","trex"]);return h.forEach(function(e){var a=H(e,4),r=t[a];r&&(r.default={duration:H(e,12),flags:H(e,20)})}),t}function z(e){var t=e.subarray(8),a=t.subarray(86),r=G(t.subarray(4,8)),n=r,d="enca"===r||"encv"===r;if(d){var o=q(t,[r])[0],s=o.subarray("enca"===r?28:78),l=q(s,["sinf"]);l.forEach(function(e){var t=q(e,["schm"])[0];if(t){var a=G(t.subarray(4,8));if("cbcs"===a||"cenc"===a){var r=q(e,["frma"])[0];r&&(n=G(r))}}})}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{var u=q(a,["avcC"])[0];n+="."+Z(u[1])+Z(u[2])+Z(u[3]);break}case"mp4a":{var c=q(t,[r])[0],f=q(c.subarray(28),["esds"])[0];if(f&&12<f.length){var g=4;if(3!==f[g++])break;g=Q(f,g),g+=2;var m=f[g++];if(128&m&&(g+=2),64&m&&(g+=f[g++]),4!==f[g++])break;g=Q(f,g);var p=f[g++];if(64===p)n+="."+Z(p);else break;if(g+=12,5!==f[g++])break;g=Q(f,g);var y=f[g++],h=(248&y)>>3;31===h&&(h+=1+((7&y)<<3)+((224&f[g])>>5)),n+="."+h}break}case"hvc1":case"hev1":{var T=q(a,["hvcC"])[0],E=T[1],S=["","A","B","C"][E>>6],L=H(T,2),R=(32&E)>>5?"H":"L",A=T[12],v=T.subarray(6,12);n+="."+S+(31&E),n+="."+L.toString(16).toUpperCase(),n+="."+R+A;for(var I="",D=v.length,k;D--;)if(k=v[D],k||I){var _=k.toString(16).toUpperCase();I="."+_+I}n+=I;break}case"dvh1":case"dvhe":{var C=q(a,["dvcC"])[0],b=127&C[2]>>1,x=32&C[2]<<5|31&C[3]>>3;n+="."+$(b)+"."+$(x);break}case"vp09":{var P=q(a,["vpcC"])[0],F=P[4],O=P[5],N=15&P[6]>>4;n+="."+$(F)+"."+$(O)+"."+$(N);break}case"av01":{var w=q(a,["av1C"])[0],M=w[1]>>>5,B=31&w[1],U=w[2]>>>7?"H":"M",K=(64&w[2])>>6,V=(32&w[2])>>5,Y=2===M&&K?V?12:10:K?10:8,W=(16&w[2])>>4,j=(8&w[2])>>3,X=(4&w[2])>>2,z=3&w[2];n+="."+M+"."+$(B)+U+"."+$(Y)+"."+W+"."+j+X+z+"."+$(1)+"."+$(1)+"."+$(1)+"."+0;break}}return{codec:n,encrypted:d}}function Q(e,t){for(var a=t+5;128&e[t++]&&t<a;);return t}function Z(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function $(e){return(10>e?"0":"")+e}function J(e,t){if(!e||!t)return e;var a=t.keyId;if(a&&t.isCommonEncryption){var r=q(e,["moov","trak"]);r.forEach(function(e){var t=q(e,["mdia","minf","stbl","stsd"])[0],r=t.subarray(8),n=q(r,["enca"]),i=0<n.length;i||(n=q(r,["encv"])),n.forEach(function(e){var t=i?e.subarray(28):e.subarray(78),r=q(t,["sinf"]);r.forEach(function(e){var t=ee(e);if(t){var r=t.subarray(8,24);r.some(function(e){return 0!==e})||(In.log("[eme] Patching keyId in 'enc"+(i?"a":"v")+">sinf>>tenc' box: "+ti.hexDump(r)+" -> "+ti.hexDump(a)),t.set(a,8))}})})})}return e}function ee(e){var t=q(e,["schm"])[0];if(t){var a=G(t.subarray(4,8));if("cbcs"===a||"cenc"===a)return q(e,["schi","tenc"])[0]}return In.error("[eme] missing 'schm' box"),null}function te(e,t){return q(t,["moof","traf"]).reduce(function(t,a){var r=q(a,["tfdt"])[0],n=r[0],i=q(a,["tfhd"]).reduce(function(t,a){var i=H(a,4),d=e[i];if(d){var o=H(r,4);if(1===n){if(4294967295===o)return In.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=4294967296,o+=H(r,8)}var s=d.timescale||9e4,l=o/s;if(yn(l)&&(null===t||l<t))return l}return t},null);return null!==i&&yn(i)&&(null===t||i<t)?i:t},null)}function ae(e,t){for(var a=0,r=0,n=0,d=q(e,["moof","traf"]),o=0;o<d.length;o++){var s=d[o],l=q(s,["tfhd"])[0],u=H(l,4),c=t[u];if(c){var f=c.default,g=H(l,0)|(null==f?void 0:f.flags),m=null==f?void 0:f.duration;8&g&&(2&g?m=H(l,12):m=H(l,8));for(var p=c.timescale||9e4,y=q(s,["trun"]),h=0;h<y.length;h++){if(a=re(y[h]),!a&&m){var T=H(y[h],4);a=m*T}c.type===bn.VIDEO?r+=a/p:c.type===bn.AUDIO&&(n+=a/p)}}}if(0===r&&0===n){for(var E=0,S=q(e,["sidx"]),L=0,R;L<S.length;L++)R=j(S[L]),null!=R&&R.references&&(E+=R.references.reduce(function(e,t){return e+t.info.duration||0},0));return E}return r?r:n}function re(e){var t=H(e,0),a=8;1&t&&(a+=4),4&t&&(a+=4);for(var r=0,n=H(e,4),d=0;d<n;d++){if(256&t){var o=H(e,a);r+=o,a+=4}512&t&&(a+=4),1024&t&&(a+=4),2048&t&&(a+=4)}return r}function ne(e,t,a){q(t,["moof","traf"]).forEach(function(t){q(t,["tfhd"]).forEach(function(r){var n=H(r,4),i=e[n];if(i){var d=i.timescale||9e4;q(t,["tfdt"]).forEach(function(e){var t=e[0],r=a*d;if(r){var n=H(e,4);if(0===t)n-=r,n=Math.max(n,0),Y(e,4,n);else{n*=Math.pow(2,32),n+=H(e,8),n-=r,n=Math.max(n,0);var i=Math.floor(n/4294967296),o=Math.floor(n%4294967296);Y(e,4,i),Y(e,8,o)}}})}})})}function ie(e){var t={valid:null,remainder:null},a=q(e,["moof"]);if(2>a.length)return t.remainder=e,t;var r=a[a.length-1];return t.valid=B(e,0,r.byteOffset-8),t.remainder=B(e,r.byteOffset-8),t}function de(e,t){var a=new Uint8Array(e.length+t.length);return a.set(e),a.set(t,e.length),a}function oe(e,t){var a=[],r=t.samples,n=t.timescale,i=t.id,d=!1,o=q(r,["moof"]);return o.map(function(o){var s=o.byteOffset-8,l=q(o,["traf"]);l.map(function(o){var l=q(o,["tfdt"]).map(function(e){var t=e[0],a=H(e,4);return 1===t&&(a*=Math.pow(2,32),a+=H(e,8)),a/n})[0];return void 0!==l&&(e=l),q(o,["tfhd"]).map(function(l){var u=H(l,4),c=16777215&H(l,0),f=0,g=0,m=8;u===i&&(0!=(1&c)&&(m+=8),0!=(2&c)&&(m+=4),0!=(8&c)&&(f=H(l,m),m+=4),0!=(16&c)&&(g=H(l,m),m+=4),0!=(32&c)&&(m+=4),"video"===t.type&&(d=se(t.codec)),q(o,["trun"]).map(function(i){var o=i[0],l=16777215&H(i,0),u=0,c=0,m=0,p=0,y=H(i,4),h=8;0!=(1&l)&&(u=H(i,h),h+=4),0!=(4&l)&&(h+=4);for(var T=u+s,E=0;E<y;E++){if(0!=(256&l)?(c=H(i,h),h+=4):c=f,0!=(512&l)?(m=H(i,h),h+=4):m=g,0!=(1024&l)&&(h+=4),0!=(2048&l)&&(p=0===o?H(i,h):V(i,h),h+=4),t.type===bn.VIDEO)for(var S=0,L;S<m;){if(L=H(r,T),T+=4,le(d,r[T])){var R=r.subarray(T,T+L);ue(R,d?2:1,e+p/n,a)}T+=L,S+=L+4}e+=c/n}}))})})}),a}function se(e){if(!e)return!1;var t=e.indexOf("."),a=0>t?e:e.substring(0,t);return"hvc1"===a||"hev1"===a||"dvh1"===a||"dvhe"===a}function le(e,t){if(e){var a=63&t>>1;return 39==a||40===a}return 6==(31&t)}function ue(e,t,a,r){var n=ce(e),d=0;d+=t;for(var o=0,s=0,l=0;d<n.length;){o=0;do{if(d>=n.length)break;l=n[d++],o+=l}while(255===l);s=0;do{if(d>=n.length)break;l=n[d++],s+=l}while(255===l);var u=n.length-d,c=d;if(s<u)d+=s;else if(s>u){In.error("Malformed SEI payload. "+s+" is too small, only "+u+" bytes left to parse.");break}if(4===o){var f=n[c++];if(181===f){var g=K(n,c);if(c+=2,49===g){var m=H(n,c);if(c+=4,1195456820===m){var p=n[c++];if(3===p){var y=n[c++],h=64&y,T=h?2+3*(31&y):0,E=new Uint8Array(T);if(h){E[0]=y;for(var S=1;S<T;S++)E[S]=n[c++]}r.push({type:p,payloadType:o,pts:a,bytes:E})}}}}}else if(5===o&&16<s){for(var L=[],R=0,A;16>R;R++)A=n[c++].toString(16),L.push(1==A.length?"0"+A:A),(3==R||5===R||7===R||9===R)&&L.push("-");for(var v=s-16,I=new Uint8Array(v),D=0;D<v;D++)I[D]=n[c++];r.push({payloadType:o,pts:a,uuid:L.join(""),userData:ei(I),userDataBytes:I})}}}function ce(e){for(var t=e.byteLength,a=[],r=1;r<t-2;)0===e[r]&&0===e[r+1]&&3===e[r+2]?(a.push(r+2),r+=2):r++;if(0===a.length)return e;var n=t-a.length,d=new Uint8Array(n),o=0;for(r=0;r<n;o++,r++)o===a[0]&&(o++,a.shift()),d[r]=e[o];return d}function fe(e){var t=e[0],a="",r="",n=0,i=0,d=0,o=0,s=0,l=0;if(0===t){for(;"\0"!==G(e.subarray(l,l+1));)a+=G(e.subarray(l,l+1)),l+=1;for(a+=G(e.subarray(l,l+1)),l+=1;"\0"!==G(e.subarray(l,l+1));)r+=G(e.subarray(l,l+1)),l+=1;r+=G(e.subarray(l,l+1)),l+=1,n=H(e,12),i=H(e,16),o=H(e,20),s=H(e,24),l=28}else if(1===t){l+=4,n=H(e,l),l+=4;var u=H(e,l);l+=4;var c=H(e,l);for(l+=4,d=Math.pow(2,32)*u+c,hn(d)||(d=Number.MAX_SAFE_INTEGER,In.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=H(e,l),l+=4,s=H(e,l),l+=4;"\0"!==G(e.subarray(l,l+1));)a+=G(e.subarray(l,l+1)),l+=1;for(a+=G(e.subarray(l,l+1)),l+=1;"\0"!==G(e.subarray(l,l+1));)r+=G(e.subarray(l,l+1)),l+=1;r+=G(e.subarray(l,l+1)),l+=1}var f=e.subarray(l,e.byteLength);return{schemeIdUri:a,value:r,timeScale:n,presentationTime:d,presentationTimeDelta:i,eventDuration:o,id:s,payload:f}}function ge(e){for(var t=arguments.length,a=Array(1<t?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];for(var n=a.length,d=8,o=n;o--;)d+=a[o].byteLength;var s=new Uint8Array(d);for(s[0]=255&d>>24,s[1]=255&d>>16,s[2]=255&d>>8,s[3]=255&d,s.set(e,4),(o=0,d=8);o<n;o++)s.set(a[o],d),d+=a[o].byteLength;return s}function me(e,t,a){if(16!==e.byteLength)throw new RangeError("Invalid system id");var r,n;if(t){r=1,n=new Uint8Array(16*t.length);for(var i=0,d;i<t.length;i++){if(d=t[i],16!==d.byteLength)throw new RangeError("Invalid key");n.set(d,16*i)}}else r=0,n=new Uint8Array;var o;0<r?(o=new Uint8Array(4),0<t.length&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;var s=new Uint8Array(4);return a&&0<a.byteLength&&new DataView(s.buffer).setUint32(0,a.byteLength,!1),ge([112,115,115,104],new Uint8Array([r,0,0,0]),e,o,n,s,a||new Uint8Array)}function pe(e){if(!(e instanceof ArrayBuffer)||32>e.byteLength)return null;var t={version:0,systemId:"",kids:null,data:null},a=new DataView(e),r=a.getUint32(0);if(e.byteLength!==r&&44<r)return null;var n=a.getUint32(4);if(1886614376!==n)return null;if(t.version=a.getUint32(8)>>>24,1<t.version)return null;t.systemId=ti.hexDump(new Uint8Array(e,12,16));var d=a.getUint32(28);if(0===t.version){if(r-32<d)return null;t.data=new Uint8Array(e,32,d)}else if(1===t.version){t.kids=[];for(var o=0;o<d;o++)t.kids.push(new Uint8Array(e,32+16*o,16))}return t}function ye(e){for(var t=new Uint8Array(16),a=12;16>a;a++)t[a]=255&e>>8*(15-a);return t}function he(e){return oi.test(e)}function Te(e,t,a){if(null!==e.variableList||e.hasVariableRefs)for(var r=a.length;r--;){var n=a[r],d=t[n];d&&(t[n]=Ee(e,d))}}function Ee(e,t){if(null!==e.variableList||e.hasVariableRefs){var a=e.variableList;return t.replace(oi,function(t){var r=t.substring(2,t.length-1),n=null==a?void 0:a[r];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error("Missing preceding EXT-X-DEFINE tag for Variable Reference: \""+r+"\"")),t):n})}return t}function Se(e,t,a){var r=e.variableList;r||(e.variableList=r={});var n,i;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{var d=new self.URL(a).searchParams;if(d.has(n))i=d.get(n);else throw new Error("\""+n+"\" does not match any query parameter in URI: \""+a+"\"")}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else n=t.NAME,i=t.VALUE;n in r?e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE duplicate Variable Name declarations: \""+n+"\"")):r[n]=i||""}function Le(e,t,a){var r=t.IMPORT;if(a&&r in a){var n=e.variableList;n||(e.variableList=n={}),n[r]=a[r]}else e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: \""+r+"\""))}function Re(e){if(void 0===e&&(e=!0),"undefined"!=typeof self){var t=(e||!self.MediaSource)&&self.ManagedMediaSource;return t||self.MediaSource||self.WebKitMediaSource}}function Ae(e,t){var a=si[t];return!!a&&!!a[e.slice(0,4)]}function ve(e,t,a){return void 0===a&&(a=!0),!e.split(",").some(function(e){return!Ie(e,t,a)})}function Ie(e,t,a){var r;void 0===a&&(a=!0);var n=Re(a);return null!=(r=null==n?void 0:n.isTypeSupported(De(e,t)))&&r}function De(e,t){return t+"/mp4;codecs=\""+e+"\""}function ke(e){if(e){var t=e.substring(0,4);return si.video[t]}return 2}function _e(e){return e.split(",").reduce(function(e,t){var a=si.video[t];return a?(2*a+e)/(e?3:2):(si.audio[t]+e)/(e?2:1)},0)}function Ce(e,t){if(void 0===t&&(t=!0),li[e])return li[e];for(var a={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],r=0;r<a.length;r++)if(Ie(a[r],"audio",t))return li[e]=a[r],a[r];return e}function be(e,t){return void 0===t&&(t=!0),e.replace(ui,function(e){return Ce(e.toLowerCase(),t)})}function xe(e,t){return e&&"mp4a"!==e?e:t}function Pe(e){var t=e.split(".");if(2<t.length){var a=t.shift()+".";return a+=parseInt(t.shift()).toString(16),a+=("000"+parseInt(t.shift()).toString(16)).slice(-4),a}return e}function Fe(e,t,a){var r=new kn(e),n,i;Te(a,r,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var d=null==(n=r.METHOD)?"":n,o=r.URI,s=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,u=null==(i=r.KEYFORMAT)?"identity":i;o&&r.IV&&!s&&In.error("Invalid IV: "+r.IV);var c=o?pi.resolve(o,t):"",f=(l?l:"1").split("/").map(Number).filter(Number.isFinite);return new di(d,c,u,f,s)}function Oe(e){var t=new kn(e),a=t.decimalFloatingPoint("TIME-OFFSET");return yn(a)?a:null}function Ne(e,t){var a=(e||"").split(/[ ,]+/).filter(function(e){return e});["video","audio","text"].forEach(function(e){var r=a.filter(function(t){return Ae(t,e)});r.length&&(t[e+"Codec"]=r.join(","),a=a.filter(function(e){return-1===r.indexOf(e)}))}),t.unknownCodecs=a}function we(e,t,a){var r=t[a];r&&(e[a]=r)}function Me(e,t){for(var a=e[t],r=t,n;r--;){if(n=e[r],!n)return;n.programDateTime=a.programDateTime-1e3*n.duration,a=n}}function Be(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),yn(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function Ue(e,t,a,r){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=a,e.sn="initSegment",r&&(e.levelkeys=r),e.initSegment=null}function Ge(e,t,a){e.levelkeys=t;var r=a.encryptedFragments;(!r.length||r[r.length-1].levelkeys!==t)&&Object.keys(t).some(function(e){return t[e].isCommonEncryption})&&r.push(e)}function Ke(e){var t=e.type;return t===yi.AUDIO_TRACK?hi.AUDIO:t===yi.SUBTITLE_TRACK?hi.SUBTITLE:hi.MAIN}function He(e,t){var a=e.url;return(void 0===a||0===a.indexOf("data:"))&&(a=t.url),a}function Ve(e,t){var a;try{a=new Event("addtrack")}catch(e){a=document.createEvent("Event"),a.initEvent("addtrack",!1,!1)}a.track=e,t.dispatchEvent(a)}function Ye(e,t){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(a){In.debug("[texttrack-utils]: "+a);try{var r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){In.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===a&&(e.mode=a)}function We(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var a=e.cues.length;a--;)e.removeCue(e.cues[a]);"disabled"===t&&(e.mode=t)}function qe(e,t,a,r){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&0<e.cues.length)for(var d=Xe(e.cues,t,a),o=0;o<d.length;o++)(!r||r(d[o]))&&e.removeCue(d[o]);"disabled"===n&&(e.mode=n)}function je(e,t){if(t<e[0].startTime)return 0;var a=e.length-1;if(t>e[a].endTime)return-1;for(var r=0,n=a,i;r<=n;)if(i=Math.floor((n+r)/2),t<e[i].startTime)n=i-1;else if(t>e[i].startTime&&r<a)r=i+1;else return i;return e[r].startTime-t<t-e[n].startTime?r:n}function Xe(e,t,a){var r=[],n=je(e,t);if(-1<n)for(var d=n,o=e.length,s;d<o;d++)if(s=e[d],s.startTime>=t&&s.endTime<=a)r.push(s);else if(s.startTime>a)return r;return r}function ze(e){for(var t=[],a=0,r;a<e.length;a++)r=e[a],("subtitles"===r.kind||"captions"===r.kind)&&r.label&&t.push(e[a]);return t}function Qe(){return"undefined"==typeof self?void 0:self.VTTCue||self.TextTrackCue}function Ze(t,a,n,i,d){var o=new t(a,n,"");try{o.value=i,d&&(o.type=d)}catch(s){o=new t(a,n,JSON.stringify(d?r({type:d},i):i))}return o}function $e(e,t){return e.getTime()/1e3-t}function Je(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function et(e){return-1<Ai.indexOf(e)}function tt(e){return!!e&&-1<vi.indexOf(e)}function at(e,t){var a=e.canSkipUntil,r=e.canSkipDateRanges,n=e.endSN,i=void 0===t?0:t-n;return a&&i<a?r?Ii.v2:Ii.Yes:Ii.No}function rt(e,t){return!!(t&&e)&&-1!==e.indexOf(t)}function nt(e,t){var a=t.startPTS;if(yn(a)){var r=0,n;t.sn>e.sn?(r=a-e.start,n=e):(r=e.start-a,n=t),n.duration!==r&&(n.duration=r)}else if(t.sn>e.sn){var i=e.cc===t.cc;t.start=i&&e.minEndPTS?e.start+(e.minEndPTS-e.start):e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function it(e,t,a,r,n,d){var o=r-a;0>=o&&(In.warn("Fragment should have a positive duration",t),r=a+t.duration,d=n+t.duration);var s=a,l=r,u=t.startPTS,c=t.endPTS;if(yn(u)){var f=Math.abs(u-a);t.deltaPTS=yn(t.deltaPTS)?Math.max(f,t.deltaPTS):f,s=Math.max(a,u),a=Math.min(a,u),n=Math.min(n,t.startDTS),l=Math.min(r,c),r=Math.max(r,c),d=Math.max(d,t.endDTS)}var g=a-t.start;0!==t.start&&(t.start=a),t.duration=r-t.start,t.startPTS=a,t.maxStartPTS=s,t.startDTS=n,t.endPTS=r,t.minEndPTS=l,t.endDTS=d;var m=t.sn;if(!e||m<e.startSN||m>e.endSN)return 0;var p=m-e.startSN,y=e.fragments,h;for(y[p]=t,h=p;0<h;h--)nt(y[h],y[h-1]);for(h=p;h<y.length-1;h++)nt(y[h],y[h+1]);return e.fragmentHint&&nt(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,g}function dt(e,t){for(var a=null,r=e.fragments,n=r.length-1,d;0<=n;n--)if(d=r[n].initSegment,d){a=d;break}e.fragmentHint&&delete e.fragmentHint.endPTS;var o=0,s;if(lt(e,t,function(e,r){e.relurl&&(o=e.cc-r.cc),yn(e.startPTS)&&yn(e.endPTS)&&(r.start=r.startPTS=e.startPTS,r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.duration=e.endPTS-e.startPTS,r.duration&&(s=r),t.PTSKnown=t.alignedSliding=!0),r.elementaryStreams=e.elementaryStreams,r.loader=e.loader,r.stats=e.stats,e.initSegment&&(r.initSegment=e.initSegment,a=e.initSegment)}),a){var l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;l.forEach(function(e){var t;e&&(!e.initSegment||e.initSegment.relurl===(null==(t=a)?void 0:t.relurl))&&(e.initSegment=a)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(e){return!e}),t.deltaUpdateFailed){In.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=t.skippedSegments;u--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=ot(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var c=t.fragments;if(o){In.warn("discontinuity sliding from playlist, take drift into account");for(var f=0;f<c.length;f++)c[f].cc+=o}t.skippedSegments&&(t.startCC=t.fragments[0].cc),st(e.partList,t.partList,function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?it(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):ut(e,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var g=t.advancedDateTime;if(t.advanced&&g){var m=t.edge;t.driftStart||(t.driftStartTime=g,t.driftStart=m),t.driftEndTime=g,t.driftEnd=m}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function ot(e,t,a){var r=u({},e);return a&&a.forEach(function(e){delete r[e]}),Object.keys(t).forEach(function(e){var a=new _n(t[e].attr,r[e]);a.isValid?r[e]=a:In.warn("Ignoring invalid Playlist Delta Update DATERANGE tag: \""+JSON.stringify(t[e].attr)+"\"")}),r}function st(e,t,a){if(e&&t)for(var r=0,n=0,d=e.length;n<=d;n++){var o=e[n],s=t[n+r];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?a(o,s):r--}}function lt(e,t,a){for(var r=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,d=(e.fragmentHint?1:0)+(r?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=n;u<=d;u++){var c=l[o+u],f=s[u];r&&!f&&u<r&&(f=t.fragments[u]=c),c&&f&&a(c,f)}}function ut(e,t){var a=t.startSN+t.skippedSegments-e.startSN,r=e.fragments;0>a||a>=r.length||ct(t,r[a].start)}function ct(e,t){if(t){for(var a=e.fragments,r=e.skippedSegments;r<a.length;r++)a[r].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function ft(e,t){void 0===t&&(t=1/0);var a=1e3*e.targetduration;if(e.updated){var r=e.fragments;if(r.length&&a*4>t){var n=1e3*r[r.length-1].duration;n<a&&(a=n)}}else a/=2;return Math.round(a)}function gt(e,t,a){if(!(null!=e&&e.details))return null;var r=e.details,n=r.fragments[t-r.startSN];return n?n:(n=r.fragmentHint,n&&n.sn===t?n:t<r.startSN&&a&&a.sn===t?a:null)}function mt(e,t,a){var r;return null!=e&&e.details?pt(null==(r=e.details)?void 0:r.partList,t,a):null}function pt(e,t,a){if(e)for(var r=e.length,n;r--;)if(n=e[r],n.index===a&&n.fragment.sn===t)return n;return null}function yt(e){e.forEach(function(e,t){var a=e.details;null!=a&&a.fragments&&a.fragments.forEach(function(e){e.level=t})})}function ht(e){switch(e.details){case Ln.FRAG_LOAD_TIMEOUT:case Ln.KEY_LOAD_TIMEOUT:case Ln.LEVEL_LOAD_TIMEOUT:case Ln.MANIFEST_LOAD_TIMEOUT:return!0;}return!1}function Tt(e,t){var a=ht(t);return e.default[(a?"timeout":"error")+"Retry"]}function Et(e,t){var a="linear"===e.backoff?1:Math.pow(2,t);return Math.min(a*e.retryDelayMs,e.maxRetryDelayMs)}function St(e){return r(r({},e),{errorRetry:null,timeoutRetry:null})}function Lt(e,t,a,r){if(!e)return!1;var n=null==r?void 0:r.code,i=t<e.maxNumRetry&&(Rt(n)||!!a);return e.shouldRetry?e.shouldRetry(e,t,a,r,i):i}function Rt(e){return 0===e&&!1===navigator.onLine||!!e&&(400>e||499<e)}function At(e,t,a){if(null===t||!Array.isArray(e)||!e.length||!yn(t))return null;var r=e[0].programDateTime;if(t<(r||0))return null;var n=e[e.length-1].endProgramDateTime;if(t>=(n||0))return null;a=a||0;for(var i=0,d;i<e.length;++i)if(d=e[i],Dt(t,a,d))return d;return null}function vt(e,t,a,r){void 0===a&&(a=0),void 0===r&&(r=0);var n=null;if(e){n=t[e.sn-t[0].sn+1]||null;var i=e.endDTS-a;0<i&&15e-7>i&&(a+=15e-7)}else 0===a&&0===t[0].start&&(n=t[0]);if(n&&(!e||e.level===n.level)&&0===It(a,r,n))return n;var d=_i.search(t,It.bind(null,a,r));return d&&(d!==e||!n)?d:n}function It(e,t,a){if(void 0===e&&(e=0),void 0===t&&(t=0),a.start<=e&&a.start+a.duration>e)return 0;var r=Math.min(t,a.duration+(a.deltaPTS?a.deltaPTS:0));return a.start+a.duration-r<=e?1:a.start-r>e&&a.start?-1:0}function Dt(e,t,a){var r=1e3*Math.min(t,a.duration+(a.deltaPTS?a.deltaPTS:0)),n=a.endProgramDateTime||0;return n-r>e}function kt(e,t){return _i.search(e,function(e){return e.cc<t?1:e.cc>t?-1:0})}function _t(e,t,a,r,n,i){var d=e.audioCodec?e.audioGroups:null,o=null==i?void 0:i.audioCodec,s=null==i?void 0:i.channels,l=s?parseInt(s):o?1/0:2,u=null;if(null!=d&&d.length)try{u=1===d.length&&d[0]?t.groups[d[0]].channels:d.reduce(function(e,a){if(a){var r=t.groups[a];if(!r)throw new Error("Audio track group "+a+" not found");Object.keys(r.channels).forEach(function(t){e[t]=(e[t]||0)+r.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(1920<e.width&&1088<e.height||1920<e.height&&1088<e.width||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==a||e.bitrate>Math.max(n,8e6))||!!u&&yn(l)&&Object.keys(u).some(function(e){return parseInt(e)>l})}function Ct(e,t,a){var n=e.videoCodec,i=e.audioCodec;if(!n||!i||!a)return Promise.resolve(Ni);var d={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(d.transferFunction=o.toLowerCase());var s=n.split(",").map(function(e){return{type:"media-source",video:r(r({},d),{},{contentType:De(e,"video")})}});return i&&e.audioGroups&&e.audioGroups.forEach(function(e){var a;e&&(null==(a=t.groups[e])?void 0:a.tracks.forEach(function(t){if(t.groupId===e){var a=t.channels||"",r=parseFloat(a);yn(r)&&2<r&&s.push.apply(s,i.split(",").map(function(e){return{type:"media-source",audio:{contentType:De(e,"audio"),channels:""+r}}}))}}))}),Promise.all(s.map(function(e){var t=bt(e);return wi[t]||(wi[t]=a.decodingInfo(e))})).then(function(e){return{supported:!e.some(function(e){return!e.supported}),configurations:s,decodingInfoResults:e}}).catch(function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}})}function bt(e){var t=e.audio,a=e.video,r=a||t;if(r){var n=r.contentType.split("\"")[1];if(a)return"r"+a.height+"x"+a.width+"f"+Math.ceil(a.framerate)+(a.transferFunction||"sd")+"_"+n+"_"+Math.ceil(a.bitrate/1e5);if(t)return"c"+t.channels+(t.spatialRendering?"s":"n")+"_"+n}return""}function xt(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}function Pt(e,t){var a=!1,r=[];return e&&(a="SDR"!==e,r=[e]),t&&(r=t.allowedVideoRanges||vi.slice(0),a=void 0===t.preferHDR?xt():t.preferHDR,r=a?r.filter(function(e){return"SDR"!==e}):["SDR"]),{preferHDR:a,allowedVideoRanges:r}}function Ft(e,t,a,r,n){for(var d=Object.keys(e),o=null==r?void 0:r.channels,s=null==r?void 0:r.audioCodec,l=o&&2===parseInt(o),u=!0,c=!1,f=1/0,g=1/0,m=1/0,p=0,y=[],h=Pt(t,n),T=h.preferHDR,E=h.allowedVideoRanges,S=function(){var t=e[d[L]];u=0<t.channels[2],f=Math.min(f,t.minHeight),g=Math.min(g,t.minFramerate),m=Math.min(m,t.minBitrate);var a=E.filter(function(e){return 0<t.videoRanges[e]});0<a.length&&(c=!0,y=a)},L=d.length;L--;)S();f=yn(f)?f:0,g=yn(g)?g:0;var R=Math.max(1080,f),A=Math.max(30,g);m=yn(m)?m:a,a=Math.max(m,a),c||(t=void 0,y=[]);var v=d.reduce(function(t,r){var n=e[r];if(r===t)return t;if(n.minBitrate>a)return Ot(r,"min bitrate of "+n.minBitrate+" > current estimate of "+a),t;if(!n.hasDefaultAudio)return Ot(r,"no renditions with default or auto-select sound found"),t;if(s&&0!=r.indexOf(s.substring(0,4))%5)return Ot(r,"audio codec preference \""+s+"\" not found"),t;if(o&&!l){if(!n.channels[o])return Ot(r,"no renditions with "+o+" channel sound found (channels options: "+Object.keys(n.channels)+")"),t;}else if((!s||l)&&u&&0===n.channels[2])return Ot(r,"no renditions with stereo sound found"),t;return n.minHeight>R?(Ot(r,"min resolution of "+n.minHeight+" > maximum of "+R),t):n.minFramerate>A?(Ot(r,"min framerate of "+n.minFramerate+" > maximum of "+A),t):y.some(function(e){return 0<n.videoRanges[e]})?n.maxScore<p?(Ot(r,"max score of "+n.maxScore+" < selected max of "+p),t):t&&(_e(r)>=_e(t)||n.fragmentError>e[t].fragmentError)?t:(p=n.maxScore,r):(Ot(r,"no variants with VIDEO-RANGE of "+JSON.stringify(y)+" found"),t)},void 0);return{codecSet:v,videoRanges:y,preferHDR:T,minFramerate:g,minBitrate:m}}function Ot(e,t){In.log("[abr] start candidates with \""+e+"\" ignored because "+t)}function Nt(e){return e.reduce(function(e,t){var a=e.groups[t.groupId];a||(a=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),a.tracks.push(t);var r=t.channels||"2";return a.channels[r]=(a.channels[r]||0)+1,a.hasDefault=a.hasDefault||t.default,a.hasAutoSelect=a.hasAutoSelect||t.autoselect,a.hasDefault&&(e.hasDefaultAudio=!0),a.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function wt(e,t,a,r){return e.slice(a,r+1).reduce(function(e,a){if(!a.codecSet)return e;var r=a.audioGroups,n=e[a.codecSet];n||(e[a.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,a.bitrate);var i=Math.min(a.height,a.width);return n.minHeight=Math.min(n.minHeight,i),n.minFramerate=Math.min(n.minFramerate,a.frameRate),n.maxScore=Math.max(n.maxScore,a.score),n.fragmentError+=a.fragmentError,n.videoRanges[a.videoRange]=(n.videoRanges[a.videoRange]||0)+1,r&&r.forEach(function(e){if(e){var a=t.groups[e];n.hasDefaultAudio=n.hasDefaultAudio||t.hasDefaultAudio?a.hasDefault:a.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(a.channels).forEach(function(e){n.channels[e]=(n.channels[e]||0)+a.channels[e]})}}),e},{})}function Mt(e,t,a){if("attrs"in e){var r=t.indexOf(e);if(-1!==r)return r}for(var n=0,d;n<t.length;n++)if(d=t[n],Bt(e,d,a))return n;return-1}function Bt(e,t,a){var r=e.groupId,n=e.name,i=e.lang,d=e.assocLang,o=e.characteristics,s=e.default,l=e.forced;return(void 0===r||t.groupId===r)&&(void 0===n||t.name===n)&&(void 0===i||t.lang===i)&&(void 0===i||t.assocLang===d)&&(void 0===s||t.default===s)&&(void 0===l||t.forced===l)&&(void 0===o||Ut(o,t.characteristics))&&(void 0===a||a(e,t))}function Ut(e,t){void 0===t&&(t="");var a=e.split(","),r=t.split(",");return a.length===r.length&&!a.some(function(e){return-1===r.indexOf(e)})}function Gt(e,t){var a=e.audioCodec,r=e.channels;return(void 0===a||(t.audioCodec||"").substring(0,4)===a.substring(0,4))&&(void 0===r||r===(t.channels||"2"))}function Kt(e,t,a,r,n){var i=t[r],d=t.reduce(function(e,t,a){var r=t.uri,n=e[r]||(e[r]=[]);return n.push(a),e},{}),o=d[i.uri];1<o.length&&(r=Math.max.apply(Math,o));var s=i.videoRange,l=i.frameRate,u=i.codecSet.substring(0,4),c=Ht(t,r,function(t){if(t.videoRange!==s||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var r=t.audioGroups,i=a.filter(function(e){return!r||-1!==r.indexOf(e.groupId)});return-1<Mt(e,i,n)});return-1<c?c:Ht(t,r,function(t){var r=t.audioGroups,i=a.filter(function(e){return!r||-1!==r.indexOf(e.groupId)});return-1<Mt(e,i,n)})}function Ht(e,t,a){for(var r=t;r;r--)if(a(e[r]))return r;for(var n=t+1;n<e.length;n++)if(a(e[n]))return n;return-1}function Vt(e){var t,a,r;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(a=e.range.audio)?void 0:a.partial)||(null==(r=e.range.audiovideo)?void 0:r.partial))}function Yt(e){return e.type+"_"+e.level+"_"+e.sn}function Wt(){return{start:0,executeStart:0,executeEnd:0,end:0}}function qt(e,t){for(var a=0,r=e.length;a<r;a++){var n;if((null==(n=e[a])?void 0:n.cc)===t)return e[a]}return null}function jt(e,t,a){return!!(t&&(a.endCC>a.startCC||e&&e.cc<a.startCC))}function Xt(e,t){var a=e.fragments,r=t.fragments;if(!r.length||!a.length)return void In.log("No fragments to align");var n=qt(a,r[0].cc);return n&&(!n||n.startPTS)?n:void In.log("No frag in previous level to align on")}function zt(e,t){if(e){var a=e.start+t;e.start=e.startPTS=a,e.endPTS=a+e.duration}}function Qt(e,t){for(var a=t.fragments,r=0,n=a.length;r<n;r++)zt(a[r],e);t.fragmentHint&&zt(t.fragmentHint,e),t.alignedSliding=!0}function Zt(e,t,a){t&&($t(e,a,t),!a.alignedSliding&&t&&Jt(a,t),!a.alignedSliding&&t&&!a.skippedSegments&&ut(t,a))}function $t(e,t,a){if(jt(e,a,t)){var r=Xt(a,t);r&&yn(r.start)&&(In.log("Adjusting PTS using last level due to CC increase within current level "+t.url),Qt(r.start,t))}}function Jt(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var a=e.fragments,r=t.fragments;if(a.length&&r.length){var n=Math.min(t.endCC,e.endCC),i,d;t.startCC<n&&e.startCC<n&&(i=qt(r,n),d=qt(a,n)),i&&d||(i=r[Math.floor(r.length/2)],d=qt(a,i.cc)||a[Math.floor(a.length/2)]);var o=i.programDateTime,s=d.programDateTime;if(o&&s){var l=(s-o)/1e3-(d.start-i.start);Qt(l,e)}}}}function ea(e,t){void 0===t&&(t=null);var a=t||e,r={frag:e,part:t,responseType:"arraybuffer",url:a.url,headers:{},rangeStart:0,rangeEnd:0},n=a.byteRangeStartOffset,i=a.byteRangeEndOffset;if(yn(n)&&yn(i)){var d=n,o=i,s;if("initSegment"===e.sn&&"AES-128"===(null==(s=e.decryptdata)?void 0:s.method)){var l=i-n;l%16&&(o=i+(16-l%16)),0!==n&&(r.resetIV=!0,d=n-16)}r.rangeStart=d,r.rangeEnd=o}return r}function ta(e,t){var a=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),r={type:Sn.MEDIA_ERROR,details:Ln.FRAG_GAP,fatal:!1,frag:e,error:a,networkDetails:null};return t&&(r.part=t),(t?t:e).stats.aborted=!0,new qi(r)}function aa(e){var t=e.byteLength,a=t&&new DataView(e.buffer).getUint8(t-1);return a?B(e,0,t-a):e}function ra(e,t){for(var a=new Uint8Array(t),r=0,n=0,d;n<e.length;n++)d=e[n],a.set(d,r),r+=d.length;return a}function na(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}function ia(e,t,a,r){var n=navigator.userAgent.toLowerCase(),i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],d,o,s,l;d=((192&t[a+2])>>>6)+1;var u=(60&t[a+2])>>>2;if(u>i.length-1){var c=new Error("invalid ADTS sampling index:"+u);return void e.emit(En.ERROR,En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}return s=(1&t[a+2])<<2,s|=(192&t[a+3])>>>6,In.log("manifest codec:"+r+", ADTS type:"+d+", samplingIndex:"+u),/firefox/i.test(n)?6<=u?(d=5,l=[,,,,],o=u-3):(d=2,l=[,,],o=u):-1===n.indexOf("android")?(d=5,l=[,,,,],r&&(-1!==r.indexOf("mp4a.40.29")||-1!==r.indexOf("mp4a.40.5"))||!r&&6<=u?o=u-3:((r&&-1!==r.indexOf("mp4a.40.2")&&(6<=u&&1===s||/vivaldi/i.test(n))||!r&&1===s)&&(d=2,l=[,,]),o=u)):(d=2,l=[,,],o=u),l[0]=d<<3,l[0]|=(14&u)>>1,l[1]|=(1&u)<<7,l[1]|=s<<3,5===d&&(l[1]|=(14&o)>>1,l[2]=(1&o)<<7,l[2]|=8,l[3]=0),{config:l,samplerate:i[u],channelCount:s,codec:"mp4a.40."+d,manifestCodec:r}}function da(e,t){return 255===e[t]&&240==(246&e[t+1])}function oa(e,t){return 1&e[t+1]?7:9}function sa(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function la(e,t){return t+5<e.length}function ua(e,t){return t+1<e.length&&da(e,t)}function ca(e,t){return la(e,t)&&da(e,t)&&sa(e,t)<=e.length-t}function fa(e,t){if(ua(e,t)){var a=oa(e,t);if(t+a>=e.length)return!1;var r=sa(e,t);if(r<=a)return!1;var n=t+r;return n===e.length||ua(e,n)}return!1}function ga(e,t,a,r,n){if(!e.samplerate){var i=ia(t,a,r,n);if(!i)return;e.config=i.config,e.samplerate=i.samplerate,e.channelCount=i.channelCount,e.codec=i.codec,e.manifestCodec=i.manifestCodec,In.log("parsed codec:"+e.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function ma(e){return 92160000/e}function pa(e,t){var a=oa(e,t);if(t+a<=e.length){var r=sa(e,t)-a;if(0<r)return{headerLength:a,frameLength:r}}}function ya(e,t,a,r,n){var i=ma(e.samplerate),d=r+n*i,o=pa(t,a),s;if(o){var l=o.frameLength,u=o.headerLength,c=u+l,f=Math.max(0,a+c-t.length);f?(s=new Uint8Array(c-u),s.set(t.subarray(a+u,t.length),0)):s=t.subarray(a+u,a+c);var g={unit:s,pts:d};return f||e.samples.push(g),{sample:g,length:c,missing:f}}var m=t.length-a;s=new Uint8Array(m),s.set(t.subarray(a,t.length),0);var p={unit:s,pts:d};return{sample:p,length:m,missing:-1}}function ha(e,t,a,r,n){if(!(a+24>t.length)){var i=Ta(t,a);if(i&&a+i.frameLength<=t.length){var d=9e4*i.samplesPerFrame/i.sampleRate,o=r+n*d,s={unit:t.subarray(a,a+i.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=i.channelCount,e.samplerate=i.sampleRate,e.samples.push(s),{sample:s,length:i.frameLength,missing:0}}}}function Ta(e,t){var a=3&e[t+1]>>3,r=3&e[t+1]>>1,n=15&e[t+2]>>4,i=3&e[t+2]>>2;if(1!=a&&0!==n&&15!==n&&3!==i){var d=1&e[t+2]>>1,o=e[t+3]>>6,s=3===a?3-r:3===r?3:4,l=1e3*nd[14*s+n-1],u=3===a?0:2===a?1:2,c=id[3*u+i],f=3===o?1:2,g=dd[a][r],m=od[r],p=Math.floor(g*l/c+d)*m;if(null===rd){var y=navigator.userAgent||"",h=y.match(/Chrome\/(\d+)/i);rd=h?parseInt(h[1]):0}var T=!!rd&&87>=rd;return T&&2===r&&224e3<=l&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:f,frameLength:p,samplesPerFrame:8*g*m}}}function Ea(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Sa(e,t){return t+1<e.length&&Ea(e,t)}function La(e,t){return Ea(e,t)&&4<=e.length-t}function Ra(e,t){if(t+1<e.length&&Ea(e,t)){var a=Ta(e,t),r=4;null!=a&&a.frameLength&&(r=a.frameLength);var n=t+r;return n===e.length||Sa(e,n)}return!1}function Aa(e,t,a,r,n){if(a+8>t.length)return-1;if(11!==t[a]||119!==t[a+1])return-1;var i=t[a+4]>>6;if(3<=i)return-1;var d=[48e3,44100,32e3][i],o=63&t[a+4],s=2*[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][3*o+i];if(a+s>t.length)return-1;var l=t[a+6]>>5,u=0;2==l?u+=2:(1&l&&1!==l&&(u+=2),4&l&&(u+=2));var c=1&(t[a+6]<<8|t[a+7])>>12-u,f=[2,1,2,3,3,4,4,5][l]+c,g=t[a+5]>>3,m=7&t[a+5],p=new Uint8Array([i<<6|g<<1|m>>2,(3&m)<<6|l<<3|c<<2|o>>4,224&o<<4]),y=t.subarray(a,a+s);return e.config=p,e.channelCount=f,e.samplerate=d,e.samples.push({unit:y,pts:r+n*(9e4*(1536/d))}),s}function va(e,t){return((31&e[t+1])<<8)+e[t+2]}function Ia(e,t){return(31&e[t+10])<<8|e[t+11]}function Da(e,t,a,r){var n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},i=(15&e[t+1])<<8|e[t+2],d=t+3+i-4,o=(15&e[t+10])<<8|e[t+11];for(t+=12+o;t<d;){var s=va(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!r){ka("ADTS AAC");break}case 15:-1===n.audioPid&&(n.audioPid=s);break;case 21:-1===n.id3Pid&&(n.id3Pid=s);break;case 219:if(!r){ka("H.264");break}case 27:-1===n.videoPid&&(n.videoPid=s,n.segmentVideoCodec="avc");break;case 3:case 4:a.mpeg||a.mp3?-1===n.audioPid&&(n.audioPid=s,n.segmentAudioCodec="mp3"):In.log("MPEG audio found, not supported in this browser");break;case 193:if(!r){ka("AC-3");break}case 129:a.ac3?-1===n.audioPid&&(n.audioPid=s,n.segmentAudioCodec="ac3"):In.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===n.audioPid&&0<l)for(var u=t+5,c=l,f;2<c;){f=e[u],106===f?!0===a.ac3?(n.audioPid=s,n.segmentAudioCodec="ac3"):In.log("AC-3 audio found, not supported in this browser for now"):void 0;var g=e[u+1]+2;u+=g,c-=g}break;case 194:case 135:In.warn("Unsupported EC-3 in M2TS found");break;case 36:In.warn("Unsupported HEVC in M2TS found");}t+=l+5}return n}function ka(e){In.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function _a(e){var t=0,a=e.data,r,n,d,o,s;if(!e||0===e.size)return null;for(;19>a[0].length&&1<a.length;)a[0]=de(a[0],a[1]),a.splice(1,1);r=a[0];var l=(r[0]<<16)+(r[1]<<8)+r[2];if(1===l){if(n=(r[4]<<8)+r[5],n&&n>e.size-6)return null;var u=r[7];192&u&&(o=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,5400000<o-s&&(In.warn(Math.round((o-s)/9e4)+"s delta between PTS and DTS, align them"),o=s)):s=o),d=r[8];var c=d+9;if(e.size<=c)return null;e.size-=c;for(var f=new Uint8Array(e.size),g=0,m=a.length;g<m;g++){r=a[g];var p=r.byteLength;if(c)if(c>p){c-=p;continue}else r=r.subarray(c),p-=c,c=0;f.set(r,t),t+=p}return n&&(n-=d+3),{data:f,pts:o,dts:s,len:n}}return null}function Ca(e,t,a,r){void 0===a&&(a=1),void 0===r&&(r=!1);var n=e*t*a;return r?Math.round(n):n}function ba(e,t,a,r){return void 0===a&&(a=1),void 0===r&&(r=!1),Ca(e,t,1/a,r)}function xa(e,t){return void 0===t&&(t=!1),Ca(e,1e3,1/90000,t)}function Pa(e,t){return void 0===t&&(t=1),Ca(e,90000,1/t)}function Fa(e,t){var a;if(null===t)return e;for(a=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=a;return e}function Oa(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}function Na(e,t,a,r){var n=e.samples.length;if(n){for(var i=e.inputTimeScale,d=0,o;d<n;d++)o=e.samples[d],o.pts=Fa(o.pts-a.baseTime*i/a.timescale,t*i)/i,o.dts=Fa(o.dts-r.baseTime*i/r.timescale,t*i)/i;var s=e.samples;return e.samples=[],{samples:s}}}function wa(e,t,a){var r=e.samples.length;if(r){for(var n=e.inputTimeScale,i=0,d;i<r;i++)d=e.samples[i],d.pts=Fa(d.pts-a.baseTime*n/a.timescale,t*n)/n;e.samples.sort(function(e,t){return e.pts-t.pts});var o=e.samples;return e.samples=[],{samples:o}}}function Ma(e,t,a,r){if(null===e)return!0;var n=Math.max(r,1),i=t-e.baseTime/e.timescale;return Math.abs(i-a)>n}function Ba(e,t){var a=null==e?void 0:e.codec;if(a&&4<a.length)return a;if(t===bn.AUDIO){if("ec-3"===a||"ac-3"===a||"alac"===a)return a;if("fLaC"===a||"Opus"===a){return be(a,!1)}return In.info("Parsed audio codec \""+a+"\" or audio object type not handled. Using \"mp4a.40.5\""),"mp4a.40.5"}return In.warn("Unhandled video codec \""+a+"\""),"hvc1"===a||"hev1"===a?"hvc1.1.6.L120.90":"av01"===a?"av01.0.04M.08":"avc1.42e01e"}function Ua(e,t){var a=null;return 0<e.byteLength&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(a=t),a}function Ga(e){return"then"in e&&e.then instanceof Function}function Ka(e,t){if(Ya(t.remuxResult))return!1;var a=[],r=t.remuxResult,n=r.audio,i=r.video;return n&&Ha(a,n),i&&Ha(a,i),e.postMessage({event:"transmuxComplete",data:t},a),!0}function Ha(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function Va(e,t,a){var r=t.reduce(function(t,a){return Ka(e,a)||t},!1);r||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:a})}function Ya(e){return!e.audio&&!e.video&&!e.text&&!e.id3&&!e.initSegment}function Wa(){return"function"==typeof e}function qa(){var t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+e.toString()+")(true);"],{type:"text/javascript"}),a=self.URL.createObjectURL(t),r=new self.Worker(a);return{worker:r,objectURL:a}}function ja(e){var t=new self.URL(e,self.location.href).href,a=new self.Worker(t);return{worker:a,scriptURL:t}}function Xa(e,t){if(e.length!==t.length)return!1;for(var a=0;a<e.length;a++)if(!za(e[a].attrs,t[a].attrs))return!1;return!0}function za(e,t,a){var r=e["STABLE-RENDITION-ID"];return r&&!a?r===t["STABLE-RENDITION-ID"]:!(a||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(function(a){return e[a]!==t[a]})}function Qa(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}function Za(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(function(t){e.removeChild(t)})}function $a(e,t){var a=self.document.createElement("source");a.type="video/mp4",a.src=t,e.appendChild(a)}function Ja(e,t,a){a.a=e,a.b=t}function er(e,t,a){return a.a===e&&a.b===t}function tr(){return{a:null,b:null}}function ar(e){function t(e,t,a,r){return 3600*(0|e)+60*(0|t)+(0|a)+parseFloat(r||0)}var a=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return a?59<parseFloat(a[2])?t(a[2],a[3],0,a[4]):t(a[1],a[2],a[3],a[4]):null}function rr(e,t,a,r){var n=r?e.split(r):[e];for(var d in n)if("string"==typeof n[d]){var i=n[d].split(a);if(2===i.length){var o=i[0],s=i[1];t(o,s)}}}function nr(e,t,a){function r(){var t=ar(e);if(null===t)throw new Error("Malformed timestamp: "+d);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(e,t){var r=new yo;rr(e,function(e,t){var n;switch(e){case"region":for(var d=a.length-1;0<=d;d--)if(a[d].id===t){r.set(e,a[d].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),r.integer(e,n[0]),r.percent(e,n[0])&&r.set("snapToLines",!1),r.alt(e,n[0],["auto"]),2===n.length&&r.alt("lineAlign",n[1],["start",To,"end"]);break;case"position":n=t.split(","),r.percent(e,n[0]),2===n.length&&r.alt("positionAlign",n[1],["start",To,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",To,"end","left","right"]);}},/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical","");var n=r.get("line","auto");"auto"===n&&-1===ho.line&&(n=-1),t.line=n,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",To);var i=r.get("position","auto");"auto"===i&&50===ho.position&&(i="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=i}function i(){e=e.replace(/^\s+/,"")}var d=e;if(i(),t.startTime=r(),i(),"-->"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);e=e.slice(3),i(),t.endTime=r(),i(),n(e,t)}function ir(e){return e.replace(/<br(?: \/)?>/gi,"\n")}function dr(e,t,a){return Ao(e.toString())+Ao(t.toString())+Ao(a)}function or(e,t,a,r,n,i,d){var o=new Eo,s=ei(new Uint8Array(e)).trim().replace(So,"\n").split("\n"),l=[],u=t?Pa(t.baseTime,t.timescale):0,c="00:00.000",f=0,g=0,m=!0,p;o.oncue=function(e){var i=a[r],d=a.ccOffset,o=(f-u)/9e4;if(null!=i&&i.new&&(void 0===g?vo(a,r,o):d=a.ccOffset=i.start),o){if(!t)return void(p=new Error("Missing initPTS for VTT MPEGTS"));d=o-a.presentationOffset}var s=e.endTime-e.startTime,c=Fa(9e4*(e.startTime+d-g),9e4*n)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+s,0);var m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=dr(e.startTime,e.endTime,m)),0<e.endTime&&l.push(e)},o.onparsingerror=function(e){p=e},o.onflush=function(){return p?void d(p):void i(l)},s.forEach(function(e){if(m){if(Lo(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(function(e){Lo(e,"LOCAL:")?c=e.slice(6):Lo(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{g=Ro(c)/1e3}catch(e){p=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}function sr(e,t,a,r){var n=q(new Uint8Array(e),["mdat"]);if(0===n.length)return void r(new Error("Could not parse IMSC1 mdat"));var i=n.map(function(e){return ei(e)}),d=ba(t.baseTime,1,t.timescale);try{i.forEach(function(e){return a(lr(e,d))})}catch(e){r(e)}}function lr(e,t){var a=new DOMParser,r=a.parseFromString(e,"text/xml"),n=r.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},d=Object.keys(i).reduce(function(e,t){return e[t]=n.getAttribute("ttp:"+t)||i[t],e},{}),o="preserve"!==n.getAttribute("xml:space"),s=cr(ur(n,"styling","style")),l=cr(ur(n,"layout","region")),c=ur(n,"body","[begin]");return[].map.call(c,function(e){var a=fr(e,o);if(!a||!e.hasAttribute("begin"))return null;var r=yr(e.getAttribute("begin"),d),n=yr(e.getAttribute("dur"),d),i=yr(e.getAttribute("end"),d);if(null===r)throw pr(e);if(null===i){if(null===n)throw pr(e);i=r+n}var c=new mo(r-t,i-t,a);c.id=dr(c.startTime,c.endTime,c.text);var f=l[e.getAttribute("region")],g=s[e.getAttribute("style")],m=gr(f,g,s),p=m.textAlign;if(p){var y=_o[p];y&&(c.lineAlign=y),c.align=p}return u(c,m),c}).filter(function(e){return null!==e})}function ur(e,t,a){var r=e.getElementsByTagName(t)[0];return r?[].slice.call(r.querySelectorAll(a)):[]}function cr(e){return e.reduce(function(e,t){var a=t.getAttribute("xml:id");return a&&(e[a]=t),e},{})}function fr(e,t){return[].slice.call(e.childNodes).reduce(function(e,a,r){var n;return"br"===a.nodeName&&r?e+"\n":null!=(n=a.childNodes)&&n.length?fr(a,t):t?e+a.textContent.trim().replace(/\s+/g," "):e+a.textContent},"")}function gr(e,t,a){var r=null,n=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return n&&a.hasOwnProperty(n)&&(r=a[n]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(a,n){var i=mr(t,"http://www.w3.org/ns/ttml#styling",n)||mr(e,"http://www.w3.org/ns/ttml#styling",n)||mr(r,"http://www.w3.org/ns/ttml#styling",n);return i&&(a[n]=i),a},{})}function mr(e,t,a){return e?e.hasAttributeNS(t,a)?e.getAttributeNS(t,a):null:null}function pr(e){return new Error("Could not parse ttml timestamp "+e)}function yr(e,t){if(!e)return null;var a=ar(e);return null===a&&(Do.test(e)?a=hr(e,t):ko.test(e)&&(a=Tr(e,t))),a}function hr(e,t){var a=Do.exec(e),r=(0|a[4])+(0|a[5])/t.subFrameRate;return 3600*(0|a[1])+60*(0|a[2])+(0|a[3])+r/t.frameRate}function Tr(e,t){var a=ko.exec(e),r=+a[1],n=a[2];return"h"===n?3600*r:"m"===n?60*r:"ms"===n?1e3*r:"f"===n?r/t.frameRate:"t"===n?r/t.tickRate:r}function Er(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function Sr(e,t){return!!e&&e.kind===Er(t)&&Qa(t,e)}function Lr(e,t,a,r){return Math.min(t,r)-Math.max(e,a)}function Rr(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}function Ar(e){return Array.isArray(e)?JSON.stringify(e):e instanceof Map?"Map{}":e instanceof Set?"Set{}":"object"==typeof e?JSON.stringify(e):e+""}function vr(e,t,a,r){return new Error("failed to "+e+" \""+Ar(t)+"\" as "+a,{cause:r})}function Ir(e){return-999999999999999>e||999999999999999<e}function Dr(e,t,a){return vr("serialize",e,t,a)}function kr(e){if("boolean"!=typeof e)throw Dr(e,"Boolean");return e?"?1":"?0"}function _r(e){return btoa(String.fromCharCode.apply(String,e))}function Cr(e){if(!1===ArrayBuffer.isView(e))throw Dr(e,"Byte Sequence");return":"+_r(e)+":"}function br(e){if(Ir(e))throw Dr(e,"Integer");return e.toString()}function xr(e){return"@"+br(e.getTime()/1e3)}function Pr(e,t){if(0>e)return-Pr(-e,t);var a=Math.pow(10,t),r=Math.abs(e*a%1-.5)<Number.EPSILON;if(r){var n=Math.floor(e*a);return(0==n%2?n:n+1)/a}return Math.round(e*a)/a}function Fr(e){var t=Pr(e,3);if(12<Math.floor(Math.abs(t)).toString().length)throw Dr(e,"Decimal");var a=t.toString();return a.includes(".")?a:a+".0"}function Or(e){if(Ko.test(e))throw Dr(e,"String");return"\""+e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")+"\""}function Nr(e){return e.description||e.toString().slice(7,-1)}function wr(e){var t=Nr(e);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw Dr(t,"Token");return t}function Mr(e){switch(typeof e){case"number":if(!yn(e))throw Dr(e,"Bare Item");return Number.isInteger(e)?br(e):Fr(e);case"string":return Or(e);case"symbol":return wr(e);case"boolean":return kr(e);case"object":if(e instanceof Date)return xr(e);if(e instanceof Uint8Array)return Cr(e);if(e instanceof Go)return wr(e);default:throw Dr(e,"Bare Item");}}function Br(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw Dr(e,"Key");return e}function Ur(e){return null==e?"":Object.entries(e).map(function(e){var t=e[0],a=e[1];return!0===a?";"+Br(t):";"+Br(t)+"="+Mr(a)}).join("")}function Gr(e){return e instanceof Uo?""+Mr(e.value)+Ur(e.params):Mr(e)}function Kr(e){return"("+e.value.map(Gr).join(" ")+")"+Ur(e.params)}function Hr(e,t){var a;if(void 0===t&&(t={whitespace:!0}),"object"!=typeof e)throw Dr(e,"Dict");var r=e instanceof Map?e.entries():Object.entries(e),n=null!=(a=t)&&a.whitespace?" ":"";return Array.from(r).map(function(e){var t=e[0],a=e[1];!1==a instanceof Uo&&(a=new Uo(a));var r=Br(t);return!0===a.value?r+=Ur(a.params):(r+="=",r+=Array.isArray(a.value)?Kr(a):Gr(a)),r}).join(","+n)}function Vr(e,t){return Hr(e,t)}function Yr(e,t){var a=new URL(e),r=new URL(t);if(a.origin!==r.origin)return e;for(var n=a.pathname.split("/").slice(1),i=r.pathname.split("/").slice(1,-1);n[0]===i[0];)n.shift(),i.shift();for(;i.length;)i.shift(),n.unshift("..");return n.join("/")}function Wr(){try{return crypto.randomUUID()}catch(n){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var a=new Date().getTime(),r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=0|(a+16*Math.random())%16;return a=Math.floor(a/16),("x"==e?t:8|3&t).toString(16)});return r}}}function qr(e,t){var a={};if(null==e||"object"!=typeof e)return a;var r=Object.keys(e).sort(),n=u({},qo,null==t?void 0:t.formatters),i=null==t?void 0:t.filter;return r.forEach(function(r){if(!(null!=i&&i(r))){var d=e[r],o=n[r];o&&(d=o(d,t)),("v"!==r||1!==d)&&("pr"!=r||1!==d)&&Vo(d)&&(Ho(r)&&"string"==typeof d&&(d=new Go(d)),a[r]=d)}}),a}function jr(e,t){return void 0===t&&(t={}),e?Vr(qr(e,t),u({whitespace:!1},t)):""}function Xr(e,t){var a;if(void 0===t&&(t={}),!e)return{};var r=Object.entries(e),n=Object.entries(Bo).concat(Object.entries((null==(a=t)?void 0:a.customHeaderMap)||{})),i=r.reduce(function(e,t){var a=t[0],r=t[1],i=(null==(d=n.find(function(e){return e[1].includes(a)}))?void 0:d[0])||Mo.REQUEST,d,o;return null==(o=e[i])?e[i]={}:o,e[i][a]=r,e},{});return Object.entries(i).reduce(function(e,a){var r=a[0],n=a[1];return e[r]=jr(n,t),e},{})}function zr(e,t,a){return u(e,Xr(t,a))}function Qr(e,t){if(void 0===t&&(t={}),!e)return"";var a=jr(e,t);return"CMCD="+encodeURIComponent(a)}function Zr(e,t,a){var r=Qr(t,a);if(!r)return e;if(jo.test(e))return e.replace(jo,r);var n=e.includes("?")?"&":"?";return""+e+n+r}function $r(e,t,a,r){e&&Object.keys(t).forEach(function(n){var i=e.filter(function(e){return e.groupId===n}).map(function(e){var i=u({},e);return i.details=void 0,i.attrs=new kn(i.attrs),i.url=i.attrs.URI=Jr(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",a),i.groupId=i.attrs["GROUP-ID"]=t[n],i.attrs["PATHWAY-ID"]=r,i});e.push.apply(e,i)})}function Jr(e,t,a,r){var n=r.HOST,i=r.PARAMS,d=r[a],o;t&&(o=null==d?void 0:d[t],o&&(e=o));var s=new self.URL(e);return n&&!o&&(s.host=n),i&&Object.keys(i).sort().forEach(function(e){e&&s.searchParams.set(e,i[e])}),s.href}function en(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}function tn(e,t){var a={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(u({},e.headers))};return e.rangeEnd&&a.headers.set("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1+"")),a}function an(e){var t=Zo.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}function rn(e){var t=e.get("Content-Range");if(t){var a=an(t);if(yn(a))return a}var r=e.get("Content-Length");if(r)return parseInt(r)}function nn(e,t){return new self.Request(e.url,t)}function dn(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error("Illegal hls.js config: \"liveMaxLatencyDurationCount\" must be greater than \"liveSyncDurationCount\"");if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error("Illegal hls.js config: \"liveMaxLatencyDuration\" must be greater than \"liveSyncDuration\"");var a=on(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(e){var r=("level"===e?"playlist":e)+"LoadPolicy",i=void 0===t[r],d=[];n.forEach(function(n){var o=e+"Loading"+n,s=t[o];if(void 0!==s&&i){d.push(o);var l=a[r].default;t[r]={default:l},"TimeOut"===n?(l.maxLoadTimeMs=s,l.maxTimeToFirstByteMs=s):"MaxRetry"===n?(l.errorRetry.maxNumRetry=s,l.timeoutRetry.maxNumRetry=s):"RetryDelay"===n?(l.errorRetry.retryDelayMs=s,l.timeoutRetry.retryDelayMs=s):"MaxRetryTimeout"===n?(l.errorRetry.maxRetryDelayMs=s,l.timeoutRetry.maxRetryDelayMs=s):void 0}}),d.length&&In.warn("hls.js config: \""+d.join("\", \"")+"\" setting(s) are deprecated, use \""+r+"\": "+JSON.stringify(t[r]))}),r(r({},a),t)}function on(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(on):Object.keys(e).reduce(function(t,a){return t[a]=on(e[a]),t},{}):e}function sn(e){var t=e.loader;if(t!==$o&&t!==Qo)In.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{var a=en();a&&(e.loader=$o,e.progressive=!0,e.enableSoftwareAES=!0,In.log("[config]: Progressive streaming enabled, using FetchLoader"))}}function ln(e){var t={};e.forEach(function(e){var a=e.groupId||"";e.id=t[a]=t[a]||0,t[a]++})}function un(){return self.SourceBuffer||self.WebKitSourceBuffer}function cn(){var e=Re();if(!e)return!1;var t=un();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}function fn(){if(!cn())return!1;var e=Re();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(function(t){return e.isTypeSupported(De(t,"video"))})||["mp4a.40.2","fLaC"].some(function(t){return e.isTypeSupported(De(t,"audio"))}))}function gn(){var e=un(),t;return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}var mn={exports:{}};(function(e){(function(){var t={buildAbsoluteURL:function(e,a,r){if(r=r||{},e=e.trim(),a=a.trim(),!a){if(!r.alwaysNormalize)return e;var n=t.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=t.normalizePath(n.path),t.buildURLFromParts(n)}var i=t.parseURL(a);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=t.normalizePath(i.path),t.buildURLFromParts(i)):a;var d=t.parseURL(e);if(!d)throw new Error("Error trying to parse base URL.");if(!d.netLoc&&d.path&&"/"!==d.path[0]){var o=/^(?=([^\/?#]*))\1([^]*)$/.exec(d.path);d.netLoc=o[1],d.path=o[2]}d.netLoc&&!d.path&&(d.path="/");var s={scheme:d.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(s.netLoc=d.netLoc,"/"!==i.path[0]))if(!i.path)s.path=d.path,i.params||(s.params=d.params,!i.query&&(s.query=d.query));else{var l=d.path,u=l.substring(0,l.lastIndexOf("/")+1)+i.path;s.path=t.normalizePath(u)}return null===s.path&&(s.path=r.alwaysNormalize?t.normalizePath(i.path):i.path),t.buildURLFromParts(s)},parseURL:function(e){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(/(?:\/|^)\.(?=\/)/g,"");e.length!==(e=e.replace(/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=t})()})(mn);var pn=mn.exports,yn=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},hn=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Tn},Tn=Number.MAX_SAFE_INTEGER||9007199254740991,En=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),Sn=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),Ln=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),Rn=function(){},An={trace:Rn,debug:Rn,log:Rn,warn:Rn,info:Rn,error:Rn},vn=An,In=vn,Dn=/(.+?)=(".*?"|.*?)(?:,|$)/g,kn=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),u(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var a=new Uint8Array(t.length/2),r=0;r<t.length/2;r++)a[r]=parseInt(t.slice(2*r,2*r+2),16);return a}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var a=this[e];return a?parseFloat(a):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=/^(\d+)x(\d+)$/.exec(this[e]);return null===t?void 0:{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t={},a="\"",r;for(Dn.lastIndex=0;null!==(r=Dn.exec(e));){var n=r[2];0===n.indexOf(a)&&n.lastIndexOf(a)===n.length-1&&(n=n.slice(1,-1));var i=r[1].trim();t[i]=n}return t},s(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter(function(e){return"X-"===e.substring(0,2)})}}]),e}(),_n=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var a=t.attr;for(var r in a)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==a[r]){In.warn("DATERANGE tag attribute: \""+r+"\" does not match for tags with ID: \""+e.ID+"\""),this._badValueForSameId=r;break}e=u(new kn({}),a,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);yn(n.getTime())&&(this._endDate=n)}}return s(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null===e?null:new Date(this._startDate.getTime()+1e3*e)}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(yn(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&yn(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}]),e}(),Cn=function(){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}},bn={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},xn=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(t={},t[bn.AUDIO]=null,t[bn.VIDEO]=null,t[bn.AUDIOVIDEO]=null,t),this.baseurl=e}var t=e.prototype;return t.setByteRange=function(e,t){var a=e.split("@",2),r;r=1===a.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(a[1]),this._byteRange=[r,parseInt(a[0])+r]},s(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=pn.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),Pn=function(e){function t(t,a){var r;return r=e.call(this,a)||this,r._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new Cn,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.urlId=0,r.type=t,r}c(t,e);var a=t.prototype;return a.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},a.abortRequests=function(){var e,t;null==(e=this.loader)?void 0:e.abort(),null==(t=this.keyLoader)?void 0:t.abort()},a.setElementaryStreamInfo=function(e,t,a,r,n,i){void 0===i&&(i=!1);var d=this.elementaryStreams,o=d[e];return o?void(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,a),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,n)):void(d[e]={startPTS:t,endPTS:a,startDTS:r,endDTS:n,partial:i})},a.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[bn.AUDIO]=null,e[bn.VIDEO]=null,e[bn.AUDIOVIDEO]=null},s(t,[{key:"decryptdata",get:function(){var e=this.levelkeys;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var a=Object.keys(this.levelkeys);if(1===a.length)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!yn(this.programDateTime))return null;var e=yn(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),a=t.length;if(1<a||1===a&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(xn),Fn=function(e){function t(t,a,r,n,i){var d;d=e.call(this,r)||this,d.fragOffset=0,d.duration=0,d.gap=!1,d.independent=!1,d.relurl=void 0,d.fragment=void 0,d.index=void 0,d.stats=new Cn,d.duration=t.decimalFloatingPoint("DURATION"),d.gap=t.bool("GAP"),d.independent=t.bool("INDEPENDENT"),d.relurl=t.enumeratedString("URI"),d.fragment=a,d.index=n;var o=t.enumeratedString("BYTERANGE");return o&&d.setByteRange(o,i),i&&(d.fragOffset=i.fragOffset+i.duration),d}return c(t,e),s(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(xn),On=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}var t=e.prototype;return t.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,a=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!a||!!t||!this.live,this.advanced=this.endSN>e.endSN||0<t||0===t&&0<a,this.misses=this.updated||this.advanced?Math.floor(.6*e.misses):e.misses+1,this.availabilityDelay=e.availabilityDelay},s(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&yn(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;if(0<e){var t=this.driftEnd-this.driftStart;return 1e3*t/e}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}(),Nn="undefined"==typeof self?void 0:self,wn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Mn={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"},Bn={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"},Un=function(e){return null!=Nn&&null!=(e=Nn.navigator)&&e.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}(),Gn=function(e,t){return!!(t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&255>e[t+3]&&255>e[t+4]&&128>e[t+6]&&128>e[t+7]&&128>e[t+8]&&128>e[t+9])},Kn=function(e,t){return!!(t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&255>e[t+3]&&255>e[t+4]&&128>e[t+6]&&128>e[t+7]&&128>e[t+8]&&128>e[t+9])},Hn=function(e,t){for(var a=t,r=0;Gn(e,t);){r+=10;var n=Vn(e,t+6);r+=n,Kn(e,t+10)&&(r+=10),t+=r}return 0<r?e.subarray(a,a+r):void 0},Vn=function(e,t){var a=0;return a=(127&e[t])<<21,a|=(127&e[t+1])<<14,a|=(127&e[t+2])<<7,a|=127&e[t+3],a},Yn=function(e,t){return Gn(e,t)&&Vn(e,t+6)+10<=e.length-t},Wn=function(e){for(var t=Xn(e),a=0,r;a<t.length;a++)if(r=t[a],qn(r))return Jn(r)},qn=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},jn=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),a=Vn(e,4),r=10;return{type:t,size:a,data:e.subarray(r,r+a)}},Xn=function(e){for(var t=0,a=[],r;Gn(e,t);){r=Vn(e,t+6),t+=10;for(var n=t+r;t+8<n;){var i=jn(e.subarray(t)),d=zn(i);d&&a.push(d),t+=i.size+10}Kn(e,t)&&(t+=10)}return a},zn=function(e){return"PRIV"===e.type?Qn(e):"W"===e.type[0]?$n(e):Zn(e)},Qn=function(e){if(!(2>e.size)){var t=ei(e.data,!0),a=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:a.buffer}}},Zn=function(e){if(!(2>e.size)){if("TXXX"===e.type){var t=1,a=ei(e.data.subarray(t),!0);t+=a.length+1;var r=ei(e.data.subarray(t));return{key:e.type,info:a,data:r}}var n=ei(e.data.subarray(1));return{key:e.type,data:n}}},$n=function(e){if("WXXX"===e.type){if(2>e.size)return;var t=1,a=ei(e.data.subarray(t),!0);t+=a.length+1;var r=ei(e.data.subarray(t));return{key:e.type,info:a,data:r}}var n=ei(e.data);return{key:e.type,data:n}},Jn=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),a=1&t[3],r=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return r/=45,a&&(r+=47721858.84),Math.round(r)}},ei=function(e,t){void 0===t&&(t=!1);var a=U();if(a){var r=a.decode(e);if(t){var n=r.indexOf("\0");return-1===n?r:r.substring(0,n)}return r.replace(/\0/g,"")}for(var d=e.length,o="",s=0,l,u,f;s<d;){if(l=e[s++],0===l&&t)return o;if(0!==l&&3!==l)switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(l);break;case 12:case 13:u=e[s++],o+=String.fromCharCode((31&l)<<6|63&u);break;case 14:u=e[s++],f=e[s++],o+=String.fromCharCode((15&l)<<12|(63&u)<<6|(63&f)<<0);}}return o},ti={hexDump:function(e){for(var t="",a=0,r;a<e.length;a++)r=e[a].toString(16),2>r.length&&(r="0"+r),t+=r;return t}},ai=Math.pow(2,32)-1,ri=[].push,ni={video:1,audio:2,id3:3,text:4},ii={},di=function(){function e(e,t,a,r,n){void 0===r&&(r=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=a,this.keyFormatVersions=r,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){ii={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Mn.FAIRPLAY:case Mn.WIDEVINE:case Mn.PLAYREADY:case Mn.CLEARKEY:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method);}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"===this.method&&!this.iv&&In.warn("missing IV for initialization segment with method=\""+this.method+"\" - compliance issue"),t=0);var a=ye(t),r=new e(this.method,this.uri,"identity",this.keyFormatVersions,a);return r}var n=b(this.uri);if(n)switch(this.keyFormat){case Mn.WIDEVINE:this.pssh=n,22<=n.length&&(this.keyId=n.subarray(n.length-22,n.length-6));break;case Mn.PLAYREADY:{var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=me(i,null,n);var d=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2),o=String.fromCharCode.apply(null,Array.from(d)),s=o.substring(o.indexOf("<"),o.length),l=new DOMParser,u=l.parseFromString(s,"text/xml"),c=u.getElementsByTagName("KID")[0];if(c){var f=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(f){var g=k(f).subarray(0,16);C(g),this.keyId=g}}break}default:{var m=n.subarray(0,16);if(16!==m.length){var p=new Uint8Array(16);p.set(m,16-m.length),m=p}this.keyId=m;break}}if(!this.keyId||16!==this.keyId.byteLength){var y=ii[this.uri];if(!y){var h=Object.keys(ii).length%Number.MAX_SAFE_INTEGER;y=new Uint8Array(16);var T=new DataView(y.buffer,12,4);T.setUint32(0,h),ii[this.uri]=y}this.keyId=y}return this},e}(),oi=/\{\$([a-zA-Z0-9-_]+)\}/g,si={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}},li={},ui=/flac|opus/i,ci=/#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,fi=/#EXT-X-MEDIA:(.*)/g,gi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),mi=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),pi=function(){function e(){}return e.findGroup=function(e,t){for(var a=0,r;a<e.length;a++)if(r=e[a],r.id===t)return r},e.resolve=function(e,t){return pn.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return /^#EXT(?:INF|-X-TARGETDURATION):/m.test(e)},e.parseMasterPlaylist=function(t,a){var r=he(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},i=[];ci.lastIndex=0;for(var d;null!=(d=ci.exec(t));)if(d[1]){var o=new kn(d[1]),s;Te(n,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Ee(n,d[2]),u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,a)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),Ne(o.CODECS,u),null!=(s=u.unknownCodecs)&&s.length||i.push(u),n.levels.push(u)}else if(d[3]){var f=d[3],g=d[4];switch(f){case"SESSION-DATA":{var m=new kn(g);Te(n,m,["DATA-ID","LANGUAGE","VALUE","URI"]);var p=m["DATA-ID"];p&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[p]=m);break}case"SESSION-KEY":{var y=Fe(g,a,n);y.encrypted&&y.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(y)):In.warn("[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: \""+g+"\"");break}case"DEFINE":{{var h=new kn(g);Te(n,h,["NAME","VALUE","QUERYPARAM"]),Se(n,h,a)}break}case"CONTENT-STEERING":{var T=new kn(g);Te(n,T,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:e.resolve(T["SERVER-URI"],a),pathwayId:T["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Oe(g);break}}}var E=0<i.length&&i.length<n.levels.length;return n.levels=E?i:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n},e.parseMasterPlaylistMedia=function(t,a,r){var n={},i=r.levels,d={AUDIO:i.map(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}}),SUBTITLES:i.map(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}}),"CLOSED-CAPTIONS":[]},o=0,s;for(fi.lastIndex=0;null!==(s=fi.exec(t));){var l=new kn(s[1]),u=l.TYPE;if(u){var c=d[u],f=n[u]||[];n[u]=f,Te(r,l,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var g=l.LANGUAGE,m=l["ASSOC-LANGUAGE"],p=l.CHANNELS,y=l.CHARACTERISTICS,h=l["INSTREAM-ID"],T={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"]||"",name:l.NAME||g||"",type:u,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:g,url:l.URI?e.resolve(l.URI,a):""};if(m&&(T.assocLang=m),p&&(T.channels=p),y&&(T.characteristics=y),h&&(T.instreamId=h),null!=c&&c.length){var E=e.findGroup(c,T.groupId)||c[0];we(T,E,"audioCodec"),we(T,E,"textCodec")}f.push(T)}}return n},e.parseLevelPlaylist=function(e,t,a,r,n,d){var o=new On(t),s=o.fragments,l=null,c=0,f=0,g=0,m=0,p=null,y=new Pn(r,t),h=-1,T=!1,E=null,S,L,R;for(gi.lastIndex=0,o.m3u8=e,o.hasVariableRefs=he(e);null!==(S=gi.exec(e));){T&&(T=!1,y=new Pn(r,t),y.start=g,y.sn=c,y.cc=m,y.level=a,l&&(y.initSegment=l,y.rawProgramDateTime=l.rawProgramDateTime,l.rawProgramDateTime=null,E&&(y.setByteRange(E),E=null)));var A=S[1];if(A){y.duration=parseFloat(A);var v=(" "+S[2]).slice(1);y.title=v||null,y.tagList.push(v?["INF",A,v]:["INF",A])}else if(S[3]){if(yn(y.duration)){y.start=g,R&&Ge(y,R,o),y.sn=c,y.level=a,y.cc=m,s.push(y);var I=(" "+S[3]).slice(1);y.relurl=Ee(o,I),Be(y,p),p=y,g+=y.duration,c++,f=0,T=!0}}else if(S[4]){var D=(" "+S[4]).slice(1);p?y.setByteRange(D,p):y.setByteRange(D)}else if(S[5])y.rawProgramDateTime=(" "+S[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===h&&(h=s.length);else{if(S=S[0].match(mi),!S){In.warn("No matches on slow regex match for level playlist!");continue}for(L=1;L<S.length&&"undefined"==typeof S[L];L++);var k=(" "+S[L]).slice(1),_=(" "+S[L+1]).slice(1),C=S[L+2]?(" "+S[L+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=_.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(_);break;case"SKIP":{var b=new kn(_);Te(o,b,["RECENTLY-REMOVED-DATERANGES"]);var x=b.decimalInteger("SKIPPED-SEGMENTS");if(yn(x)){o.skippedSegments=x;for(var P=x;P--;)s.unshift(null);c+=x}var F=b.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(o.recentlyRemovedDateranges=F.split("\t"));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(_),1);break;case"VERSION":o.version=parseInt(_);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(_||C)&&y.tagList.push(C?[_,C]:[_]);break;case"DISCONTINUITY":m++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([k]);break;case"BITRATE":y.tagList.push([k,_]);break;case"DATERANGE":{var O=new kn(_);Te(o,O,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Te(o,O,O.clientAttrs);var N=new _n(O,o.dateRanges[O.ID]);N.isValid||o.skippedSegments?o.dateRanges[N.id]=N:In.warn("Ignoring invalid DATERANGE tag: \""+_+"\""),y.tagList.push(["EXT-X-DATERANGE",_]);break}case"DEFINE":{{var w=new kn(_);Te(o,w,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in w?Le(o,w,d):Se(o,w,t)}break}case"DISCONTINUITY-SEQUENCE":m=parseInt(_);break;case"KEY":{var M=Fe(_,t,o);if(M.isSupported()){if("NONE"===M.method){R=void 0;break}R||(R={}),R[M.keyFormat]&&(R=u({},R)),R[M.keyFormat]=M}else In.warn("[Keys] Ignoring invalid EXT-X-KEY tag: \""+_+"\"");break}case"START":o.startTimeOffset=Oe(_);break;case"MAP":{var B=new kn(_);if(Te(o,B,["BYTERANGE","URI"]),y.duration){var U=new Pn(r,t);Ue(U,B,a,R),l=U,y.initSegment=l,l.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=l.rawProgramDateTime)}else{var G=y.byteRangeEndOffset;if(G){var K=y.byteRangeStartOffset;E=G-K+"@"+K}else E=null;Ue(y,B,a,R),l=y,T=!0}break}case"SERVER-CONTROL":{var H=new kn(_);o.canBlockReload=H.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=H.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=0<o.canSkipUntil&&H.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=H.optionalFloat("PART-HOLD-BACK",0),o.holdBack=H.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var V=new kn(_);o.partTarget=V.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Y=o.partList;Y||(Y=o.partList=[]);var W=0<f?Y[Y.length-1]:void 0,q=f++,j=new kn(_);Te(o,j,["BYTERANGE","URI"]);var X=new Fn(j,y,t,q,W);Y.push(X),y.duration+=X.duration;break}case"PRELOAD-HINT":{var z=new kn(_);Te(o,z,["URI"]),o.preloadHint=z;break}case"RENDITION-REPORT":{var Q=new kn(_);Te(o,Q,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(Q);break}default:In.warn("line parsed but not handled: "+S);}}}p&&!p.relurl?(s.pop(),g-=p.duration,o.partList&&(o.fragmentHint=p)):o.partList&&(Be(y,p),y.cc=m,o.fragmentHint=y,R&&Ge(y,R,o));var Z=s.length,$=s[0],J=s[Z-1];if(g+=o.skippedSegments*o.targetduration,0<g&&Z&&J){o.averagetargetduration=g/Z;var ee=J.sn;o.endSN="initSegment"===ee?0:ee,o.live||(J.endList=!0),$&&(o.startCC=$.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(g+=o.fragmentHint.duration),o.totalduration=g,o.endCC=m,0<h&&Me(s,h),o},e}(),yi={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},hi={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},Ti=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.LEVEL_LOADING,this.onLevelLoading,this),e.on(En.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(En.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.LEVEL_LOADING,this.onLevelLoading,this),e.off(En.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(En.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,a=t.pLoader,r=t.loader,n=new(a||r)(t);return this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var a=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:yi.MANIFEST,url:a,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var a=t.id,r=t.level,n=t.pathwayId,i=t.url,d=t.deliveryDirectives;this.load({id:a,level:r,pathwayId:n,responseType:"text",type:yi.LEVEL,url:i,deliveryDirectives:d})},t.onAudioTrackLoading=function(e,t){var a=t.id,r=t.groupId,n=t.url,i=t.deliveryDirectives;this.load({id:a,groupId:r,level:null,responseType:"text",type:yi.AUDIO_TRACK,url:n,deliveryDirectives:i})},t.onSubtitleTrackLoading=function(e,t){var a=t.id,r=t.groupId,n=t.url,i=t.deliveryDirectives;this.load({id:a,groupId:r,level:null,responseType:"text",type:yi.SUBTITLE_TRACK,url:n,deliveryDirectives:i})},t.load=function(e){var t=this,a=this.hls.config,r=this.getInternalLoader(e),n;if(r){var i=r.context;if(i&&i.url===e.url&&i.level===e.level)return void In.trace("[playlist-loader]: playlist request ongoing");In.log("[playlist-loader]: aborting previous loader for type: "+e.type),r.abort()}var d;if(d=e.type===yi.MANIFEST?a.manifestLoadPolicy.default:u({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),yn(null==(n=e.deliveryDirectives)?void 0:n.part)){var o;if(e.type===yi.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===yi.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===yi.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o){var s=o.partTarget,l=o.targetduration;if(s&&l){var c=1e3*Math.max(3*s,.8*l);d=u({},d,{maxTimeToFirstByteMs:Math.min(c,d.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(c,d.maxTimeToFirstByteMs)})}}}var f=d.errorRetry||d.timeoutRetry||{},g={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0};r.load(e,g,{onSuccess:function(e,a,r,n){var i=t.getInternalLoader(r);t.resetInternalLoader(r.type);var d=e.data;return 0===d.indexOf("#EXTM3U")?void(a.parsing.start=performance.now(),pi.isMediaPlaylist(d)?t.handleTrackOrLevelPlaylist(e,a,r,n||null,i):t.handleMasterPlaylist(e,a,r,n)):void t.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),n||null,a)},onError:function(e,a,r,n){t.handleNetworkError(a,r,!1,e,n)},onTimeout:function(e,a,r){t.handleNetworkError(a,r,!0,void 0,e)}})},t.handleMasterPlaylist=function(e,t,a,r){var n=this.hls,i=e.data,d=He(e,a),o=pi.parseMasterPlaylist(i,d);if(o.playlistParsingError)return void this.handleManifestParsingError(e,a,o.playlistParsingError,r,t);var s=o.contentSteering,l=o.levels,u=o.sessionData,c=o.sessionKeys,f=o.startTimeOffset,g=o.variableList;this.variableList=g;var m=pi.parseMasterPlaylistMedia(i,d,o),p=m.AUDIO,y=void 0===p?[]:p,h=m.SUBTITLES,T=m["CLOSED-CAPTIONS"];if(y.length){var E=y.some(function(e){return!e.url});E||!l[0].audioCodec||l[0].attrs.AUDIO||(In.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new kn({}),bitrate:0,url:""}))}n.trigger(En.MANIFEST_LOADED,{levels:l,audioTracks:y,subtitles:h,captions:T,contentSteering:s,url:d,stats:t,networkDetails:r,sessionData:u,sessionKeys:c,startTimeOffset:f,variableList:g})},t.handleTrackOrLevelPlaylist=function(e,t,a,r,n){var i=this.hls,d=a.id,o=a.level,s=a.type,l=He(e,a),u=yn(o)?o:yn(d)?d:0,c=Ke(a),f=pi.parseLevelPlaylist(e.data,l,u,c,0,this.variableList);if(s===yi.MANIFEST){var g={attrs:new kn({}),bitrate:0,details:f,name:"",url:l};i.trigger(En.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:l,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),a.levelDetails=f,this.handlePlaylistLoaded(f,e,t,a,r,n)},t.handleManifestParsingError=function(e,t,a,r,n){this.hls.trigger(En.ERROR,{type:Sn.NETWORK_ERROR,details:Ln.MANIFEST_PARSING_ERROR,fatal:t.type===yi.MANIFEST,url:e.url,err:a,error:a,reason:a.message,response:e,context:t,networkDetails:r,stats:n})},t.handleNetworkError=function(e,t,a,n,i){void 0===a&&(a=!1);var d="A network "+(a?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+e.type;e.type===yi.LEVEL?d+=": "+e.level+" id: "+e.id:(e.type===yi.AUDIO_TRACK||e.type===yi.SUBTITLE_TRACK)&&(d+=" id: "+e.id+" group-id: \""+e.groupId+"\"");var o=new Error(d);In.warn("[playlist-loader]: "+d);var s=Ln.UNKNOWN,l=!1,u=this.getInternalLoader(e);switch(e.type){case yi.MANIFEST:s=a?Ln.MANIFEST_LOAD_TIMEOUT:Ln.MANIFEST_LOAD_ERROR,l=!0;break;case yi.LEVEL:s=a?Ln.LEVEL_LOAD_TIMEOUT:Ln.LEVEL_LOAD_ERROR,l=!1;break;case yi.AUDIO_TRACK:s=a?Ln.AUDIO_TRACK_LOAD_TIMEOUT:Ln.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case yi.SUBTITLE_TRACK:s=a?Ln.SUBTITLE_TRACK_LOAD_TIMEOUT:Ln.SUBTITLE_LOAD_ERROR,l=!1;}u&&this.resetInternalLoader(e.type);var c={type:Sn.NETWORK_ERROR,details:s,fatal:l,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:i};if(n){var f=(null==t?void 0:t.url)||e.url;c.response=r({url:f,data:void 0},n)}this.hls.trigger(En.ERROR,c)},t.handlePlaylistLoaded=function(e,t,a,r,n,i){var d=this.hls,o=r.type,s=r.level,l=r.id,u=r.groupId,c=r.deliveryDirectives,f=He(t,r),g=Ke(r),m="number"==typeof r.level&&g===hi.MAIN?s:void 0;if(!e.fragments.length){var p=new Error("No Segments found in Playlist");return void d.trigger(En.ERROR,{type:Sn.NETWORK_ERROR,details:Ln.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:p,reason:p.message,response:t,context:r,level:m,parent:g,networkDetails:n,stats:a})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var y=e.playlistParsingError;return y?void d.trigger(En.ERROR,{type:Sn.NETWORK_ERROR,details:Ln.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:y,reason:y.message,response:t,context:r,level:m,parent:g,networkDetails:n,stats:a}):void(e.live&&i&&(i.getCacheAge&&(e.ageHeader=i.getCacheAge()||0),(!i.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),o===yi.MANIFEST||o===yi.LEVEL?d.trigger(En.LEVEL_LOADED,{details:e,level:m||0,id:l||0,stats:a,networkDetails:n,deliveryDirectives:c}):o===yi.AUDIO_TRACK?d.trigger(En.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:u||"",stats:a,networkDetails:n,deliveryDirectives:c}):o===yi.SUBTITLE_TRACK?d.trigger(En.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:u||"",stats:a,networkDetails:n,deliveryDirectives:c}):void 0)},e}(),Ei={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},Si=function(){var e=Qe();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}(),Li=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(En.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(En.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&(We(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0,a;t<e.length;t++)if(a=e[t],"metadata"===a.kind&&"id3"===a.label)return Ve(a,this.media),a;return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var a=this.hls.config,r=a.enableEmsgMetadataCues,n=a.enableID3MetadataCues;if(r||n){var d=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=Qe();if(o)for(var s=0,l;s<d.length;s++)if(l=d[s].type,(l!==Ei.emsg||r)&&n){var u=Xn(d[s].data);if(u){var c=d[s].pts,f=c+d[s].duration;f>Si&&(f=Si);var g=f-c;0>=g&&(f=c+.25);for(var m=0,p;m<u.length;m++)if(p=u[m],!qn(p)){this.updateId3CueEnds(c,l);var y=Ze(o,c,f,p,l);y&&this.id3Track.addCue(y)}}}}}},t.updateId3CueEnds=function(e,t){var a=null==(r=this.id3Track)?void 0:r.cues,r;if(a)for(var n=a.length,d;n--;)d=a[n],d.type===t&&d.startTime<e&&d.endTime===Si&&(d.endTime=e)},t.onBufferFlushing=function(e,t){var a=t.startOffset,r=t.endOffset,n=t.type,i=this.id3Track,d=this.hls;if(d){var o=d.config,s=o.enableEmsgMetadataCues,l=o.enableID3MetadataCues;if(i&&(s||l)){var u;u="audio"===n?function(e){return e.type===Ei.audioId3&&l}:"video"===n?function(e){return e.type===Ei.emsg&&s}:function(e){return e.type===Ei.audioId3&&l||e.type===Ei.emsg&&s},qe(i,a,r,u)}}},t.onLevelUpdated=function(e,t){var a=this,r=t.details;if(this.media&&r.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var n=this.dateRangeCuesAppended,d=this.id3Track,o=r.dateRanges,s=Object.keys(o);if(d)for(var l=Object.keys(n).filter(function(e){return!s.includes(e)}),u=function(){var e=l[c];Object.keys(n[e].cues).forEach(function(t){d.removeCue(n[e].cues[t])}),delete n[e]},c=l.length;c--;)u();var f=r.fragments[r.fragments.length-1];if(0!==s.length&&yn(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var g=f.programDateTime/1e3-f.start,m=Qe(),p=function(){var e=s[y],t=o[e],r=$e(t.startDate,g),i=n[e],d=(null==i?void 0:i.cues)||{},l=(null==i?void 0:i.durationKnown)||!1,u=Si,c=t.endDate;if(c)u=$e(c,g),l=!0;else if(t.endOnNext&&!l){var f=s.reduce(function(e,a){if(a!==t.id){var r=o[a];if(r.class===t.class&&r.startDate>t.startDate&&(!e||t.startDate<e.startDate))return r}return e},null);f&&(u=$e(f.startDate,g),l=!0)}for(var p=Object.keys(t.attr),h=0,T;h<p.length;h++)if(T=p[h],!!I(T)){var E=d[T];if(E)l&&!i.durationKnown&&(E.endTime=u);else if(m){var S=t.attr[T];D(T)&&(S=Je(S));var L=Ze(m,r,u,{key:T,data:S},Ei.dateRange);L&&(L.id=e,a.id3Track.addCue(L),d[T]=L)}}n[e]={cues:d,dateRange:t,durationKnown:l}},y=0;y<s.length;y++)p()}}},e}(),Ri=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(En.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(En.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(En.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(En.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(En.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(En.ERROR,this.onError,this)},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var a=t.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(e,t){var a;t.details!==Ln.BUFFER_STALLED_ERROR||(this.stallCount++,null!=(a=this.levelDetails)&&a.live&&In.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var a=this.computeLatency();if(null!==a){this._latency=a;var r=this.config,n=r.lowLatencyMode,i=r.maxLiveSyncPlaybackRate;if(n&&1!==i&&t.live){var d=this.targetLatency;if(null!==d){var o=a-d,s=Math.min(this.maxLatency,d+t.targetduration);if(o<s&&.05<o&&1<this.forwardBufferLength){var l=Math.min(2,Math.max(1,i)),u=Math.round(20*(2/(1+Math.exp(-.75*o-this.edgeStalled))))/20;e.playbackRate=Math.min(l,Math.max(1,u))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},s(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0===e.liveMaxLatencyDuration?t?e.liveMaxLatencyDurationCount*t.targetduration:0:e.liveMaxLatencyDuration}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,a=e.partHoldBack,r=e.targetduration,n=this.config,i=n.liveSyncDuration,d=n.liveSyncDurationCount,o=n.lowLatencyMode,s=this.hls.userConfig,l=o?a||t:t;(s.liveSyncDuration||s.liveSyncDurationCount||0===l)&&(l=void 0===i?d*r:i);return l+Math.min(this.stallCount*1,r)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,a=this.levelDetails;if(null===e||null===t||null===a)return null;var r=a.edge,n=e-t-this.edgeStalled,i=r-a.totalduration,d=r-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(i,n),d)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var a=e.buffered.length;return(a?e.buffered.end(a-1):t.edge)-this.currentTime}}]),e}(),Ai=["NONE","TYPE-0","TYPE-1",null],vi=["SDR","PQ","HLG"],Ii={No:"",Yes:"YES",v2:"v2"},Di=function(){function e(e,t,a){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=a}var t=e.prototype;return t.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),ki=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(function(e){return!!e}).map(function(e){return e.substring(0,4)}).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}var t=e.prototype;return t.hasAudioGroup=function(e){return rt(this._audioGroups,e)},t.hasSubtitleGroup=function(e){return rt(this._subtitleGroups,e)},t.addGroupId=function(e,t){if(t)if("audio"===e){var a=this._audioGroups;a||(a=this._audioGroups=[]),-1===a.indexOf(t)&&a.push(t)}else if("text"===e){var r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),-1===r.indexOf(t)&&r.push(t)}},t.addFallback=function(){},s(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}}]),e}(),_i={search:function(e,t){for(var a=0,r=e.length-1,n=null,i=null;a<=r;){n=0|(a+r)/2,i=e[n];var d=t(i);if(0<d)a=n+1;else if(0>d)r=n-1;else return i}return null}},Ci={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},bi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},xi=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=In.log.bind(In,"[info]:"),this.warn=In.warn.bind(In,"[warning]:"),this.error=In.error.bind(In,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(En.ERROR,this.onError,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(En.ERROR,this.onError,this),e.off(En.ERROR,this.onErrorOut,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(){},t.stopLoad=function(){this.playlistError=0},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===hi.MAIN?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var a,r;if(!t.fatal){var n=this.hls,i=t.context;switch(t.details){case Ln.FRAG_LOAD_ERROR:case Ln.FRAG_LOAD_TIMEOUT:case Ln.KEY_LOAD_ERROR:case Ln.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Ln.FRAG_PARSING_ERROR:if(null!=(a=t.frag)&&a.gap)return void(t.errorAction={action:Ci.DoNothing,flags:bi.None});case Ln.FRAG_GAP:case Ln.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Ci.SendAlternateToPenaltyBox);case Ln.LEVEL_EMPTY_ERROR:case Ln.LEVEL_PARSING_ERROR:{var d=t.parent===hi.MAIN?t.level:n.loadLevel,o,s;t.details===Ln.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(s=o.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case Ln.LEVEL_LOAD_ERROR:case Ln.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==i?void 0:i.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.level)));case Ln.AUDIO_TRACK_LOAD_ERROR:case Ln.AUDIO_TRACK_LOAD_TIMEOUT:case Ln.SUBTITLE_LOAD_ERROR:case Ln.SUBTITLE_TRACK_LOAD_TIMEOUT:if(i){var l=n.levels[n.loadLevel];if(l&&(i.type===yi.AUDIO_TRACK&&l.hasAudioGroup(i.groupId)||i.type===yi.SUBTITLE_TRACK&&l.hasSubtitleGroup(i.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Ci.SendAlternateToPenaltyBox,void(t.errorAction.flags=bi.MoveAllAlternatesMatchingHost)}return;case Ln.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var u=n.levels[n.loadLevel],c=null==u?void 0:u.attrs["HDCP-LEVEL"];c?t.errorAction={action:Ci.SendAlternateToPenaltyBox,flags:bi.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t)}return;case Ln.BUFFER_ADD_CODEC_ERROR:case Ln.REMUX_ALLOC_ERROR:case Ln.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null==(r=t.level)?n.loadLevel:r));case Ln.INTERNAL_EXCEPTION:case Ln.BUFFER_APPENDING_ERROR:case Ln.BUFFER_FULL_ERROR:case Ln.LEVEL_SWITCH_ERROR:case Ln.BUFFER_STALLED_ERROR:case Ln.BUFFER_SEEK_OVER_HOLE:case Ln.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Ci.DoNothing,flags:bi.None});}t.type===Sn.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},t.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},t.getPlaylistRetryOrSwitchAction=function(e,t){var a=this.hls,r=Tt(a.config.playlistLoadPolicy,e),n=this.playlistError++,i=Lt(r,n,ht(e),e.response);if(i)return{action:Ci.RetryRequest,flags:bi.None,retryConfig:r,retryCount:n};var d=this.getLevelSwitchAction(e,t);return r&&(d.retryConfig=r,d.retryCount=n),d},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,a=this.getVariantLevelIndex(e.frag),r=t.levels[a],n=t.config,i=n.fragLoadPolicy,d=n.keyLoadPolicy,o=Tt(e.details.startsWith("key")?d:i,e),s=t.levels.reduce(function(e,t){return e+t.fragmentError},0);if(r){e.details!==Ln.FRAG_GAP&&r.fragmentError++;var l=Lt(o,s,ht(e),e.response);if(l)return{action:Ci.RetryRequest,flags:bi.None,retryConfig:o,retryCount:s}}var u=this.getLevelSwitchAction(e,a);return o&&(u.retryConfig=o,u.retryCount=s),u},t.getLevelSwitchAction=function(e,t){var a=this.hls;(null===t||void 0===t)&&(t=a.loadLevel);var r=this.hls.levels[t];if(r){var n=e.details,d,o;r.loadError++,n===Ln.BUFFER_APPEND_ERROR&&r.fragmentError++;var s=-1,l=a.levels,u=a.loadLevel,c=a.minAutoLevel,f=a.maxAutoLevel;a.autoLevelEnabled||(a.loadLevel=-1);for(var g=null==(d=e.frag)?void 0:d.type,m=g===hi.AUDIO&&n===Ln.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(n===Ln.BUFFER_ADD_CODEC_ERROR||n===Ln.BUFFER_APPEND_ERROR),p=m&&l.some(function(e){var t=e.audioCodec;return r.audioCodec!==t}),y="video"===e.sourceBufferName&&(n===Ln.BUFFER_ADD_CODEC_ERROR||n===Ln.BUFFER_APPEND_ERROR),h=y&&l.some(function(e){var t=e.codecSet,a=e.audioCodec;return r.codecSet!==t&&r.audioCodec===a}),T=null==(o=e.context)?{}:o,E=T.type,S=T.groupId,L=function(){var t=(R+u)%l.length;if(t!==u&&t>=c&&t<=f&&0===l[t].loadError){var a=l[t],i,d;if(n===Ln.FRAG_GAP&&e.frag){var o=l[t].details;if(o){var m=vt(e.frag,o.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else{if(E===yi.AUDIO_TRACK&&a.hasAudioGroup(S)||E===yi.SUBTITLE_TRACK&&a.hasSubtitleGroup(S))return 0;if(g===hi.AUDIO&&null!=(i=r.audioGroups)&&i.some(function(e){return a.hasAudioGroup(e)})||g===hi.SUBTITLE&&null!=(d=r.subtitleGroups)&&d.some(function(e){return a.hasSubtitleGroup(e)})||p&&r.audioCodec===a.audioCodec||!p&&r.audioCodec!==a.audioCodec||h&&r.codecSet===a.codecSet)return 0}return s=t,1}},R=l.length,A;R--&&(A=L(),0===A||1!==A););if(-1<s&&a.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:Ci.SendAlternateToPenaltyBox,flags:bi.None,nextAutoLevel:s}}return{action:Ci.SendAlternateToPenaltyBox,flags:bi.MoveAllAlternatesMatchingHost}},t.onErrorOut=function(e,t){var a;switch(null==(a=t.errorAction)?void 0:a.action){case Ci.DoNothing:break;case Ci.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Ln.FRAG_GAP?/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()):t.fatal=!0;}if(t.fatal)return void this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,a=e.errorAction;if(a){var r=a.flags,n=a.hdcpLevel,i=a.nextAutoLevel;r===bi.None?this.switchLevel(e,i):r===bi.MoveAllAlternatesMatchingHDCP?(n&&(t.maxHdcpLevel=Ai[Ai.indexOf(n)-1],a.resolved=!0),this.warn("Restricting playback to HDCP-LEVEL of \""+t.maxHdcpLevel+"\" or lower")):void 0,a.resolved||this.switchLevel(e,i)}},t.switchLevel=function(e,t){void 0!==t&&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}(),Pi=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=In.log.bind(In,t+":"),this.warn=In.warn.bind(In,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},t.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var a=null==t?void 0:t.renditionReports;if(a){for(var r=-1,n=0;n<a.length;n++){var d=a[n],o=void 0;try{o=new self.URL(d.URI,t.url).href}catch(e){In.warn("Could not construct new URL for Rendition Report: "+e),o=d.URI||""}if(o===e){r=n;break}else o===e.substring(0,o.length)&&(r=n)}if(-1!==r){var s=a[r],l=parseInt(s["LAST-MSN"])||(null==t?void 0:t.lastPartSn),u=parseInt(s["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);0<=u&&c>t.partTarget&&(u+=1)}return new Di(l,0<=u?u:void 0,Ii.No)}}},t.loadPlaylist=function(){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,a){var r=this,n=t.details,i=t.stats,d=self.performance.now(),o=i.loading.first?Math.max(0,d-i.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=a&&a.live){if(n.reloaded(a),a&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),a&&0<n.fragments.length&&dt(a,n),!this.canLoad||!n.live)return;var s=void 0,l=void 0,u;if(n.canBlockReload&&n.endSN&&n.advanced){var c=this.hls.config.lowLatencyMode,f=n.lastPartSn,g=n.endSN,m=n.lastPartIndex,p=f===g,y=c?0:m;-1!==m?(s=p?g+1:f,l=p?y:m+1):s=g+1;var h=n.age,T=h+n.ageHeader,E=Math.min(T-n.partTarget,1.5*n.targetduration);if(0<E){if(a&&E>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+E+" with playlist age: "+n.age),E=0;else{var S=Math.floor(E/n.targetduration);if(s+=S,void 0!==l){var L=Math.round(E%n.targetduration/n.partTarget);l+=L}this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+h.toFixed(2)+"s goal: "+E+" skip sn "+S+" to part "+l)}n.tuneInGoal=E}if(u=this.getDeliveryDirectives(n,t.deliveryDirectives,s,l),c||!p)return void this.loadPlaylist(u)}else(n.canBlockReload||n.canSkipUntil)&&(u=this.getDeliveryDirectives(n,t.deliveryDirectives,s,l));var R=this.hls.mainForwardBufferInfo,A=R?R.end-R.len:0,v=1e3*(n.edge-A),I=ft(n,v);n.updated&&d>this.requestScheduled+I&&(this.requestScheduled=i.loading.start),void 0!==s&&n.canBlockReload?this.requestScheduled=i.loading.first+I-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+I<d?this.requestScheduled=d:0>=this.requestScheduled-d&&(this.requestScheduled+=I);var D=this.requestScheduled-d;D=Math.max(0,D),this.log("reload live playlist "+e+" in "+Math.round(D)+" ms"),this.timer=self.setTimeout(function(){return r.loadPlaylist(u)},D)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,a,r){var n=at(e,a);return null!=t&&t.skip&&e.deltaUpdateFailed&&(a=t.msn,r=t.part,n=Ii.No),new Di(a,r,n)},t.checkRetry=function(e){var t=this,a=e.details,r=ht(e),n=e.errorAction,i=n||{},d=i.action,o=i.retryCount,s=void 0===o?0:o,l=i.retryConfig,u=!!n&&!!l&&(d===Ci.RetryRequest||!n.resolved&&d===Ci.SendAlternateToPenaltyBox);if(u){var c;if(this.requestScheduled=-1,s>=l.maxNumRetry)return!1;if(r&&null!=(c=e.context)&&c.deliveryDirectives)this.warn("Retrying playlist loading "+(s+1)+"/"+l.maxNumRetry+" after \""+a+"\" without delivery-directives"),this.loadPlaylist();else{var f=Et(l,s);this.timer=self.setTimeout(function(){return t.loadPlaylist()},f),this.warn("Retrying playlist loading "+(s+1)+"/"+l.maxNumRetry+" after \""+a+"\" in "+f+"ms")}e.levelRetry=!0,n.resolved=!0}return u},e}(),Fi=function(){function e(e,t,a){void 0===t&&(t=0),void 0===a&&(a=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_=a}var t=e.prototype;return t.sample=function(e,t){var a=Math.pow(this.alpha_,e);this.estimate_=t*(1-a)+a*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),Oi=function(){function e(e,t,a,r){void 0===r&&(r=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=a,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Fi(e),this.fast_=new Fi(t),this.defaultTTFB_=r,this.ttfb_=new Fi(e)}var t=e.prototype;return t.update=function(e,t){var a=this.slow_,r=this.fast_,n=this.ttfb_;a.halfLife!==e&&(this.slow_=new Fi(e,a.getEstimate(),a.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Fi(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Fi(e,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var a=e/1e3,r=8*t/a;this.fast_.sample(a,r),this.slow_.sample(a,r)},t.sampleTTFB=function(e){var t=Math.sqrt(2)*Math.exp(-Math.pow(e/1e3,2)/2);this.ttfb_.sample(t,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}(),Ni={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},wi={},Mi=function(){function e(e){var t=this;this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=function(){var e=t.fragCurrent,a=t.partCurrent,r=t.hls,n=r.autoLevelEnabled,i=r.media;if(e&&i){var d=performance.now(),o=a?a.stats:e.stats,s=a?a.duration:e.duration,l=d-o.loading.start,u=r.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=u)return t.clearTimer(),void(t._nextAutoLevel=-1);if(n&&!i.paused&&i.playbackRate&&i.readyState){var c=r.mainForwardBufferInfo;if(null!==c){var f=t.bwEstimator.getEstimateTTFB(),g=Math.abs(i.playbackRate);if(!(l<=Math.max(f,1e3*(s/(2*g))))){var m=c.len/g,p=o.loading.first?o.loading.first-o.loading.start:-1,y=o.loaded&&-1<p,h=t.getBwEstimate(),T=r.levels,E=T[e.level],S=o.total||Math.max(o.loaded,Math.round(s*E.maxBitrate/8)),L=y?l-p:l;1>L&&y&&(L=Math.min(l,8*o.loaded/h));var R=y?1e3*o.loaded/L:0,A=R?(S-o.loaded)/R:8*S/h+f/1e3;if(!(A<=m)){var v=R?8*R:h,I=Number.POSITIVE_INFINITY,D;for(D=e.level-1;D>u;D--){var k=T[D].maxBitrate;if(I=t.getTimeToLoadFrag(f/1e3,v,s*k,!T[D].details),I<m)break}if(!(I>=A)&&!(I>10*s)){r.nextLoadLevel=r.nextAutoLevel=D,y?t.bwEstimator.sample(l-Math.min(f,p),o.loaded):t.bwEstimator.sampleTTFB(l);var _=T[D].bitrate;t.getBwEstimate()*t.hls.config.abrBandWidthUpFactor>_&&t.resetEstimator(_),t.clearTimer(),In.warn("[abr] Fragment "+e.sn+(a?" part "+a.index:"")+" of level "+e.level+" is loading too slowly;\n      Time to underbuffer: "+m.toFixed(3)+" s\n      Estimated load time for current fragment: "+A.toFixed(3)+" s\n      Estimated load time for down switch fragment: "+I.toFixed(3)+" s\n      TTFB estimate: "+(0|p)+" ms\n      Current BW estimate: "+(yn(h)?0|h:"Unknown")+" bps\n      New BW estimate: "+(0|t.getBwEstimate())+" bps\n      Switching to level "+D+" @ "+(0|_)+" bps"),r.trigger(En.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:a,stats:o})}}}}}}},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}var t=e.prototype;return t.resetEstimator=function(e){e&&(In.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},t.initEstimator=function(){var e=this.hls.config;return new Oi(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},t.registerListeners=function(){var e=this.hls;e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.FRAG_LOADING,this.onFragLoading,this),e.on(En.FRAG_LOADED,this.onFragLoaded,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this),e.on(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(En.LEVEL_LOADED,this.onLevelLoaded,this),e.on(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(En.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(En.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.FRAG_LOADING,this.onFragLoading,this),e.off(En.FRAG_LOADED,this.onFragLoaded,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this),e.off(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(En.LEVEL_LOADED,this.onLevelLoaded,this),e.off(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(En.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(En.ERROR,this.onError,this))},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},t.onManifestLoading=function(){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},t.onLevelsUpdated=function(){-1<this.lastLoadedFragLevel&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},t.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},t.onFragLoading=function(e,t){var a=t.frag;if(!this.ignoreFragment(a)){if(!a.bitrateTest){var r;this.fragCurrent=a,this.partCurrent=null==(r=t.part)?null:r}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}},t.onLevelSwitching=function(){this.clearTimer()},t.onError=function(e,t){if(!t.fatal)switch(t.details){case Ln.BUFFER_ADD_CODEC_ERROR:case Ln.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ln.FRAG_LOAD_TIMEOUT:{var a=t.frag,r=this.fragCurrent,n=this.partCurrent;if(a&&r&&a.sn===r.sn&&a.level===r.level){var i=performance.now(),d=n?n.stats:a.stats,o=i-d.loading.start,s=d.loading.first?d.loading.first-d.loading.start:-1,l=d.loaded&&-1<s;if(l){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,s),d.loaded)}else this.bwEstimator.sampleTTFB(o)}break}}},t.getTimeToLoadFrag=function(e,t,a,r){var n=r?this.lastLevelLoadSec:0;return e+a/t+n},t.onLevelLoaded=function(e,t){var a=this.hls.config,r=t.stats.loading,n=r.end-r.start;yn(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},t.onFragLoaded=function(e,t){var a=t.frag,r=t.part,n=r?r.stats:a.stats;if(a.type===hi.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),a.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var i=r?r.duration:a.duration,d=this.hls.levels[a.level],o=(d.loaded?d.loaded.bytes:0)+n.loaded,s=(d.loaded?d.loaded.duration:0)+i;d.loaded={bytes:o,duration:s},d.realBitrate=Math.round(8*o/s)}if(a.bitrateTest){var l={stats:n,frag:a,part:r,id:a.type};this.onFragBuffered(En.FRAG_BUFFERED,l),a.bitrateTest=!1}else this.lastLoadedFragLevel=a.level}},t.onFragBuffered=function(e,t){var a=t.frag,r=t.part,n=null!=r&&r.stats.loaded?r.stats:a.stats;if(!n.aborted&&!this.ignoreFragment(a)){var i=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.getBwEstimate(),this.bitrateTestDelay=a.bitrateTest?i/1e3:0}},t.ignoreFragment=function(e){return e.type!==hi.MAIN||"initSegment"===e.sn},t.clearTimer=function(){-1<this.timer&&(self.clearInterval(this.timer),this.timer=-1)},t.getAutoLevelKey=function(){var e;return this.getBwEstimate()+"_"+(null==(e=this.hls.mainForwardBufferInfo)?void 0:e.len)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,a=this.hls,r=a.maxAutoLevel,n=a.config,i=a.minAutoLevel,d=a.media,o=t?t.duration:e?e.duration:0,s=d&&0!==d.playbackRate?Math.abs(d.playbackRate):1,l=this.getBwEstimate(),u=a.mainForwardBufferInfo,c=(u?u.len:0)/s,f=n.abrBandWidthFactor,g=n.abrBandWidthUpFactor;if(c){var m=this.findBestLevel(l,i,r,c,0,f,g);if(0<=m)return m}var p=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!c){var y=this.bitrateTestDelay;if(y){var h=o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay;p=h-y,In.info("[abr] bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),f=g=1}}var T=this.findBestLevel(l,i,r,c,p,f,g);if(In.info("[abr] "+(c?"rebuffering expected":"buffer is empty")+", optimal quality level "+T),-1<T)return T;var E=a.levels[i],S=a.levels[a.loadLevel];return(null==E?void 0:E.bitrate)<(null==S?void 0:S.bitrate)?i:a.loadLevel},t.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},t.findBestLevel=function(e,t,a,r,n,d,o){var s=this,l=r+n,u=this.lastLoadedFragLevel,c=-1===u?this.hls.firstLevel:u,f=this.fragCurrent,g=this.partCurrent,m=this.hls,p=m.levels,y=m.allAudioTracks,h=m.loadLevel,T=m.config,E;if(1===p.length)return 0;var S=p[c],L=!!(null!=S&&null!=(E=S.details)&&E.live),R=-1===h||-1===u,A="SDR",v=(null==S?void 0:S.frameRate)||0,I=T.audioPreference,D=T.videoPreference,k=this.audioTracksByGroup||(this.audioTracksByGroup=Nt(y)),_;if(R){if(-1!==this.firstSelection)return this.firstSelection;var C=this.codecTiers||(this.codecTiers=wt(p,k,t,a)),b=Ft(C,A,e,I,D),x=b.codecSet,P=b.videoRanges,F=b.minFramerate,O=b.minBitrate,N=b.preferHDR;_=x,A=N?P[P.length-1]:P[0],v=F,e=Math.max(e,O),In.log("[abr] picked start tier "+JSON.stringify(b))}else _=null==S?void 0:S.codecSet,A=null==S?void 0:S.videoRange;for(var w=g?g.duration:f?f.duration:0,M=this.bwEstimator.getEstimateTTFB()/1e3,B=[],U=function(){var t=p[G],i=G>c,f,m;if(!t)return 0;if(T.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var y=navigator.mediaCapabilities;"function"==typeof(null==y?void 0:y.decodingInfo)&&_t(t,k,A,v,e,I)?(t.supportedPromise=Ct(t,k,y),t.supportedPromise.then(function(e){t.supportedResult=e;var a=s.hls.levels,r=a.indexOf(t);e.error?In.warn("[abr] MediaCapabilities decodingInfo error: \""+e.error+"\" for level "+r+" "+JSON.stringify(e)):!e.supported&&(In.warn("[abr] Unsupported MediaCapabilities decodingInfo result for level "+r+" "+JSON.stringify(e)),-1<r&&1<a.length&&(In.log("[abr] Removing unsupported level "+r),s.hls.removeLevel(r)))})):t.supportedResult=Ni}if(_&&t.codecSet!==_||A&&t.videoRange!==A||i&&v>t.frameRate||!i&&0<v&&v<t.frameRate||!(null!=(f=t.supportedResult)&&null!=(m=f.decodingInfoResults)&&m[0].smooth))return B.push(G),0;var E=t.details,D=(g?null==E?void 0:E.partTarget:null==E?void 0:E.averagetargetduration)||w,C;C=i?o*e:d*e;var b=w&&r>=2*w&&0===n?p[G].averageBitrate:p[G].maxBitrate,x=s.getTimeToLoadFrag(M,C,b*D,void 0===E),P=C>=b&&(G===u||0===t.loadError&&0===t.fragmentError)&&(x<=M||!yn(x)||L&&!s.bitrateTestDelay||x<l);if(P){var F=s.forcedAutoLevel;return G!==h&&(-1===F||F!==h)&&(B.length&&In.trace("[abr] Skipped level(s) "+B.join(",")+" of "+a+" max with CODECS and VIDEO-RANGE:\""+p[B[0]].codecs+"\" "+p[B[0]].videoRange+"; not compatible with \""+S.codecs+"\" "+A),In.info("[abr] switch candidate:"+c+"->"+G+" adjustedbw("+Math.round(C)+")-bitrate="+Math.round(C-b)+" ttfb:"+M.toFixed(1)+" avgDuration:"+D.toFixed(1)+" maxFetchDuration:"+l.toFixed(1)+" fetchDuration:"+x.toFixed(1)+" firstSelection:"+R+" codecSet:"+_+" videoRange:"+A+" hls.loadLevel:"+h)),R&&(s.firstSelection=G),{v:G}}},G=a,K;G>=t;G--)if(K=U(),0!==K&&K)return K.v;return-1},s(e,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,a=e.minAutoLevel,r=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,i=this.findBestLevel(r,a,t,0,n,1,1);if(-1<i)return i;var d=this.hls.firstLevel,o=Math.min(Math.max(d,a),t);return In.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+d+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator,a=t.canEstimate(),r=-1<this.lastLoadedFragLevel;if(-1!==e&&(!a||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;var n=a&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var i=this.hls.levels;if(i.length>Math.max(e,n)&&i[e].loadError<=i[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=Math.max(this.hls.minAutoLevel,e);this._nextAutoLevel!=t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}}]),e}(),Bi=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),Ui={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Gi=function(){function e(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()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(En.BUFFER_APPENDED,this.onBufferAppended,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this),e.on(En.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(En.BUFFER_APPENDED,this.onBufferAppended,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this),e.off(En.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var a=this.activePartLists[t];if(a)for(var r=a.length,n,d;r--&&(n=a[r],!!n);)if(d=n.end,n.start<=e&&null!==d&&e<=d)return n;return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var a=this.fragments,r=Object.keys(a),n=r.length,d;n--;)if(d=a[r[n]],(null==d?void 0:d.body.type)===t&&d.buffered){var o=d.body;if(o.start<=e&&e<=o.end)return o}return null},t.detectEvictedFragments=function(e,t,a,r){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var i=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(r){var d=n.fragments[r];if(d&&!(i>=d.body.sn)){if(!d.buffered&&!d.loaded)return void(d.body.type===a&&n.removeFragment(d.body));var o=d.range[e];o&&o.time.some(function(e){var a=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return a&&n.removeFragment(d.body),a})}})},t.detectPartialFragments=function(e){var t=this,a=this.timeRanges,r=e.frag,n=e.part;if(a&&"initSegment"!==r.sn){var i=Yt(r),d=this.fragments[i];if(!(!d||d.buffered&&r.gap)){var o=!r.relurl;if(Object.keys(a).forEach(function(e){var i=r.elementaryStreams[e];if(i){var s=a[e],l=o||!0===i.partial;d.range[e]=t.getBufferedTimes(r,n,l,s)}}),d.loaded=null,Object.keys(d.range).length){d.buffered=!0;var s=d.body.endList=r.endList||d.body.endList;s&&(this.endListFragments[d.body.type]=d),Vt(d)||this.removeParts(r.sn-1,r.type)}else this.removeFragment(d.body)}}},t.removeParts=function(e,t){var a=this.activePartLists[t];a&&(this.activePartLists[t]=a.filter(function(t){return t.fragment.sn>=e}))},t.fragBuffered=function(e,t){var a=Yt(e),r=this.fragments[a];!r&&t&&(r=this.fragments[a]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,a,r){for(var n={time:[],partial:a},d=e.start,o=e.end,s=e.minEndPTS||o,l=e.maxStartPTS||d,u=0;u<r.length;u++){var c=r.start(u)-this.bufferPadding,f=r.end(u)+this.bufferPadding;if(l>=c&&s<=f){n.time.push({startPTS:Math.max(d,r.start(u)),endPTS:Math.min(o,r.end(u))});break}else if(d<f&&o>c){var g=Math.max(d,r.start(u)),m=Math.min(o,r.end(u));m>g&&(n.partial=!0,n.time.push({startPTS:g,endPTS:m}))}else if(o<=c)break}return n},t.getPartialFragment=function(e){var t=null,a=0,r=this.bufferPadding,n=this.fragments,i,d,o;return Object.keys(n).forEach(function(s){var l=n[s];!l||Vt(l)&&(d=l.body.start-r,o=l.body.end+r,e>=d&&e<=o&&(i=Math.min(e-d,o-e),a<=i&&(t=l.body,a=i)))}),t},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Vt(t))},t.getState=function(e){var t=Yt(e),a=this.fragments[t];return a?a.buffered?Vt(a)?Ui.PARTIAL:Ui.OK:Ui.APPENDING:Ui.NOT_LOADED},t.isTimeBuffered=function(e,t,a){for(var r=0,n,d;r<a.length;r++){if(n=a.start(r)-this.bufferPadding,d=a.end(r)+this.bufferPadding,e>=n&&t<=d)return!0;if(t<=n)return!1}return!1},t.onFragLoaded=function(e,t){var a=t.frag,r=t.part;if(!("initSegment"===a.sn||a.bitrateTest)){var n=r?null:t,i=Yt(a);this.fragments[i]={body:a,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var a=this,r=t.frag,n=t.part,i=t.timeRanges;if("initSegment"!==r.sn){var d=r.type;if(n){var o=this.activePartLists[d];o||(this.activePartLists[d]=o=[]),o.push(n)}this.timeRanges=i,Object.keys(i).forEach(function(e){var t=i[e];a.detectEvictedFragments(e,t,d,n)})}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Yt(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!!(null!=(t=this.activePartLists[e])&&t.length)},t.removeFragmentsInRange=function(e,t,a,r,n){var i=this;r&&!this.hasGaps||Object.keys(this.fragments).forEach(function(d){var o=i.fragments[d];if(o){var s=o.body;s.type!==a||r&&!s.gap||s.start<t&&s.end>e&&(o.buffered||n)&&i.removeFragment(s)}})},t.removeFragment=function(e){var t=Yt(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var a=this.activePartLists[e.type];if(a){var r=e.sn;this.activePartLists[e.type]=a.filter(function(e){return e.fragment.sn!==r})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}(),Ki={length:0,start:function(){return 0},end:function(){return 0}},Hi=function(){function e(){}return e.isBuffered=function(t,a){try{if(t)for(var r=e.getBuffered(t),n=0;n<r.length;n++)if(a>=r.start(n)&&a<=r.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,a,r){try{if(t){var n=e.getBuffered(t),d=[],o;for(o=0;o<n.length;o++)d.push({start:n.start(o),end:n.end(o)});return this.bufferedInfo(d,a,r)}}catch(e){}return{len:0,start:a,end:a,nextStart:void 0}},e.bufferedInfo=function(e,t,a){t=Math.max(0,t),e.sort(function(e,t){var a=e.start-t.start;return a?a:t.end-e.end});var r=[];if(a){for(var n=0,d;n<e.length;n++)if(d=r.length,d){var o=r[d-1].end;e[n].start-o<a?e[n].end>o&&(r[d-1].end=e[n].end):r.push(e[n])}else r.push(e[n]);}else r=e;for(var s=0,l=t,u=t,c=0,f;c<r.length;c++){var g=r[c].start,m=r[c].end;if(t+a>=g&&t<m)l=g,u=m,s=u-t;else if(t+a<g){f=g;break}}return{len:s,start:l||0,end:u||0,nextStart:f}},e.getBuffered=function(e){try{return e.buffered}catch(t){return In.log("failed to get media.buffered",t),Ki}},e}(),Vi=function(e,t,a,r,n,i){void 0===r&&(r=0),void 0===n&&(n=-1),void 0===i&&(i=!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=Wt(),this.buffering={audio:Wt(),video:Wt(),audiovideo:Wt()},this.level=e,this.sn=t,this.id=a,this.size=r,this.part=n,this.partial=i},Yi=Math.pow(2,17),Wi=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var a=this,n=e.url;if(!n)return Promise.reject(new qi({type:Sn.NETWORK_ERROR,details:Ln.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var i=this.config,d=i.fLoader,o=i.loader;return new Promise(function(s,l){if(a.loader&&a.loader.destroy(),e.gap){if(e.tagList.some(function(e){return"GAP"===e[0]}))return void l(ta(e));e.gap=!1}var u=a.loader=e.loader=d?new d(i):new o(i),c=ea(e),f=St(i.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Yi};e.stats=u.stats,u.load(c,g,{onSuccess:function(t,r,n,i){a.resetLoader(e,u);var d=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(d.slice(0,16)),d=d.slice(16)),s({frag:e,part:null,payload:d,networkDetails:i})},onError:function(t,i,d,o){a.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:r({url:n,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:d,stats:o}))},onAbort:function(t,r,n){a.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:function(t,r,n){a.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:n,stats:t}))},onProgress:function(a,r,n,i){t&&t({frag:e,part:null,payload:n,networkDetails:i})}})})},t.loadPart=function(e,t,a){var n=this;this.abort();var i=this.config,d=i.fLoader,o=i.loader;return new Promise(function(s,l){if(n.loader&&n.loader.destroy(),e.gap||t.gap)return void l(ta(e,t));var u=n.loader=e.loader=d?new d(i):new o(i),c=ea(e,t),f=St(i.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Yi};t.stats=u.stats,u.load(c,g,{onSuccess:function(r,i,d,o){n.resetLoader(e,u),n.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:r.data,networkDetails:o};a(l),s(l)},onError:function(a,i,d,o){n.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r({url:c.url,data:void 0},a),error:new Error("HTTP Error "+a.code+" "+a.text),networkDetails:d,stats:o}))},onAbort:function(a,r,i){e.stats.aborted=t.stats.aborted,n.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:i,stats:a}))},onTimeout:function(a,r,i){n.resetLoader(e,u),l(new qi({type:Sn.NETWORK_ERROR,details:Ln.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+g.timeout+"ms"),networkDetails:i,stats:a}))}})})},t.updateStatsFromPart=function(e,t){var a=e.stats,r=t.stats,n=r.total;if(a.loaded+=r.loaded,n){var i=Math.round(e.duration/t.duration),d=Math.min(Math.round(a.loaded/n),i),o=(i-d)*Math.round(a.loaded/d);a.total=a.loaded+o}else a.total=Math.max(a.loaded,a.total);var s=a.loading,l=r.loading;s.start?s.first+=l.first-l.start:(s.start=l.start,s.first=l.first),s.end=l.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}(),qi=function(e){function t(t){var a;return a=e.call(this,t.error.message)||this,a.data=void 0,a.data=t,a}return c(t,e),t}(h(Error)),ji=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}var t=e.prototype;return t.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),Xi=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}var t=e.prototype;return t.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}(),zi=function(){function e(){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()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),a=new Uint32Array(4),r=0;4>r;r++)a[r]=t.getUint32(4*r);return a},t.initTable=function(){var e=this.sBox,a=this.invSBox,r=this.subMix,n=r[0],o=r[1],s=r[2],l=r[3],u=this.invSubMix,c=u[0],f=u[1],g=u[2],m=u[3],p=new Uint32Array(256),d=0,y=0,h=0;for(h=0;256>h;h++)p[h]=128>h?h<<1:283^h<<1;for(h=0;256>h;h++){var T=y^y<<1^y<<2^y<<3^y<<4;T=99^(T>>>8^255&T),e[d]=T,a[T]=d;var E=p[d],S=p[E],L=p[S],R=257*p[T]^16843008*T;n[d]=R<<24|R>>>8,o[d]=R<<16|R>>>16,s[d]=R<<8|R>>>24,l[d]=R,R=16843009*L^65537*S^257*E^16843008*d,c[T]=R<<24|R>>>8,f[T]=R<<16|R>>>16,g[T]=R<<8|R>>>24,m[T]=R,d?(d=E^p[p[p[L^E]]],y^=p[p[y]]):d=y=1}},t.expandKey=function(e){for(var a=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<a.length&&r;)r=a[n]===this.key[n],n++;if(!r){this.key=a;var i=this.keySize=a.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var d=this.ksRows=4*(i+6+1),o=this.keySchedule=new Uint32Array(d),s=this.invKeySchedule=new Uint32Array(d),l=this.sBox,u=this.rcon,c=this.invSubMix,f=c[0],g=c[1],m=c[2],p=c[3],y,h,T,E;for(y=0;y<d;y++){if(y<i){T=o[y]=a[y];continue}E=T,0==y%i?(E=E<<8|E>>>24,E=l[E>>>24]<<24|l[255&E>>>16]<<16|l[255&E>>>8]<<8|l[255&E],E^=u[0|y/i]<<24):6<i&&4==y%i&&(E=l[E>>>24]<<24|l[255&E>>>16]<<16|l[255&E>>>8]<<8|l[255&E]),o[y]=T=(o[y-i]^E)>>>0}for(h=0;h<d;h++)y=d-h,E=3&h?o[y]:o[y-4],s[h]=4>h||4>=y?E:f[l[E>>>24]]^g[l[255&E>>>16]]^m[l[255&E>>>8]]^p[l[255&E]],s[h]>>>=0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,a){for(var r=this.keySize+6,n=this.invKeySchedule,d=this.invSBox,o=this.invSubMix,s=o[0],l=o[1],u=o[2],c=o[3],f=this.uint8ArrayToUint32Array_(a),g=f[0],m=f[1],p=f[2],y=f[3],h=new Int32Array(e),T=new Int32Array(h.length),E=this.networkToHostOrderSwap,S,L,R,A,v,I,D,k,_,C,b,x,P,F;t<h.length;){for(_=E(h[t]),C=E(h[t+1]),b=E(h[t+2]),x=E(h[t+3]),v=_^n[0],I=x^n[1],D=b^n[2],k=C^n[3],P=4,F=1;F<r;F++)S=s[v>>>24]^l[255&I>>16]^u[255&D>>8]^c[255&k]^n[P],L=s[I>>>24]^l[255&D>>16]^u[255&k>>8]^c[255&v]^n[P+1],R=s[D>>>24]^l[255&k>>16]^u[255&v>>8]^c[255&I]^n[P+2],A=s[k>>>24]^l[255&v>>16]^u[255&I>>8]^c[255&D]^n[P+3],v=S,I=L,D=R,k=A,P+=4;S=d[v>>>24]<<24^d[255&I>>16]<<16^d[255&D>>8]<<8^d[255&k]^n[P],L=d[I>>>24]<<24^d[255&D>>16]<<16^d[255&k>>8]<<8^d[255&v]^n[P+1],R=d[D>>>24]<<24^d[255&k>>16]<<16^d[255&v>>8]<<8^d[255&I]^n[P+2],A=d[k>>>24]<<24^d[255&v>>16]<<16^d[255&I>>8]<<8^d[255&D]^n[P+3],T[t]=E(S^g),T[t+1]=E(A^m),T[t+2]=E(R^p),T[t+3]=E(L^y),g=_,m=C,p=b,y=x,t+=4}return T.buffer},e}(),Qi=function(){function e(e,t){var a=void 0===t?{}:t,r=a.removePKCS7Padding,n=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?aa(a):a},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,a){var r=this;return this.useSoftware?new Promise(function(n,i){r.softwareDecrypt(new Uint8Array(e),t,a);var d=r.flush();d?n(d.buffer):i(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,a)},t.softwareDecrypt=function(e,t,a){var r=this.currentIV,n=this.currentResult,i=this.remainderData;this.logOnce("JS AES decrypt"),i&&(e=de(i,e),this.remainderData=null);var d=this.getValidChunk(e);if(!d.length)return null;r&&(a=r);var o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new zi),o.expandKey(t);var s=n;return this.currentResult=o.decrypt(d.buffer,0,a),this.currentIV=B(d,-16).buffer,s?s:null},t.webCryptoDecrypt=function(e,t,a){var r=this,n=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new Xi(n,t)),this.fastAesKey.expandKey().then(function(t){if(!n)return Promise.reject(new Error("web crypto not initialized"));r.logOnce("WebCrypto AES decrypt");var i=new ji(n,new Uint8Array(a));return i.decrypt(e.buffer,t)}).catch(function(n){return In.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),r.onWebCryptoError(e,t,a)})},t.onWebCryptoError=function(e,t,a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,a);var r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},t.getValidChunk=function(e){var t=e,a=e.length-e.length%16;return a!==e.length&&(t=B(e,0,a),this.remainderData=B(e,a)),t},t.logOnce=function(e){this.logEnabled&&(In.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),Zi={toString:function(e){for(var t="",a=e.length,r=0;r<a;r++)t+="["+e.start(r).toFixed(3)+"-"+e.end(r).toFixed(3)+"]";return t}},$i={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"},Ji=function(e){function t(t,a,r,n,i){var d;return d=e.call(this)||this,d.hls=void 0,d.fragPrevious=null,d.fragCurrent=null,d.fragmentTracker=void 0,d.transmuxer=null,d._state=$i.STOPPED,d.playlistType=void 0,d.media=null,d.mediaBuffer=null,d.config=void 0,d.bitrateTest=!1,d.lastCurrentTime=0,d.nextLoadPosition=0,d.startPosition=0,d.startTimeOffset=null,d.loadedmetadata=!1,d.retryDate=0,d.levels=null,d.fragmentLoader=void 0,d.keyLoader=void 0,d.levelLastLoaded=null,d.startFragRequested=!1,d.decrypter=void 0,d.initPTS=[],d.onvseeking=null,d.onvended=null,d.logPrefix="",d.log=void 0,d.warn=void 0,d.playlistType=i,d.logPrefix=n,d.log=In.log.bind(In,n+":"),d.warn=In.warn.bind(In,n+":"),d.hls=t,d.fragmentLoader=new Wi(t.config),d.keyLoader=r,d.fragmentTracker=a,d.config=t.config,d.decrypter=new Qi(t.config),t.on(En.MANIFEST_LOADED,d.onManifestLoaded,T(d)),d}c(t,e);var a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(){},a.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=$i.STOPPED},a._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var a=t.partList;if(null!=a&&a.length){var r=a[a.length-1],n=Hi.isBuffered(this.media,r.start+r.duration/2);return n}var i=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)},a.getLevelDetails=function(){if(this.levels&&null!==this.levelLastLoaded){var e;return null==(e=this.levelLastLoaded)?void 0:e.details}},a.onMediaAttached=function(e,t){var a=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),a.addEventListener("seeking",this.onvseeking),a.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.state===$i.STOPPED&&this.startLoad(r.startPosition)},a.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,a=this.media,r=this.mediaBuffer,n=this.state,i=a?a.currentTime:0,d=Hi.bufferInfo(r?r:a,i,e.maxBufferHole);if(this.log("media seeking to "+(yn(i)?i.toFixed(3):i)+", state: "+n),this.state===$i.ENDED)this.resetLoadingState();else if(t){var o=e.maxFragLookUpTolerance,s=t.start-o,l=t.start+t.duration+o;if(!d.len||l<d.start||s>d.end){var u=i>l;(i<s||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}a&&(this.fragmentTracker.removeFragmentsInRange(i,1/0,this.playlistType,!0),this.lastCurrentTime=i),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=i),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]},a.onHandlerDestroying=function(){this.hls.off(En.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),e.prototype.onHandlerDestroying.call(this),this.hls=null},a.onHandlerDestroyed=function(){this.state=$i.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,e.prototype.onHandlerDestroyed.call(this)},a.loadFragment=function(e,t,a){this._loadFragForPlayback(e,t,a)},a._loadFragForPlayback=function(e,t,a){var r=this;this._doFragLoad(e,t,a,function(t){return r.fragContextChanged(e)?(r.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void r.fragmentTracker.removeFragment(e)):void(e.stats.chunkCount++,r._handleFragmentLoadProgress(t))}).then(function(t){if(t){var a=r.state;return r.fragContextChanged(e)?void(a!==$i.FRAG_LOADING&&(r.fragCurrent||a!==$i.PARSING)||(r.fragmentTracker.removeFragment(e),r.state=$i.IDLE)):void("payload"in t&&(r.log("Loaded fragment "+e.sn+" of level "+e.level),r.hls.trigger(En.FRAG_LOADED,t)),r._handleFragmentLoadComplete(t))}}).catch(function(t){r.state===$i.STOPPED||r.state===$i.ERROR||(r.warn(t),r.resetFragmentLoading(e))})},a.clearTrackerIfNeeded=function(e){var t=this.fragmentTracker,a=t.getState(e),r;if(a===Ui.APPENDING){var n=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,n),d=Math.max(e.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(d)&&t.removeFragment(e)}else 0===(null==(r=this.mediaBuffer)?void 0:r.buffered.length)?t.removeAllFragments():t.hasParts(e.type)&&(t.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),t.getState(e)===Ui.PARTIAL&&t.removeFragment(e))},a.checkLiveUpdate=function(e){if(e.updated&&!e.live){var 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)},a.flushMainBuffer=function(e,t,a){if(void 0===a&&(a=null),!!(e-t)){var r={startOffset:e,endOffset:t,type:a};this.hls.trigger(En.BUFFER_FLUSHING,r)}},a._loadInitSegment=function(e,t){var a=this;this._doFragLoad(e,t).then(function(t){if(!t||a.fragContextChanged(e)||!a.levels)throw new Error("init load aborted");return t}).then(function(t){var r=a.hls,n=t.payload,i=e.decryptdata;if(n&&0<n.byteLength&&null!=i&&i.key&&i.iv&&"AES-128"===i.method){var d=self.performance.now();return a.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer).catch(function(t){throw r.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(function(n){var i=self.performance.now();return r.trigger(En.FRAG_DECRYPTED,{frag:e,payload:n,stats:{tstart:d,tdecrypt:i}}),t.payload=n,a.completeInitSegmentLoad(t)})}return a.completeInitSegmentLoad(t)}).catch(function(t){a.state===$i.STOPPED||a.state===$i.ERROR||(a.warn(t),a.resetFragmentLoading(e))})},a.completeInitSegmentLoad=function(e){var t=this.levels;if(!t)throw new Error("init load aborted, missing levels");var a=e.frag.stats;this.state=$i.IDLE,e.frag.data=new Uint8Array(e.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),this.tick()},a.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},a.fragBufferedComplete=function(e,t){var a=this.mediaBuffer?this.mediaBuffer:this.media,r,n,i,d;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===hi.MAIN?"level":"track")+" "+e.level+" (frag:["+(null==(r=e.startPTS)?NaN:r).toFixed(3)+"-"+(null==(n=e.endPTS)?NaN:n).toFixed(3)+"] > buffer:"+(a?Zi.toString(Hi.getBuffered(a)):"(detached)")+")"),"initSegment"!==e.sn){var o;if(e.type!==hi.SUBTITLE){var s=e.elementaryStreams;if(!Object.keys(s).some(function(e){return!!s[e]}))return void(this.state=$i.IDLE)}var l=null==(o=this.levels)?void 0:o[e.level];null!=l&&l.fragmentError&&(this.log("Resetting level fragment error count of "+l.fragmentError+" on frag buffered"),l.fragmentError=0)}this.state=$i.IDLE,a&&(!this.loadedmetadata&&e.type==hi.MAIN&&a.buffered.length&&(null==(i=this.fragCurrent)?void 0:i.sn)===(null==(d=this.fragPrevious)?void 0:d.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var a=e.frag,r=e.part,n=e.partsLoaded,i=!n||0===n.length||n.some(function(e){return!e}),d=new Vi(a.level,a.sn,a.stats.chunkCount+1,0,r?r.index:-1,!i);t.flush(d)}},a._handleFragmentLoadProgress=function(){},a._doFragLoad=function(e,t,a,r){var n=this,i;void 0===a&&(a=null);var d=null==t?void 0:t.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var o=null;if(e.encrypted&&!(null!=(i=e.decryptdata)&&i.key)?(this.log("Loading key for "+e.sn+" of ["+d.startSN+"-"+d.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=$i.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(function(e){if(!n.fragContextChanged(e.frag))return n.hls.trigger(En.KEY_LOADED,e),n.state===$i.KEY_LOADING&&(n.state=$i.IDLE),e}),this.hls.trigger(En.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(e,d.encryptedFragments),a=Math.max(e.start,a||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var s=d.partList;if(s&&r){a>e.end&&d.fragmentHint&&(e=d.fragmentHint);var l=this.getNextPart(s,e,a);if(-1<l){var u=s[l];this.log("Loading part sn: "+e.sn+" p: "+u.index+" cc: "+e.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+l+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(a.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=$i.FRAG_LOADING;var c;return c=o?o.then(function(a){return!a||n.fragContextChanged(a.frag)?null:n.doFragPartsLoad(e,u,t,r)}).catch(function(e){return n.handleFragLoadError(e)}):this.doFragPartsLoad(e,u,t,r).catch(function(e){return n.handleFragLoadError(e)}),this.hls.trigger(En.FRAG_LOADING,{frag:e,part:u,targetBufferTime:a}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(s,a))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(a.toFixed(3))),yn(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=$i.FRAG_LOADING;var f=this.config.progressive,g;return g=f&&o?o.then(function(t){return!t||n.fragContextChanged(null==t?void 0:t.frag)?null:n.fragmentLoader.load(e,r)}).catch(function(e){return n.handleFragLoadError(e)}):Promise.all([this.fragmentLoader.load(e,f?r:void 0),o]).then(function(e){var t=e[0];return!f&&t&&r&&r(t),t}).catch(function(e){return n.handleFragLoadError(e)}),this.hls.trigger(En.FRAG_LOADING,{frag:e,targetBufferTime:a}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g},a.doFragPartsLoad=function(e,t,a,r){var n=this;return new Promise(function(i,d){var o=[],s=null==(l=a.details)?void 0:l.partList,l;(function t(l){n.fragmentLoader.loadPart(e,l,r).then(function(r){o[l.index]=r;var d=r.part;n.hls.trigger(En.FRAG_LOADED,r);var u=mt(a,e.sn,l.index+1)||pt(s,e.sn,l.index+1);return u?void t(u):i({frag:e,part:d,partsLoaded:o})}).catch(d)})(t)})},a.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===Ln.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(En.ERROR,t)}else this.hls.trigger(En.ERROR,{type:Sn.OTHER_ERROR,details:Ln.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},a._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(!t||this.state!==$i.PARSING)return void(this.fragCurrent||this.state===$i.STOPPED||this.state===$i.ERROR||(this.state=$i.IDLE));var a=t.frag,r=t.part,n=t.level,i=self.performance.now();a.stats.parsing.end=i,r&&(r.stats.parsing.end=i),this.updateLevelTiming(a,r,n,e.partial)},a.getCurrentContext=function(e){var t=this.levels,a=this.fragCurrent,r=e.level,n=e.sn,i=e.part;if(!(null!=t&&t[r]))return this.warn("Levels object was unset while buffering fragment "+n+" of level "+r+". The current chunk will not be buffered."),null;var d=t[r],o=-1<i?mt(d,n,i):null,s=o?o.fragment:gt(d,n,a);return s?(a&&a!==s&&(s.stats=a.stats),{frag:s,part:o,level:d}):null},a.bufferFragmentData=function(e,t,a,r,n){var i;if(e&&this.state===$i.PARSING){var d=e.data1,o=e.data2,s=d;if(d&&o&&(s=de(d,o)),!!(null!=(i=s)&&i.length)){var l={type:e.type,frag:t,part:a,chunkMeta:r,parent:t.type,data:s};if(this.hls.trigger(En.BUFFER_APPENDING,l),e.dropped&&e.independent&&!a){if(n)return;this.flushBufferGap(t)}}}},a.flushBufferGap=function(e){var t=this.media;if(t){if(!Hi.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);var a=t.currentTime,r=Hi.bufferInfo(t,a,0),n=e.duration,i=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),d=Math.max(Math.min(e.start-i,r.end-i),a+i);e.start-d>i&&this.flushMainBuffer(d,e.start)}},a.getFwdBufferInfo=function(e,t){var a=this.getLoadPosition();return yn(a)?this.getFwdBufferInfoAtPos(e,a,t):null},a.getFwdBufferInfoAtPos=function(e,t,a){var r=this.config.maxBufferHole,n=Hi.bufferInfo(e,t,r);if(0===n.len&&void 0!==n.nextStart){var i=this.fragmentTracker.getBufferedFrag(t,a);if(i&&n.nextStart<i.end)return Hi.bufferInfo(e,t,Math.max(n.nextStart,r))}return n},a.getMaxBufferLength=function(e){var t=this.config,a;return a=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(a,t.maxMaxBufferLength)},a.reduceMaxBufferLength=function(e){var t=this.config,a=e||t.maxBufferLength;return!!(t.maxMaxBufferLength>=a)&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},a.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,hi.MAIN);return t&&"fragment"in t?t.fragment:t},a.getNextFragment=function(e,t){var a=t.fragments,r=a.length;if(!r)return null;var n=this.config,i=a[0].start,d;if(t.live){var o=n.initialLiveManifestSize;if(r<o)return this.warn("Not enough fragments to start playback (have: "+r+", need: "+o+")"),null;(t.PTSKnown||this.startFragRequested||-1!==this.startPosition)&&!(e<i)||(d=this.getInitialLiveFragment(t,a),this.startPosition=this.nextLoadPosition=d?this.hls.liveSyncPosition||d.start:e)}else e<=i&&(d=a[0]);if(!d){var s=n.lowLatencyMode?t.partEnd:t.fragmentEnd;d=this.getFragmentAtPosition(e,s,t)}return this.mapToInitFragWhenRequired(d)},a.isLoopLoading=function(e,t){var a=this.fragmentTracker.getState(e);return(a===Ui.OK||a===Ui.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t},a.getNextFragmentLoopLoading=function(e,t,a,r,n){var i=e.gap,d=this.getNextFragment(this.nextLoadPosition,t);if(null===d)return d;if(e=d,i&&e&&!e.gap&&a.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,a.nextStart,r);if(null!==o&&a.len+o.len>=n)return this.log("buffer full after gaps in \""+r+"\" playlist starting at sn: "+e.sn),null}return e},a.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},a.getNextPart=function(e,t,a){for(var r=-1,n=!1,d=!0,o=0,s=e.length,l,u;o<s&&(l=e[o],d=d&&!l.independent,!(-1<r&&a<l.start));o++)u=l.loaded,u?r=-1:(n||l.independent||d)&&l.fragment===t&&(r=o),n=u;return r},a.loadedEndOfParts=function(e,t){var a=e[e.length-1];return a&&t>a.start&&a.loaded},a.getInitialLiveFragment=function(e,t){var a=this.fragPrevious,r=null;if(!a){var n=this.hls.liveSyncPosition;null!==n&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}else if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),r=At(t,a.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){var i=a.sn+1;if(i>=e.startSN&&i<=e.endSN){var d=t[i-e.startSN];a.cc===d.cc&&(r=d,this.log("Live playlist, switching playlist, load frag with next SN: "+r.sn))}r||(r=kt(t,a.cc),r&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn))}return r},a.getFragmentAtPosition=function(e,t,a){var r=this.config,n=this.fragPrevious,i=a.fragments,d=a.endSN,o=a.fragmentHint,s=r.maxFragLookUpTolerance,l=a.partList,u=!!(r.lowLatencyMode&&null!=l&&l.length&&o);u&&o&&!this.bitrateTest&&(i=i.concat(o),d=o.sn);var c;if(e<t){var f=e>t-s?0:s;c=vt(n,i,e,f)}else c=i[i.length-1];if(c){var g=c.sn-a.startSN,m=this.fragmentTracker.getState(c);if((m===Ui.OK||m===Ui.PARTIAL&&c.gap)&&(n=c),n&&c.sn===n.sn&&(!u||l[0].fragment.sn>c.sn)){var p=n&&c.level===n.level;if(p){var y=i[g+1];c=c.sn<d&&this.fragmentTracker.getState(y)!==Ui.OK?y:null}}}return c},a.synchronizeToLiveEdge=function(e){var t=this.config,a=this.media;if(a){var r=this.hls.liveSyncPosition,n=a.currentTime,i=e.fragments[0].start,d=e.edge,o=n>=i-t.maxFragLookUpTolerance&&n<=d;if(null!==r&&a.duration>r&&(n<r||!o)){var s=void 0===t.liveMaxLatencyDuration?t.liveMaxLatencyDurationCount*e.targetduration:t.liveMaxLatencyDuration;(!o&&4>a.readyState||n<d-s)&&(!this.loadedmetadata&&(this.nextLoadPosition=r),a.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+r.toFixed(3)),a.currentTime=r))}}},a.alignPlaylists=function(e,t,a){var r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;var n=e.fragments[0].start,i=e.alignedSliding&&yn(n);if(!t||!i&&!n){var d=this.fragPrevious;Zt(d,a,e);var o=e.fragments[0].start;return this.log("Live playlist sliding: "+o.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(d?d.sn:"na")+" fragments: "+r),o}return n},a.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},a.setStartPosition=function(e,t){var a=this.startPosition;if(a<t&&(a=-1),-1===a||-1===this.lastCurrentTime){var r=null!==this.startTimeOffset,n=r?this.startTimeOffset:e.startTimeOffset;null!==n&&yn(n)?(a=t+n,0>n&&(a+=e.totalduration),a=Math.min(Math.max(t,a),t+e.totalduration),this.log("Start time offset "+n+" found in "+(r?"multivariant":"media")+" playlist, adjust startPosition to "+a),this.startPosition=a):e.live?a=this.hls.liveSyncPosition||t:this.startPosition=a=0,this.lastCurrentTime=a}this.nextLoadPosition=a},a.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},a.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},a.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===$i.FRAG_LOADING_WAITING_RETRY)||(this.state=$i.IDLE)},a.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var a=this.getCurrentContext(t.chunkMeta);a&&(t.frag=a.frag)}var r=t.frag;if(r&&r.type===e&&this.levels){if(this.fragContextChanged(r)){var n;return void this.warn("Frag load error must match current frag to retry "+r.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}var i=t.details===Ln.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(r,!0);var d=t.errorAction,o=d||{},s=o.action,l=o.retryCount,u=void 0===l?0:l,c=o.retryConfig;if(d&&s===Ci.RetryRequest&&c){this.resetStartWhenNotLoaded(this.levelLastLoaded);var f=Et(c,u);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" errored with "+t.details+", retrying loading "+(u+1)+"/"+c.maxNumRetry+" in "+f+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+f,this.state=$i.FRAG_LOADING_WAITING_RETRY}else if(!(c&&d))this.state=(null==d?void 0:d.action)===Ci.SendAlternateToPenaltyBox?$i.WAITING_LEVEL:$i.ERROR;else if(this.resetFragmentErrors(e),u<c.maxNumRetry)i||s===Ci.RemoveAlternatePermanently||(d.resolved=!0);else return void In.warn(t.details+" reached or exceeded max retry ("+u+")");this.tickImmediate()}},a.reduceLengthAndFlushBuffer=function(e){if(this.state===$i.PARSING||this.state===$i.PARSED){var t=e.parent,a=this.getFwdBufferInfo(this.mediaBuffer,t),r=a&&.5<a.len;r&&this.reduceMaxBufferLength(a.len);var n=!r;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+t+" buffer"),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1},a.resetFragmentErrors=function(e){e===hi.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==$i.STOPPED&&(this.state=$i.IDLE)},a.afterBufferFlushed=function(e,t,a){if(e){var r=Hi.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,a),this.state===$i.ENDED&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=$i.IDLE},a.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},a.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},a.updateLevelTiming=function(e,t,a,r){var n=this,i=a.details,d;if(!i)return void this.warn("level.details undefined");var o=Object.keys(e.elementaryStreams).reduce(function(t,d){var o=e.elementaryStreams[d];if(o){var s=o.endPTS-o.startPTS;if(0>=s)return n.warn("Could not parse fragment "+e.sn+" "+d+" duration reliably ("+s+")"),t||!1;var l=r?0:it(i,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(En.LEVEL_PTS_UPDATED,{details:i,level:a,drift:l,type:d,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1);if(!o&&null===(null==(d=this.transmuxer)?void 0:d.error)){var s=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===a.fragmentError&&(a.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(s.message),this.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:"Found no media in msn "+e.sn+" of level \""+a.url+"\""}),!this.hls)return;this.resetTransmuxer()}this.state=$i.PARSED,this.hls.trigger(En.FRAG_PARSED,{frag:e,part:t})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},a.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(Bi),ed=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e=this.chunks,t=this.dataLength,a;return e.length?(a=1===e.length?e[0]:ra(e,t),this.reset(),a):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}(),td=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(){return!1},t.appendFrame=function(){},t.demux=function(e,t){this.cachedData&&(e=de(this.cachedData,e),this.cachedData=null);var a=Hn(e,0),r=a?a.length:0,n=this._audioTrack,i=this._id3Track,d=a?Wn(a):void 0,o=e.length,s;for((null===this.basePTS||0===this.frameIndex&&yn(d))&&(this.basePTS=ad(d,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),a&&0<a.length&&i.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:Ei.audioId3,duration:Number.POSITIVE_INFINITY});r<o;){if(this.canParse(e,r)){var l=this.appendFrame(n,e,r);l?(this.frameIndex++,this.lastPTS=l.sample.pts,r+=l.length,s=r):r=o}else Yn(e,r)?(a=Hn(e,r),i.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:Ei.audioId3,duration:Number.POSITIVE_INFINITY}),r+=a.length,s=r):r++;if(r===o&&s!==o){var u=B(e,s);this.cachedData=this.cachedData?de(this.cachedData,u):u}}return{audioTrack:n,videoTrack:na(),id3Track:i,textTrack:na()}},t.demuxSampleAes=function(){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:na(),id3Track:this._id3Track,textTrack:na()}},t.destroy=function(){},e}(),ad=function(e,t,a){if(yn(e))return 90*e;var r=a?9e4*a.baseTime/a.timescale:0;return 9e4*t+r},rd=null,nd=[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],id=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],dd=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],od=[0,1,1,4],sd=function(e){function t(t,a){var r;return r=e.call(this)||this,r.observer=void 0,r.config=void 0,r.observer=t,r.config=a,r}c(t,e);var a=t.prototype;return a.resetInitSegment=function(t,a,r,n){e.prototype.resetInitSegment.call(this,t,a,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:a,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=Hn(e,0),a=(null==t?void 0:t.length)||0;if(Ra(e,a))return!1;for(var r=e.length;a<r;a++)if(fa(e,a))return In.log("ADTS sync word found !"),!0;return!1},a.canParse=function(e,t){return ca(e,t)},a.appendFrame=function(e,t,a){ga(e,this.observer,t,a,e.manifestCodec);var r=ya(e,t,a,this.basePTS,this.frameIndex);if(r&&0===r.missing)return r},t}(td),ld=function(){function e(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}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,a,r){var n=this.videoTrack=na("video",1),i=this.audioTrack=na("audio",1),d=this.txtTrack=na("text",1);if(this.id3Track=na("id3",1),this.timeOffset=0,!!(null!=e&&e.byteLength)){var o=X(e);if(o.video){var s=o.video,l=s.id,u=s.timescale,c=s.codec;n.id=l,n.timescale=d.timescale=u,n.codec=c}if(o.audio){var f=o.audio,g=f.id,m=f.timescale,p=f.codec;i.id=g,i.timescale=m,i.codec=p}d.id=ni.text,n.sampleDuration=0,n.duration=i.duration=r}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return W(e)},t.demux=function(e,t){this.timeOffset=t;var a=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(a=de(this.remainderData,e));var i=ie(a);this.remainderData=i.remainder,r.samples=i.valid||new Uint8Array}else r.samples=a;var d=this.extractID3Track(r,t);return n.samples=oe(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:d,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,a=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var r=this.extractID3Track(t,this.timeOffset);return a.samples=oe(e,t),{videoTrack:t,audioTrack:na(),id3Track:r,textTrack:na()}},t.extractID3Track=function(e,t){var a=this.id3Track;if(e.samples.length){var r=q(e.samples,["emsg"]);r&&r.forEach(function(e){var r=fe(e);if(/\/emsg[-/]ID3/i.test(r.schemeIdUri)){var n=yn(r.presentationTime)?r.presentationTime/r.timeScale:t+r.presentationTimeDelta/r.timeScale,i=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;.001>=i&&(i=Number.POSITIVE_INFINITY);var d=r.payload;a.samples.push({data:d,len:d.byteLength,dts:n,pts:n,type:Ei.emsg,duration:i})}})}return a},t.demuxSampleAes=function(){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),ud=function(e,t){var a=0,r=5;t+=r;for(var n=new Uint32Array(1),i=new Uint32Array(1),d=new Uint8Array(1);0<r;){d[0]=e[t];var o=Math.min(r,8),s=8-o;i[0]=4278190080>>>24+s<<s,n[0]=(d[0]&i[0])>>s,a=a?a<<o|n[0]:n[0],t+=1,r-=o}return a},cd=function(e){function t(t){var a;return a=e.call(this)||this,a.observer=void 0,a.observer=t,a}c(t,e);var a=t.prototype;return a.resetInitSegment=function(t,a,r,n){e.prototype.resetInitSegment.call(this,t,a,r,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:a,duration:n,inputTimeScale:9e4,dropped:0}},a.canParse=function(e,t){return t+64<e.length},a.appendFrame=function(e,t,a){var r=Aa(e,t,a,this.basePTS,this.frameIndex);if(-1!==r){var n=e.samples[e.samples.length-1];return{sample:n,length:r,missing:0}}},t.probe=function(e){if(!e)return!1;var t=Hn(e,0);if(!t)return!1;var a=t.length;return!!(11===e[a]&&119===e[a+1]&&void 0!==Wn(t)&&16>ud(e,a))},t}(td),fd=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,a,r){return{key:e,frame:!1,pts:t,dts:a,units:[],debug:r,length:0}},t.getLastNalUnit=function(e){var t=this.VideoSample,a,r;if(t&&0!==t.units.length||(t=e[e.length-1]),null!=(a=t)&&a.units){var n=t.units;r=n[n.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var a=t.samples,r=a.length;if(r){var n=a[r-1];e.pts=n.pts,e.dts=n.dts}else return void t.dropped++}t.samples.push(e)}e.debug.length&&In.log(e.pts+"/"+e.dts+":"+e.debug)},e}(),gd=function(){function e(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}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,a=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");r.set(e.subarray(a,a+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),a=this.word>>>32-t;if(32<e&&In.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable)this.word<<=t;else if(0<this.bytesAvailable)this.loadWord();else throw new Error("no bits available");return t=e-t,0<t&&this.bitsAvailable?a<<t|this.readBits(t):a},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,a=8,r=0,n;r<e;r++)0!==a&&(n=this.readEG(),a=(t+n+256)%256),t=0===a?t:a},t.readSPS=function(){var e=0,t=0,a=0,r=0,n=this.readUByte.bind(this),d=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),l=this.skipBits.bind(this),u=this.skipEG.bind(this),c=this.skipUEG.bind(this),f=this.skipScalingList.bind(this),g,m,p;n();var y=n();if(d(5),l(3),n(),c(),100===y||110===y||122===y||244===y||44===y||83===y||86===y||118===y||128===y){var h=o();if(3===h&&l(1),c(),c(),l(1),s())for(m=3===h?12:8,p=0;p<m;p++)s()&&(6>p?f(16):f(64))}c();var T=o();if(0===T)o();else if(1===T)for(l(1),u(),u(),g=o(),p=0;p<g;p++)u();c(),l(1);var E=o(),S=o(),L=d(1);0===L&&l(1),l(1),s()&&(e=o(),t=o(),a=o(),r=o());var R=[1,1];if(s()&&s()){var A=n();switch(A){case 1:R=[1,1];break;case 2:R=[12,11];break;case 3:R=[10,11];break;case 4:R=[16,11];break;case 5:R=[40,33];break;case 6:R=[24,11];break;case 7:R=[20,11];break;case 8:R=[32,11];break;case 9:R=[80,33];break;case 10:R=[18,11];break;case 11:R=[15,11];break;case 12:R=[64,33];break;case 13:R=[160,99];break;case 14:R=[4,3];break;case 15:R=[3,2];break;case 16:R=[2,1];break;case 255:{R=[n()<<8|n(),n()<<8|n()];break}}}return{width:Math.ceil(16*(E+1)-2*e-2*t),height:16*((2-L)*(S+1))-(L?2:4)*(a+r),pixelRatio:R}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),md=function(e){function t(){return e.apply(this,arguments)||this}c(t,e);var a=t.prototype;return a.parseAVCPES=function(e,t,a,r,n){var d=this,o=this.parseAVCNALu(e,a.data),s=this.VideoSample,l=!1,u;a.data=null,s&&o.length&&!e.audFound&&(this.pushAccessUnit(s,e),s=this.VideoSample=this.createVideoSample(!1,a.pts,a.dts,"")),o.forEach(function(r){var o;switch(r.type){case 1:{var c=!1;u=!0;var f=r.data;if(l&&4<f.length){var g=new gd(f).readSliceType();(2===g||4===g||7===g||9===g)&&(c=!0)}if(c){var m;null!=(m=s)&&m.frame&&!s.key&&(d.pushAccessUnit(s,e),s=d.VideoSample=null)}s||(s=d.VideoSample=d.createVideoSample(!0,a.pts,a.dts,"")),s.frame=!0,s.key=c;break}case 5:u=!0,null!=(o=s)&&o.frame&&!s.key&&(d.pushAccessUnit(s,e),s=d.VideoSample=null),s||(s=d.VideoSample=d.createVideoSample(!0,a.pts,a.dts,"")),s.key=!0,s.frame=!0;break;case 6:{u=!0,ue(r.data,1,a.pts,t.samples);break}case 7:{var p,y;u=!0,l=!0;var T=r.data,E=new gd(T),S=E.readSPS();if(!e.sps||e.width!==S.width||e.height!==S.height||(null==(p=e.pixelRatio)?void 0:p[0])!==S.pixelRatio[0]||(null==(y=e.pixelRatio)?void 0:y[1])!==S.pixelRatio[1]){e.width=S.width,e.height=S.height,e.pixelRatio=S.pixelRatio,e.sps=[T],e.duration=n;for(var L=T.subarray(1,4),R="avc1.",A=0,v;3>A;A++)v=L[A].toString(16),2>v.length&&(v="0"+v),R+=v;e.codec=R}break}case 8:u=!0,e.pps=[r.data];break;case 9:u=!0,e.audFound=!0,s&&d.pushAccessUnit(s,e),s=d.VideoSample=d.createVideoSample(!1,a.pts,a.dts,"");break;case 12:u=!0;break;default:u=!1,s&&(s.debug+="unknown NAL "+r.type+" ");}if(s&&u){var I=s.units;I.push(r)}}),r&&s&&(this.pushAccessUnit(s,e),this.VideoSample=null)},a.parseAVCNALu=function(e,t){var a=t.byteLength,r=e.naluState||0,n=r,d=[],o=0,s=-1,l=0,u,c,f;for(-1===r&&(s=0,l=31&t[0],r=0,o=1);o<a;){if(u=t[o++],!r){r=u?0:1;continue}if(1===r){r=u?0:2;continue}if(!u)r=3;else if(1===u){if(c=o-r-1,0<=s){var g={data:t.subarray(s,c),type:l};d.push(g)}else{var m=this.getLastNalUnit(e.samples);m&&(n&&o<=4-n&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-n)),0<c&&(m.data=de(m.data,t.subarray(0,c)),m.state=0))}o<a?(f=31&t[o],s=o,l=f,r=0):r=-1}else r=0}if(0<=s&&0<=r){var p={data:t.subarray(s,a),type:l,state:r};d.push(p)}if(0===d.length){var y=this.getLastNalUnit(e.samples);y&&(y.data=de(y.data,t))}return e.naluState=r,d},t}(fd),pd=function(){function e(e,t,a){this.keyData=void 0,this.decrypter=void 0,this.keyData=a,this.decrypter=new Qi(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},t.decryptAacSample=function(e,t,a){var r=this,n=e[t].unit;if(!(16>=n.length)){var i=n.subarray(16,n.length-n.length%16),d=i.buffer.slice(i.byteOffset,i.byteOffset+i.length);this.decryptBuffer(d).then(function(i){var d=new Uint8Array(i);n.set(d,16),r.decrypter.isSync()||r.decryptAacSamples(e,t+1,a)})}},t.decryptAacSamples=function(e,t,a){for(;;t++){if(t>=e.length)return void a();if(!(32>e[t].unit.length)&&(this.decryptAacSample(e,t,a),!this.decrypter.isSync()))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,a=new Int8Array(t),r=0,n=32;n<e.length-16;n+=160,r+=16)a.set(e.subarray(n,n+16),r);return a},t.getAvcDecryptedUnit=function(e,t){for(var a=new Uint8Array(t),r=0,n=32;n<e.length-16;n+=160,r+=16)e.set(a.subarray(r,r+16),n);return e},t.decryptAvcSample=function(e,t,a,r,n){var i=this,d=ce(n.data),o=this.getAvcEncryptedData(d);this.decryptBuffer(o.buffer).then(function(o){n.data=i.getAvcDecryptedUnit(d,o),i.decrypter.isSync()||i.decryptAvcSamples(e,t,a+1,r)})},t.decryptAvcSamples=function(e,t,a,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,a=0){if(t>=e.length)return void r();for(var n=e[t].units;;a++){if(a>=n.length)break;var i=n[a];if(!(48>=i.data.length||1!==i.type&&5!==i.type)&&(this.decryptAvcSample(e,t,a,r,i),!this.decrypter.isSync()))return}}},e}(),yd=188,hd=function(){function e(e,t,a){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=a,this.videoParser=new md}e.probe=function(t){var a=e.syncOffset(t);return 0<a&&In.warn("MPEG2-TS detected but first sync word found @ offset "+a),-1!==a},e.syncOffset=function(e){for(var t=e.length,a=Math.min(5*yd,t-yd)+1,r=0;r<a;){for(var n=!1,d=-1,o=0,s=r;s<t;s+=yd)if(71!==e[s]||t-s!==yd&&71!==e[s+yd]){if(o)return-1;break}else if(o++,-1===d&&(d=s,0!==d&&(a=Math.min(d+99*yd,e.length-yd)+1)),n||(n=0===va(e,s)),n&&1<o&&(0===d&&2<o||s+yd>a))return d;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:ni[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,a,r,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=a,this.videoCodec=r,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,a=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),a&&(a.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,a,r,n){void 0===r&&(r=!1),void 0===n&&(n=!1),r||(this.sampleAes=null);var i=this._videoTrack,d=this._audioTrack,o=this._id3Track,s=this._txtTrack,l=i.pid,u=i.pesData,c=d.pid,f=o.pid,g=d.pesData,m=o.pesData,p=null,y=this.pmtParsed,h=this._pmtId,T=t.length,E;if(this.remainderData&&(t=de(this.remainderData,t),T=t.length,this.remainderData=null),T<yd&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:i,id3Track:o,textTrack:s};var S=Math.max(0,e.syncOffset(t));T-=(T-S)%yd,T<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,T,t.buffer.byteLength-T));for(var L=0,R=S;R<T;R+=yd)if(71===t[R]){var A=!!(64&t[R+1]),v=va(t,R),I=(48&t[R+3])>>4,D=void 0;if(!(1<I))D=R+4;else if(D=R+5+t[R+4],D===R+yd)continue;switch(v){case l:A&&(u&&(E=_a(u))&&this.videoParser.parseAVCPES(i,s,E,!1,this._duration),u={data:[],size:0}),u&&(u.data.push(t.subarray(D,R+yd)),u.size+=R+yd-D);break;case c:if(A){if(g&&(E=_a(g)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,E);break;case"mp3":this.parseMPEGPES(d,E);break;case"ac3":this.parseAC3PES(d,E);}g={data:[],size:0}}g&&(g.data.push(t.subarray(D,R+yd)),g.size+=R+yd-D);break;case f:A&&(m&&(E=_a(m))&&this.parseID3PES(o,E),m={data:[],size:0}),m&&(m.data.push(t.subarray(D,R+yd)),m.size+=R+yd-D);break;case 0:A&&(D+=t[D]+1),h=this._pmtId=Ia(t,D);break;case h:{A&&(D+=t[D]+1);var k=Da(t,D,this.typeSupported,r);l=k.videoPid,0<l&&(i.pid=l,i.segmentCodec=k.segmentVideoCodec),c=k.audioPid,0<c&&(d.pid=c,d.segmentCodec=k.segmentAudioCodec),f=k.id3Pid,0<f&&(o.pid=f),null===p||y||(In.warn("MPEG-TS PMT found at "+R+" after unknown PID '"+p+"'. Backtracking to sync byte @"+S+" to parse all TS packets."),p=null,R=S-188),y=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=v;}}else L++;if(0<L){var _=new Error("Found "+L+" TS packet/s that do not start with 0x47");this.observer.emit(En.ERROR,En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,fatal:!1,error:_,reason:_.message})}i.pesData=u,d.pesData=g,o.pesData=m;var C={audioTrack:d,videoTrack:i,id3Track:o,textTrack:s};return n&&this.extractRemainingSamples(C),C},t.flush=function(){var e=this.remainderData;this.remainderData=null;var t;return t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},t.extractRemainingSamples=function(e){var t=e.audioTrack,a=e.videoTrack,r=e.id3Track,n=e.textTrack,i=a.pesData,d=t.pesData,o=r.pesData,s;if(i&&(s=_a(i))?(this.videoParser.parseAVCPES(a,n,s,!0,this._duration),a.pesData=null):a.pesData=i,d&&(s=_a(d))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,s);break;case"mp3":this.parseMPEGPES(t,s);break;case"ac3":this.parseAC3PES(t,s);}t.pesData=null}else null!=d&&d.size&&In.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=d;o&&(s=_a(o))?(this.parseID3PES(r,s),r.pesData=null):r.pesData=o},t.demuxSampleAes=function(e,t,a){var r=this.demux(e,a,!0,!this.config.progressive),n=this.sampleAes=new pd(this.observer,this.config,t);return this.decrypt(r,n)},t.decrypt=function(e,t){return new Promise(function(a){var r=e.audioTrack,n=e.videoTrack;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,function(){n.samples?t.decryptAvcSamples(n.samples,0,0,function(){a(e)}):a(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,function(){a(e)})})},t.destroy=function(){this._duration=0},t.parseAACPES=function(e,t){var a=0,r=this.aacOverFlow,n=t.data;if(r){this.aacOverFlow=null;var i=r.missing,d=r.sample.unit.byteLength;if(-1===i)n=de(r.sample.unit,n);else{r.sample.unit.set(n.subarray(0,i),d-i),e.samples.push(r.sample),a=r.missing}}var o,s;for(o=a,s=n.length;o<s-1&&!ua(n,o);o++);if(o!==a){var l=o<s-1,u;u=l?"AAC PES did not start with ADTS header,offset:"+o:"No ADTS header found in AAC PES";var c=new Error(u);if(In.warn("parsing error: "+u),this.observer.emit(En.ERROR,En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,fatal:!1,levelRetry:l,error:c,reason:u}),!l)return}ga(e,this.observer,n,o,this.audioCodec);var f;if(void 0!==t.pts)f=t.pts;else if(r){var g=ma(e.samplerate);f=r.sample.pts+g}else return void In.warn("[tsdemuxer]: AAC PES unknown PTS");for(var m=0,p;o<s;)if(p=ya(e,n,o,f,m),o+=p.length,!p.missing)for(m++;o<s-1&&!ua(n,o);o++);else{this.aacOverFlow=p;break}},t.parseMPEGPES=function(e,t){var a=t.data,r=a.length,n=0,i=0,d=t.pts;if(void 0===d)return void In.warn("[tsdemuxer]: MPEG PES unknown PTS");for(;i<r;)if(Sa(a,i)){var o=ha(e,a,i,d,n);if(o)i+=o.length,n++;else break}else i++},t.parseAC3PES=function(e,t){{var a=t.data,r=t.pts;if(void 0===r)return void In.warn("[tsdemuxer]: AC3 PES unknown PTS");for(var n=a.length,i=0,d=0,o;d<n&&0<(o=Aa(e,a,d,r,i++));)d+=o}},t.parseID3PES=function(e,t){if(void 0===t.pts)return void In.warn("[tsdemuxer]: ID3 PES unknown PTS");var a=u({},t,{type:this._videoTrack?Ei.emsg:Ei.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(a)},e}(),Td=function(e){function t(){return e.apply(this,arguments)||this}c(t,e);var a=t.prototype;return a.resetInitSegment=function(t,a,r,n){e.prototype.resetInitSegment.call(this,t,a,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:a,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=Hn(e,0),a=(null==t?void 0:t.length)||0;if(t&&11===e[a]&&119===e[a+1]&&void 0!==Wn(t)&&16>=ud(e,a))return!1;for(var r=e.length;a<r;a++)if(Ra(e,a))return In.log("MPEG Audio sync word found !"),!0;return!1},a.canParse=function(e,t){return La(e,t)},a.appendFrame=function(e,t,a){return null===this.basePTS?void 0:ha(e,t,a,this.basePTS,this.frameIndex)},t}(td),Ed=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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(1===t)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(2===t)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(3===t)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]);}},e}(),Sd=Math.pow(2,32)-1,Ld=function(){function e(){}return e.init=function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};for(var t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var a=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:a,audio:r};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=i,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var d=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,d,s,d,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,a=arguments.length,r=Array(1<a?a-1:0),n=1;n<a;n++)r[n-1]=arguments[n];for(var d=r.length,o=d;d--;)t+=r[d].byteLength;var s=new Uint8Array(t);for(s[0]=255&t>>24,s[1]=255&t>>16,s[2]=255&t>>8,s[3]=255&t,s.set(e,4),(d=0,t=8);d<o;d++)s.set(r[d],t),t+=r[d].byteLength;return s},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,a){a*=t;var r=Math.floor(a/(Sd+1)),n=Math.floor(a%(Sd+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,255&t>>24,255&t>>16,255&t>>8,255&t,r>>24,255&r>>16,255&r>>8,255&r,n>>24,255&n>>16,255&n>>8,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,255&t>>16,255&t>>8,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,a,r){return e.box(e.types.moof,e.mfhd(t),e.traf(r,a))},e.moov=function(t){for(var a=t.length,r=[];a--;)r[a]=e.trak(t[a]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(e.mvex(t)))},e.mvex=function(t){for(var a=t.length,r=[];a--;)r[a]=e.trex(t[a]);return e.box.apply(null,[e.types.mvex].concat(r))},e.mvhd=function(t,a){a*=t;var r=Math.floor(a/(Sd+1)),n=Math.floor(a%(Sd+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,255&t>>24,255&t>>16,255&t>>8,255&t,r>>24,255&r>>16,255&r>>8,255&r,n>>24,255&n>>16,255&n>>8,255&n,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 e.box(e.types.mvhd,i)},e.sdtp=function(t){var a=t.samples||[],r=new Uint8Array(4+a.length),n,d;for(n=0;n<a.length;n++)d=a[n].flags,r[n+4]=d.dependsOn<<4|d.isDependedOn<<2|d.hasRedundancy;return e.box(e.types.sdtp,r)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var a=[],r=[],n,d,o;for(n=0;n<t.sps.length;n++)d=t.sps[n],o=d.byteLength,a.push(255&o>>>8),a.push(255&o),a=a.concat(Array.prototype.slice.call(d));for(n=0;n<t.pps.length;n++)d=t.pps[n],o=d.byteLength,r.push(255&o>>>8),r.push(255&o),r=r.concat(Array.prototype.slice.call(d));var s=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(r))),l=t.width,u=t.height,c=t.pixelRatio[0],f=t.pixelRatio[1];return e.box(e.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,255&l>>8,255&l,255&u>>8,255&u,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]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,255&c>>16,255&c>>8,255&c,f>>24,255&f>>16,255&f>>8,255&f])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.audioStsd=function(e){var t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,255&t>>8,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):"ac3"===t.segmentCodec?e.box(e.types.stsd,e.STSD,e.ac3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var a=t.id,r=t.duration*t.timescale,n=t.width,i=t.height,d=Math.floor(r/(Sd+1)),o=Math.floor(r%(Sd+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,255&a>>24,255&a>>16,255&a>>8,255&a,0,0,0,0,d>>24,255&d>>16,255&d>>8,255&d,o>>24,255&o>>16,255&o>>8,255&o,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,255&n>>8,255&n,0,0,255&i>>8,255&i,0,0]))},e.traf=function(t,a){var r=e.sdtp(t),n=t.id,i=Math.floor(a/(Sd+1)),d=Math.floor(a%(Sd+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,255&n>>16,255&n>>8,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,i>>24,255&i>>16,255&i>>8,255&i,d>>24,255&d>>16,255&d>>8,255&d])),e.trun(t,r.length+16+20+8+16+8+8),r)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var a=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,a>>24,255&a>>16,255&a>>8,255&a,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,a){var r=t.samples||[],n=r.length,d=12+16*n,o=new Uint8Array(d),s,l,u,c,f,g;for(a+=8+d,o.set(["video"===t.type?1:0,0,15,1,255&n>>>24,255&n>>>16,255&n>>>8,255&n,255&a>>>24,255&a>>>16,255&a>>>8,255&a],0),s=0;s<n;s++)l=r[s],u=l.duration,c=l.size,f=l.flags,g=l.cts,o.set([255&u>>>24,255&u>>>16,255&u>>>8,255&u,255&c>>>24,255&c>>>16,255&c>>>8,255&c,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,61440&f.degradPrio,15&f.degradPrio,255&g>>>24,255&g>>>16,255&g>>>8,255&g],12+16*s);return e.box(e.types.trun,o)},e.initSegment=function(t){e.types||e.init();var a=e.moov(t),r=de(e.FTYP,a);return r},e}(),Rd;Ld.types=void 0,Ld.HDLR_TYPES=void 0,Ld.STTS=void 0,Ld.STSC=void 0,Ld.STCO=void 0,Ld.STSZ=void 0,Ld.VMHD=void 0,Ld.SMHD=void 0,Ld.STSD=void 0,Ld.FTYP=void 0,Ld.DINF=void 0;var Ad=1024,vd=null,Id=null,Dd=function(){function e(e,t,a){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=a,this.ISGenerated=!1,null===vd){var r=navigator.userAgent||"",n=r.match(/Chrome\/(\d+)/i);vd=n?parseInt(n[1]):0}if(null===Id){var i=navigator.userAgent.match(/Safari\/(\d+)/i);Id=i?parseInt(i[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){In.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){In.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){In.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,a=e.reduce(function(e,a){var r=a.pts-e;return-4294967296>r?(t=!0,Fa(e,a.pts)):0<r?e:a.pts},e[0].pts);return t&&In.debug("PTS rollover detected"),a},t.remux=function(e,t,a,r,n,i,d,o){var s=n,l=n,u=-1<e.pid,c=-1<t.pid,f=t.samples.length,g=0<e.samples.length,m=d&&0<f||1<f,p=(!u||g)&&(!c||m)||this.ISGenerated||d,y,h,T,E,S,L;if(p){if(this.ISGenerated){var R=this.videoTrackConfig,A,v,I,D;R&&(t.width!==R.width||t.height!==R.height||(null==(A=t.pixelRatio)?void 0:A[0])!==(null==(v=R.pixelRatio)?void 0:v[0])||(null==(I=t.pixelRatio)?void 0:I[1])!==(null==(D=R.pixelRatio)?void 0:D[1]))&&this.resetInitSegment()}else T=this.generateIS(e,t,n,i);var k=this.isVideoContiguous,_=-1,C;if(m&&(_=Oa(t.samples),!k&&this.config.forceKeyFrameOnDiscontinuity))if(L=!0,0<_){In.warn("[mp4-remuxer]: Dropped "+_+" out of "+f+" video samples due to a missing keyframe");var b=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(_),t.dropped+=_,l+=(t.samples[0].pts-b)/t.inputTimeScale,C=l}else-1===_&&(In.warn("[mp4-remuxer]: No keyframe found out of "+f+" video samples"),L=!1);if(this.ISGenerated){if(g&&m){var x=this.getVideoStartPts(t.samples),P=Fa(e.samples[0].pts,x)-x,F=P/t.inputTimeScale;s+=Math.max(0,F),l+=Math.max(0,-F)}if(!g)m&&(y=this.remuxVideo(t,l,k,0));else if(e.samplerate||(In.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),T=this.generateIS(e,t,n,i)),h=this.remuxAudio(e,s,this.isAudioContiguous,i,c||m||o===hi.AUDIO?l:void 0),m){var O=h?h.endPTS-h.startPTS:0;t.inputTimeScale||(In.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),T=this.generateIS(e,t,n,i)),y=this.remuxVideo(t,l,k,O)}y&&(y.firstKeyFrame=_,y.independent=-1!==_,y.firstKeyFramePTS=C)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(a.samples.length&&(S=Na(a,n,this._initPTS,this._initDTS)),r.samples.length&&(E=wa(r,n,this._initPTS))),{audio:h,video:y,initSegment:T,independent:L,text:E,id3:S}},t.generateIS=function(e,t,a,r){var n=e.samples,i=t.samples,d=this.typeSupported,o={},s=this._initPTS,l=!s||r,u="audio/mp4",c,f,g;if(l&&(c=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(u="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";}o.audio={id:"audio",container:u,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):Ld.initSegment([e]),metadata:{channelCount:e.channelCount}},l&&(g=e.inputTimeScale,s&&g===s.timescale?l=!1:c=f=n[0].pts-Math.round(g*a))}if(t.sps&&t.pps&&i.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Ld.initSegment([t]),metadata:{width:t.width,height:t.height}},l)if(g=t.inputTimeScale,!s||g!==s.timescale){var m=this.getVideoStartPts(i),p=Math.round(g*a);f=Math.min(f,Fa(i[0].dts,m)-p),c=Math.min(c,m-p)}else l=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}return Object.keys(o).length?(this.ISGenerated=!0,l?(this._initPTS={baseTime:c,timescale:g},this._initDTS={baseTime:f,timescale:g}):c=g=void 0,{tracks:o,initPTS:c,timescale:g}):void 0},t.remuxVideo=function(e,t,a,r){var n=e.inputTimeScale,d=e.samples,o=[],s=d.length,l=this._initPTS,c=this.nextAvcDts,f=8,g=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,y=!1,h,T;if(!a||null===c){var E=t*n,S=d[0].pts-Fa(d[0].dts,d[0].pts);vd&&null!==c&&15e3>Math.abs(E-S-c)?a=!0:c=E-S}for(var L=l.baseTime*n/l.timescale,R=0,A;R<s;R++)A=d[R],A.pts=Fa(A.pts-L,c),A.dts=Fa(A.dts-L,c),A.dts<d[0<R?R-1:R].dts&&(y=!0);y&&d.sort(function(e,t){var a=e.dts-t.dts,r=e.pts-t.pts;return a||r}),h=d[0].dts,T=d[d.length-1].dts;var v=T-h,I=v?Math.round(v/(s-1)):g||e.inputTimeScale/30;if(a){var D=h-c,k=D>I,_=-1>D;if((k||_)&&(k?In.warn("AVC: "+xa(D,!0)+" ms ("+D+"dts) hole between fragments detected at "+t.toFixed(3)):In.warn("AVC: "+xa(-D,!0)+" ms ("+D+"dts) overlapping between fragments detected at "+t.toFixed(3)),!_||c>=d[0].pts||vd)){h=c;var C=d[0].pts-D;if(k)d[0].dts=h,d[0].pts=C;else for(var b=0;b<d.length&&!(d[b].dts>C);b++)d[b].dts-=D,d[b].pts-=D;In.log("Video: Initial PTS/DTS adjusted: "+xa(C,!0)+"/"+xa(h,!0)+", delta: "+xa(D,!0)+" ms")}}h=Math.max(0,h);for(var x=0,P=0,F=h,O=0;O<s;O++){for(var N=d[O],w=N.units,M=w.length,B=0,U=0;U<M;U++)B+=w[U].data.length;P+=B,x+=M,N.length=B,N.dts<F?(N.dts=F,F+=0|I/4||1):F=N.dts,m=Math.min(N.pts,m),p=Math.max(N.pts,p)}T=d[s-1].dts;var G=P+4*x+8,K;try{K=new Uint8Array(G)}catch(e){return void this.observer.emit(En.ERROR,En.ERROR,{type:Sn.MUX_ERROR,details:Ln.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:G,reason:"fail allocating video mdat "+G})}var H=new DataView(K.buffer);H.setUint32(0,G),K.set(Ld.types.mdat,4);for(var V=!1,Y=Number.POSITIVE_INFINITY,W=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=0;z<s;z++){for(var Q=d[z],Z=Q.units,$=0,J=0,ee=Z.length;J<ee;J++){var te=Z[J],ae=te.data,re=te.data.byteLength;H.setUint32(f,re),f+=4,K.set(ae,f),f+=re,$+=4+re}var ne=void 0;if(z<s-1)g=d[z+1].dts-Q.dts,ne=d[z+1].pts-Q.pts;else{var ie=this.config,de=0<z?Q.dts-d[z-1].dts:I;if(ne=0<z?Q.pts-d[z-1].pts:I,ie.stretchShortVideoTrack&&null!==this.nextAudioPts){var oe=Math.floor(ie.maxBufferHole*n),se=(r?m+r*n:this.nextAudioPts)-Q.pts;se>oe?(g=se-de,0>g?g=de:V=!0,In.log("[mp4-remuxer]: It is approximately "+se/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=de}else g=de}var le=Math.round(Q.pts-Q.dts);Y=Math.min(Y,g),q=Math.max(q,g),W=Math.min(W,ne),X=Math.max(X,ne),o.push(new kd(Q.key,g,$,le))}if(o.length)if(vd){if(70>vd){var ue=o[0].flags;ue.dependsOn=2,ue.isNonSync=0}}else if(Id&&X-W<q-Y&&.025>I/q&&0===o[0].cts){In.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=h,fe=0,ge=o.length;fe<ge;fe++){var me=ce+o[fe].duration,pe=ce+o[fe].cts;if(fe<ge-1){var ye=me+o[fe+1].cts;o[fe].duration=ye-pe}else o[fe].duration=fe?o[fe-1].duration:I;o[fe].cts=0,ce=me}}g=V||!g?I:g,this.nextAvcDts=c=T+g,this.videoSampleDuration=g,this.isVideoContiguous=!0;var he=Ld.moof(e.sequenceNumber++,h,u({},e,{samples:o})),Te={data1:he,data2:K,startPTS:m/n,endPTS:(p+g)/n,startDTS:h/n,endDTS:c/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Te},t.getSamplesPerFrame=function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return Ad;}},t.remuxAudio=function(e,t,a,r,n){var d=e.inputTimeScale,o=e.samplerate?e.samplerate:d,s=d/o,l=this.getSamplesPerFrame(e),c=l*s,f=this._initPTS,g="mp3"===e.segmentCodec&&this.typeSupported.mpeg,m=[],p=void 0!==n,y=e.samples,h=g?0:8,T=this.nextAudioPts||-1,E=t*d,S=f.baseTime*d/f.timescale;if(this.isAudioContiguous=a=a||y.length&&0<T&&(r&&9e3>Math.abs(E-T)||Math.abs(Fa(y[0].pts-S,E)-T)<20*c),y.forEach(function(e){e.pts=Fa(e.pts-S,E)}),!a||0>T){if(y=y.filter(function(e){return 0<=e.pts}),!y.length)return;T=0===n?0:r&&!p?Math.max(0,E):y[0].pts}if("aac"===e.segmentCodec)for(var L=this.config.maxAudioFramesDrift,R=0,A=T;R<y.length;R++){var v=y[R],I=v.pts,D=I-A,k=Math.abs(1e3*D/d);if(D<=-L*c&&p)0===R&&(In.warn("Audio frame @ "+(I/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/d)+" ms."),this.nextAudioPts=T=A=I);else if(D>=L*c&&k<10000&&p){var _=Math.round(D/c);A=I-_*c,0>A&&(_--,A+=c),0===R&&(this.nextAudioPts=T=A),In.warn("[mp4-remuxer]: Injecting "+_+" audio frame @ "+(A/d).toFixed(3)+"s due to "+Math.round(1e3*D/d)+" ms gap.");for(var C=0;C<_;C++){var b=Math.max(A,0),x=Ed.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);x||(In.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),x=v.unit.subarray()),y.splice(R,0,{unit:x,pts:b}),A+=c,R++}}v.pts=A,A+=c}for(var P=null,F=null,O=0,N=y.length,w;N--;)O+=y[N].unit.byteLength;for(var M=0,B=y.length;M<B;M++){var U=y[M],G=U.unit,K=U.pts;if(null!==F){var H=m[M-1];H.duration=Math.round((K-F)/s)}else if(a&&"aac"===e.segmentCodec&&(K=T),P=K,0<O){O+=h;try{w=new Uint8Array(O)}catch(e){return void this.observer.emit(En.ERROR,En.ERROR,{type:Sn.MUX_ERROR,details:Ln.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:O,reason:"fail allocating audio mdat "+O})}if(!g){var V=new DataView(w.buffer);V.setUint32(0,O),w.set(Ld.types.mdat,4)}}else return;w.set(G,h);var Y=G.byteLength;h+=Y,m.push(new kd(!0,l,Y,0)),F=K}var W=m.length;if(W){var q=m[m.length-1];this.nextAudioPts=T=F+s*q.duration;var X=g?new Uint8Array(0):Ld.moof(e.sequenceNumber++,P/s,u({},e,{samples:m}));e.samples=[];var z=P/d,Q=T/d,Z={data1:X,data2:w,startPTS:z,endPTS:Q,startDTS:z,endDTS:Q,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Z}},t.remuxEmptyAudio=function(e,t,a,r){var n=e.inputTimeScale,d=e.samplerate?e.samplerate:n,o=this.nextAudioPts,s=this._initDTS,l=9e4*s.baseTime/s.timescale,u=(null===o?r.startDTS*n:o)+l,c=r.endDTS*n+l,f=n/d*Ad,g=Math.ceil((c-u)/f),m=Ed.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(In.warn("[mp4-remuxer]: remux empty Audio"),!m)return void In.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");for(var p=[],y=0,h;y<g;y++)h=u+y*f,p.push({unit:m,pts:h,dts:h});return e.samples=p,this.remuxAudio(e,t,a,!1)},e}(),kd=function(e,t,a,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=a,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}},_d=function(){function e(){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}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,a,r){this.audioCodec=t,this.videoCodec=a,this.generateInitSegment(J(e,r)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,a=this.videoCodec;if(!(null!=e&&e.byteLength))return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=X(e);r.audio&&(t=Ba(r.audio,bn.AUDIO)),r.video&&(a=Ba(r.video,bn.VIDEO));var n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+a,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:a,initSegment:e,id:"main"}:In.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,a,r,n,i){var d=this.initPTS,o=this.lastEndTime,s={audio:void 0,video:void 0,text:r,id3:a,initSegment:void 0},l,u;yn(o)||(o=this.lastEndTime=n||0);var c=t.samples;if(!(null!=c&&c.length))return s;var f={initPTS:void 0,timescale:1},g=this.initData;if(null!=(l=g)&&l.length||(this.generateInitSegment(c),g=this.initData),!(null!=(u=g)&&u.length))return In.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var m=ae(c,g),p=te(g,c),y=null===p?n:p;(Ma(d,y,n,m)||f.timescale!==d.timescale&&i)&&(f.initPTS=y-n,d&&1===d.timescale&&In.warn("Adjusting initPTS by "+(f.initPTS-d.baseTime)),this.initPTS=d={baseTime:f.initPTS,timescale:1});var h=e?y-d.baseTime/d.timescale:o,T=h+m;ne(g,c,d.baseTime/d.timescale),0<m?this.lastEndTime=T:(In.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!g.audio,S=!!g.video,L="";E&&(L+="audio"),S&&(L+="video");var R={data1:c,startPTS:h,startDTS:h,endPTS:T,endDTS:T,type:L,hasAudio:E,hasVideo:S,nb:1,dropped:0};return s.audio="audio"===R.type?R:void 0,s.video="audio"===R.type?void 0:R,s.initSegment=f,s.id3=Na(a,n,d,d),r.samples.length&&(s.text=wa(r,n,d)),s},e}(),Cd;try{Cd=self.performance.now.bind(self.performance)}catch(e){In.debug("Unable to use Performance API on this environment"),Cd=null==Nn?void 0:Nn.Date.now}var bd=[{demux:ld,remux:_d},{demux:hd,remux:Dd},{demux:sd,remux:Dd},{demux:Td,remux:Dd}];bd.splice(2,0,{demux:cd,remux:Dd});var xd=function(){function e(e,t,a,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=a,this.vendor=r,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,a,r){var n=this,i=a.transmuxing;i.executeStart=Cd();var d=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;r&&(this.currentTransmuxState=r);var l=r||o,u=l.contiguous,c=l.discontinuity,f=l.trackSwitch,g=l.accurateTimeOffset,m=l.timeOffset,p=l.initSegmentChange,y=s.audioCodec,h=s.videoCodec,T=s.defaultInitPts,E=s.duration,S=s.initSegmentData,L=Ua(d,t);if(L&&"AES-128"===L.method){var R=this.getDecrypter();if(R.isSync()){var A=R.softwareDecrypt(d,L.key.buffer,L.iv.buffer),v=-1<a.part;if(v&&(A=R.flush()),!A)return i.executeEnd=Cd(),Pd(a);d=new Uint8Array(A)}else return this.decryptionPromise=R.webCryptoDecrypt(d,L.key.buffer,L.iv.buffer).then(function(e){var t=n.push(e,null,a);return n.decryptionPromise=null,t}),this.decryptionPromise}var I=this.needsProbing(c,f);if(I){var D=this.configureTransmuxer(d);if(D)return In.warn("[transmuxer] "+D.message),this.observer.emit(En.ERROR,En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),i.executeEnd=Cd(),Pd(a)}(c||f||p||I)&&this.resetInitSegment(S,y,h,E,t),(c||p||I)&&this.resetInitialTimestamp(T),u||this.resetContiguity();var k=this.transmux(d,L,m,g,a),_=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,i.executeEnd=Cd(),k},t.flush=function(e){var t=this,a=e.transmuxing;a.executeStart=Cd();var r=this.decrypter,n=this.currentTransmuxState,i=this.decryptionPromise;if(i)return i.then(function(){return t.flush(e)});var d=[],o=n.timeOffset;if(r){var s=r.flush();s&&d.push(this.push(s,null,e))}var l=this.demuxer,u=this.remuxer;if(!l||!u)return a.executeEnd=Cd(),[Pd(e)];var c=l.flush(o);return Ga(c)?c.then(function(a){return t.flushRemux(d,a,e),d}):(this.flushRemux(d,c,e),d)},t.flushRemux=function(e,t,a){var r=t.audioTrack,n=t.videoTrack,i=t.id3Track,d=t.textTrack,o=this.currentTransmuxState,s=o.accurateTimeOffset,l=o.timeOffset;In.log("[transmuxer.ts]: Flushed fragment "+a.sn+(-1<a.part?" p: "+a.part:"")+" of level "+a.level);var u=this.remuxer.remux(r,n,i,d,l,s,!0,this.id);e.push({remuxResult:u,chunkMeta:a}),a.transmuxing.executeEnd=Cd()},t.resetInitialTimestamp=function(e){var t=this.demuxer,a=this.remuxer;t&&a&&(t.resetTimeStamp(e),a.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,a,r,n){var i=this.demuxer,d=this.remuxer;i&&d&&(i.resetInitSegment(e,t,a,r),d.resetInitSegment(e,t,a,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,a,r,n){var i;return i=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,a,r,n):this.transmuxUnencrypted(e,a,r,n),i},t.transmuxUnencrypted=function(e,t,a,r){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),i=n.audioTrack,d=n.videoTrack,o=n.id3Track,s=n.textTrack,l=this.remuxer.remux(i,d,o,s,t,a,!1,this.id);return{remuxResult:l,chunkMeta:r}},t.transmuxSampleAes=function(e,t,a,r,n){var i=this;return this.demuxer.demuxSampleAes(e,t,a).then(function(e){var t=i.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,a,r,!1,i.id);return{remuxResult:t,chunkMeta:n}})},t.configureTransmuxer=function(e){for(var t=this.config,a=this.observer,r=this.typeSupported,n=this.vendor,d=0,o=bd.length,s;d<o;d++){var l;if(null!=(l=bd[d].demux)&&l.probe(e)){s=bd[d];break}}if(!s)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,c=this.remuxer,f=s.remux,g=s.demux;c&&c instanceof f||(this.remuxer=new f(a,t,r,n)),u&&u instanceof g||(this.demuxer=new g(a,t,r),this.probe=g.probe)},t.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Qi(this.config)),e},e}(),Pd=function(e){return{remuxResult:{},chunkMeta:e}},Fd=function(e,t,a,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=a,this.duration=r,this.defaultInitPts=n||null},Od=function(e,t,a,r,n,i){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=a,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=i},Nd={exports:{}};(function(e){function t(){}function a(e,t,a){this.fn=e,this.context=t,this.once=a||!1}function r(e,t,r,n,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var d=new a(r,n||e,i),s=o?o+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],d]:e._events[s].push(d):(e._events[s]=d,e._eventsCount++),e}function n(e,a){0==--e._eventsCount?e._events=new t:delete e._events[a]}function i(){this._events=new t,this._eventsCount=0}var d=Object.prototype.hasOwnProperty,o="~";Object.create&&(t.prototype=Object.create(null),!new t().__proto__&&(o=!1)),i.prototype.eventNames=function(){var e=[],t,a;if(0===this._eventsCount)return e;for(a in t=this._events)d.call(t,a)&&e.push(o?a.slice(1):a);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},i.prototype.listeners=function(e){var t=o?o+e:e,a=this._events[t];if(!a)return[];if(a.fn)return[a.fn];for(var r=0,n=a.length,d=Array(n);r<n;r++)d[r]=a[r].fn;return d},i.prototype.listenerCount=function(e){var t=o?o+e:e,a=this._events[t];return a?a.fn?1:a.length:0},i.prototype.emit=function(e,t,a,r,n,d){var s=o?o+e:e;if(!this._events[s])return!1;var l=this._events[s],u=arguments.length,c,f;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),u){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,a),!0;case 4:return l.fn.call(l.context,t,a,r),!0;case 5:return l.fn.call(l.context,t,a,r,n),!0;case 6:return l.fn.call(l.context,t,a,r,n,d),!0;}for(f=1,c=Array(u-1);f<u;f++)c[f-1]=arguments[f];l.fn.apply(l.context,c)}else{var g=l.length,m;for(f=0;f<g;f++)switch(l[f].once&&this.removeListener(e,l[f].fn,void 0,!0),u){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,t);break;case 3:l[f].fn.call(l[f].context,t,a);break;case 4:l[f].fn.call(l[f].context,t,a,r);break;default:if(!c)for(m=1,c=Array(u-1);m<u;m++)c[m-1]=arguments[m];l[f].fn.apply(l[f].context,c);}}return!0},i.prototype.on=function(e,t,a){return r(this,e,t,a,!1)},i.prototype.once=function(e,t,a){return r(this,e,t,a,!0)},i.prototype.removeListener=function(e,t,a,r){var d=o?o+e:e;if(!this._events[d])return this;if(!t)return n(this,d),this;var s=this._events[d];if(s.fn)s.fn!==t||r&&!s.once||a&&s.context!==a||n(this,d);else{for(var l=0,u=[],c=s.length;l<c;l++)(s[l].fn!==t||r&&!s[l].once||a&&s[l].context!==a)&&u.push(s[l]);u.length?this._events[d]=1===u.length?u[0]:u:n(this,d)}return this},i.prototype.removeAllListeners=function(e){var a;return e?(a=o?o+e:e,this._events[a]&&n(this,a)):(this._events=new t,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=o,i.EventEmitter=i,e.exports=i})(Nd);var wd=Nd.exports,Md=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}(wd);"undefined"!=typeof t&&t&&function(e){var t=new Md,a=function(t,a){e.postMessage({event:t,data:a})};t.on(En.FRAG_DECRYPTED,a),t.on(En.ERROR,a);var r=function(){var e=function(e){In[e]=function(t){a("workerLog",{logType:e,message:t})}};for(var t in In)e(t)};e.addEventListener("message",function(n){var i=n.data;switch(i.cmd){case"init":{var d=JSON.parse(i.config);e.transmuxer=new xd(t,i.typeSupported,d,i.vendor,i.id),v(d.debug,i.id),r(),a("init",null);break}case"configure":{e.transmuxer.configure(i.config);break}case"demux":{var o=e.transmuxer.push(i.data,i.decryptdata,i.chunkMeta,i.state);Ga(o)?(e.transmuxer.async=!0,o.then(function(t){Ka(e,t)}).catch(function(e){a(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker push error"})})):(e.transmuxer.async=!1,Ka(e,o));break}case"flush":{var s=i.chunkMeta,l=e.transmuxer.flush(s),u=Ga(l);u||e.transmuxer.async?(!Ga(l)&&(l=Promise.resolve(l)),l.then(function(t){Va(e,t,s)}).catch(function(e){a(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:e,err:e,reason:"transmuxer-worker flush error"})})):Va(e,l,s);break}}})}(self);var Bd=function(){function e(e,t,a,r){var n=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var i=e.config;this.hls=e,this.id=t,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=a,this.onFlush=r;var d=function(e,t){t=t||{},t.frag=n.frag,t.id=n.id,e===En.ERROR&&(n.error=t.error),n.hls.trigger(e,t)};this.observer=new Md,this.observer.on(En.FRAG_DECRYPTED,d),this.observer.on(En.ERROR,d);var o=Re(i.preferManagedMediaSource)||{isTypeSupported:function(){return!1}},s={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported("audio/mp4; codecs=\"mp3\""),ac3:o.isTypeSupported("audio/mp4; codecs=\"ac-3\"")},l=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){var u=i.workerPath||Wa();if(u){try{i.workerPath?(In.log("loading Web Worker "+i.workerPath+" for \""+t+"\""),this.workerContext=ja(i.workerPath)):(In.log("injecting Web Worker for \""+t+"\""),this.workerContext=qa()),this.onwmsg=function(e){return n.onWorkerMessage(e)};var c=this.workerContext.worker;c.addEventListener("message",this.onwmsg),c.onerror=function(e){var a=new Error(e.message+"  ("+e.filename+":"+e.lineno+")");i.enableWorker=!1,In.warn("Error in \""+t+"\" Web Worker, fallback to inline"),n.hls.trigger(En.ERROR,{type:Sn.OTHER_ERROR,details:Ln.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:a})},c.postMessage({cmd:"init",typeSupported:s,vendor:l,id:t,config:JSON.stringify(i)})}catch(e){In.warn("Error setting up \""+t+"\" Web Worker, fallback to inline",e),this.resetWorker(),this.error=null,this.transmuxer=new xd(this.observer,s,i,l,t)}return}}this.transmuxer=new xd(this.observer,s,i,l,t)}var t=e.prototype;return t.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,a=e.objectURL;a&&self.URL.revokeObjectURL(a),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},t.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},t.push=function(e,t,a,r,n,i,d,o,s,l){var u=this,c,f;s.transmuxing.start=self.performance.now();var g=this.transmuxer,m=i?i.start:n.start,p=n.decryptdata,y=this.frag,h=!(y&&n.cc===y.cc),T=!(y&&s.level===y.level),E=y?s.sn-y.sn:-1,S=this.part?s.part-this.part.index:-1,L=0===E&&1<s.id&&s.id===(null==y?void 0:y.stats.chunkCount),R=!T&&(1===E||0===E&&(1===S||L&&0>=S)),A=self.performance.now();(T||E||0===n.stats.parsing.start)&&(n.stats.parsing.start=A),i&&(S||!R)&&(i.stats.parsing.start=A);var v=!(y&&(null==(c=n.initSegment)?void 0:c.url)===(null==(f=y.initSegment)?void 0:f.url)),I=new Od(h,R,o,T,m,v);if(!R||h||v){In.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+s.sn+" p: "+s.part+" level: "+s.level+" id: "+s.id+"\n        discontinuity: "+h+"\n        trackSwitch: "+T+"\n        contiguous: "+R+"\n        accurateTimeOffset: "+o+"\n        timeOffset: "+m+"\n        initSegmentChange: "+v);var D=new Fd(a,r,t,d,l);this.configureTransmuxer(D)}if(this.frag=n,this.part=i,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:s,state:I},e instanceof ArrayBuffer?[e]:[]);else if(g){var k=g.push(e,p,s,I);Ga(k)?(g.async=!0,k.then(function(e){u.handleTransmuxComplete(e)}).catch(function(e){u.transmuxerError(e,s,"transmuxer-interface push error")})):(g.async=!1,this.handleTransmuxComplete(k))}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(a){var r=a.flush(e),n=Ga(r);n||a.async?(!Ga(r)&&(r=Promise.resolve(r)),r.then(function(a){t.handleFlushResult(a,e)}).catch(function(a){t.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}},t.transmuxerError=function(e,t,a){this.hls&&(this.error=e,this.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:a}))},t.handleFlushResult=function(e,t){var a=this;e.forEach(function(e){a.handleTransmuxComplete(e)}),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,a=this.hls;switch(t.event){case"init":{var r=null==(n=this.workerContext)?void 0:n.objectURL,n;r&&self.URL.revokeObjectURL(r);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":In[t.data.logType]&&In[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,a.trigger(t.event,t.data);break}}},t.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),Ud=100,Gd=function(e){function t(t,a,r){var n;return n=e.call(this,t,a,r,"[audio-stream-controller]",hi.AUDIO)||this,n.videoBuffer=null,n.videoTrackCC=-1,n.waitingVideoCC=-1,n.bufferedTrack=null,n.switchingTrack=null,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.flushing=!1,n.bufferFlushed=!1,n.cachedTrackLoadedData=null,n._registerListeners(),n}c(t,e);var a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},a._registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.LEVEL_LOADED,this.onLevelLoaded,this),e.on(En.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(En.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(En.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(En.ERROR,this.onError,this),e.on(En.BUFFER_RESET,this.onBufferReset,this),e.on(En.BUFFER_CREATED,this.onBufferCreated,this),e.on(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(En.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(En.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.LEVEL_LOADED,this.onLevelLoaded,this),e.off(En.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(En.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(En.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(En.ERROR,this.onError,this),e.off(En.BUFFER_RESET,this.onBufferReset,this),e.off(En.BUFFER_CREATED,this.onBufferCreated,this),e.off(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(En.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(En.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this)},a.onInitPtsFound=function(e,t){var a=t.frag,r=t.id,n=t.initPTS,i=t.timescale;if("main"===r){var d=a.cc;this.initPTS[a.cc]={baseTime:n,timescale:i},this.log("InitPTS for cc: "+d+" found from main: "+n),this.videoTrackCC=d,this.state===$i.WAITING_INIT_PTS&&this.tick()}},a.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=$i.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Ud),0<t&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=$i.IDLE):(this.loadedmetadata=!1,this.state=$i.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},a.doTick=function(){switch(this.state){case $i.IDLE:this.doTickIdle();break;case $i.WAITING_TRACK:{var t=this.levels,a=this.trackId,r=null==t||null==(n=t[a])?void 0:n.details,n;if(r){if(this.waitForCdnTuneIn(r))break;this.state=$i.WAITING_INIT_PTS}break}case $i.FRAG_LOADING_WAITING_RETRY:{var i=performance.now(),d=this.retryDate,o;if(!d||i>=d||null!=(o=this.media)&&o.seeking){var s=this.levels,l=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==s?void 0:s[l])||null),this.state=$i.IDLE}break}case $i.WAITING_INIT_PTS:{var u=this.waitingData;if(u){var c=u.frag,f=u.part,g=u.cache,m=u.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=$i.FRAG_LOADING;var p=g.flush(),y={frag:c,part:f,payload:p,networkDetails:null};this._handleFragmentLoadProgress(y),m&&e.prototype._handleFragmentLoadComplete.call(this,y)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var h=this.getLoadPosition(),T=Hi.bufferInfo(this.mediaBuffer,h,this.config.maxBufferHole),E=It(T.end,this.config.maxFragLookUpTolerance,c);0>E&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+T.end+" is needed"),this.clearWaitingFragment())}}else this.state=$i.IDLE}}this.onTickEnd()},a.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=$i.IDLE)},a.resetLoadingState=function(){this.clearWaitingFragment(),e.prototype.resetLoadingState.call(this)},a.onTickEnd=function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},a.doTickIdle=function(){var e=this.hls,t=this.levels,a=this.media,r=this.trackId,n=e.config;if((a||!this.startFragRequested&&n.startFragPrefetch)&&null!=t&&t[r]){var i=t[r],d=i.details;if(!d||d.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(d))return void(this.state=$i.WAITING_TRACK);var o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,bn.AUDIO,hi.AUDIO));var s=this.getFwdBufferInfo(o,hi.AUDIO);if(null!==s){var l=this.bufferedTrack,u=this.switchingTrack;if(!u&&this._streamEnded(s,d))return e.trigger(En.BUFFER_EOS,{type:"audio"}),void(this.state=$i.ENDED);var c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,hi.MAIN),f=s.len,g=this.getMaxBufferLength(null==c?void 0:c.len),m=d.fragments,p=m[0].start,y=this.flushing?this.getLoadPosition():s.end;if(u&&a){var h=this.getLoadPosition();l&&!za(u.attrs,l.attrs)&&(y=h),d.PTSKnown&&h<p&&(s.end>p||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=p+.05)}if(!(f>=g&&!u&&y<m[m.length-1].start)){var T=this.getNextFragment(y,d),E=!1;if(T&&this.isLoopLoading(T,y)&&(E=!!T.gap,T=this.getNextFragmentLoopLoading(T,d,s,hi.MAIN,g)),!T)return void(this.bufferFlushed=!0);var S=c&&T.start>c.end+d.targetduration;if(S||!(null!=c&&c.len)&&s.len){var L=this.getAppendedFrag(T.start,hi.MAIN);if(null===L)return;if(E||(E=!!L.gap||!!S&&0===c.len),S&&!E||E&&s.nextStart&&s.nextStart<L.end)return}this.loadFragment(T,i,y)}}}},a.getMaxBufferLength=function(t){var a=e.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(a,t),this.config.maxMaxBufferLength):a},a.onMediaDetaching=function(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,e.prototype.onMediaDetaching.call(this)},a.onAudioTracksUpdated=function(e,t){var a=t.audioTracks;this.resetTransmuxer(),this.levels=a.map(function(e){return new ki(e)})},a.onAudioTrackSwitching=function(e,t){var a=!!t.url;this.trackId=t.id;var r=this.fragCurrent;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),a?this.setInterval(Ud):this.resetTransmuxer(),a?(this.switchingTrack=t,this.state=$i.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=$i.STOPPED),this.tick()},a.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},a.onLevelLoaded=function(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(En.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},a.onAudioTrackLoaded=function(e,t){var a;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);var r=this.levels,n=t.details,i=t.id;if(!r)return void this.warn("Audio tracks were reset while loading level "+i);this.log("Audio track "+i+" loaded ["+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+",duration:"+n.totalduration);var d=r[i],o=0;if(n.live||null!=(a=d.details)&&a.live){this.checkLiveUpdate(n);var s=this.mainDetails;if(n.deltaUpdateFailed||!s)return;if(!d.details&&n.hasProgramDateTime&&s.hasProgramDateTime)Jt(n,s),o=n.fragments[0].start;else{var l;o=this.alignPlaylists(n,d.details,null==(l=this.levelLastLoaded)?void 0:l.details)}}d.details=n,this.levelLastLoaded=d,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(d.details,o),this.state!==$i.WAITING_TRACK||this.waitForCdnTuneIn(n)||(this.state=$i.IDLE),this.tick()},a._handleFragmentLoadProgress=function(e){var t=e.frag,a=e.part,r=e.payload,n=this.config,i=this.trackId,d=this.levels,o;if(!d)return void this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");var s=d[i];if(!s)return void this.warn("Audio track is undefined on fragment load progress");var l=s.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(t.start);var u=n.defaultAudioCodec||s.audioCodec||"mp4a.40.2",c=this.transmuxer;c||(c=this.transmuxer=new Bd(this.hls,hi.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var f=this.initPTS[t.cc],g=null==(o=t.initSegment)?void 0:o.data;if(void 0!==f){var m=a?a.index:-1,p=new Vi(t.level,t.sn,t.stats.chunkCount,r.byteLength,m,-1!==m);c.push(r,g,u,"",t,a,l.totalduration,!1,p,f)}else{this.log("Unknown video PTS for cc "+t.cc+", waiting for video PTS before demuxing audio frag "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],track "+i);var y=this.waitingData=this.waitingData||{frag:t,part:a,cache:new ed,complete:!1},h=y.cache;h.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=$i.WAITING_INIT_PTS}},a._handleFragmentLoadComplete=function(t){return this.waitingData?void(this.waitingData.complete=!0):void e.prototype._handleFragmentLoadComplete.call(this,t)},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.onBufferCreated=function(e,t){var a=t.tracks.audio;a&&(this.mediaBuffer=a.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)},a.onFragBuffered=function(e,t){var a=t.frag,n=t.part;if(a.type!==hi.AUDIO){if(!this.loadedmetadata&&a.type===hi.MAIN){var i=this.videoBuffer||this.media;if(i){var d=Hi.getBuffered(i);d.length&&(this.loadedmetadata=!0)}}return}if(this.fragContextChanged(a))return void this.warn("Fragment "+a.sn+(n?" p: "+n.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));if("initSegment"!==a.sn){this.fragPrevious=a;var o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(En.AUDIO_TRACK_SWITCHED,r({},o)))}this.fragBufferedComplete(a,n)},a.onError=function(t,a){var r;if(a.fatal)return void(this.state=$i.ERROR);switch(a.details){case Ln.FRAG_GAP:case Ln.FRAG_PARSING_ERROR:case Ln.FRAG_DECRYPT_ERROR:case Ln.FRAG_LOAD_ERROR:case Ln.FRAG_LOAD_TIMEOUT:case Ln.KEY_LOAD_ERROR:case Ln.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(hi.AUDIO,a);break;case Ln.AUDIO_TRACK_LOAD_ERROR:case Ln.AUDIO_TRACK_LOAD_TIMEOUT:case Ln.LEVEL_PARSING_ERROR:a.levelRetry||this.state!==$i.WAITING_TRACK||(null==(r=a.context)?void 0:r.type)!==yi.AUDIO_TRACK||(this.state=$i.IDLE);break;case Ln.BUFFER_APPEND_ERROR:case Ln.BUFFER_FULL_ERROR:if(!a.parent||"audio"!==a.parent)return;if(a.details===Ln.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(a)&&(this.bufferedTrack=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case Ln.INTERNAL_EXCEPTION:this.recoverWorkerError(a);}},a.onBufferFlushing=function(e,t){var a=t.type;a!==bn.VIDEO&&(this.flushing=!0)},a.onBufferFlushed=function(e,t){var a=t.type;if(a!==bn.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===$i.ENDED&&(this.state=$i.IDLE);var r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,a,hi.AUDIO),this.tick())}},a._handleTransmuxComplete=function(e){var t="audio",a=this.hls,r=e.remuxResult,n=e.chunkMeta,i=this.getCurrentContext(n),d;if(!i)return void this.resetWhenMissingContext(n);var o=i.frag,s=i.part,l=i.level,c=l.details,f=r.audio,g=r.text,m=r.id3,p=r.initSegment;if(this.fragContextChanged(o)||!c)return void this.fragmentTracker.removeFragment(o);if(this.state=$i.PARSING,this.switchingTrack&&f&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){var y=o.initSegment||o;this._bufferInitSegment(l,p.tracks,y,n),a.trigger(En.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:t,tracks:p.tracks})}if(f){var h=f.startPTS,T=f.endPTS,E=f.startDTS,S=f.endDTS;s&&(s.elementaryStreams[bn.AUDIO]={startPTS:h,endPTS:T,startDTS:E,endDTS:S}),o.setElementaryStreamInfo(bn.AUDIO,h,T,E,S),this.bufferFragmentData(f,o,s,n)}if(null!=m&&null!=(d=m.samples)&&d.length){var L=u({id:t,frag:o,details:c},m);a.trigger(En.FRAG_PARSING_METADATA,L)}if(g){var R=u({id:t,frag:o,details:c},g);a.trigger(En.FRAG_PARSING_USERDATA,R)}},a._bufferInitSegment=function(e,t,a,r){if(this.state===$i.PARSING){t.video&&delete t.video;var n=t.audio;if(n){n.id="audio";var i=e.audioCodec;this.log("Init audio buffer, container:"+n.container+", codecs[level/parsed]=["+i+"/"+n.codec+"]"),i&&1===i.split(",").length&&(n.levelCodec=i),this.hls.trigger(En.BUFFER_CODECS,t);var d=n.initSegment;if(null!=d&&d.byteLength){var o={type:"audio",frag:a,part:null,chunkMeta:r,parent:a.type,data:d};this.hls.trigger(En.BUFFER_APPENDING,o)}this.tickImmediate()}}},a.loadFragment=function(t,a,r){var n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===Ui.NOT_LOADED||n===Ui.PARTIAL){var i;if("initSegment"===t.sn)this._loadInitSegment(t,a);else if(null!=(i=a.details)&&i.live&&!this.initPTS[t.cc]){this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=$i.WAITING_INIT_PTS;var d=this.mainDetails;d&&d.fragments[0].start!==a.details.fragments[0].start&&Jt(a.details,d)}else this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,a,r)}else this.clearTrackerIfNeeded(t)},a.flushAudioIfNeeded=function(t){var a=this.media,r=this.bufferedTrack,n=null==r?void 0:r.attrs,i=t.attrs;a&&n&&(n.CHANNELS!==i.CHANNELS||r.name!==t.name||r.lang!==t.lang)&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)},a.completeAudioSwitch=function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(En.AUDIO_TRACK_SWITCHED,r({},e))},t}(Ji),Kd=function(e){function t(t){var a;return a=e.call(this,t,"[audio-track-controller]")||this,a.tracks=[],a.groupIds=null,a.tracksInGroup=[],a.trackId=-1,a.currentTrack=null,a.selectDefaultTrack=!0,a.registerListeners(),a}c(t,e);var a=t.prototype;return a.registerListeners=function(){var e=this.hls;e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.LEVEL_LOADING,this.onLevelLoading,this),e.on(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(En.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(En.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.LEVEL_LOADING,this.onLevelLoading,this),e.off(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(En.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(En.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,e.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},a.onAudioTrackLoaded=function(e,t){var a=t.id,r=t.groupId,n=t.details,i=this.tracksInGroup[a];if(!i||i.groupId!==r)return void this.warn("Audio track with id:"+a+" and group:"+r+" not found in active group "+(null==i?void 0:i.groupId));var d=i.details;i.details=t.details,this.log("Audio track "+a+" \""+i.name+"\" lang:"+i.lang+" group:"+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),a===this.trackId&&this.playlistLoaded(a,t,d)},a.onLevelLoading=function(e,t){this.switchLevel(t.level)},a.onLevelSwitching=function(e,t){this.switchLevel(t.level)},a.switchLevel=function(e){var t=this.hls.levels[e];if(t){var a=t.audioGroups||null,r=this.groupIds,n=this.currentTrack;if(!a||(null==r?void 0:r.length)!==(null==a?void 0:a.length)||null!=a&&a.some(function(e){return-1===(null==r?void 0:r.indexOf(e))})){this.groupIds=a,this.trackId=-1,this.currentTrack=null;var i=this.tracks.filter(function(e){return!a||-1!==a.indexOf(e.groupId)});if(i.length)this.selectDefaultTrack&&!i.some(function(e){return e.default})&&(this.selectDefaultTrack=!1),i.forEach(function(e,t){e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=i;var d=this.hls.config.audioPreference;if(!n&&d){var o=Mt(d,i,Gt);if(-1<o)n=i[o];else{var s=Mt(d,this.tracks);n=this.tracks[s]}}var l=this.findTrackId(n);-1===l&&n&&(l=this.findTrackId(null));this.log("Updating audio tracks, "+i.length+" track(s) found in group(s): "+(null==a?void 0:a.join(","))),this.hls.trigger(En.AUDIO_TRACKS_UPDATED,{audioTracks:i});var u=this.trackId;if(-1!==l&&-1===u)this.setAudioTrack(l);else if(i.length&&-1===u){var c=new Error("No audio track selected for current audio group-ID(s): "+(null==(f=this.groupIds)?void 0:f.join(","))+" track count: "+i.length),f;this.warn(c.message),this.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:c})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}},a.onError=function(e,t){!t.fatal&&t.context&&(t.context.type!==yi.AUDIO_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))},a.setAudioOption=function(e){var t=this.hls;if(t.config.audioPreference=e,e){var a=this.allAudioTracks;if(this.selectDefaultTrack=!1,a.length){var r=this.currentTrack;if(r&&Bt(e,r,Gt))return r;var n=Mt(e,this.tracksInGroup,Gt);if(-1<n){var i=this.tracksInGroup[n];return this.setAudioTrack(n),i}if(r){var d=t.loadLevel;-1===d&&(d=t.firstAutoLevel);var o=Kt(e,t.levels,a,d,Gt);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var s=Mt(e,a);if(-1<s)return a[s]}}}return null},a.setAudioTrack=function(e){var t=this.tracksInGroup;if(0>e||e>=t.length)return void this.warn("Invalid audio track id: "+e);this.clearTimer(),this.selectDefaultTrack=!1;var a=this.currentTrack,n=t[e],i=n.details&&!n.details.live;if(!(e===this.trackId&&n===a&&i)&&(this.log("Switching to audio-track "+e+" \""+n.name+"\" lang:"+n.lang+" group:"+n.groupId+" channels:"+n.channels),this.trackId=e,this.currentTrack=n,this.hls.trigger(En.AUDIO_TRACK_SWITCHING,r({},n)),!i)){var d=this.switchParams(n.url,null==a?void 0:a.details);this.loadPlaylist(d)}},a.findTrackId=function(e){for(var t=this.tracksInGroup,a=0,r;a<t.length;a++)if((r=t[a],!this.selectDefaultTrack||r.default)&&(!e||Bt(e,r,Gt)))return a;if(e){for(var n=e.name,d=e.lang,o=e.assocLang,s=e.characteristics,l=e.audioCodec,u=e.channels,c=0,f;c<t.length;c++)if(f=t[c],Bt({name:n,lang:d,assocLang:o,characteristics:s,audioCodec:l,channels:u},f,Gt))return c;for(var g=0,m;g<t.length;g++)if(m=t[g],za(e.attrs,m.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return g;for(var p=0,y;p<t.length;p++)if(y=t[p],za(e.attrs,y.attrs,["LANGUAGE"]))return p}return-1},a.loadPlaylist=function(t){var a=this.currentTrack;if(this.shouldLoadPlaylist(a)&&a){e.prototype.loadPlaylist.call(this);var r=a.id,n=a.groupId,i=a.url;if(t)try{i=t.addDirectives(i)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist "+r+" \""+a.name+"\" lang:"+a.lang+" group:"+n),this.clearTimer(),this.hls.trigger(En.AUDIO_TRACK_LOADING,{url:i,id:r,groupId:n,deliveryDirectives:t||null})}},s(t,[{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}]),t}(Pi),Hd=500,Vd=function(e){function t(t,a,r){var n;return n=e.call(this,t,a,r,"[subtitle-stream-controller]",hi.SUBTITLE)||this,n.currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n._registerListeners(),n}c(t,e);var a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.mainDetails=null},a._registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.LEVEL_LOADED,this.onLevelLoaded,this),e.on(En.ERROR,this.onError,this),e.on(En.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(En.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(En.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(En.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.LEVEL_LOADED,this.onLevelLoaded,this),e.off(En.ERROR,this.onError,this),e.off(En.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(En.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(En.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(En.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(e){this.stopLoad(),this.state=$i.IDLE,this.setInterval(Hd),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onMediaDetaching=function(){this.tracksBuffered=[],e.prototype.onMediaDetaching.call(this)},a.onLevelLoaded=function(e,t){this.mainDetails=t.details},a.onSubtitleFragProcessed=function(e,t){var a=t.frag,r=t.success;if(this.fragPrevious=a,this.state=$i.IDLE,!!r){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var d=a.start,o=0,s;o<n.length;o++)if(d>=n[o].start&&d<=n[o].end){s=n[o];break}var l=a.start+a.duration;s?s.end=l:(s={start:d,end:l},n.push(s)),this.fragmentTracker.fragBuffered(a),this.fragBufferedComplete(a,null)}}},a.onBufferFlushing=function(e,t){var a=t.startOffset,r=t.endOffset;if(0===a&&r!==Number.POSITIVE_INFINITY){var n=r-1;if(0>=n)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(function(e){for(var t=0;t<e.length;){if(e[t].end<=n){e.shift();continue}else if(e[t].start<n)e[t].start=n;else break;t++}}),this.fragmentTracker.removeFragmentsInRange(a,n,hi.SUBTITLE)}},a.onFragBuffered=function(e,t){if(!this.loadedmetadata&&t.frag.type===hi.MAIN){var a;null!=(a=this.media)&&a.buffered.length&&(this.loadedmetadata=!0)}},a.onError=function(e,t){var a=t.frag;(null==a?void 0:a.type)===hi.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==$i.STOPPED&&(this.state=$i.IDLE))},a.onSubtitleTracksUpdated=function(e,t){var a=this,r=t.subtitleTracks;return!this.levels||Xa(this.levels,r)?void(this.levels=r.map(function(e){return new ki(e)})):void(this.tracksBuffered=[],this.levels=r.map(function(e){var t=new ki(e);return a.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,hi.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null)},a.onSubtitleTrackSwitch=function(e,t){var a;if(this.currentTrackId=t.id,!(null!=(a=this.levels)&&a.length)||-1===this.currentTrackId)return void this.clearInterval();var r=this.levels[this.currentTrackId];this.mediaBuffer=null!=r&&r.details?this.mediaBufferTimeRanges:null,r&&this.setInterval(Hd)},a.onSubtitleTrackLoaded=function(e,t){var a=this.currentTrackId,r=this.levels,n=t.details,i=t.id,d;if(!r)return void this.warn("Subtitle tracks were reset while loading level "+i);var o=r[a];if(!(i>=r.length)&&i===a&&o){this.log("Subtitle track "+i+" loaded ["+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+",duration:"+n.totalduration),this.mediaBuffer=this.mediaBufferTimeRanges;var s=0;if(n.live||null!=(d=o.details)&&d.live){var l=this.mainDetails;if(n.deltaUpdateFailed||!l)return;var u=l.fragments[0];if(!o.details)n.hasProgramDateTime&&l.hasProgramDateTime?(Jt(n,l),s=n.fragments[0].start):u&&(s=u.start,ct(n,s));else{var c;s=this.alignPlaylists(n,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===s&&u&&(s=u.start,ct(n,s))}}if(o.details=n,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(o.details,s),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===$i.IDLE){var f=vt(null,n.fragments,this.media.currentTime,0);f||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}},a._handleFragmentLoadComplete=function(e){var t=this,a=e.frag,r=e.payload,n=a.decryptdata,i=this.hls;if(!this.fragContextChanged(a)&&r&&0<r.byteLength&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){var d=performance.now();this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).catch(function(e){throw i.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:a}),e}).then(function(e){var t=performance.now();i.trigger(En.FRAG_DECRYPTED,{frag:a,payload:e,stats:{tstart:d,tdecrypt:t}})}).catch(function(e){t.warn(e.name+": "+e.message),t.state=$i.IDLE})}},a.doTick=function(){if(!this.media)return void(this.state=$i.IDLE);if(this.state===$i.IDLE){var e=this.currentTrackId,t=this.levels,a=null==t?void 0:t[e];if(!a||!t.length||!a.details)return;var r=this.config,n=this.getLoadPosition(),i=Hi.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),d=i.end,o=i.len,s=this.getFwdBufferInfo(this.media,hi.MAIN),l=a.details,u=this.getMaxBufferLength(null==s?void 0:s.len)+l.levelTargetDuration;if(o>u)return;var c=l.fragments,f=c.length,g=l.edge,m=null,p=this.fragPrevious;if(d<g){var y=r.maxFragLookUpTolerance,h=d>g-y?0:y;m=vt(p,c,Math.max(c[0].start,d),h),!m&&p&&p.start<c[0].start&&(m=c[0])}else m=c[f-1];if(!m)return;if(m=this.mapToInitFragWhenRequired(m),"initSegment"!==m.sn){var T=m.sn-l.startSN,E=c[T-1];E&&E.cc===m.cc&&this.fragmentTracker.getState(E)===Ui.NOT_LOADED&&(m=E)}this.fragmentTracker.getState(m)===Ui.NOT_LOADED&&this.loadFragment(m,a,d)}},a.getMaxBufferLength=function(t){var a=e.prototype.getMaxBufferLength.call(this);return t?Math.max(a,t):a},a.loadFragment=function(t,a,r){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t,a):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,a,r))},s(t,[{key:"mediaBufferTimeRanges",get:function(){return new Yd(this.tracksBuffered[this.currentTrackId]||[])}}]),t}(Ji),Yd=function(e){this.buffered=void 0;var t=function(t,a,r){if(a>>>=0,a>r-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+a+") is greater than the maximum bound ("+r+")");return e[a][t]};this.buffered={get length(){return e.length},end:function(a){return t("end",a,e.length)},start:function(a){return t("start",a,e.length)}}},Wd=function(e){function t(t){var a;return a=e.call(this,t,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupIds=null,a.tracksInGroup=[],a.trackId=-1,a.currentTrack=null,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a._subtitleDisplay=!0,a.onTextTracksChanged=function(){if(a.useTextTrackPolling||self.clearInterval(a.subtitlePollingInterval),a.media&&a.hls.config.renderTextTracksNatively){for(var e=null,t=ze(a.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var n=a.findTrackForTextTrack(e);a.subtitleTrack!==n&&a.setSubtitleTrack(n)}},a.registerListeners(),a}c(t,e);var a=t.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},a.registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.LEVEL_LOADING,this.onLevelLoading,this),e.on(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(En.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(En.ERROR,this.onError,this)},a.unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.LEVEL_LOADING,this.onLevelLoading,this),e.off(En.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(En.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(En.ERROR,this.onError,this)},a.onMediaAttached=function(e,t){this.media=t.media,this.media&&(-1<this.queuedDefaultTrack&&(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))},a.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)},a.onMediaDetaching=function(){if(this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId);var e=ze(this.media.textTracks);e.forEach(function(e){We(e)}),this.subtitleTrack=-1,this.media=null}},a.onManifestLoading=function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},a.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},a.onSubtitleTrackLoaded=function(e,t){var a=t.id,r=t.groupId,n=t.details,i=this.tracksInGroup[a];if(!i||i.groupId!==r)return void this.warn("Subtitle track with id:"+a+" and group:"+r+" not found in active group "+(null==i?void 0:i.groupId));var d=i.details;i.details=t.details,this.log("Subtitle track "+a+" \""+i.name+"\" lang:"+i.lang+" group:"+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),a===this.trackId&&this.playlistLoaded(a,t,d)},a.onLevelLoading=function(e,t){this.switchLevel(t.level)},a.onLevelSwitching=function(e,t){this.switchLevel(t.level)},a.switchLevel=function(e){var t=this.hls.levels[e];if(t){var a=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!a||(null==r?void 0:r.length)!==(null==a?void 0:a.length)||null!=a&&a.some(function(e){return-1===(null==r?void 0:r.indexOf(e))})){this.groupIds=a,this.trackId=-1,this.currentTrack=null;var i=this.tracks.filter(function(e){return!a||-1!==a.indexOf(e.groupId)});if(i.length)this.selectDefaultTrack&&!i.some(function(e){return e.default})&&(this.selectDefaultTrack=!1),i.forEach(function(e,t){e.id=t});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=i;var d=this.hls.config.subtitlePreference;if(!n&&d){this.selectDefaultTrack=!1;var o=Mt(d,i);if(-1<o)n=i[o];else{var s=Mt(d,this.tracks);n=this.tracks[s]}}var l=this.findTrackId(n);-1===l&&n&&(l=this.findTrackId(null));this.log("Updating subtitle tracks, "+i.length+" track(s) found in \""+(null==a?void 0:a.join(","))+"\" group-id"),this.hls.trigger(En.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:i}),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}},a.findTrackId=function(e){for(var t=this.tracksInGroup,a=this.selectDefaultTrack,r=0,n;r<t.length;r++)if((n=t[r],(!a||n.default)&&(a||e))&&(!e||Bt(n,e)))return r;if(e){for(var d=0,o;d<t.length;d++)if(o=t[d],za(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d;for(var s=0,l;s<t.length;s++)if(l=t[s],za(e.attrs,l.attrs,["LANGUAGE"]))return s}return-1},a.findTrackForTextTrack=function(e){if(e)for(var t=this.tracksInGroup,a=0,r;a<t.length;a++)if(r=t[a],Qa(r,e))return a;return-1},a.onError=function(e,t){!t.fatal&&t.context&&(t.context.type!==yi.SUBTITLE_TRACK||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))},a.setSubtitleOption=function(e){if(this.hls.config.subtitlePreference=e,e){var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var a=this.currentTrack;if(a&&Bt(e,a))return a;var r=Mt(e,this.tracksInGroup);if(-1<r){var n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}if(a)return null;var i=Mt(e,t);if(-1<i)return t[i]}}return null},a.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var a=this.currentTrack;if(this.shouldLoadPlaylist(a)&&a){var r=a.id,n=a.groupId,i=a.url;if(t)try{i=t.addDirectives(i)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(En.SUBTITLE_TRACK_LOADING,{url:i,id:r,groupId:n,deliveryDirectives:t||null})}},a.toggleTrackModes=function(){var e=this.media;if(e){var t=ze(e.textTracks),a=this.currentTrack,r;if(a&&(r=t.filter(function(e){return Qa(a,e)})[0],!r&&this.warn("Unable to find subtitle TextTrack with name \""+a.name+"\" and language \""+a.lang+"\"")),[].slice.call(t).forEach(function(e){"disabled"!==e.mode&&e!==r&&(e.mode="disabled")}),r){var n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n)}}},a.setSubtitleTrack=function(e){var t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(-1>e||e>=t.length||!yn(e))return void this.warn("Invalid subtitle track id: "+e);this.clearTimer(),this.selectDefaultTrack=!1;var a=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r)return void this.hls.trigger(En.SUBTITLE_TRACK_SWITCH,{id:e});var n=!!r.details&&!r.details.live;if(!(e===this.trackId&&r===a&&n)){this.log("Switching to subtitle-track "+e+(r?" \""+r.name+"\" lang:"+r.lang+" group:"+r.groupId:""));var i=r.id,d=r.groupId,o=void 0===d?"":d,s=r.name,l=r.type,u=r.url;this.hls.trigger(En.SUBTITLE_TRACK_SWITCH,{id:i,groupId:o,name:s,type:l,url:u});var c=this.switchParams(r.url,null==a?void 0:a.details);this.loadPlaylist(c)}},s(t,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,-1<this.trackId&&this.toggleTrackModes()}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}}]),t}(Pi),qd=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t,a){var r=this.queues[t];r.push(e),1!==r.length||a||this.executeNext(t)},t.insertAbort=function(e,t){var a=this.queues[t];a.unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t=new Promise(function(e){r=e}),a={execute:r,onStart:function(){},onComplete:function(){},onError:function(){}},r;return this.append(a,e),t},t.executeNext=function(e){var t=this.queues[e];if(t.length){var a=t[0];try{a.execute()}catch(t){In.warn("[buffer-operation-queue]: Exception executing \""+e+"\" SourceBuffer operation: "+t),a.onError(t);var r=this.buffers[e];null!=r&&r.updating||this.shiftAndExecuteNext(e)}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}(),jd=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Xd=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(){t.hls&&t.hls.pauseBuffering()},this._onStartStreaming=function(){t.hls&&t.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var e=t.media,a=t.mediaSource;t.log("Media source opened"),e&&(e.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(En.MEDIA_ATTACHED,{media:e,mediaSource:a})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){t.log("Media source closed")},this._onMediaSourceEnded=function(){t.log("Media source ended")},this._onMediaEmptied=function(){var e=t.mediaSrc,a=t._objectUrl;e!==a&&In.error("Media element src was set while attaching MediaSource ("+a+" > "+e+")")},this.hls=e;this.appendSource=e.config.preferManagedMediaSource,this.log=In.log.bind(In,"[buffer-controller]"),this.warn=In.warn.bind(In,"[buffer-controller]"),this.error=In.error.bind(In,"[buffer-controller]"),this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},t.registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.BUFFER_RESET,this.onBufferReset,this),e.on(En.BUFFER_APPENDING,this.onBufferAppending,this),e.on(En.BUFFER_CODECS,this.onBufferCodecs,this),e.on(En.BUFFER_EOS,this.onBufferEos,this),e.on(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(En.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(En.FRAG_PARSED,this.onFragParsed,this),e.on(En.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.BUFFER_RESET,this.onBufferReset,this),e.off(En.BUFFER_APPENDING,this.onBufferAppending,this),e.off(En.BUFFER_CODECS,this.onBufferCodecs,this),e.off(En.BUFFER_EOS,this.onBufferEos,this),e.off(En.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(En.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(En.FRAG_PARSED,this.onFragParsed,this),e.off(En.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new qd(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){var a=2;(!t.audio||t.video)&&t.altAudio&&!0||(a=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=a,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var a=this.media=t.media,r=Re(this.appendSource);if(a&&r){var n=this.mediaSource=new r,i;this.log("created media source: "+(null==(i=n.constructor)?void 0:i.name)),n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming);var d=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{a.removeAttribute("src");var o=self.ManagedMediaSource;a.disableRemotePlayback=a.disableRemotePlayback||o&&n instanceof o,Za(a),$a(a,d),a.load()}catch(e){a.src=d}else a.src=d;a.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,a=this._objectUrl;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming),e&&(e.removeEventListener("emptied",this._onMediaEmptied),a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(e.removeAttribute("src"),this.appendSource&&Za(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(En.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){e.resetBuffer(t)}),this._initSourceBuffer()},t.resetBuffer=function(e){var t=this.sourceBuffer[e];try{if(t){var a;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(a=this.mediaSource)&&a.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(t){this.warn("onBufferReset "+e,t)}},t.onBufferCodecs=function(e,t){var a=this,r=this.getSourceBufferTypes().length,n=Object.keys(t);if(n.forEach(function(e){if(r){var n=a.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var i=t[e],d=i.id,o=i.codec,s=i.levelCodec,l=i.container,u=i.metadata,c=xe(n.codec,n.levelCodec),f=null==c?void 0:c.replace(jd,"$1"),g=xe(o,s),m=null==(p=g)?void 0:p.replace(jd,"$1"),p;if(g&&f!==m){"audio"===e.slice(0,5)&&(g=be(g,a.hls.config.preferManagedMediaSource));var y=l+";codecs="+g;a.appendChangeType(e,y),a.log("switching codec "+c+" to "+g),a.tracks[e]={buffer:n.buffer,codec:o,container:l,levelCodec:s,metadata:u,id:d}}}}else a.pendingTracks[e]=t[e]}),!r){var i=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==i&&(this.log(i+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=i),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},t.appendChangeType=function(e,t){var a=this,r=this.operationQueue;r.append({execute:function(){var n=a.sourceBuffer[e];n&&(a.log("changing "+e+" sourceBuffer type to "+t),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.warn("Failed to change "+e+" SourceBuffer type",t)}},e,!!this.pendingTracks[e])},t.onBufferAppending=function(e,t){var a=this,r=this.hls,n=this.operationQueue,i=this.tracks,d=t.data,o=t.type,s=t.frag,l=t.part,u=t.chunkMeta,c=u.buffering[o],f=self.performance.now();c.start=f;var g=s.stats.buffering,m=l?l.stats.buffering:null;0===g.start&&(g.start=f),m&&0===m.start&&(m.start=f);var p=i.audio,y=!1;"audio"===o&&"audio/mpeg"===(null==p?void 0:p.container)&&(y=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var h=s.start;n.append({execute:function(){if(c.executeStart=self.performance.now(),y){var e=a.sourceBuffer[o];if(e){var t=h-e.timestampOffset;.1<=Math.abs(t)&&(a.log("Updating audio SourceBuffer timestampOffset to "+h+" (delta: "+t+") sn: "+s.sn+")"),e.timestampOffset=h)}}a.appendExecutor(d,o)},onStart:function(){},onComplete:function(){var e=self.performance.now();c.executeEnd=c.end=e,0===g.first&&(g.first=e),m&&0===m.first&&(m.first=e);var t=a.sourceBuffer,r={};for(var n in t)r[n]=Hi.getBuffered(t[n]);a.appendErrors[o]=0,"audio"===o||"video"===o?a.appendErrors.audiovideo=0:(a.appendErrors.audio=0,a.appendErrors.video=0),a.hls.trigger(En.BUFFER_APPENDED,{type:o,frag:s,part:l,chunkMeta:u,parent:s.type,timeRanges:r})},onError:function(e){var t={type:Sn.MEDIA_ERROR,parent:s.type,details:Ln.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:s,part:l,chunkMeta:u,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=Ln.BUFFER_FULL_ERROR;else{var n=++a.appendErrors[o];t.details=Ln.BUFFER_APPEND_ERROR,a.warn("Failed "+n+"/"+r.config.appendErrorMaxRetry+" times to append segment in \""+o+"\" sourceBuffer"),n>=r.config.appendErrorMaxRetry&&(t.fatal=!0)}r.trigger(En.ERROR,t)}},o,!!this.pendingTracks[o])},t.onBufferFlushing=function(e,t){var a=this,r=this.operationQueue,n=function(e){return{execute:a.removeExecutor.bind(a,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){a.hls.trigger(En.BUFFER_FLUSHED,{type:e})},onError:function(t){a.warn("Failed to remove from "+e+" SourceBuffer",t)}}};t.type?r.append(n(t.type),t.type):this.getSourceBufferTypes().forEach(function(e){r.append(n(e),e)})},t.onFragParsed=function(e,t){var a=this,r=t.frag,n=t.part,i=[],d=n?n.elementaryStreams:r.elementaryStreams;d[bn.AUDIOVIDEO]?i.push("audiovideo"):(d[bn.AUDIO]&&i.push("audio"),d[bn.VIDEO]&&i.push("video"));var o=function(){var e=self.performance.now();r.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:r.stats;a.hls.trigger(En.FRAG_BUFFERED,{frag:r,part:n,stats:t,id:r.type})};0===i.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(o,i)},t.onFragChanged=function(){this.trimBuffers()},t.onBufferEos=function(e,t){var a=this,r=this.getSourceBufferTypes().reduce(function(e,r){var n=a.sourceBuffer[r];return n&&(!t.type||t.type===r)&&(n.ending=!0,!n.ended&&(n.ended=!0,a.log(r+" sourceBuffer now EOS"))),e&&(!n||n.ended)},!0);r&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){a.getSourceBufferTypes().forEach(function(e){var t=a.sourceBuffer[e];t&&(t.ending=!1)});var e=a.mediaSource;return e&&"open"===e.readyState?void(a.log("Calling mediaSource.endOfStream()"),e.endOfStream()):void(e&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState))}))},t.onLevelUpdated=function(e,t){var a=t.details;a.fragments.length&&(this.details=a,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.trimBuffers=function(){var e=this.hls,t=this.details,a=this.media;if(a&&null!==t){var r=this.getSourceBufferTypes();if(r.length){var n=e.config,i=a.currentTime,d=t.levelTargetDuration,o=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(yn(o)&&0<o){var s=Math.max(o,d),l=Math.floor(i/d)*d-s;this.flushBackBuffer(i,d,l)}if(yn(n.frontBufferFlushThreshold)&&0<n.frontBufferFlushThreshold){var u=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),c=Math.max(u,d),f=Math.floor(i/d)*d+c;this.flushFrontBuffer(i,d,f)}}}},t.flushBackBuffer=function(e,t,a){var r=this,n=this.details,i=this.sourceBuffer,d=this.getSourceBufferTypes();d.forEach(function(d){var o=i[d];if(o){var s=Hi.getBuffered(o);if(0<s.length&&a>s.start(0)){if(r.hls.trigger(En.BACK_BUFFER_REACHED,{bufferEnd:a}),null!=n&&n.live)r.hls.trigger(En.LIVE_BACK_BUFFER_REACHED,{bufferEnd:a});else if(o.ended&&s.end(s.length-1)-e<2*t)return void r.log("Cannot flush "+d+" back buffer while SourceBuffer is in ended state");r.hls.trigger(En.BUFFER_FLUSHING,{startOffset:0,endOffset:a,type:d})}}})},t.flushFrontBuffer=function(e,t,a){var r=this,n=this.sourceBuffer,i=this.getSourceBufferTypes();i.forEach(function(i){var d=n[i];if(d){var o=Hi.getBuffered(d),s=o.length;if(2>s)return;var l=o.start(s-1),u=o.end(s-1);if(a>l||e>=l&&e<=u)return;if(d.ended&&e-u<2*t)return void r.log("Cannot flush "+i+" front buffer while SourceBuffer is in ended state");r.hls.trigger(En.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:i})}})},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,a=this.media,r=this.mediaSource,n=e.fragments[0].start+e.totalduration,i=a.duration,d=yn(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(r.duration=1/0,this.updateSeekableRange(e)):(n>d&&n>i||!yn(i))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),r.duration=n)}},t.updateSeekableRange=function(e){var t=this.mediaSource,a=e.fragments,r=a.length;if(r&&e.live&&null!=t&&t.setLiveSeekableRange){var n=Math.max(0,a[0].start),i=Math.max(n,n+e.totalduration);this.log("Media Source duration is set to "+t.duration+". Setting seekable range to "+n+"-"+i+"."),t.setLiveSeekableRange(n,i)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,a=this.pendingTracks,r=Object.keys(a).length;if(r&&(!e||2===r||"audiovideo"in a)){this.createSourceBuffers(a),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(En.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(function(e){t.executeNext(e)});else{var i=new Error("could not create source buffer for media codec(s)");this.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:i,reason:i.message})}}},t.createSourceBuffers=function(e){var t=this,a=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var n=function(n){if(!a[n]){var i=e[n];if(!i)throw Error("source buffer exists for track "+n+", however track does not");var d=i.levelCodec||i.codec;d&&"audio"===n.slice(0,5)&&(d=be(d,t.hls.config.preferManagedMediaSource));var o=i.container+";codecs="+d;t.log("creating sourceBuffer("+o+")");try{var s=a[n]=r.addSourceBuffer(o),l=n;t.addBufferListener(l,"updatestart",t._onSBUpdateStart),t.addBufferListener(l,"updateend",t._onSBUpdateEnd),t.addBufferListener(l,"error",t._onSBUpdateError),t.addBufferListener(l,"bufferedchange",function(e,a){var r=a.removedRanges;null!=r&&r.length&&t.hls.trigger(En.BUFFER_FLUSHED,{type:n})}),t.tracks[n]={buffer:s,codec:d,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(e){t.error("error while trying to add sourceBuffer: "+e.message),t.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:o})}}};for(var i in e)n(i)},t._onSBUpdateStart=function(e){var t=this.operationQueue,a=t.current(e);a.onStart()},t._onSBUpdateEnd=function(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);var a=this.operationQueue,r=a.current(e);r.onComplete(),a.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){var a=new Error(e+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState)),r;this.error(""+a,t),this.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:a,fatal:!1});var n=this.operationQueue.current(e);n&&n.onError(a)},t.removeExecutor=function(e,t,a){var r=this.media,n=this.mediaSource,i=this.operationQueue,d=this.sourceBuffer,o=d[e];if(!r||!n||!o)return this.warn("Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(e);var s=yn(r.duration)?r.duration:1/0,l=yn(n.duration)?n.duration:1/0,u=Math.max(0,t),c=Math.min(a,s,l);c>u&&(!o.ending||o.ended)?(o.ended=!1,this.log("Removing ["+u+","+c+"] from the "+e+" SourceBuffer"),o.remove(u,c)):i.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var a=this.sourceBuffer[t];if(!a){if(!this.pendingTracks[t])throw new Error("Attempting to append to the "+t+" SourceBuffer, but it does not exist");return}a.ended=!1,a.appendBuffer(e)},t.blockBuffers=function(e,t){var a=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var r=this.operationQueue,n=t.map(function(e){return r.appendBlocker(e)});Promise.all(n).then(function(){e(),t.forEach(function(e){var t=a.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,a){var r=this.sourceBuffer[e];if(r){var n=a.bind(this,e);this.listeners[e].push({event:t,listener:n}),r.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(e){t.removeEventListener(e.event,e.listener)})},s(e,[{key:"mediaSrc",get:function(){var e=(null==(t=this.media)?void 0:t.firstChild)||this.media,t;return null==e?void 0:e.src}}]),e}(),zd={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},Qd=function(e){var t=e;return zd.hasOwnProperty(e)&&(t=zd[e]),String.fromCharCode(t)},Zd=15,$d=100,Jd={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},eo={17:2,18:4,21:6,22:8,23:10,19:13,20:15},to={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ao={25:2,26:4,29:6,30:8,31:10,27:13,28:15},ro=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],no=function(){function e(){this.time=null,this.verboseLevel=0}var t=e.prototype;return t.log=function(e,t){if(this.verboseLevel>=e){var a="function"==typeof t?t():t;In.log(this.time+" ["+e+"] "+a)}},e}(),io=function(e){for(var t=[],a=0;a<e.length;a++)t.push(e[a].toString(16));return t},oo=function(){function e(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],a=0,r;a<t.length;a++)r=t[a],e.hasOwnProperty(r)&&(this[r]=e[r])},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),so=function(){function e(){this.uchar=" ",this.penState=new oo}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),lo=function(){function e(e){this.chars=[],this.pos=0,this.currPenState=new oo,this.cueStartTime=null,this.logger=void 0;for(var t=0;t<$d;t++)this.chars.push(new so);this.logger=e}var t=e.prototype;return t.equals=function(e){for(var t=0;t<$d;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0},t.copy=function(e){for(var t=0;t<$d;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<$d;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),0>this.pos?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>$d&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=$d)},t.moveCursor=function(e){var t=this.pos+e;if(1<e)for(var a=this.pos+1;a<t+1;a++)this.chars[a].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){var t=this;144<=e&&this.backSpace();var a=Qd(e);return this.pos>=$d?void this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+a+") at position "+t.pos+". Skipping it!"}):void(this.chars[this.pos].setChar(a,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<$d;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,a=0,r;a<$d;a++)r=this.chars[a].uchar," "!==r&&(t=!1),e.push(r);return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e);var t=this.chars[this.pos];t.setPenState(this.currPenState)},e}(),uo=function(){function e(e){this.rows=[],this.currRow=Zd-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var t=0;t<Zd;t++)this.rows.push(new lo(e));this.logger=e}var t=e.prototype;return t.reset=function(){for(var e=0;e<Zd;e++)this.rows[e].clear();this.currRow=Zd-1},t.equals=function(e){for(var t=!0,a=0;a<Zd;a++)if(!this.rows[a].equals(e.rows[a])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<Zd;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<Zd;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){var e=this.rows[this.currRow];e.backSpace()},t.clearToEndOfRow=function(){var e=this.rows[this.currRow];e.clearToEndOfRow()},t.insertChar=function(e){var t=this.rows[this.currRow];t.insertChar(e)},t.setPen=function(e){var t=this.rows[this.currRow];t.setPenStyles(e)},t.moveCursor=function(e){var t=this.rows[this.currRow];t.moveCursor(e)},t.setCursor=function(e){this.logger.log(2,"setCursor: "+e);var t=this.rows[this.currRow];t.setCursor(e)},t.setPAC=function(e){this.logger.log(2,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var a=0;a<Zd;a++)this.rows[a].clear();var r=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){var d=n.rows[r].cueStartTime,o=this.logger.time;if(null!==d&&null!==o&&d<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(n.rows[r+s])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,c=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[c].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)},t.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){var e=this;if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,a=this.rows.splice(t,1)[0];a.clear(),this.rows.splice(this.currRow,0,a),this.logger.log(2,"Rolling up")},t.getDisplayText=function(e){e=e||!1;for(var t=[],a="",r=-1,n=0,d;n<Zd;n++)d=this.rows[n].getTextString(),d&&(r=n+1,e?t.push("Row "+r+": '"+d+"'"):t.push(d.trim()));return 0<t.length&&(e?a="["+t.join(" | ")+"]":a=t.join("\n")),a},t.getTextAndFormat=function(){return this.rows},e}(),co=function(){function e(e,t,a){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 uo(a),this.nonDisplayedMemory=new uo(a),this.lastOutputScreen=new uo(a),this.currRollUpRow=this.displayedMemory.rows[Zd-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=a}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Zd-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e===this.mode||(this.mode=e,this.logger.log(2,function(){return"MODE="+e}),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=this,a=0;a<e.length;a++)this.writeScreen.insertChar(e[a]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return r+": "+t.writeScreen.getDisplayText(!0)}),("MODE_PAINT-ON"===this.mode||"MODE_ROLL-UP"===this.mode)&&(this.logger.log(1,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"===this.mode||(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1,underline:1==e%2,italics:46<=e};if(!t.italics){var a=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][a]}else t.foreground="white";this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null===t||this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?!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.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&!this.displayedMemory.isEmpty()&&(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)},e}(),fo=function(){function e(e,t,a){this.channels=void 0,this.currentChannel=0,this.cmdHistory=tr(),this.logger=void 0;var r=this.logger=new no;this.channels=[null,new co(e,t,r),new co(e+1,a,r)]}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r=!1,n,d,o;this.logger.time=e;for(var s=0;s<t.length;s+=2){if(d=127&t[s],o=127&t[s+1],0===d&&0===o)continue;else this.logger.log(3,"["+io([t[s],t[s+1]])+"] -> ("+io([d,o])+")");if(n=this.parseCmd(d,o),n||(n=this.parseMidrow(d,o)),n||(n=this.parsePAC(d,o)),n||(n=this.parseBackgroundAttributes(d,o)),!n&&(r=this.parseChars(d,o),r)){var l=this.currentChannel;if(l&&0<l){var u=this.channels[l];u.insertChars(r)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||r||this.logger.log(2,"Couldn't parse cleaned data "+io([d,o])+" orig: "+io([t[s],t[s+1]]))}},t.parseCmd=function(e,t){var a=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&32<=t&&47>=t||(23===e||31===e)&&33<=t&&35>=t))return!1;if(er(e,t,a))return Ja(null,null,a),this.logger.log(3,"Repeated command ("+io([e,t])+") is dropped"),!0;var r=20===e||21===e||23===e?1:2,n=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47==t&&n.ccEOC():n.ccTO(t-32),Ja(e,t,a),this.currentChannel=r,!0},t.parseMidrow=function(e,t){var a=0;if((17===e||25===e)&&32<=t&&47>=t){if(a=17===e?1:2,a!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var r=this.channels[a];return!!r&&(r.ccMIDROW(t),this.logger.log(3,"MIDROW ("+io([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var a=this.cmdHistory,r;if(!((17<=e&&23>=e||25<=e&&31>=e)&&64<=t&&127>=t||(16===e||24===e)&&64<=t&&95>=t))return!1;if(er(e,t,a))return Ja(null,null,a),!0;var n=23>=e?1:2;r=64<=t&&95>=t?1===n?Jd[e]:to[e]:1===n?eo[e]:ao[e];var i=this.channels[n];return!!i&&(i.setPAC(this.interpretPAC(r,t)),Ja(e,t,a),this.currentChannel=n,!0)},t.interpretPAC=function(e,t){var a={color:null,italics:!1,indent:null,underline:!1,row:e},r;return r=95<t?t-96:t-64,a.underline=1==(1&r),13>=r?a.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:15>=r?(a.italics=!0,a.color="white"):a.indent=4*Math.floor((r-16)/2),a},t.parseChars=function(e,t){var a=null,r=null,n;if(25<=e?(n=2,r=e-8):(n=1,r=e),17<=r&&19>=r){var i;i=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,"Special char '"+Qd(i)+"' in channel "+n),a=[i]}else 32<=e&&127>=e&&(a=0===t?[e]:[e,t]);if(a){var d=io(a);this.logger.log(3,"Char codes =  "+d.join(",")),Ja(e,t,this.cmdHistory)}return a},t.parseBackgroundAttributes=function(e,t){if(!((16===e||24===e)&&32<=t&&47>=t||(23===e||31===e)&&45<=t&&47>=t))return!1;var a={},r;16===e||24===e?(r=Math.floor((t-32)/2),a.background=ro[r],1==t%2&&(a.background+="_semi")):45===t?a.background="transparent":(a.foreground="black",47==t&&(a.underline=!0));var n=23>=e?1:2,i=this.channels[n];return i.setBkgData(a),Ja(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0,t;e<Object.keys(this.channels).length;e++)t=this.channels[e],t&&t.reset();this.cmdHistory=tr()},t.cueSplitAtTime=function(e){for(var t=0,a;t<this.channels.length;t++)a=this.channels[t],a&&a.cueSplitAtTime(e)},e}(),go=function(){function e(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}var t=e.prototype;return t.dispatchCue=function(){null===this.startTime||(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,a){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=a,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}(),mo=function(){function e(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var a=t.toLowerCase();return!!~e.indexOf(a)&&a}function t(t){return e(i,t)}function a(t){return e(d,t)}function r(e){for(var t=arguments.length,a=Array(1<t?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];for(var n=1,d;n<arguments.length;n++)for(var o in d=arguments[n],d)e[o]=d[o];return e}function n(e,n,i){var d=this,o={enumerable:!0};d.hasBeenReset=!1;var s="",l=!1,u=e,c=n,f=i,g=null,m="",p=!0,y="auto",h="start",T=50,E="middle",S=50,L="middle";Object.defineProperty(d,"id",r({},o,{get:function(){return s},set:function(e){s=""+e}})),Object.defineProperty(d,"pauseOnExit",r({},o,{get:function(){return l},set:function(e){l=!!e}})),Object.defineProperty(d,"startTime",r({},o,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},o,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},o,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},o,{get:function(){return g},set:function(e){g=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},o,{get:function(){return m},set:function(e){var a=t(e);if(!1===a)throw new SyntaxError("An invalid or illegal string was specified.");m=a,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},o,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},o,{get:function(){return y},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},o,{get:function(){return h},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");h=t,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},o,{get:function(){return T},set:function(e){if(0>e||100<e)throw new Error("Position must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},o,{get:function(){return E},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},o,{get:function(){return S},set:function(e){if(0>e||100<e)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},o,{get:function(){return L},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");L=t,this.hasBeenReset=!0}})),d.displayState=void 0}if(null!=Nn&&Nn.VTTCue)return self.VTTCue;var i=["","lr","rl"],d=["start","middle","end","left","right"];return n.prototype.getCueAsHTML=function(){var e=self.WebVTT;return e.convertCueToDOMTree(self,this.text)},n}(),po=function(){function e(){}var t=e.prototype;return t.decode=function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}(),yo=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,a){return a?this.has(e)?this.values[e]:t[a]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var a=0;a<r.length;++a)if(t===r[a]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function e(t,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var e=parseFloat(a);if(0<=e&&100>=e)return this.set(t,e),!0}return!1},e}(),ho=new mo(0,0,""),To="middle"===ho.align?"middle":"center",Eo=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new po,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){function t(){var e=r.buffer,t=0;for(e=ir(e);t<e.length&&"\r"!==e[t]&&"\n"!==e[t];)++t;var a=e.slice(0,t);return"\r"===e[t]&&++t,"\n"===e[t]&&++t,r.buffer=e.slice(t),a}function a(e){rr(e,function(){},/:/)}var r=this;e&&(r.buffer+=r.decoder.decode(e,{stream:!0}));try{var n="";if("INITIAL"===r.state){if(!/\r\n|\n/.test(r.buffer))return this;n=t();var i=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(null!=i&&i[0]))throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var d=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(d?d=!1:n=t(),r.state){case"HEADER":/:/.test(n)?a(n):!n&&(r.state="ID");continue;case"NOTE":n||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){r.state="NOTE";break}if(!n)continue;if(r.cue=new mo(0,0,""),r.state="CUE",-1===n.indexOf("-->")){r.cue.id=n;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{nr(n,r.cue,r.regionList)}catch(t){r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var o=-1!==n.indexOf("-->");if(!n||o&&(d=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(null===r.cue)continue;r.cue.text&&(r.cue.text+="\n"),r.cue.text+=n}continue;case"BADCUE":n||(r.state="ID");}}}catch(t){"CUETEXT"===r.state&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state="INITIAL"===r.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){var t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(a){t.onparsingerror&&t.onparsingerror(a)}return t.onflush&&t.onflush(),this},e}(),So=/\r\n|\n\r|\n|\r/g,Lo=function(e,t,a){return void 0===a&&(a=0),e.slice(a,a+t.length)===t},Ro=function(e){var t=parseInt(e.slice(-3)),a=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=9<e.length?parseInt(e.substring(0,e.indexOf(":"))):0;if(!yn(t)||!yn(a)||!yn(r)||!yn(n))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*a,t+=60000*r,t+=3600000*n,t},Ao=function e(t){for(var e=5381,a=t.length;a;)e=33*e^t.charCodeAt(--a);return(e>>>0).toString()},vo=function(e,t,a){var r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,void(r.new=!1);for(;null!=(i=n)&&i.new;){var i;e.ccOffset+=r.start-n.start,r.new=!1,r=n,n=e[r.prevCC]}e.presentationOffset=a},Io="stpp.ttml.im1t",Do=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ko=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_o={left:"start",center:"center",right:"end",start:"start",end:"end"},Co=function(){function e(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=Rr(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(En.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(En.FRAG_LOADING,this.onFragLoading,this),e.on(En.FRAG_LOADED,this.onFragLoaded,this),e.on(En.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(En.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(En.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(En.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(En.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(En.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(En.FRAG_LOADING,this.onFragLoading,this),e.off(En.FRAG_LOADED,this.onFragLoaded,this),e.off(En.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(En.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(En.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(En.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(En.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0},t.initCea608Parsers=function(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){var e=new go(this,"textTrack1"),t=new go(this,"textTrack2"),a=new go(this,"textTrack3"),r=new go(this,"textTrack4");this.cea608Parser1=new fo(1,e,t),this.cea608Parser2=new fo(3,a,r)}},t.addCues=function(e,t,a,r,n){for(var d=!1,o=n.length;o--;){var s=n[o],l=Lr(s[0],s[1],t,a);if(0<=l&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],a),d=!0,.5<l/(a-t)))return}if(d||n.push([t,a]),this.config.renderTextTracksNatively){var u=this.captionsTracks[e];this.Cues.newCue(u,t,a,r)}else{var c=this.Cues.newCue(null,t,a,r);this.hls.trigger(En.CUES_PARSED,{type:"captions",cues:c,track:e})}},t.onInitPtsFound=function(e,t){var a=this,r=t.frag,n=t.id,i=t.initPTS,d=t.timescale,o=this.unparsedVttFrags;"main"===n&&(this.initPTS[r.cc]={baseTime:i,timescale:d}),o.length&&(this.unparsedVttFrags=[],o.forEach(function(e){a.onFragLoaded(En.FRAG_LOADED,e)}))},t.getExistingTrack=function(e,t){var a=this.media;if(a)for(var r=0,n;r<a.textTracks.length;r++)if(n=a.textTracks[r],Sr(n,{name:e,lang:t,attrs:{}}))return n;return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,a=this.captionsTracks,r=this.media,n=t[e],i=n.label,d=n.languageCode,o=this.getExistingTrack(i,d);if(!o){var s=this.createTextTrack("captions",i,d);s&&(s[e]=!0,a[e]=s)}else a[e]=o,We(a[e]),Ve(a[e],r)}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var a=t.label,r={_id:e,label:a,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(En.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},t.createTextTrack=function(e,t,a){var r=this.media;return r?r.addTextTrack(e,t,a):void 0},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){We(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Rr(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var a=0;a<t.length;a++)We(t[a])}},t.onSubtitleTracksUpdated=function(e,t){var a=this,r=t.subtitleTracks||[],n=r.some(function(e){return e.textCodec===Io});if(this.config.enableWebVTT||n&&this.config.enableIMSC1){var i=Xa(this.tracks,r);if(i)return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){var d=this.media,o=d?ze(d.textTracks):null;if(this.tracks.forEach(function(e){var t;if(o){for(var r=null,n=0;n<o.length;n++)if(o[n]&&Sr(o[n],e)){r=o[n],o[n]=null;break}r&&(t=r)}if(t)We(t);else{var d=Er(e);t=a.createTextTrack(d,e.name,e.lang),t&&(t.mode="disabled")}t&&a.textTracks.push(t)}),null!=o&&o.length){var s=o.filter(function(e){return null!==e}).map(function(e){return e.label});s.length&&In.warn("Media element contains unused subtitle tracks: "+s.join(", ")+". Replace media element for each source to clear TextTracks and captions menu.")}}else if(this.tracks.length){var l=this.tracks.map(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}});this.hls.trigger(En.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},t.onManifestLoaded=function(e,t){var a=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack"+t[1],n=a.captionsProperties[r];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}})},t.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]},t.onFragLoading=function(e,t){this.initCea608Parsers();var a=this.cea608Parser1,r=this.cea608Parser2,n=this.lastCc,i=this.lastSn,d=this.lastPartIndex;if(this.enabled&&a&&r&&t.frag.type===hi.MAIN){var o=t.frag,s=o.cc,l=o.sn,u=null==(c=null==t||null==(f=t.part)?void 0:f.index)?-1:c,c,f;l===i+1||l===i&&u===d+1||s===n||(a.reset(),r.reset()),this.lastCc=s,this.lastSn=l,this.lastPartIndex=u}},t.onFragLoaded=function(e,t){var a=t.frag,r=t.payload;if(a.type===hi.SUBTITLE)if(r.byteLength){var n=a.decryptdata,i=("stats"in t);if(null==n||!n.encrypted||i){var d=this.tracks[a.level],o=this.vttCCs;o[a.cc]||(o[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),d&&d.textCodec===Io?this._parseIMSC1(a,r):this._parseVTTs(t)}}else this.hls.trigger(En.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var a=this,r=this.hls;sr(t,this.initPTS[e.cc],function(t){a._appendCues(t,e.level),r.trigger(En.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(t){In.log("Failed to parse IMSC1: "+t),r.trigger(En.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})},t._parseVTTs=function(e){var t=this,a=e.frag,r=e.payload,n=this.initPTS,i=this.unparsedVttFrags,d=n.length-1,o;if(!n[a.cc]&&-1===d)return void i.push(e);var s=this.hls,l=null!=(o=a.initSegment)&&o.data?de(a.initSegment.data,new Uint8Array(r)):r;or(l,this.initPTS[a.cc],this.vttCCs,a.cc,a.start,function(e){t._appendCues(e,a.level),s.trigger(En.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(n){var o="Missing initPTS for VTT MPEGTS"===n.message;o?i.push(e):t._fallbackToIMSC1(a,r),In.log("Failed to parse VTT cue: "+n),o&&d>a.cc||s.trigger(En.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:n})})},t._fallbackToIMSC1=function(e,t){var a=this,r=this.tracks[e.level];r.textCodec||sr(t,this.initPTS[e.cc],function(){r.textCodec=Io,a._parseIMSC1(e,t)},function(){r.textCodec="wvtt"})},t._appendCues=function(e,t){var a=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(function(e){return Ye(r,e)})}else{var n=this.tracks[t];if(!n)return;var i=n.default?"default":"subtitles"+t;a.trigger(En.CUES_PARSED,{type:"subtitles",cues:e,track:i})}},t.onFragDecrypted=function(e,t){var a=t.frag;a.type===hi.SUBTITLE&&this.onFragLoaded(En.FRAG_LOADED,t)},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){this.initCea608Parsers();var a=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&a&&r){var n=t.frag,d=t.samples;if(n.type!==hi.MAIN||"NONE"!==this.closedCaptionsForLevel(n))for(var o=0,s;o<d.length;o++)if(s=d[o].bytes,s){var l=this.extractCea608Data(s);a.addData(d[o].pts,l[0]),r.addData(d[o].pts,l[1])}}},t.onBufferFlushing=function(e,t){var a=t.startOffset,r=t.endOffset,n=t.endOffsetSubtitles,i=t.type,d=this.media;if(d&&!(d.currentTime<r)){if(!i||"video"===i){var o=this.captionsTracks;Object.keys(o).forEach(function(e){return qe(o[e],a,r)})}if(this.config.renderTextTracksNatively&&0===a&&void 0!==n){var s=this.textTracks;Object.keys(s).forEach(function(e){return qe(s[e],a,n)})}}},t.extractCea608Data=function(e){for(var t=[[],[]],a=31&e[0],r=2,n=0;n<a;n++){var i=e[r++],d=127&e[r++],o=127&e[r++];if(0!==d||0!==o){if(0!=(4&i)){var s=3&i;(0==s||1===s)&&(t[s].push(d),t[s].push(o))}}}return t},e}(),bo=function(){function e(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()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var e=this.hls;e.on(En.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(En.BUFFER_CODECS,this.onBufferCodecs,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var e=this.hls;e.off(En.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(En.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(En.BUFFER_CODECS,this.onBufferCodecs,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(e,t){var a=this.hls.levels[t.droppedLevel];this.isLevelAllowed(a)&&this.restrictedLevels.push({bitrate:a.bitrate,height:a.height,width:a.width})},t.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},t.onManifestParsed=function(e,t){var a=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,a.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onLevelsUpdated=function(){this.timer&&yn(this.autoLevelCapping)&&this.detectPlayerSize()},t.onBufferCodecs=function(e,t){var a=this.hls;a.config.capLevelToPlayerSize&&t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media){if(0>=this.mediaHeight||0>=this.mediaWidth)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,a=this.getMaxLevel(e.length-1);a!==this.autoLevelCapping&&In.log("Setting autoLevelCapping to "+a+": "+e[a].height+"p@"+e[a].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=a,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var a=this,r=this.hls.levels;if(!r.length)return-1;var n=r.filter(function(e,r){return a.isLevelAllowed(e)&&r<=t});return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var a=e.getBoundingClientRect();t.width=a.width,t.height=a.height,t.width||t.height||(t.width=a.right-a.left||e.width||0,t.height=a.bottom-a.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},e.getMaxLevelByMediaSize=function(e,t,a){if(!(null!=e&&e.length))return-1;for(var r=function(e,t){return!t||e.width!==t.width||e.height!==t.height},n=e.length-1,d=Math.max(t,a),o=0,s;o<e.length;o+=1)if(s=e[o],(s.width>=d||s.height>=d)&&r(s,e[o+1])){n=o;break}return n},s(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return e}}]),e}(),xo=function(){function e(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()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(En.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(En.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var a=this.hls.config;if(a.capLevelOnFPSDrop){var r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),a.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,a){var r=performance.now();if(t){if(this.lastTime){var n=r-this.lastTime,i=a-this.lastDroppedFrames,d=t-this.lastDecodedFrames,o=this.hls;if(o.trigger(En.FPS_DROP,{currentDropped:i,currentDecoded:d,totalDroppedFrames:a}),0<1e3*i/n&&i>o.config.fpsDroppedMonitoringThreshold*d){var s=o.currentLevel;In.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0<s&&(-1===o.autoLevelCapping||o.autoLevelCapping>=s)&&(--s,o.trigger(En.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:o.currentLevel}),o.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=a,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),Po="[eme]",Fo=function(){function e(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=In.debug.bind(In,Po),this.log=In.log.bind(In,Po),this.warn=In.warn.bind(In,Po),this.error=In.error.bind(In,Po),this.hls=t,this.config=t.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},t.registerListeners=function(){this.hls.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(En.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(En.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(En.MANIFEST_LOADED,this.onManifestLoaded,this)},t.unregisterListeners=function(){this.hls.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(En.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(En.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(En.MANIFEST_LOADED,this.onManifestLoaded,this)},t.getLicenseServerUrl=function(e){var t=this.config,a=t.drmSystems,r=t.widevineLicenseUrl,n=a[e];if(n)return n.licenseUrl;if(e===wn.WIDEVINE&&r)return r;throw new Error("no license server URL configured for key-system \""+e+"\"")},t.getServerCertificateUrl=function(e){var t=this.config.drmSystems,a=t[e];return a?a.serverCertificateUrl:void this.log("No Server Certificate in config.drmSystems[\""+e+"\"]")},t.attemptKeySystemAccess=function(e){var t=this,a=this.hls.levels,r=function(e,t,r){return!!e&&r.indexOf(e)===t},n=a.map(function(e){return e.audioCodec}).filter(r),i=a.map(function(e){return e.videoCodec}).filter(r);return 0===n.length+i.length&&i.push("avc1.42e01e"),new Promise(function(a,r){(function e(d){var o=d.shift();t.getMediaKeysPromise(o,n,i).then(function(e){return a({keySystem:o,mediaKeys:e})}).catch(function(t){d.length?e(d):t instanceof Oo?r(t):r(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})})(e)})},t.requestMediaKeySystemAccess=function(e,t){var a=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof a){var r="Configured requestMediaKeySystemAccess is not a function "+a;return null===Un&&"http:"===self.location.protocol&&(r="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(r))}return a(e,t)},t.getMediaKeysPromise=function(e,t,a){var r=this,n=w(e,t,a,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e],d=null==i?void 0:i.keySystemAccess;if(!d){this.log("Requesting encrypted media \""+e+"\" key-system access with config: "+JSON.stringify(n)),d=this.requestMediaKeySystemAccess(e,n);var o=this.keySystemAccessPromises[e]={keySystemAccess:d};return d.catch(function(t){r.log("Failed to obtain access to key-system \""+e+"\": "+t)}),d.then(function(t){r.log("Access for key-system \""+t.keySystem+"\" obtained");var a=r.fetchServerCertificate(e);return r.log("Create media-keys for \""+e+"\""),o.mediaKeys=t.createMediaKeys().then(function(t){return r.log("Media-keys created for \""+e+"\""),a.then(function(a){return a?r.setMediaKeysServerCertificate(t,e,a):t})}),o.mediaKeys.catch(function(t){r.error("Failed to create media-keys for \""+e+"\"}: "+t)}),o.mediaKeys})}return d.then(function(){return i.mediaKeys})},t.createMediaKeySessionContext=function(e){var t=e.decryptdata,a=e.keySystem,r=e.mediaKeys;this.log("Creating key-system session \""+a+"\" keyId: "+ti.hexDump(t.keyId||[]));var n=r.createSession(),i={decryptdata:t,keySystem:a,mediaKeys:r,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i},t.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var a=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t);this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(a,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},t.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return ti.hexDump(e.keyId)},t.updateKeySession=function(e,t){var a=e.mediaKeysSession,r;return this.log("Updating key-session \""+a.sessionId+"\" for keyID "+ti.hexDump((null==(r=e.decryptdata)?void 0:r.keyId)||[])+"\n      } (data length: "+(t?t.byteLength:t)+")"),a.update(t)},t.selectKeySystemFormat=function(e){var 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},t.getKeyFormatPromise=function(e){var t=this;return new Promise(function(a,r){var n=N(t.config),i=e.map(P).filter(function(e){return!!e&&-1!==n.indexOf(e)});return t.getKeySystemSelectionPromise(i).then(function(e){var t=e.keySystem,n=O(t);n?a(n):r(new Error("Unable to find format for key-system \""+t+"\""))}).catch(r)})},t.loadKey=function(e){var t=this,a=e.keyInfo.decryptdata,r=this.getKeyIdString(a),n="(keyId: "+r+" format: \""+a.keyFormat+"\" method: "+a.method+" uri: "+a.uri+")";this.log("Starting session for key "+n);var i=this.keyIdToKeySessionPromise[r];return i||(i=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(a).then(function(r){var i=r.keySystem,d=r.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+n),t.attemptSetMediaKeys(i,d).then(function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({keySystem:i,mediaKeys:d,decryptdata:a});return t.generateRequestWithPreferredKeySession(e,"cenc",a.pssh,"playlist-key")})}),i.catch(function(e){return t.handleError(e)})),i},t.throwIfDestroyed=function(){if(!this.hls)throw new Error("invalid state")},t.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Oo?this.hls.trigger(En.ERROR,e.data):this.hls.trigger(En.ERROR,{type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},t.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),a=this.keyIdToKeySessionPromise[t];if(!a){var r=P(e.keyFormat),n=r?[r]:N(this.config);return this.attemptKeySystemAccess(n)}return a},t.getKeySystemSelectionPromise=function(e){if(e.length||(e=N(this.config)),0===e.length)throw new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},t._onMediaEncrypted=function(e){var t=this,a=e.initDataType,r=e.initData;if(this.debug("\""+e.type+"\" event: init data type: \""+a+"\""),null!==r){var n,d;if("sinf"===a&&this.config.drmSystems[wn.FAIRPLAY]){var o=G(new Uint8Array(r));try{var s=k(JSON.parse(o).sinf),l=ee(new Uint8Array(s));if(!l)return;n=l.subarray(8,24),d=wn.FAIRPLAY}catch(e){return void this.warn("Failed to parse sinf \"encrypted\" event message initData")}}else{var u=pe(r);if(null===u)return;0===u.version&&u.systemId===Bn.WIDEVINE&&u.data&&(n=u.data.subarray(8,24)),d=F(u.systemId)}if(d&&n){for(var c=ti.hexDump(n),f=this.keyIdToKeySessionPromise,g=this.mediaKeySessions,m=f[c],p=function(){var e=g[y],i=e.decryptdata;if(i.pssh||!i.keyId)return 0;var d=ti.hexDump(i.keyId);if(c===d||-1!==i.uri.replace(/-/g,"").indexOf(c))return m=f[d],delete f[d],i.pssh=new Uint8Array(r),i.keyId=n,m=f[c]=m.then(function(){return t.generateRequestWithPreferredKeySession(e,a,r,"encrypted-event-key-match")}),1},y=0,h;y<g.length&&(h=p(),0===h||1!==h);y++);m||(m=f[c]=this.getKeySystemSelectionPromise([d]).then(function(e){var i=e.keySystem,d=e.mediaKeys,o;t.throwIfDestroyed();var s=new di("ISO-23001-7",c,null==(o=O(i))?"":o);return s.pssh=new Uint8Array(r),s.keyId=n,t.attemptSetMediaKeys(i,d).then(function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({decryptdata:s,keySystem:i,mediaKeys:d});return t.generateRequestWithPreferredKeySession(e,a,r,"encrypted-event-no-match")})})),m.catch(function(e){return t.handleError(e)})}}},t._onWaitingForKey=function(e){this.log("\""+e.type+"\" event")},t.attemptSetMediaKeys=function(e,t){var a=this,r=this.setMediaKeysQueue.slice();this.log("Setting media-keys for \""+e+"\"");var n=Promise.all(r).then(function(){if(!a.media)throw new Error("Attempted to set mediaKeys without media element attached");return a.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(n),n.then(function(){a.log("Media-keys set for \""+e+"\""),r.push(n),a.setMediaKeysQueue=a.setMediaKeysQueue.filter(function(e){return-1===r.indexOf(e)})})},t.generateRequestWithPreferredKeySession=function(e,t,a,r){var n=this,i=null==(d=this.config.drmSystems)||null==(o=d[e.keySystem])?void 0:o.generateRequest,d,o;if(i)try{var s=i.call(this.hls,t,a,e);if(!s)throw new Error("Invalid response from configured generateRequest filter");t=s.initDataType,a=e.decryptdata.pssh=s.initData?new Uint8Array(s.initData):null}catch(e){var l;if(this.warn(e.message),null!=(l=this.hls)&&l.config.debug)throw e}if(null===a)return this.log("Skipping key-session request for \""+r+"\" (no initData)"),Promise.resolve(e);var u=this.getKeyIdString(e.decryptdata);this.log("Generating key-session request for \""+r+"\": "+u+" (init data type: "+t+" length: "+(a?a.byteLength:null)+")");var c=new Md,f=e._onmessage=function(t){var a=e.mediaKeysSession;if(!a)return void c.emit("error",new Error("invalid state"));var r=t.messageType,i=t.message;n.log("\""+r+"\" message event for session \""+a.sessionId+"\" message size: "+i.byteLength),"license-request"===r||"license-renewal"===r?n.renewLicense(e,i).catch(function(e){n.handleError(e),c.emit("error",e)}):"license-release"===r?e.keySystem===wn.FAIRPLAY&&(n.updateKeySession(e,x("acknowledged")),n.removeSession(e)):n.warn("unhandled media key message type \""+r+"\"")},g=e._onkeystatuseschange=function(){var t=e.mediaKeysSession;if(!t)return void c.emit("error",new Error("invalid state"));n.onKeyStatusChange(e);var a=e.keyStatus;c.emit("keyStatus",a),"expired"===a&&(n.warn(e.keySystem+" expired for key "+u),n.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",f),e.mediaKeysSession.addEventListener("keystatuseschange",g);var m=new Promise(function(e,t){c.on("error",t),c.on("keyStatus",function(a){a.startsWith("usable")?e():"output-restricted"===a?t(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===a?t(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},"key status changed to \""+a+"\"")):"expired"===a?t(new Error("key expired while generating request")):n.warn("unhandled key status change \""+a+"\"")})});return e.mediaKeysSession.generateRequest(t,a).then(function(){var t;n.log("Request generated for key-session \""+(null==(t=e.mediaKeysSession)?void 0:t.sessionId)+"\" keyId: "+u)}).catch(function(e){throw new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)}).then(function(){return m}).catch(function(t){throw c.removeAllListeners(),n.removeSession(e),t}).then(function(){return c.removeAllListeners(),e})},t.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(a,r){t.log("key status change \""+a+"\" for keyStatuses keyId: "+ti.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))+" session keyId: "+ti.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=a})},t.fetchServerCertificate=function(e){var t=this.config,a=t.loader,n=new a(t),i=this.getServerCertificateUrl(e);return i?(this.log("Fetching server certificate for \""+e+"\""),new Promise(function(a,d){var o={responseType:"arraybuffer",url:i},s=t.certLoadPolicy.default,l={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};n.load(o,l,{onSuccess:function(e){a(e.data)},onError:function(t,a,n){d(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:r({url:o.url,data:void 0},t)},"\""+e+"\" certificate request failed ("+i+"). Status: "+t.code+" ("+t.text+")"))},onTimeout:function(t,a,r){d(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:o.url,data:void 0}},"\""+e+"\" certificate request timed out ("+i+")"))},onAbort:function(){d(new Error("aborted"))}})})):Promise.resolve()},t.setMediaKeysServerCertificate=function(e,t,a){var r=this;return new Promise(function(n,i){e.setServerCertificate(a).then(function(i){r.log("setServerCertificate "+(i?"success":"not supported by CDM")+" ("+(null==a?void 0:a.byteLength)+") on \""+t+"\""),n(e)}).catch(function(e){i(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})},t.renewLicense=function(e,t){var a=this;return this.requestLicense(e,new Uint8Array(t)).then(function(t){return a.updateKeySession(e,new Uint8Array(t)).catch(function(e){throw new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)})})},t.unpackPlayReadyKeyMessage=function(e,t){var a=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!a.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var r=new DOMParser().parseFromString(a,"application/xml"),n=r.querySelectorAll("HttpHeader");if(0<n.length)for(var d=0,o=n.length,s;d<o;d++){var l,u;s=n[d];var c=null==(l=s.querySelector("name"))?void 0:l.textContent,f=null==(u=s.querySelector("value"))?void 0:u.textContent;c&&f&&e.setRequestHeader(c,f)}var g=r.querySelector("Challenge"),m=null==g?void 0:g.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return x(atob(m))},t.setupLicenseXHR=function(e,t,a,r){var n=this,i=this.config.licenseXhrSetup;return i?Promise.resolve().then(function(){if(!a.decryptdata)throw new Error("Key removed");return i.call(n.hls,e,t,a,r)}).catch(function(d){if(!a.decryptdata)throw d;return e.open("POST",t,!0),i.call(n.hls,e,t,a,r)}).then(function(a){e.readyState||e.open("POST",t,!0);var n=a?a:r;return{xhr:e,licenseChallenge:n}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))},t.requestLicense=function(e,t){var a=this,r=this.config.keyLoadPolicy.default;return new Promise(function(n,i){var d=a.getLicenseServerUrl(e.keySystem);a.log("Sending license request to URL: "+d);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!a.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(4===o.readyState)if(200===o.status){a._requestLicenseFailureCount=0;var s=o.response;a.log("License received "+(s instanceof ArrayBuffer?s.byteLength:s));var l=a.config.licenseResponseCallback;if(l)try{s=l.call(a.hls,o,d,e)}catch(e){a.error(e)}n(s)}else{var u=r.errorRetry,c=u?u.maxNumRetry:0;if(a._requestLicenseFailureCount++,a._requestLicenseFailureCount>c||400<=o.status&&500>o.status)i(new Oo({type:Sn.KEY_SYSTEM_ERROR,details:Ln.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:d,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+d+"). Status: "+o.status+" ("+o.statusText+")"));else{var f=c-a._requestLicenseFailureCount+1;a.warn("Retrying license request, "+f+" attempts left"),a.requestLicense(e,t).then(n,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,a.setupLicenseXHR(o,d,e,t).then(function(t){var r=t.xhr,n=t.licenseChallenge;e.keySystem==wn.PLAYREADY&&(n=a.unpackPlayReadyKeyMessage(r,n)),r.send(n)})})},t.onMediaAttached=function(e,t){if(this.config.emeEnabled){var a=t.media;this.media=a,a.addEventListener("encrypted",this.onMediaEncrypted),a.addEventListener("waitingforkey",this.onWaitingForKey)}},t.onMediaDetached=function(){var t=this,a=this.media,r=this.mediaKeySessions;a&&(a.removeEventListener("encrypted",this.onMediaEncrypted),a.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},di.clearKeyUriToKeyIdMap();var n=r.length;e.CDMCleanupPromise=Promise.all(r.map(function(e){return t.removeSession(e)}).concat(null==a?void 0:a.setMediaKeys(null).catch(function(e){t.log("Could not clear media keys: "+e)}))).then(function(){n&&(t.log("finished closing key sessions and clearing media keys"),r.length=0)}).catch(function(e){t.log("Could not close sessions and clear media keys: "+e)})},t.onManifestLoading=function(){this.keyFormatPromise=null},t.onManifestLoaded=function(e,t){var a=t.sessionKeys;if(a&&this.config.emeEnabled&&!this.keyFormatPromise){var r=a.reduce(function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e},[]);this.log("Selecting key-system from session-keys "+r.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(r)}},t.removeSession=function(e){var t=this,a=e.mediaKeysSession,r=e.licenseXhr;if(a){this.log("Remove licenses and keys and close session "+a.sessionId),e._onmessage&&(a.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(a.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(e);return-1<n&&this.mediaKeySessions.splice(n,1),a.remove().catch(function(e){t.log("Could not remove session: "+e)}).then(function(){return a.close()}).catch(function(e){t.log("Could not close session: "+e)})}},e}();Fo.CDMCleanupPromise=void 0;var Oo=function(e){function t(t,a){var r;return r=e.call(this,a)||this,r.data=void 0,t.error||(t.error=new Error(a)),r.data=t,t.err=t.error,r}return c(t,e),t}(h(Error)),No;(function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"})(No||(No={}));var wo;(function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"})(wo||(wo={}));var Mo;(function(e){e.OBJECT="CMCD-Object",e.REQUEST="CMCD-Request",e.SESSION="CMCD-Session",e.STATUS="CMCD-Status"})(Mo||(Mo={}));var Bo=(ss={},ss[Mo.OBJECT]=["br","d","ot","tb"],ss[Mo.REQUEST]=["bl","dl","mtp","nor","nrr","su"],ss[Mo.SESSION]=["cid","pr","sf","sid","st","v"],ss[Mo.STATUS]=["bs","rtp"],ss),Uo=function e(t,a){this.value=void 0,this.params=void 0,Array.isArray(t)&&(t=t.map(function(t){return t instanceof e?t:new e(t)})),this.value=t,this.params=a},Go=function(e){this.description=void 0,this.description=e},Ko=/[\x00-\x1f\x7f]+/,Ho=function(e){return"ot"===e||"sf"===e||"st"===e},Vo=function(e){return"number"==typeof e?yn(e):null!=e&&""!==e&&!1!==e},Yo=function(e){return Math.round(e)},Wo=function(e){return 100*Yo(e/100)},qo={br:Yo,d:Yo,bl:Wo,dl:Wo,mtp:Wo,nor:function(e,t){return null!=t&&t.baseUrl&&(e=Yr(e,t.baseUrl)),encodeURIComponent(e)},rtp:Wo,tb:Yo},jo=/CMCD=[^&#]+/,Xo=function(){function e(e){var t=this;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=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(e){try{t.apply(e,{ot:No.MANIFEST,su:!t.initialized})}catch(e){In.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var a=e.frag,r=t.hls.levels[a.level],n=t.getObjectType(a),i={d:1e3*a.duration,ot:n};(n===No.VIDEO||n===No.AUDIO||n==No.MUXED)&&(i.br=r.bitrate/1e3,i.tb=t.getTopBandwidth(n)/1e3,i.bl=t.getBufferLength(n)),t.apply(e,i)}catch(e){In.warn("Could not generate segment CMCD data.",e)}},this.hls=e;var a=this.config=e.config,r=a.cmcd;null!=r&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Wr(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHED,this.onMediaDetached,this),e.on(En.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHED,this.onMediaDetached,this),e.off(En.BUFFER_CREATED,this.onBufferCreated,this)},t.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var a,r;this.audioBuffer=null==(a=t.tracks.audio)?void 0:a.buffer,this.videoBuffer=null==(r=t.tracks.video)?void 0:r.buffer},t.createData=function(){var e;return{v:1,sf:wo.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(e,t){void 0===t&&(t={}),u(t,this.createData());var a=t.ot===No.INIT||t.ot===No.VIDEO||t.ot===No.MUXED;this.starved&&a&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var r=this.includeKeys;r&&(t=Object.keys(t).reduce(function(e,a){return r.includes(a)&&(e[a]=t[a]),e},{})),this.useHeaders?(!e.headers&&(e.headers={}),zr(e.headers,t)):e.url=Zr(e.url,t)},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?No.TIMED_TEXT:"initSegment"===e.sn?No.INIT:"audio"===t?No.AUDIO:"main"===t?this.hls.audioTracks.length?No.VIDEO:No.MUXED:void 0},t.getTopBandwidth=function(e){var t=0,a=this.hls,r;if(e===No.AUDIO)r=a.audioTracks;else{var n=a.maxAutoLevel,i=-1<n?n+1:a.levels.length;r=a.levels.slice(0,i)}for(var d=L(r),o,s;!(o=d()).done;)s=o.value,s.bitrate>t&&(t=s.bitrate);return 0<t?t:NaN},t.getBufferLength=function(e){var t=this.hls.media,a=e===No.AUDIO?this.audioBuffer:this.videoBuffer;if(!a||!t)return NaN;var r=Hi.bufferInfo(a,t.currentTime,this.config.maxBufferHole);return 1e3*r.len},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,a=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new a(e)}var r=e.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(e,a,r){t(e),this.loader.load(e,a,r)},s(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,a=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new a(e)}var r=e.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(e,a,r){t(e),this.loader.load(e,a,r)},s(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},e}(),zo=function(){function e(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=In.log.bind(In,"[content-steering]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.ERROR,this.onError,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.ERROR,this.onError,this))},t.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(0<e)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},t.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},t.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},t.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},t.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(t){return t!==e}))},t.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},t.onManifestLoaded=function(e,t){var a=t.contentSteering;null===a||(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},t.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},t.onError=function(e,t){var a=t.errorAction;if((null==a?void 0:a.action)===Ci.SendAlternateToPenaltyBox&&a.flags===bi.MoveAllAlternatesMatchingHost){var r=this.levels,n=this.pathwayPriority,i=this.pathwayId;if(t.context){var d=t.context,o=d.groupId,s=d.pathwayId,l=d.type;o&&r?i=this.getPathwayForGroupId(o,l,i):s&&(i=s)}i in this.penalizedPathways||(this.penalizedPathways[i]=performance.now()),!n&&r&&(n=r.reduce(function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e},[])),n&&1<n.length&&(this.updatePathwayPriority(n),a.resolved=this.pathwayId!==i),a.resolved||In.warn("Could not resolve "+t.details+" (\""+t.error.message+"\") with content-steering for Pathway: "+i+" levels: "+(r?r.length:r)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var a=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+". Setting initial Pathway to \""+a+"\""),t=this.getLevelsForPathway(a),this.pathwayId=a}return t.length===e.length?e:(this.log("Found "+t.length+"/"+e.length+" levels in Pathway \""+this.pathwayId+"\""),t)},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter(function(t){return e===t.pathwayId})},t.updatePathwayPriority=function(e){this.pathwayPriority=e;var t=this.penalizedPathways,a=performance.now(),r;Object.keys(t).forEach(function(e){a-t[e]>3e5&&delete t[e]});for(var n=0,d;n<e.length;n++)if(d=e[n],!(d in t)){if(d===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if(r=this.getLevelsForPathway(d),0<r.length){this.log("Setting Pathway to \""+d+"\""),this.pathwayId=d,yt(r),this.hls.trigger(En.LEVELS_UPDATED,{levels:r});var l=this.hls.levels[o];s&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==s.bitrate&&this.log("Unstable Pathways change from bitrate "+s.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=o);break}}},t.getPathwayForGroupId=function(e,t,a){for(var r=this.getLevelsForPathway(a).concat(this.levels||[]),n=0;n<r.length;n++)if(t===yi.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===yi.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return a},t.clonePathways=function(e){var t=this,a=this.levels;if(a){var r={},n={};e.forEach(function(e){var d=e.ID,o=e["BASE-ID"],s=e["URI-REPLACEMENT"];if(!a.some(function(e){return e.pathwayId===d})){var l=t.getLevelsForPathway(o).map(function(e){var t=new kn(e.attrs);t["PATHWAY-ID"]=d;var a=t.AUDIO&&t.AUDIO+"_clone_"+d,o=t.SUBTITLES&&t.SUBTITLES+"_clone_"+d;a&&(r[t.AUDIO]=a,t.AUDIO=a),o&&(n[t.SUBTITLES]=o,t.SUBTITLES=o);var l=Jr(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s),u=new ki({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var c=1;c<e.audioGroups.length;c++)u.addGroupId("audio",e.audioGroups[c]+"_clone_"+d);if(e.subtitleGroups)for(var f=1;f<e.subtitleGroups.length;f++)u.addGroupId("text",e.subtitleGroups[f]+"_clone_"+d);return u});a.push.apply(a,l),$r(t.audioTracks,r,s,d),$r(t.subtitleTracks,n,s,d)}})}},t.loadSteeringManifest=function(e){var t=this,a=this.hls.config,r=a.loader;this.loader&&this.loader.destroy(),this.loader=new r(a);var n;try{n=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==n.protocol){var i=0|(this.hls.bandwidthEstimate||a.abrEwmaDefaultEstimate);n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+i)}var d={responseType:"json",url:n.href},o=a.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0};this.log("Requesting steering manifest: "+n),this.loader.load(d,l,{onSuccess:function(e,a,r){t.log("Loaded steering manifest: \""+n+"\"");var i=e.data;if(1!==i.VERSION)return void t.log("Steering VERSION "+i.VERSION+" not supported!");t.updated=performance.now(),t.timeToLoad=i.TTL;var d=i["RELOAD-URI"],o=i["PATHWAY-CLONES"],s=i["PATHWAY-PRIORITY"];if(d)try{t.uri=new self.URL(d,n).href}catch(e){return t.enabled=!1,void t.log("Failed to parse Steering Manifest RELOAD-URI: "+d)}t.scheduleRefresh(t.uri||r.url),o&&t.clonePathways(o);var l={steeringManifest:i,url:n.toString()};t.hls.trigger(En.STEERING_MANIFEST_LOADED,l),s&&t.updatePathwayPriority(s)},onError:function(e,a){if(t.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+a.url+")"),t.stopLoad(),410===e.code)return t.enabled=!1,void t.log("Steering manifest "+a.url+" no longer available");var r=1e3*t.timeToLoad;if(429===e.code){var n=t.loader;if("function"==typeof(null==n?void 0:n.getResponseHeader)){var i=n.getResponseHeader("Retry-After");i&&(r=1e3*parseFloat(i))}return void t.log("Steering manifest "+a.url+" rate limited")}t.scheduleRefresh(t.uri||a.url,r)},onTimeout:function(e,a){t.log("Timeout loading steering manifest ("+a.url+")"),t.scheduleRefresh(t.uri||a.url)}})},t.scheduleRefresh=function(e,t){var a=this;void 0===t&&(t=1e3*this.timeToLoad),this.clearTimeout(),this.reloadTimer=self.setTimeout(function(){var t=null==(r=a.hls)?void 0:r.media,r;return t&&!t.ended?void a.loadSteeringManifest(e):void a.scheduleRefresh(e,1e3*a.timeToLoad)},t)},e}(),Qo=function(){function e(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:null,this.stats=new Cn,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,a){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=a,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,a=this.context;if(t&&a){var r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var i=this.xhrSetup;i?Promise.resolve().then(function(){return e.stats.aborted?void 0:i(r,a.url)}).catch(function(){return r.open("GET",a.url,!0),i(r,a.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(r,a,t)}).catch(function(t){e.callbacks.onError({code:r.status,text:t.message},a,r,n)}):this.openAndSendXhr(r,a,t)}},t.openAndSendXhr=function(e,t,a){e.readyState||e.open("GET",t.url,!0);var r=t.headers,n=a.loadPolicy,i=n.maxTimeToFirstByteMs,d=n.maxLoadTimeMs;if(r)for(var 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),a.timeout=i&&yn(i)?i:d,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,a=this.stats;if(e&&t){var r=t.readyState,n=this.config;if(!a.aborted&&2<=r&&(0===a.loading.first&&(a.loading.first=Math.max(self.performance.now(),a.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-(a.loading.first-a.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var i=t.status,d="text"!==t.responseType;if(200<=i&&300>i&&(d&&t.response||null!==t.responseText)){a.loading.end=Math.max(self.performance.now(),a.loading.first);var o=d?t.response:t.responseText,s="arraybuffer"===t.responseType?o.byteLength:o.length;if(a.loaded=a.total=s,a.bwEstimate=8e3*a.total/(a.loading.end-a.loading.first),!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(a,e,o,t),!this.callbacks)return;var u={url:t.responseURL,data:o,code:i};this.callbacks.onSuccess(u,a,e,t)}else{var c=n.loadPolicy.errorRetry,f=a.retry,g={url:e.url,data:void 0,code:i};Lt(c,f,!1,g)?this.retry(c):(In.error(i+" while loading "+e.url),this.callbacks.onError({code:i,text:t.statusText},e,t,a))}}}},t.loadtimeout=function(){var e=null==(a=this.config)?void 0:a.loadPolicy.timeoutRetry,t=this.stats.retry,a;if(Lt(e,t,!0))this.retry(e);else{var r;In.warn("timeout while loading "+(null==(r=this.context)?void 0:r.url));var n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}},t.retry=function(e){var t=this.context,a=this.stats;this.retryDelay=Et(e,a.retry),a.retry++,In.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+a.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)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&/^age:\s*[\d.]+\s*$/im.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),Zo=/(\d+)-(\d+)\/(\d+)/,$o=function(){function e(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||nn,this.controller=new self.AbortController,this.stats=new Cn}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,a){var r=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var i=tn(e,this.controller.signal),d=a.onProgress,o="arraybuffer"===e.responseType,s=o?"byteLength":"length",l=t.loadPolicy,u=l.maxTimeToFirstByteMs,c=l.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=a,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=u&&yn(u)?u:c,this.requestTimeout=self.setTimeout(function(){r.abortInternal(),a.onTimeout(n,e,r.response)},t.timeout),self.fetch(this.request).then(function(i){r.response=r.loader=i;var s=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(r.requestTimeout),t.timeout=c,r.requestTimeout=self.setTimeout(function(){r.abortInternal(),a.onTimeout(n,e,r.response)},c-(s-n.loading.start)),!i.ok){var l=i.status,u=i.statusText;throw new Jo(u||"fetch, bad network response",l,i)}return n.loading.first=s,n.total=rn(i.headers)||n.total,d&&yn(t.highWaterMark)?r.loadProgressively(i,n,e,t.highWaterMark,d):o?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(function(i){var o=r.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(r.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var l=i[s];l&&(n.loaded=n.total=l);var u={url:o.url,data:i,code:o.status};d&&!yn(t.highWaterMark)&&d(n,e,i,o),a.onSuccess(u,n,e,o)}).catch(function(t){if(self.clearTimeout(r.requestTimeout),!n.aborted){var i=t?t.code||0:0,d=t?t.message:null;a.onError({code:i,text:d},e,t?t.details:null,n)}})},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,a,r,n){void 0===r&&(r=0);var i=new ed,d=e.body.getReader();return function o(){return d.read().then(function(d){if(d.done)return i.dataLength&&n(t,a,i.flush(),e),Promise.resolve(new ArrayBuffer(0));var s=d.value,l=s.length;return t.loaded+=l,l<r||i.dataLength?(i.push(s),i.dataLength>=r&&n(t,a,i.flush(),e)):n(t,a,s,e),o()}).catch(function(){return Promise.reject()})}()},e}(),Jo=function(e){function t(t,a,r){var n;return n=e.call(this,t)||this,n.code=void 0,n.details=void 0,n.code=a,n.details=r,n}return c(t,e),t}(h(Error)),es={newCue:function(e,t,a,n){for(var i=[],d=self.VTTCue||self.TextTrackCue,o=0,s,l,u,f,g;o<n.rows.length;o++)if(s=n.rows[o],u=!0,f=0,g="",!s.isEmpty()){for(var m=0,p;m<s.chars.length;m++)/\s/.test(s.chars[m].uchar)&&u?f++:(g+=s.chars[m].uchar,u=!1);s.cueStartTime=t,t===a&&(a+=1e-4),16<=f?f--:f++;var y=ir(g.trim()),h=dr(t,a,y);null!=e&&null!=(p=e.cues)&&p.getCueById(h)||(l=new d(t,a,y),l.id=h,l.line=o+1,l.align="left",l.position=10+Math.min(80,10*Math.floor(8*f/32)),i.push(l))}return e&&i.length&&(i.sort(function(e,t){return"auto"===e.line||"auto"===t.line?0:8<e.line&&8<t.line?t.line-e.line:e.line-t.line}),i.forEach(function(t){return Ye(e,t)})),i}},ts=r(r({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60000000,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Qo,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Mi,bufferController:Xd,capLevelController:bo,errorController:xi,fpsController:xo,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:Un,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},function(){return{cueHandler:es,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}()),{},{subtitleStreamController:Vd,subtitleTrackController:Wd,timelineController:Co,audioStreamController:Gd,audioTrackController:Kd,emeController:Fo,cmcdController:Xo,contentSteeringController:zo}),as=function(e){function t(t,a){var r;return r=e.call(this,t,"[level-controller]")||this,r._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=a,r._registerListeners(),r}c(t,e);var a=t.prototype;return a._registerListeners=function(){var e=this.hls;e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(En.LEVEL_LOADED,this.onLevelLoaded,this),e.on(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this),e.on(En.ERROR,this.onError,this)},a._unregisterListeners=function(){var e=this.hls;e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(En.LEVEL_LOADED,this.onLevelLoaded,this),e.off(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this),e.off(En.ERROR,this.onError,this)},a.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},a.stopLoad=function(){var t=this._levels;t.forEach(function(e){e.loadError=0,e.fragmentError=0}),e.prototype.stopLoad.call(this)},a.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},a.onManifestLoading=function(){this.resetLevels()},a.onManifestLoaded=function(e,t){var a=this.hls.config.preferManagedMediaSource,r=[],n={},i={},d=!1,o=!1,s=!1;t.levels.forEach(function(e){var t=e.attrs,l=e.audioCodec,u=e.videoCodec,c,f;-1!==(null==(c=l)?void 0:c.indexOf("mp4a.40.34"))&&(ls||(ls=/chrome|firefox/i.test(navigator.userAgent)),ls&&(e.audioCodec=l=void 0)),l&&(e.audioCodec=l=be(l,a)),0===(null==(f=u)?void 0:f.indexOf("avc1"))&&(u=e.videoCodec=Pe(u));var g=e.width,m=e.height,p=e.unknownCodecs;if(d||(d=!!(g&&m)),o||(o=!!u),s||(s=!!l),!(null!=p&&p.length||l&&!ve(l,"audio",a)||u&&!ve(u,"video",a))){var y=t.CODECS,h=t["FRAME-RATE"],T=t["HDCP-LEVEL"],E=t["PATHWAY-ID"],S=t.RESOLUTION,L=t["VIDEO-RANGE"],R=""+((E||".")+"-")+e.bitrate+"-"+S+"-"+h+"-"+y+"-"+L+"-"+T;if(!n[R]){var A=new ki(e);n[R]=A,i[R]=1,r.push(A)}else if(n[R].uri!==e.url&&!e.attrs["PATHWAY-ID"]){var v=i[R]+=1;e.attrs["PATHWAY-ID"]=Array(v+1).join(".");var I=new ki(e);n[R]=I,r.push(I)}else n[R].addGroupId("audio",t.AUDIO),n[R].addGroupId("text",t.SUBTITLES)}}),this.filterAndSortMediaOptions(r,t,d,o,s)},a.filterAndSortMediaOptions=function(e,t,r,n,d){var o=this,s=[],l=[],u=e;if((r||n)&&d&&(u=u.filter(function(e){var t=e.videoCodec,a=e.videoRange,r=e.width,n=e.height;return(!!t||!!(r&&n))&&tt(a)})),0===u.length)return void Promise.resolve().then(function(){if(o.hls){t.levels.length&&o.warn("One or more CODECS in variant not supported: "+JSON.stringify(t.levels[0].attrs));var e=new Error("no level with compatible codecs found in manifest");o.hls.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}});if(t.audioTracks){var c=this.hls.config.preferManagedMediaSource;s=t.audioTracks.filter(function(e){return!e.audioCodec||ve(e.audioCodec,"audio",c)}),ln(s)}t.subtitles&&(l=t.subtitles,ln(l));var f=u.slice(0);u.sort(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return vi.indexOf(e.videoRange)-vi.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var a=ke(e.videoCodec),n=ke(t.videoCodec);if(a!==n)return n-a}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var i=_e(e.codecSet),d=_e(t.codecSet);if(i!==d)return d-i}return e.bitrate===t.bitrate?0:e.bitrate-t.bitrate});var g=f[0];if(this.steering&&(u=this.steering.filterParsedLevels(u),u.length!==f.length))for(var m=0;m<f.length;m++)if(f[m].pathwayId===u[0].pathwayId){g=f[m];break}this._levels=u;for(var a=0;a<u.length;a++)if(u[a]===g){var p;this._firstLevel=a;var y=g.bitrate,h=this.hls.bandwidthEstimate;if(this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+y),void 0===(null==(p=this.hls.userConfig)?void 0:p.abrEwmaDefaultEstimate)){var T=Math.min(y,this.hls.config.abrEwmaDefaultEstimateMax);T>h&&h===ts.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}var E={levels:u,audioTracks:s,subtitleTracks:l,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:d,video:n,altAudio:!(d&&!n)&&s.some(function(e){return!!e.url})};this.hls.trigger(En.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)},a.onError=function(e,t){t.fatal||!t.context||t.context.type===yi.LEVEL&&t.context.level===this.level&&this.checkRetry(t)},a.onFragBuffered=function(e,t){var a=t.frag;if(void 0!==a&&a.type===hi.MAIN){var r=a.elementaryStreams;if(!Object.keys(r).some(function(e){return!!r[e]}))return;var n=this._levels[a.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},a.onLevelLoaded=function(e,t){var a=t.level,r=t.details,n=this._levels[a],i;if(!n){var d;return this.warn("Invalid level index "+a),void(null!=(d=t.deliveryDirectives)&&d.skip&&(r.deltaUpdateFailed=!0))}a===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(a,t,n.details)):null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)},a.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var a=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){var n=r.uri;if(t)try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var i=r.attrs["PATHWAY-ID"];this.log("Loading level index "+a+(void 0===(null==t?void 0:t.msn)?"":" at sn "+t.msn+" part "+t.part)+" with"+(i?" Pathway "+i:"")+" "+n),this.clearTimer(),this.hls.trigger(En.LEVEL_LOADING,{url:n,level:a,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},a.removeLevel=function(e){var t=this,a=this._levels.filter(function(a,r){return r!==e||(t.steering&&t.steering.removeLevel(a),a===t.currentLevel&&(t.currentLevel=null,t.currentLevelIndex=-1,a.details&&a.details.fragments.forEach(function(e){return e.level=-1})),!1)}),r;yt(a),this._levels=a,-1<this.currentLevelIndex&&null!=(r=this.currentLevel)&&r.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(En.LEVELS_UPDATED,{levels:a})},a.onLevelsUpdated=function(e,t){var a=t.levels;this._levels=a},a.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,a=e.maxAutoLevel,r=e.maxHdcpLevel;this._maxAutoLevel!==a&&(this._maxAutoLevel=a,this.hls.trigger(En.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:a,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))},s(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(0>e||e>=t.length){var a=new Error("invalid level idx"),r=0>e;if(this.hls.trigger(En.ERROR,{type:Sn.OTHER_ERROR,details:Ln.LEVEL_SWITCH_ERROR,level:e,fatal:r,error:a,reason:a.message}),r)return;e=Math.min(e,t.length-1)}var n=this.currentLevelIndex,i=this.currentLevel,d=i?i.attrs["PATHWAY-ID"]:void 0,o=t[e],s=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,!(n===e&&o.details&&i&&d===s)){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(s?" with Pathway "+s:"")+" from level "+n+(d?" with Pathway "+d:""));var l={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(En.LEVEL_SWITCHING,l);var u=o.details;if(!u||u.live){var c=this.switchParams(o.uri,null==i?void 0:i.details);this.loadPlaylist(c)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0===e?this.hls.firstAutoLevel:e}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1===this.manualLevelIndex?this.hls.nextAutoLevel:this.manualLevelIndex},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(Pi),rs=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var a=this.keyUriToKeyInfo[t].loader;if(a){var r;if(e&&e!==(null==(r=a.context)?void 0:r.frag.type))return;a.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,a,r,n){return void 0===t&&(t=Ln.KEY_LOAD_ERROR),new qi({type:Sn.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:a,networkDetails:r})},t.loadClear=function(e,t){var a=this;if(this.emeController&&this.config.emeEnabled)for(var r=e.sn,n=e.cc,d=function(){var e=t[o];if(n<=e.cc&&("initSegment"===r||"initSegment"===e.sn||r<e.sn))return a.emeController.selectKeySystemFormat(e).then(function(t){e.setKeyFormat(t)}),1},o=0;o<t.length&&!d();o++);},t.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(a){return t.loadInternal(e,a)}):this.loadInternal(e)},t.loadInternal=function(e,t){var a,r;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var i=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,Ln.KEY_LOAD_ERROR,i))}var d=n.uri;if(!d)return Promise.reject(this.createKeyLoadError(e,Ln.KEY_LOAD_ERROR,new Error("Invalid key URI: \""+d+"\"")));var o=this.keyUriToKeyInfo[d];if(null!=(a=o)&&a.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(null!=(r=o)&&r.keyLoadPromise){var s;switch(null==(s=o.mediaKeySessionContext)?void 0:s.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(function(t){return n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o}});}}switch(o=this.keyUriToKeyInfo[d]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,Ln.KEY_LOAD_ERROR,new Error("Key supplied with unsupported METHOD: \""+n.method+"\"")));}},t.loadKeyEME=function(e,t){var a={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var r=this.emeController.loadKey(a);if(r)return(e.keyLoadPromise=r.then(function(t){return e.mediaKeySessionContext=t,a})).catch(function(t){throw e.keyLoadPromise=null,t})}return Promise.resolve(a)},t.loadKeyHTTP=function(e,t){var a=this,n=this.config,i=n.loader,d=new i(n);return t.keyLoader=e.loader=d,e.keyLoadPromise=new Promise(function(i,o){var s={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=n.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};d.load(s,u,{onSuccess:function(e,t,r,n){var d=r.frag,s=r.keyInfo,l=r.url;return d.decryptdata&&s===a.keyUriToKeyInfo[l]?void(s.decryptdata.key=d.decryptdata.key=new Uint8Array(e.data),d.keyLoader=null,s.loader=null,i({frag:d,keyInfo:s})):o(a.createKeyLoadError(d,Ln.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n))},onError:function(e,n,i){a.resetLoader(n),o(a.createKeyLoadError(t,Ln.KEY_LOAD_ERROR,new Error("HTTP Error "+e.code+" loading key "+e.text),i,r({url:s.url,data:void 0},e)))},onTimeout:function(e,r,n){a.resetLoader(r),o(a.createKeyLoadError(t,Ln.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,r,n){a.resetLoader(r),o(a.createKeyLoadError(t,Ln.INTERNAL_ABORTED,new Error("key loading aborted"),n))}})})},t.resetLoader=function(e){var t=e.frag,a=e.keyInfo,r=e.url,n=a.loader;t.keyLoader===n&&(t.keyLoader=null,a.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()},e}(),ns=2,is=function(){function e(e,t,a,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=a,this.hls=r}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var a=this.config,r=this.media,n=this.stalled;if(null!==r){var i=r.currentTime,d=r.seeking,o=this.seeking&&!d,s=!this.seeking&&d;if(this.seeking=d,i!==e){if(this.moved=!0,d||(this.nudgeRetry=0),null!==n){if(this.stallReported){var l=self.performance.now()-n;In.warn("playback not stuck anymore @"+i+", after "+Math.round(l)+"ms"),this.stallReported=!1}this.stalled=null}return}if(s||o)return void(this.stalled=null);if(r.paused&&!d||r.ended||0===r.playbackRate||!Hi.getBuffered(r).length)return void(this.nudgeRetry=0);var u=Hi.bufferInfo(r,i,0),c=u.nextStart||0;if(d){var f=u.len>ns,g=!c||t&&t.start<=i||c-i>ns&&!this.fragmentTracker.getPartialFragment(i);if(f||g)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var m=0<u.len,p;if(!m&&!c)return;var y=Math.max(c,u.start||0)-i,h=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=null==h||null==(p=h.details)?void 0:p.live,E=T?2*h.details.targetduration:ns,S=this.fragmentTracker.getPartialFragment(i);if(0<y&&(y<=E||S))return void(r.paused||this._trySkipBufferHole(S))}var L=self.performance.now();if(null===n)return void(this.stalled=L);var R=L-n;if(!(!d&&R>=250&&(this._reportStall(u),!this.media))){var A=Hi.bufferInfo(r,i,a.maxBufferHole);this._tryFixBufferStall(A,R)}}},t._tryFixBufferStall=function(e,t){var a=this.config,r=this.fragmentTracker,n=this.media;if(null!==n){var i=n.currentTime,d=r.getPartialFragment(i);if(d){var o=this._trySkipBufferHole(d);if(o||!this.media)return}(e.len>a.maxBufferHole||e.nextStart&&e.nextStart-i<a.maxBufferHole)&&t>1e3*a.highBufferWatchdogPeriod&&(In.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,a=this.media,r=this.stallReported;if(!r&&a){this.stallReported=!0;var n=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(e)+")");In.warn(n.message),t.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,a=this.hls,r=this.media;if(null===r)return 0;var n=r.currentTime,i=Hi.bufferInfo(r,n,0),d=n<i.start?i.start:i.nextStart;if(d){var o=i.len<=t.maxBufferHole,s=0<i.len&&1>i.len&&3>r.readyState,l=d-n;if(0<l&&(o||s)){if(l>t.maxBufferHole){var u=this.fragmentTracker,c=!1;if(0===n){var f=u.getAppendedFrag(0,hi.MAIN);f&&d<f.end&&(c=!0)}if(!c){var g=e||u.getAppendedFrag(n,hi.MAIN);if(g){for(var m=!1,p=g.end,y;p<d;)if(y=u.getPartialFragment(p),y)p+=y.duration;else{m=!0;break}if(m)return 0}}}var h=Math.max(d+.05,n+.1);if(In.warn("skipping hole, adjusting currentTime from "+n+" to "+h),this.moved=!0,this.stalled=null,r.currentTime=h,e&&!e.gap){var T=new Error("fragment loaded with buffer holes, seeking from "+n+" to "+h);a.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:T,reason:T.message,frag:e})}return h}}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,a=this.media,r=this.nudgeRetry;if(null!==a){var n=a.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){var i=n+(r+1)*e.nudgeOffset,d=new Error("Nudging 'currentTime' from "+n+" to "+i);In.warn(d.message),a.currentTime=i,t.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{var o=new Error("Playhead still not moving while enough data buffered @"+n+" after "+e.nudgeMaxRetry+" nudges");In.error(o.message),t.trigger(En.ERROR,{type:Sn.MEDIA_ERROR,details:Ln.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}},e}(),ds=function(e){function t(t,a,r){var n;return n=e.call(this,t,a,r,"[stream-controller]",hi.MAIN)||this,n.audioCodecSwap=!1,n.gapController=null,n.level=-1,n._forceStartLoad=!1,n.altAudio=!1,n.audioOnly=!1,n.fragPlaying=null,n.onvplaying=null,n.onvseeked=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n._registerListeners(),n}c(t,e);var a=t.prototype;return a._registerListeners=function(){var e=this.hls;e.on(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(En.MANIFEST_LOADING,this.onManifestLoading,this),e.on(En.MANIFEST_PARSED,this.onManifestParsed,this),e.on(En.LEVEL_LOADING,this.onLevelLoading,this),e.on(En.LEVEL_LOADED,this.onLevelLoaded,this),e.on(En.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(En.ERROR,this.onError,this),e.on(En.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(En.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(En.BUFFER_CREATED,this.onBufferCreated,this),e.on(En.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(En.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var e=this.hls;e.off(En.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(En.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(En.MANIFEST_LOADING,this.onManifestLoading,this),e.off(En.MANIFEST_PARSED,this.onManifestParsed,this),e.off(En.LEVEL_LOADED,this.onLevelLoaded,this),e.off(En.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(En.ERROR,this.onError,this),e.off(En.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(En.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(En.BUFFER_CREATED,this.onBufferCreated,this),e.off(En.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(En.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(En.FRAG_BUFFERED,this.onFragBuffered,this)},a.onHandlerDestroying=function(){this._unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},a.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var r=a.startLevel;-1===r&&(a.config.testBandwidth&&1<this.levels.length?(r=0,this.bitrateTest=!0):r=a.firstAutoLevel),this.level=a.nextLoadLevel=r,this.loadedmetadata=!1}0<t&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=$i.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=$i.STOPPED},a.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case $i.WAITING_LEVEL:{var e=this.levels,t=this.level,a=null==e?void 0:e[t],r=null==a?void 0:a.details;if(r&&(!r.live||this.levelLastLoaded===a)){if(this.waitForCdnTuneIn(r))break;this.state=$i.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=$i.IDLE;break}break}case $i.FRAG_LOADING_WAITING_RETRY:{var n=self.performance.now(),i=this.retryDate,d;if(!i||n>=i||null!=(d=this.media)&&d.seeking){var o=this.levels,s=this.level,l=null==o?void 0:o[s];this.resetStartWhenNotLoaded(l||null),this.state=$i.IDLE}}}this.state===$i.IDLE&&this.doTickIdle(),this.onTickEnd()},a.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},a.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,a=this.levels,r=this.media,n=e.config,i=e.nextLoadLevel;if(null!==t&&(r||!this.startFragRequested&&n.startFragPrefetch)&&!(this.altAudio&&this.audioOnly)&&null!=a&&a[i]){var d=a[i],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var l={};return this.altAudio&&(l.type="video"),this.hls.trigger(En.BUFFER_EOS,l),void(this.state=$i.ENDED)}e.loadLevel!==i&&-1===e.manualLevel&&this.log("Adapting to level "+i+" from level "+this.level),this.level=e.nextLoadLevel=i;var u=d.details;if(!u||this.state===$i.WAITING_LEVEL||u.live&&this.levelLastLoaded!==d)return this.level=i,void(this.state=$i.WAITING_LEVEL);var c=o.len,f=this.getMaxBufferLength(d.maxBitrate);if(!(c>=f)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var g=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(g,u);if(this.couldBacktrack&&!this.fragPrevious&&m&&"initSegment"!==m.sn&&this.fragmentTracker.getState(m)!==Ui.OK){var p=(null==(T=this.backtrackFragment)?m:T).sn,y=p-u.startSN,h=u.fragments[y-1],T;h&&m.cc===h.cc&&(m=h,this.fragmentTracker.removeFragment(h))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,g)){var E=m.gap;if(!E){var S=this.audioOnly&&!this.altAudio?bn.AUDIO:bn.VIDEO,L=(S===bn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;L&&this.afterBufferFlushed(L,S,hi.MAIN)}m=this.getNextFragmentLoopLoading(m,u,o,hi.MAIN,f)}m&&(m.initSegment&&!m.initSegment.data&&!this.bitrateTest&&(m=m.initSegment),this.loadFragment(m,d,g))}}}},a.loadFragment=function(t,a,r){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Ui.NOT_LOADED||n===Ui.PARTIAL?"initSegment"===t.sn?this._loadInitSegment(t,a):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,a)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,a,r)):this.clearTrackerIfNeeded(t)},a.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,hi.MAIN)},a.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},a.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var a=this.getAppendedFrag(t.currentTime),r;a&&1<a.start&&this.flushMainBuffer(0,a.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var i=this.getMainFwdBufferInfo();if(!i||i.len<2*n.targetduration)return}if(!t.paused&&e){var d=this.hls.nextLoadLevel,o=e[d],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else r=0;var l=this.getBufferedFrag(t.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,f=u.duration,g=Math.max(l.end,c+Math.min(Math.max(f-this.config.maxFragLookUpTolerance,f*(this.couldBacktrack?.5:.125)),f*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case $i.KEY_LOADING:case $i.FRAG_LOADING:case $i.FRAG_LOADING_WAITING_RETRY:case $i.PARSING:case $i.PARSED:this.state=$i.IDLE;}this.nextLoadPosition=this.getLoadPosition()},a.flushMainBuffer=function(t,a){e.prototype.flushMainBuffer.call(this,t,a,this.altAudio?"video":null)},a.onMediaAttached=function(t,a){e.prototype.onMediaAttached.call(this,t,a);var r=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new is(this.config,r,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},a.onMediaPlaying=function(){this.tick()},a.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;yn(t)&&this.log("Media seeked to "+t.toFixed(3));var a=this.getMainFwdBufferInfo();return null===a||0===a.len?void this.warn("Main forward buffer length on \"seeked\" event "+(a?a.len:"empty")+")"):void this.tick()},a.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(En.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},a.onManifestParsed=function(e,t){var a=!1,r=!1;t.levels.forEach(function(e){var t=e.audioCodec;t&&(a=a||-1!==t.indexOf("mp4a.40.2"),r=r||-1!==t.indexOf("mp4a.40.5"))}),this.audioCodecSwitch=a&&r&&!gn(),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},a.onLevelLoading=function(e,t){var a=this.levels;if(a&&this.state===$i.IDLE){var r=a[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=$i.WAITING_LEVEL)}},a.onLevelLoaded=function(e,t){var a=this.levels,r=t.level,n=t.details,i=n.totalduration,d;if(!a)return void this.warn("Levels were reset while loading level "+r);this.log("Level "+r+" loaded ["+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+", cc ["+n.startCC+", "+n.endCC+"] duration:"+i);var o=a[r],s=this.fragCurrent;s&&(this.state===$i.FRAG_LOADING||this.state===$i.FRAG_LOADING_WAITING_RETRY)&&s.level!==t.level&&s.loader&&this.abortCurrentFrag();var l=0;if(n.live||null!=(d=o.details)&&d.live){var u;if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;l=this.alignPlaylists(n,o.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(o.details=n,this.levelLastLoaded=o,this.hls.trigger(En.LEVEL_UPDATED,{details:n,level:r}),this.state===$i.WAITING_LEVEL){if(this.waitForCdnTuneIn(n))return;this.state=$i.IDLE}this.startFragRequested?n.live&&this.synchronizeToLiveEdge(n):this.setStartPosition(n,l),this.tick()},a._handleFragmentLoadProgress=function(e){var t=e.frag,a=e.part,r=e.payload,n=this.levels,i;if(!n)return void this.warn("Levels were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");var d=n[t.level],o=d.details;if(!o)return this.warn("Dropping fragment "+t.sn+" of level "+t.level+" after level details were reset"),void this.fragmentTracker.removeFragment(t);var s=d.videoCodec,l=o.PTSKnown||!o.live,u=null==(i=t.initSegment)?void 0:i.data,c=this._getAudioCodec(d),f=this.transmuxer=this.transmuxer||new Bd(this.hls,hi.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=a?a.index:-1,m=new Vi(t.level,t.sn,t.stats.chunkCount,r.byteLength,g,-1!==g),p=this.initPTS[t.cc];f.push(r,u,c,s,t,a,o.totalduration,l,m,p)},a.onAudioTrackSwitching=function(e,t){var a=this.altAudio,r=!!t.url;if(!r){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var i=this.hls;a&&(i.trigger(En.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(En.AUDIO_TRACK_SWITCHED,t)}},a.onAudioTrackSwitched=function(e,t){var a=t.id,r=!!this.hls.audioTracks[a].url;if(r){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()},a.onBufferCreated=function(e,t){var a=t.tracks,r=!1,n,i;for(var d in a){var o=a[d];if("main"!==o.id)r=!0;else if(i=d,n=o,"video"===d){var s=a[d];s&&(this.videoBuffer=s.buffer)}}r&&n?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media},a.onFragBuffered=function(e,t){var a=t.frag,r=t.part;if(!(a&&a.type!==hi.MAIN)){if(this.fragContextChanged(a))return this.warn("Fragment "+a.sn+(r?" p: "+r.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===$i.PARSED&&(this.state=$i.IDLE));var n=r?r.stats:a.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==a.sn&&(this.fragPrevious=a),this.fragBufferedComplete(a,r)}},a.onError=function(e,t){var a;if(t.fatal)return void(this.state=$i.ERROR);switch(t.details){case Ln.FRAG_GAP:case Ln.FRAG_PARSING_ERROR:case Ln.FRAG_DECRYPT_ERROR:case Ln.FRAG_LOAD_ERROR:case Ln.FRAG_LOAD_TIMEOUT:case Ln.KEY_LOAD_ERROR:case Ln.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(hi.MAIN,t);break;case Ln.LEVEL_LOAD_ERROR:case Ln.LEVEL_LOAD_TIMEOUT:case Ln.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==$i.WAITING_LEVEL||(null==(a=t.context)?void 0:a.type)!==yi.LEVEL||(this.state=$i.IDLE);break;case Ln.BUFFER_APPEND_ERROR:case Ln.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===Ln.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Ln.INTERNAL_EXCEPTION:this.recoverWorkerError(t);}},a.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!Hi.getBuffered(e).length){var a=this.state===$i.IDLE?null:this.fragCurrent;t.poll(this.lastCurrentTime,a)}this.lastCurrentTime=e.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=$i.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(e,t){var a=t.type;if(a!==bn.AUDIO||this.audioOnly&&!this.altAudio){var r=(a===bn.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,a,hi.MAIN),this.tick()}},a.onLevelsUpdated=function(e,t){-1<this.level&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,a=this.startPosition;if(0<=a&&t<a){if(e.seeking)return void this.log("could not seek to "+a+", already seeking at "+t);var r=Hi.getBuffered(e),n=r.length?r.start(0):0,i=n-a;0<i&&(i<this.config.maxBufferHole||i<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+i+" to match buffer start"),a+=i,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+t),e.currentTime=a}}},a._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1===t.indexOf("mp4a.40.5")?"mp4a.40.5":"mp4a.40.2"),t},a._loadBitrateTestFrag=function(e,t){var a=this;e.bitrateTest=!0,this._doFragLoad(e,t).then(function(r){var n=a.hls;if(r&&!a.fragContextChanged(e)){t.fragmentError=0,a.state=$i.IDLE,a.startFragRequested=!1,a.bitrateTest=!1;var i=e.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),n.trigger(En.FRAG_LOADED,r),e.bitrateTest=!1}})},a._handleTransmuxComplete=function(e){var t="main",a=this.hls,r=e.remuxResult,n=e.chunkMeta,i=this.getCurrentContext(n),d;if(!i)return void this.resetWhenMissingContext(n);var o=i.frag,s=i.part,l=i.level,u=r.video,c=r.text,f=r.id3,g=r.initSegment,m=l.details,p=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))return void this.fragmentTracker.removeFragment(o);if(this.state=$i.PARSING,g){if(null!=g&&g.tracks){var y=o.initSegment||o;this._bufferInitSegment(l,g.tracks,y,n),a.trigger(En.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:t,tracks:g.tracks})}var h=g.initPTS,T=g.timescale;yn(h)&&(this.initPTS[o.cc]={baseTime:h,timescale:T},a.trigger(En.INIT_PTS_FOUND,{frag:o,id:t,initPTS:h,timescale:T}))}if(u&&m&&"initSegment"!==o.sn){var E=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,L=!E||o.cc>E.cc;if(!1!==r.independent){var R=u.startPTS,A=u.endPTS,v=u.startDTS,I=u.endDTS;if(s)s.elementaryStreams[u.type]={startPTS:R,endPTS:A,startDTS:v,endDTS:I};else if(u.firstKeyFrame&&u.independent&&1===n.id&&!L&&(this.couldBacktrack=!0),u.dropped&&u.independent){var D=this.getMainFwdBufferInfo(),k=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,_=u.firstKeyFramePTS?u.firstKeyFramePTS:R;if(!S&&k<_-this.config.maxBufferHole&&!L)return void this.backtrack(o);L&&(o.gap=!0),o.setElementaryStreamInfo(u.type,o.start,A,o.start,I,!0)}else S&&R>ns&&(o.gap=!0);o.setElementaryStreamInfo(u.type,R,A,v,I),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(u,o,s,n,S||L)}else if(S||L)o.gap=!0;else return void this.backtrack(o)}if(p){var C=p.startPTS,b=p.endPTS,x=p.startDTS,P=p.endDTS;s&&(s.elementaryStreams[bn.AUDIO]={startPTS:C,endPTS:b,startDTS:x,endDTS:P}),o.setElementaryStreamInfo(bn.AUDIO,C,b,x,P),this.bufferFragmentData(p,o,s,n)}if(m&&null!=f&&null!=(d=f.samples)&&d.length){var F={id:t,frag:o,details:m,samples:f.samples};a.trigger(En.FRAG_PARSING_METADATA,F)}if(m&&c){var O={id:t,frag:o,details:m,samples:c.samples};a.trigger(En.FRAG_PARSING_USERDATA,O)}},a._bufferInitSegment=function(e,t,a,r){var n=this;if(this.state===$i.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var i=t.audio,d=t.video,o=t.audiovideo;if(i){var s=e.audioCodec,l=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(s&&(-1===s.indexOf("mp4a.40.5")?s="mp4a.40.5":s="mp4a.40.2"),1!==i.metadata.channelCount&&-1===l.indexOf("firefox")&&(s="mp4a.40.5")),s&&-1!==s.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==i.container&&(s="mp4a.40.2",this.log("Android: force audio codec to "+s)),e.audioCodec&&e.audioCodec!==s&&this.log("Swapping manifest audio codec \""+e.audioCodec+"\" for \""+s+"\""),i.levelCodec=s,i.id="main",this.log("Init audio buffer, container:"+i.container+", codecs[selected/level/parsed]=["+(s||"")+"/"+(e.audioCodec||"")+"/"+i.codec+"]")}d&&(d.levelCodec=e.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+d.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),this.hls.trigger(En.BUFFER_CODECS,t),Object.keys(t).forEach(function(e){var i=t[e],d=i.initSegment;null!=d&&d.byteLength&&n.hls.trigger(En.BUFFER_APPENDING,{type:e,data:d,frag:a,part:null,chunkMeta:r,parent:a.type})}),this.tickImmediate()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,hi.MAIN)},a.backtrack=function(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=$i.IDLE},a.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&1<e.readyState&&!1===e.seeking){var a=e.currentTime;if(Hi.isBuffered(e,a)?t=this.getAppendedFrag(a):Hi.isBuffered(e,a+.1)&&(t=this.getAppendedFrag(a+.1)),t){this.backtrackFragment=null;var r=this.fragPlaying,n=t.level;r&&t.sn===r.sn&&r.level===n||(this.fragPlaying=t,this.hls.trigger(En.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(En.LEVEL_SWITCHED,{level:n}))}}},s(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,a=this.currentFrag;if(a&&yn(t)&&yn(a.programDateTime)){var r=a.programDateTime+1e3*(t-a.start);return new Date(r)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(Ji),os=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Md,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,v(t.debug||!1,"Hls instance");var a=this.config=dn(e.DefaultConfig,t);this.userConfig=t,a.progressive&&sn(a);var r=a.abrController,n=a.bufferController,i=a.capLevelController,d=a.errorController,o=a.fpsController,s=new d(this),l=this.abrController=new r(this),u=this.bufferController=new n(this),c=this.capLevelController=new i(this),f=new o(this),g=new Ti(this),m=new Li(this),p=a.contentSteeringController,y=p?new p(this):null,h=this.levelController=new as(this,y),T=new Gi(this),E=new rs(this.config),S=this.streamController=new ds(this,T,E);c.setStreamController(S),f.setStreamController(S);var L=[g,h,S];y&&L.splice(1,0,y),this.networkControllers=L;var R=[l,u,c,f,m,T];this.audioTrackController=this.createController(a.audioTrackController,L);var A=a.audioStreamController;A&&L.push(new A(this,T,E)),this.subtitleTrackController=this.createController(a.subtitleTrackController,L);var I=a.subtitleStreamController;I&&L.push(new I(this,T,E)),this.createController(a.timelineController,R),E.emeController=this.emeController=this.createController(a.emeController,R),this.cmcdController=this.createController(a.cmcdController,R),this.latencyController=this.createController(Ri,R),this.coreComponents=R,L.push(s);var D=s.onErrorOut;"function"==typeof D&&this.on(En.ERROR,D,s)}e.isMSESupported=function(){return cn()},e.isSupported=function(){return fn()},e.getMediaSource=function(){return Re()};var t=e.prototype;return t.createController=function(e,t){if(e){var a=new e(this);return t&&t.push(a),a}return null},t.on=function(e,t,a){void 0===a&&(a=this),this._emitter.on(e,t,a)},t.once=function(e,t,a){void 0===a&&(a=this),this._emitter.once(e,t,a)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,a,r){void 0===a&&(a=this),this._emitter.off(e,t,a,r)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,a){return this._emitter.emit(e,t,a)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(In.error("An internal error happened while handling event "+e+". Error message: \""+t.message+"\". Here is a stacktrace:",t),!this.triggeringException){this.triggeringException=!0;var a=e===En.ERROR;this.trigger(En.ERROR,{type:Sn.OTHER_ERROR,details:Ln.INTERNAL_EXCEPTION,fatal:a,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){In.log("destroy"),this.trigger(En.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(e){return e.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(e){return e.destroy()}),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){In.log("attachMedia"),this._media=e,this.trigger(En.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){In.log("detachMedia"),this.trigger(En.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,a=this.url,r=this.url=pn.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,In.log("loadSource:"+r),t&&a&&(a!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(En.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),In.log("startLoad("+e+")"),this.started=!0,this.networkControllers.forEach(function(t){t.startLoad(e)})},t.stopLoad=function(){In.log("stopLoad"),this.started=!1,this.networkControllers.forEach(function(e){e.stopLoad()})},t.resumeBuffering=function(){this.started&&this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.startLoad(-1)})},t.pauseBuffering=function(){this.networkControllers.forEach(function(e){"fragmentLoader"in e&&e.stopLoad()})},t.swapAudioCodec=function(){In.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){In.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e){this.levelController.removeLevel(e)},t.setAudioOption=function(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)},t.setSubtitleOption=function(e){var t;return null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e),null},s(e,[{key:"levels",get:function(){var e=this.levelController.levels;return e?e:[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){In.log("set currentLevel:"+e),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){In.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){In.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){In.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&-1<this.abrController.forcedAutoLevel?this.abrController.forcedAutoLevel:e},set:function(e){In.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(In.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){et(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var a=e.length,r=0;r<a;r++)if(e[r].maxBitrate>=t)return r;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping,a=this.maxHdcpLevel,r;if(r=-1===t&&null!=e&&e.length?e.length-1:t,a)for(var n=r,d;n--;)if(d=e[n].attrs["HDCP-LEVEL"],d&&d<=a)return n;return r}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.1"}},{key:"Events",get:function(){return En}},{key:"ErrorTypes",get:function(){return Sn}},{key:"ErrorDetails",get:function(){return Ln}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:ts},set:function(t){e.defaultConfig=t}}]),e}(),ss,ls;return os.defaultConfig=void 0,os})})(!1);

FWDUVPRegisterHLSError =  function(_s){
	_s.hlsJS.on(Hls.Events.ERROR, function(event,data) {
					
		_s.HLSError_str;
		switch(data.details) {
			case Hls.ErrorDetails.MANIFEST_LOAD_ERROR:
				try {
				 	_s.HLSError_str ="cannot load <a href=\"" + data.context.url + "\">" + url + "</a><br>HTTP response code:" + data.response.code + " <br>" + data.response.text;
					if(data.response.code === 0) {
					 _s.HLSError_str += "this might be a CORS issue, consider installing <a href=\"https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi\">Allow-Control-Allow-Origin</a> Chrome Extension";
					}
				}catch(err) {
				  _s.HLSError_str = "cannot load " + _s.videoSourcePath_str;
				  console.log(err);
				}
			break;
				default:
				 _s.HLSError_str = undefined;
				console.log(data.details);
			break;
		}
		
		if(_s.HLSError_str){
			if(console) console.log(_s.HLSError_str);
			if(_s.HLSError_str == 'bufferStalledError' || _s.HLSError_str == 'bufferSeekOverHole' ||  _s.HLSError_str == 'fragParsingError'){
				_s.HLSError_str =  undefined;
				return;
			}
			_s.info_do.allowToRemove_bl = false;
			_s.videoScreenErrorHandler({'text':_s.HLSError_str});
		}
	});
}

Youez - 2016 - github.com/yon3zu
LinuXploit