feffery_utils_components 0.2.0-rc11 → 0.2.0-rc13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESCRIPTION +1 -1
- package/NAMESPACE +2 -0
- package/Project.toml +1 -1
- package/README.md +1 -1
- package/assets/demo.jpg +0 -0
- package/feffery_utils_components/FefferySetFavicon.py +45 -0
- package/feffery_utils_components/FefferySetTitle.py +7 -4
- package/feffery_utils_components/FefferySliderCaptcha.py +109 -0
- package/feffery_utils_components/__init__.py +2 -1
- package/feffery_utils_components/_imports_.py +4 -0
- package/feffery_utils_components/async-feffery_animated_3d_background_p5.js +1 -1
- package/feffery_utils_components/async-feffery_animated_3d_background_three.js +2 -2
- package/feffery_utils_components/async-feffery_animated_image.js +1 -1
- package/feffery_utils_components/async-feffery_aplayer.js +1 -1
- package/feffery_utils_components/async-feffery_auto_animate.js +1 -1
- package/feffery_utils_components/async-feffery_auto_fit.js +1 -1
- package/feffery_utils_components/async-feffery_captcha.js +1 -1
- package/feffery_utils_components/async-feffery_color_pickers.js +1 -1
- package/feffery_utils_components/async-feffery_dom2image.js +1 -1
- package/feffery_utils_components/async-feffery_dplayer.js +1 -1
- package/feffery_utils_components/async-feffery_emoji_picker.js +1 -1
- package/feffery_utils_components/async-feffery_excel_preview.js +1 -1
- package/feffery_utils_components/async-feffery_extra_spinner.js +1 -1
- package/feffery_utils_components/async-feffery_fancy_button.js +1 -1
- package/feffery_utils_components/async-feffery_grid.js +1 -1
- package/feffery_utils_components/async-feffery_image_cropper.js +1 -1
- package/feffery_utils_components/async-feffery_json_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_local_large_storage.js +1 -1
- package/feffery_utils_components/async-feffery_markdown_editor.js +2 -2
- package/feffery_utils_components/async-feffery_motion.js +1 -1
- package/feffery_utils_components/async-feffery_music_player.js +1 -1
- package/feffery_utils_components/async-feffery_photo_sphere_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_resizable.js +1 -1
- package/feffery_utils_components/async-feffery_rich_text_editor.js +2 -2
- package/feffery_utils_components/async-feffery_rnd.js +1 -1
- package/feffery_utils_components/async-feffery_seamless_scroll.js +1 -1
- package/feffery_utils_components/async-feffery_shortcut_panel.js +1 -1
- package/feffery_utils_components/async-feffery_slider_captcha.js +1 -0
- package/feffery_utils_components/async-feffery_slider_captcha.js.LICENSE.txt +1 -0
- package/feffery_utils_components/async-feffery_sortable.js +1 -1
- package/feffery_utils_components/async-feffery_word_preview.js +1 -1
- package/feffery_utils_components/async-fuc-shared.js +2 -2
- package/feffery_utils_components/feffery_utils_components.min.js +2 -2
- package/feffery_utils_components/metadata.json +298 -1
- package/feffery_utils_components/package-info.json +3 -1
- package/package.json +3 -1
- package/src/lib/components/FefferySetFavicon.react.js +58 -0
- package/src/lib/components/FefferySetTitle.react.js +21 -6
- package/src/lib/components/FefferySliderCaptcha.react.js +160 -0
- package/src/lib/fragments/FefferySliderCaptcha.react.js +102 -0
- package/src/lib/index.js +5 -1
- package/usage.py +20 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(window.webpackJsonpfeffery_utils_components=window.webpackJsonpfeffery_utils_components||[]).push([[0],{554:function(t,_,C){"use strict";!function(t){var A=C(746),a=C(747),l=C(748);function r(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t,e){if(r()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(t=null===t?new u(e):t).length=e,t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"!=typeof t)return i(this,t,e,r);if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return n(this,t)}function i(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var s=t,a=e,n=r;if(a.byteLength,n<0||a.byteLength<n)throw new RangeError("'offset' is out of bounds");if(a.byteLength<n+(i||0))throw new RangeError("'length' is out of bounds");return a=void 0===n&&void 0===i?new Uint8Array(a):void 0===i?new Uint8Array(a,n):new Uint8Array(a,n,i),u.TYPED_ARRAY_SUPPORT?(s=a).__proto__=u.prototype:s=d(s,a),s}if("string"==typeof e){n=t,i=e,a=r;if(u.isEncoding(a="string"==typeof a&&""!==a?a:"utf8"))return(i=(n=h(n,s=0|f(i,a))).write(i,a))!==s?n.slice(0,i):n;throw new TypeError('"encoding" must be a valid string encoding')}var o,r=t,i=e;if(u.isBuffer(i))return 0!==(r=h(r,o=0|c(i.length))).length&&i.copy(r,0,0,o),r;if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||(o=i.length)!=o?h(r,0):d(r,i);if("Buffer"===i.type&&l(i.data))return d(r,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function n(t,e){if(s(e),t=h(t,e<0?0:0|c(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|c(e.length);t=h(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function c(t){if(t>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function f(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;var r=(t="string"!=typeof t?""+t:t).length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return w(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(t).length;default:if(i)return w(t).length;e=(""+e).toLowerCase(),i=!0}}function e(t,e,r){var i,s=!1;if((e=void 0===e||e<0?0:e)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":var a=this,n=e,o=r,l=a.length;(!o||o<0||l<o)&&(o=l);for(var h="",d=n=!n||n<0?0:n;d<o;++d)h+=function(t){return t<16?"0"+t.toString(16):t.toString(16)}(a[d]);return h;case"utf8":case"utf-8":return R(this,e,r);case"ascii":var u=this,l=e,c=r,f="";c=Math.min(u.length,c);for(var g=l;g<c;++g)f+=String.fromCharCode(127&u[g]);return f;case"latin1":case"binary":var m=this,n=e,p=r,v="";p=Math.min(m.length,p);for(var y=n;y<p;++y)v+=String.fromCharCode(m[y]);return v;case"base64":return T=this,i=r,0===(E=e)&&i===T.length?A.fromByteArray(T):A.fromByteArray(T.slice(E,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var T=e,E=r,S=this.slice(T,E),L="",b=0;b<S.length;b+=2)L+=String.fromCharCode(S[b]+256*S[b+1]);return L;default:if(s)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),s=!0}}function o(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,s){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,(r=(r=isNaN(r)?s?0:t.length-1:r)<0?t.length+r:r)>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,i,s);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(s?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(t,e,r):m(t,[e],r,i,s);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,i,s){var a=1,n=t.length,o=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;n/=a=2,o/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(s)for(var h=-1,d=r;d<n;d++)if(l(t,d)===l(e,-1===h?0:d-h)){if(d-(h=-1===h?d:h)+1===o)return h*a}else-1!==h&&(d-=d-h),h=-1;else for(d=r=n<r+o?n-o:r;0<=d;d--){for(var u=!0,c=0;c<o;c++)if(l(t,d+c)!==l(e,c)){u=!1;break}if(u)return d}return-1}function y(t,e,r,i){return I(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function R(t,e,r){r=Math.min(t.length,r);for(var i=[],s=e;s<r;){var a,n,o,l,h=t[s],d=null,u=239<h?4:223<h?3:191<h?2:1;if(s+u<=r)switch(u){case 1:h<128&&(d=h);break;case 2:128==(192&(a=t[s+1]))&&127<(l=(31&h)<<6|63&a)&&(d=l);break;case 3:a=t[s+1],n=t[s+2],128==(192&a)&&128==(192&n)&&2047<(l=(15&h)<<12|(63&a)<<6|63&n)&&(l<55296||57343<l)&&(d=l);break;case 4:a=t[s+1],n=t[s+2],o=t[s+3],128==(192&a)&&128==(192&n)&&128==(192&o)&&65535<(l=(15&h)<<18|(63&a)<<12|(63&n)<<6|63&o)&&l<1114112&&(d=l)}null===d?(d=65533,u=1):65535<d&&(i.push((d-=65536)>>>10&1023|55296),d=56320|1023&d),i.push(d),s+=u}var c=i,f=c.length;if(f<=4096)return String.fromCharCode.apply(String,c);for(var g="",m=0;m<f;)g+=String.fromCharCode.apply(String,c.slice(m,m+=4096));return g}function p(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function v(t,e,r,i,s,a){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(s<e||e<a)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function T(t,e,r,i){e<0&&(e=65535+e+1);for(var s=0,a=Math.min(t.length-r,2);s<a;++s)t[r+s]=(e&255<<8*(i?s:1-s))>>>8*(i?s:1-s)}function E(t,e,r,i){e<0&&(e=4294967295+e+1);for(var s=0,a=Math.min(t.length-r,4);s<a;++s)t[r+s]=e>>>8*(i?s:3-s)&255}function S(t,e,r,i){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,i,s){return s||S(t,0,r,4),a.write(t,e,r,i,23,4),r+4}function b(t,e,r,i,s){return s||S(t,0,r,8),a.write(t,e,r,i,52,8),r+8}_.Buffer=u,_.SlowBuffer=function(t){return u.alloc(+(t=+t!=t?0:t))},_.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),_.kMaxLength=r(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return i(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol)&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0}),u.alloc=function(t,e,r){return e=e,r=r,s(t=t),!(t<=0)&&void 0!==e?"string"==typeof r?h(null,t).fill(e,r):h(null,t).fill(e):h(null,t)},u.allocUnsafe=function(t){return n(null,t)},u.allocUnsafeSlow=function(t){return n(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,s=0,a=Math.min(r,i);s<a;++s)if(t[s]!==e[s]){r=t[s],i=e[s];break}return r<i?-1:i<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!l(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);if(void 0===e)for(s=e=0;s<t.length;++s)e+=t[s].length;for(var r=u.allocUnsafe(e),i=0,s=0;s<t.length;++s){var a=t[s];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=f,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)o(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)o(this,e,e+3),o(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)o(this,e,e+7),o(this,e+1,e+6),o(this,e+2,e+5),o(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?R(this,0,t):e.apply(this,arguments)},u.prototype.equals=function(t){if(u.isBuffer(t))return this===t||0===u.compare(this,t);throw new TypeError("Argument must be a Buffer")},u.prototype.inspect=function(){var t="",e=_.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e)&&(t+=" ... "),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,i,s){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),(e=void 0===e?0:e)<0||r>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(s<=i&&r<=e)return 0;if(s<=i)return-1;if(r<=e)return 1;if(this===t)return 0;for(var a=(s>>>=0)-(i>>>=0),n=(r>>>=0)-(e>>>=0),o=Math.min(a,n),l=this.slice(i,s),h=t.slice(e,r),d=0;d<o;++d)if(l[d]!==h[d]){a=l[d],n=h[d];break}return a<n?-1:n<a?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},u.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var s=this.length-e;if((void 0===r||s<r)&&(r=s),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i=i||"utf8";for(var a,n,o,l,h,d=!1;;)switch(i){case"hex":var u=this,c=t,f=e,g=r,m=(f=Number(f)||0,u.length-f);if((!g||(g=Number(g))>m)&&(g=m),(m=c.length)%2!=0)throw new TypeError("Invalid hex string");m/2<g&&(g=m/2);for(var p=0;p<g;++p){var v=parseInt(c.substr(2*p,2),16);if(isNaN(v))return p;u[f+p]=v}return p;case"utf8":case"utf-8":return m=e,h=r,I(w(t,(l=this).length-m),l,m,h);case"ascii":return y(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return l=this,h=e,o=r,I(k(t),l,h,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o=e,n=r,I(function(t,e){for(var r,i,s=[],a=0;a<t.length&&!((e-=2)<0);++a)i=(r=t.charCodeAt(a))>>8,s.push(r%256),s.push(i);return s}(t,(a=this).length-o),a,o,n);default:if(d)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),d=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},u.prototype.slice=function(t,e){var r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(s=this.subarray(t,e)).__proto__=u.prototype;else for(var i=e-t,s=new u(i,void 0),a=0;a<i;++a)s[a]=this[a+t];return s},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t],s=1,a=0;++a<e&&(s*=256);)i+=this[t+a]*s;return i},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t+--e],s=1;0<e&&(s*=256);)i+=this[t+--e]*s;return i},u.prototype.readUInt8=function(t,e){return e||p(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||p(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||p(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||p(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||p(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t],s=1,a=0;++a<e&&(s*=256);)i+=this[t+a]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=e,s=1,a=this[t+--i];0<i&&(s*=256);)a+=this[t+--i]*s;return a>=(s*=128)&&(a-=Math.pow(2,8*e)),a},u.prototype.readInt8=function(t,e){return e||p(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||p(t,2,this.length);e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt16BE=function(t,e){e||p(t,2,this.length);e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt32LE=function(t,e){return e||p(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||p(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||p(t,4,this.length),a.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||p(t,4,this.length),a.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||p(t,8,this.length),a.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||p(t,8,this.length),a.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){t=+t,e|=0,r|=0,i||v(this,t,e,r,Math.pow(2,8*r)-1,0);var s=1,a=0;for(this[e]=255&t;++a<r&&(s*=256);)this[e+a]=t/s&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,i){t=+t,e|=0,r|=0,i||v(this,t,e,r,Math.pow(2,8*r)-1,0);var s=r-1,a=1;for(this[e+s]=255&t;0<=--s&&(a*=256);)this[e+s]=t/a&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):T(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):T(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):E(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){t=+t,e|=0,i||v(this,t,e,r,(i=Math.pow(2,8*r-1))-1,-i);var s=0,a=1,n=0;for(this[e]=255&t;++s<r&&(a*=256);)t<0&&0===n&&0!==this[e+s-1]&&(n=1),this[e+s]=(t/a>>0)-n&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){t=+t,e|=0,i||v(this,t,e,r,(i=Math.pow(2,8*r-1))-1,-i);var s=r-1,a=1,n=0;for(this[e+s]=255&t;0<=--s&&(a*=256);)t<0&&0===n&&0!==this[e+s+1]&&(n=1),this[e+s]=(t/a>>0)-n&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&(t=t<0?255+t+1:t),e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):T(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):T(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):E(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return b(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return b(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r=r||0,i||0===i||(i=this.length),e>=t.length&&(e=t.length),(i=0<i&&i<r?r:i)===r)return 0;if(0===t.length||0===this.length)return 0;if((e=e||0)<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length);var s,a=(i=t.length-e<i-r?t.length-e+r:i)-r;if(this===t&&r<e&&e<i)for(s=a-1;0<=s;--s)t[s+e]=this[s+r];else if(a<1e3||!u.TYPED_ARRAY_SUPPORT)for(s=0;s<a;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+a),e);return a},u.prototype.fill=function(t,e,r,i){if("string"==typeof t){var s;if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length&&(s=t.charCodeAt(0))<256&&(t=s),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(!(r<=e))if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(o=e;o<r;++o)this[o]=t;else for(var a=u.isBuffer(t)?t:w(new u(t,i).toString()),n=a.length,o=0;o<r-e;++o)this[o+e]=a[o%n];return this};var D=/[^+\/0-9A-Za-z-_]/g;function w(t,e){var r;e=e||1/0;for(var i=t.length,s=null,a=[],n=0;n<i;++n){if(55295<(r=t.charCodeAt(n))&&r<57344){if(!s){if(56319<r){-1<(e-=3)&&a.push(239,191,189);continue}if(n+1===i){-1<(e-=3)&&a.push(239,191,189);continue}s=r;continue}if(r<56320){-1<(e-=3)&&a.push(239,191,189),s=r;continue}r=65536+(s-55296<<10|r-56320)}else s&&-1<(e-=3)&&a.push(239,191,189);if(s=null,r<128){if(--e<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function k(t){return A.toByteArray(function(t){if((t=((e=t).trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(D,"")).length<2)return"";for(var e;t.length%4!=0;)t+="=";return t}(t))}function I(t,e,r,i){for(var s=0;s<i&&!(s+r>=e.length||s>=t.length);++s)e[s+r]=t[s];return s}}.call(this,C(30))},557:function(t,e){function r(){return t.exports=r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},t.exports.__esModule=!0,t.exports.default=t.exports,r.apply(this,arguments)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},562:function(t,e,r){var i=r(681);t.exports=function(t){return null==t?"":i(t)}},564:function(t,s,a){!function(t){var e=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}s.setTimeout=function(){return new i(r.call(setTimeout,e,arguments),clearTimeout)},s.setInterval=function(){return new i(r.call(setInterval,e,arguments),clearInterval)},s.clearTimeout=s.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(e,this._id)},s.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},s.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},s._unrefActive=s.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;0<=e&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a(743),s.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,s.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}.call(this,a(30))},570:function(t,e,r){"use strict";var{default:r,DraggableCore:i}=r(703);t.exports=r,t.exports.default=r,t.exports.DraggableCore=i},571:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dontSetMe=function(t,e,r){if(t[e])return new Error("Invalid prop ".concat(e," passed to ").concat(r," - do not set this, set it on the child."))},e.findInArray=function(r,i){for(let t=0,e=r.length;t<e;t++)if(i.apply(i,[r[t],t,r]))return r[t]},e.int=function(t){return parseInt(t,10)},e.isFunction=function(t){return"function"==typeof t||"[object Function]"===Object.prototype.toString.call(t)},e.isNum=function(t){return"number"==typeof t&&!isNaN(t)}},576:function(t,e,r){"use strict";t.exports=r(656)},579:function(t,e){t.exports=function(t,e){if(null==t)return{};for(var r,i={},s=Object.keys(t),a=0;a<s.length;a++)r=s[a],0<=e.indexOf(r)||(i[r]=t[r]);return i},t.exports.__esModule=!0,t.exports.default=t.exports},583:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.addClassName=h,e.addEvent=function(t,e,r,i){t&&(i={capture:!0,...i},t.addEventListener?t.addEventListener(e,r,i):t.attachEvent?t.attachEvent("on"+e,r):t["on"+e]=r)},e.addUserSelectStyles=function(t){var e;t&&((e=t.getElementById("react-draggable-style-el"))||((e=t.createElement("style")).type="text/css",e.id="react-draggable-style-el",e.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",e.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",t.getElementsByTagName("head")[0].appendChild(e)),t.body)&&h(t.body,"react-draggable-transparent-selection")},e.createCSSTransform=function(t,e){t=l(t,e,"px");return{[(0,s.browserPrefixToKey)("transform",s.default)]:t}},e.createSVGTransform=function(t,e){return l(t,e,"")},e.getTouch=function(t,e){return t.targetTouches&&(0,i.findInArray)(t.targetTouches,t=>e===t.identifier)||t.changedTouches&&(0,i.findInArray)(t.changedTouches,t=>e===t.identifier)},e.getTouchIdentifier=function(t){return t.targetTouches&&t.targetTouches[0]?t.targetTouches[0].identifier:t.changedTouches&&t.changedTouches[0]?t.changedTouches[0].identifier:void 0},e.getTranslation=l,e.innerHeight=function(t){var e=t.clientHeight,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e-=(0,i.int)(t.paddingTop))-(0,i.int)(t.paddingBottom)},e.innerWidth=function(t){var e=t.clientWidth,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e-=(0,i.int)(t.paddingLeft))-(0,i.int)(t.paddingRight)},e.matchesSelector=o,e.matchesSelectorAndParentsTo=function(t,e,r){let i=t;do{if(o(i,e))return!0;if(i===r)return!1}while(i=i.parentNode);return!1},e.offsetXYFromParent=function(t,e,r){var i=e===e.ownerDocument.body?{left:0,top:0}:e.getBoundingClientRect();return{x:(t.clientX+e.scrollLeft-i.left)/r,y:(t.clientY+e.scrollTop-i.top)/r}},e.outerHeight=function(t){var e=t.clientHeight,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e+=(0,i.int)(t.borderTopWidth))+(0,i.int)(t.borderBottomWidth)},e.outerWidth=function(t){var e=t.clientWidth,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e+=(0,i.int)(t.borderLeftWidth))+(0,i.int)(t.borderRightWidth)},e.removeClassName=d,e.removeEvent=function(t,e,r,i){t&&(i={capture:!0,...i},t.removeEventListener?t.removeEventListener(e,r,i):t.detachEvent?t.detachEvent("on"+e,r):t["on"+e]=null)},e.removeUserSelectStyles=function(t){if(t)try{var e;t.body&&d(t.body,"react-draggable-transparent-selection"),t.selection?t.selection.empty():(e=(t.defaultView||window).getSelection())&&"Caret"!==e.type&&e.removeAllRanges()}catch(t){}};var i=r(571),s=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=n(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(704));function n(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(n=function(t){return t?r:e})(t))}let a="";function o(e,t){return a=a||(0,i.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(t){return(0,i.isFunction)(e[t])}),!!(0,i.isFunction)(e[a])&&e[a](t)}function l(t,e,r){let{x:i,y:s}=t,a="translate(".concat(i).concat(r,",").concat(s).concat(r,")");if(e){const t="".concat("string"==typeof e.x?e.x:e.x+r),i="".concat("string"==typeof e.y?e.y:e.y+r);a="translate(".concat(t,", ").concat(i,")")+a}return a}function h(t,e){t.classList?t.classList.add(e):t.className.match(new RegExp("(?:^|\\s)".concat(e,"(?!\\S)")))||(t.className+=" ".concat(e))}function d(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(?:^|\\s)".concat(e,"(?!\\S)"),"g"),"")}},597:function(t,e,r){"use strict";e.a={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},598:function(t,e,r){"use strict";r.r(e),e.default=function(e){var r={};return function(t){return void 0===r[t]&&(r[t]=e(t)),r[t]}}},601:function(t,e){t.exports=function(t,e){for(var r=-1,i=null==t?0:t.length,s=Array(i);++r<i;)s[r]=e(t[r],r,t);return s}},607:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.canDragX=function(t){return"both"===t.props.axis||"x"===t.props.axis},e.canDragY=function(t){return"both"===t.props.axis||"y"===t.props.axis},e.createCoreData=function(t,e,r){var i=!(0,l.isNum)(t.lastX),s=d(t);return i?{node:s,deltaX:0,deltaY:0,lastX:e,lastY:r,x:e,y:r}:{node:s,deltaX:e-t.lastX,deltaY:r-t.lastY,lastX:t.lastX,lastY:t.lastY,x:e,y:r}},e.createDraggableData=function(t,e){var r=t.props.scale;return{node:e.node,x:t.state.x+e.deltaX/r,y:t.state.y+e.deltaY/r,deltaX:e.deltaX/r,deltaY:e.deltaY/r,lastX:t.state.x,lastY:t.state.y}},e.getBoundPosition=function(e,r,i){if(e.props.bounds){let t=e.props["bounds"];t="string"==typeof t?t:{left:(s=t).left,top:s.top,right:s.right,bottom:s.bottom};var s=d(e);if("string"==typeof t){const e=s["ownerDocument"],r=e.defaultView;var a="parent"===t?s.parentNode:e.querySelector(t);if(!(a instanceof r.HTMLElement))throw new Error('Bounds selector "'+t+'" could not find an element.');const d=a,n=r.getComputedStyle(s),o=r.getComputedStyle(d);t={left:-s.offsetLeft+(0,l.int)(o.paddingLeft)+(0,l.int)(n.marginLeft),top:-s.offsetTop+(0,l.int)(o.paddingTop)+(0,l.int)(n.marginTop),right:(0,h.innerWidth)(d)-(0,h.outerWidth)(s)-s.offsetLeft+(0,l.int)(o.paddingRight)-(0,l.int)(n.marginRight),bottom:(0,h.innerHeight)(d)-(0,h.outerHeight)(s)-s.offsetTop+(0,l.int)(o.paddingBottom)-(0,l.int)(n.marginBottom)}}(0,l.isNum)(t.right)&&(r=Math.min(r,t.right)),(0,l.isNum)(t.bottom)&&(i=Math.min(i,t.bottom)),(0,l.isNum)(t.left)&&(r=Math.max(r,t.left)),(0,l.isNum)(t.top)&&(i=Math.max(i,t.top))}return[r,i]},e.getControlPosition=function(t,e,r){var i="number"==typeof e?(0,h.getTouch)(t,e):null;return"number"!=typeof e||i?(e=d(r),e=r.props.offsetParent||e.offsetParent||e.ownerDocument.body,(0,h.offsetXYFromParent)(i||t,e,r.props.scale)):null},e.snapToGrid=function(t,e,r){return[Math.round(e/t[0])*t[0],Math.round(r/t[1])*t[1]]};var l=r(571),h=r(583);function d(t){t=t.findDOMNode();if(t)return t;throw new Error("<DraggableCore>: Unmounted during event!")}},608:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){}},639:function(i,t,e){"use strict";e.d(t,"a",function(){return xs});s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,o=/^(?=([^\/?#]*))\1([^]*)$/,l=/(?:\/|^)\.(?=\/)/g,h=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=a.parseURL(t);if(i)return i.path=a.normalizePath(i.path),a.buildURLFromParts(i);throw new Error("Error trying to parse base URL.")}i=a.parseURL(e);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):e;e=a.parseURL(t);if(!e)throw new Error("Error trying to parse base URL.");!e.netLoc&&e.path&&"/"!==e.path[0]&&(t=o.exec(e.path),e.netLoc=t[1],e.path=t[2]),e.netLoc&&!e.path&&(e.path="/");var s,t={scheme:e.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(t.netLoc=e.netLoc,"/"===i.path[0])||(i.path?(s=(s=e.path).substring(0,s.lastIndexOf("/")+1)+i.path,t.path=a.normalizePath(s)):(t.path=e.path,i.params||(t.params=e.params,i.query)||(t.query=e.query))),null===t.path&&(t.path=r.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(t)},parseURL:function(t){t=s.exec(t);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(l,"");t.length!==(t=t.replace(h,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};var s,o,l,h,a,$=a;function K(e,t){var r,i=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)),i}function m(i){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?K(Object(s),!0).forEach(function(t){var e,r;e=i,t=s[r=t],(r=function(){var t=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(r);return"symbol"==typeof t?t:String(t)}())in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(s)):K(Object(s)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(s,t))})}return i}function k(){return(k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}const D=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)};(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.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached";let I=e,_=((t={}).NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t),C=((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);function H(){}const V={trace:H,debug:H,log:H,warn:H,info:H,error:H};let Y=V;function W(r,...t){t.forEach(function(t){var e;Y[t]=r[t]?r[t].bind(r):(e=self.console[t])?e.bind(self.console,`[${t}] >`):H})}const P=Y,j=/^(\d+)x(\d+)$/,q=/(.+?)=(".*?"|.*?)(?:,|$)/g;class w{constructor(t){for(const e in t="string"==typeof t?w.parseAttrList(t):t)t.hasOwnProperty(e)&&("X-"===e.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){t=parseInt(this[t],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(t){if(this[t]){var e=(1&(e=(this[t]||"0x").slice(2)).length?"0":"")+e,r=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)r[t]=parseInt(e.slice(2*t,2*t+2),16);return r}return null}hexadecimalIntegerAsNumber(t){t=parseInt(this[t],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){t=this[t];return t?parseFloat(t):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){t=j.exec(this[t]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(t){var e,r={};for(q.lastIndex=0;null!==(e=q.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1)),r[e[1].trim()]=t}return r}}class X{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(const e in r)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==r[e]){P.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=k(new w({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);D(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var t;return this._endDate||(null!==(t=this.duration)?new Date(this._startDate.getTime()+1e3*t):null)}get duration(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(D(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&D(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class z{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var S="audio",b="video",Q="audiovideo";class J{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={audio:null,video:null,audiovideo:null},this.baseurl=t}setByteRange(t,e){var t=t.split("@",2),r=[];1===t.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=$.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Z extends J{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new z,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const t=this["levelkeys"];if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var t;return null!==this.programDateTime&&D(this.programDateTime)?(t=D(this.duration)?this.duration:0,this.programDateTime+1e3*t):null}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(1<e||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(t){this.levelkeys&&(t=this.levelkeys[t])&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}abortRequests(){var t;null!=(t=this.loader)&&t.abort(),null!=(t=this.keyLoader)&&t.abort()}setElementaryStreamInfo(t,e,r,i,s,a=!1){var n=this["elementaryStreams"],o=n[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):n[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:s,partial:a}}clearElementaryStreamInfo(){var t=this["elementaryStreams"];t[S]=null,t[b]=null,t[Q]=null}}class tt extends J{constructor(t,e,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new z,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=i;r=t.enumeratedString("BYTERANGE");r&&this.setByteRange(r,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){var t=this["elementaryStreams"];return!!(t.audio||t.video||t.audiovideo)}}class et{constructor(t){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=t}reloaded(t){var e,r;t?(e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex,this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||0<e||0==e&&0<r,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay):(this.advanced=!0,this.updated=!0)}get hasProgramDateTime(){return!!this.fragments.length&&D(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){var t=this.driftEndTime-this.driftStartTime;return 0<t?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function rt(t){return Uint8Array.from(atob(t),t=>t.charCodeAt(0))}function it(t){return Uint8Array.from(unescape(encodeURIComponent(t)),t=>t.charCodeAt(0))}var u={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},st="org.w3.clearkey",at="com.apple.streamingkeydelivery",nt="com.microsoft.playready",ot="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function lt(t){switch(t){case at:return u.FAIRPLAY;case nt:return u.PLAYREADY;case ot:return u.WIDEVINE;case st:return u.CLEARKEY}}var ht="edef8ba979d64acea3c827dcd51d21ed";function dt(t){switch(t){case u.FAIRPLAY:return at;case u.PLAYREADY:return nt;case u.WIDEVINE:return ot;case u.CLEARKEY:return st}}function ut(t){const{drmSystems:e,widevineLicenseUrl:r}=t,i=e?[u.FAIRPLAY,u.WIDEVINE,u.PLAYREADY,u.CLEARKEY].filter(t=>!!e[t]):[];return!i[u.WIDEVINE]&&r&&i.push(u.WIDEVINE),i}const ct="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ft(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}const gt=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,mt=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,pt=(t,e)=>{var r=e;let i=0;for(;gt(t,e);)i=(i+=10)+vt(t,e+6),mt(t,e+10)&&(i+=10),e+=i;if(0<i)return t.subarray(r,r+i)},vt=(t,e)=>{var r=(127&t[e])<<21;return(r|=(127&t[e+1])<<14)|(127&t[e+2])<<7|127&t[e+3]},yt=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,Tt=t=>{let e=0;for(var r,i=[];gt(t,e);){for(var s=vt(t,e+6),a=(e+=10)+s;e+8<a;){r=t.subarray(e),o=n=void 0,n=String.fromCharCode(r[0],r[1],r[2],r[3]),o=vt(r,4);var n={type:n,size:o,data:r.subarray(10,10+o)},o=("PRIV"===(r=n).type?Et:"W"===r.type[0]?Lt:St)(r);o&&i.push(o),e+=n.size+10}mt(t,e)&&(e+=10)}return i},Et=t=>{var e,r;if(!(t.size<2))return e=A(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1)),{key:t.type,info:e,data:r.buffer}},St=t=>{var e,r;if(!(t.size<2))return"TXXX"===t.type?(e=1,e+=(r=A(t.data.subarray(1),!0)).length+1,e=A(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=A(t.data.subarray(1)),{key:t.type,data:r})},Lt=t=>{var e,r;return"WXXX"===t.type?t.size<2?void 0:(e=1,e+=(r=A(t.data.subarray(1),!0)).length+1,e=A(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=A(t.data),{key:t.type,data:r})},A=(t,e=!1)=>{var r=bt=bt||void 0===self.TextDecoder?bt:new self.TextDecoder("utf-8");if(r){const i=r.decode(t);if(e){const t=i.indexOf("\0");return-1!==t?i.substring(0,t):i}return i.replace(/\0/g,"")}const i=t.length;let s,a,n,o="",l=0;for(;l<i;){if(0===(s=t[l++])&&e)return o;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:a=t[l++],o+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[l++],n=t[l++],o+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&n)<<0)}}return o};let bt;function c(r){let i="";for(let e=0;e<r.length;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}const At=Math.pow(2,32)-1,Rt=[].push,Dt={video:1,audio:2,id3:3,text:4};function f(t){return String.fromCharCode.apply(null,t)}function wt(t,e){t=t[e]<<8|t[e+1];return t<0?65536+t:t}function R(t,e){t=kt(t,e);return t<0?4294967296+t:t}function kt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function It(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function x(e,r){var i=[];if(r.length){const a=e.byteLength;for(let t=0;t<a;){var s=R(e,t),s=1<s?t+s:a;if(f(e.subarray(t+4,t+8))===r[0])if(1===r.length)i.push(e.subarray(t+8,s));else{const a=x(e.subarray(t+8,s),r.slice(1));a.length&&Rt.apply(i,a)}t=s}}return i}function _t(e){const r=[],i=x(e,["moov","trak"]);for(let t=0;t<i.length;t++){var s=i[t],a=x(s,["tkhd"])[0];if(a){var a=R(a,0===a[0]?12:20),n=x(s,["mdia","mdhd"])[0];if(n){var n=R(n,0===n[0]?12:20),o=x(s,["mdia","hdlr"])[0];if(o){const e=f(o.subarray(8,12)),i={soun:S,vide:b}[e];if(i){const e=x(s,["mdia","minf","stbl","stsd"])[0];let t;e&&(t=f(e.subarray(12,16))),r[a]={timescale:n,type:i},r[i]={timescale:n,id:a,codec:t}}}}}}return x(e,["moov","mvex","trex"]).forEach(t=>{var e=R(t,4),e=r[e];e&&(e.default={duration:R(t,12),flags:R(t,20)})}),r}function Ct(t){var e=x(t,["schm"])[0];if(e){e=f(e.subarray(4,8));if("cbcs"===e||"cenc"===e)return x(t,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function Pt(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function xt(v,y){const T=[],E=y.samples,S=y.timescale,o=y.id;let L=!1;return x(E,["moof"]).map(t=>{const p=t.byteOffset-8;x(t,["traf"]).map(n=>{var t=x(n,["tfdt"]).map(t=>{var e=t[0];let r=R(t,4);return(r=1===e?(r*=Math.pow(2,32))+R(t,8):r)/S})[0];return void 0!==t&&(v=t),x(n,["tfhd"]).map(t=>{var e=R(t,4),r=16777215&R(t,0);let g=0;var i=0!=(16&r);let m=0;var s=0!=(32&r);let a=8;e===o&&(0!=(1&r)&&(a+=8),0!=(2&r)&&(a+=4),0!=(8&r)&&(g=R(t,a),a+=4),i&&(m=R(t,a),a+=4),s&&(a+=4),"video"===y.type&&(L=!!(e=y.codec)&&("hvc1"===(e=(r=e.indexOf("."))<0?e:e.substring(0,r))||"hev1"===e||"dvh1"===e||"dvhe"===e)),x(n,["trun"]).map(e=>{var r=e[0],t=16777215&R(e,0);let i=0;var s=0!=(256&t);let a=0;var n=0!=(512&t);let o=0;var l=0!=(1024&t),h=0!=(2048&t);let d=0;var u=R(e,4);let c=8,f=(0!=(1&t)&&(i=R(e,c),c+=4),0!=(4&t)&&(c+=4),i+p);for(let t=0;t<u;t++){if(s?(a=R(e,c),c+=4):a=g,n?(o=R(e,c),c+=4):o=m,l&&(c+=4),h&&(d=(0===r?R:kt)(e,c),c+=4),y.type===b){let t=0;for(;t<o;){const e=R(E,f);f+=4,function(t,e){if(t){const t=e>>1&63;return 39==t||40==t}return 6==(31&e)}(L,E[f])&&Mt(E.subarray(f,f+e),L?2:1,v+d/S,T),f+=e,t+=e+4}}v+=a/S}}))})})}),T}function Mt(e,r,i,t){var s=Ot(e);let a=0,n=(a+=r,0),o=0,l=!1,h=0;for(;a<s.length;){for(n=0;!(a>=s.length)&&(h=s[a++],n+=h,255===h););for(o=0;!(a>=s.length)&&(h=s[a++],o+=h,255===h););const e=s.length-a;if(!l&&4===n&&a<s.length){if(l=!0,181===s[a++]){const e=wt(s,a);if(a+=2,49===e){const e=R(s,a);if(a+=4,1195456820===e){const e=s[a++];if(3===e){const r=s[a++],o=31&r,l=64&r,h=l?2+3*o:0,d=new Uint8Array(h);if(l){d[0]=r;for(let t=1;t<h;t++)d[t]=s[a++]}t.push({type:e,payloadType:n,pts:i,bytes:d})}}}}}else if(5===n&&o<e){if(l=!0,16<o){const e=[];for(let t=0;t<16;t++){const i=s[a++].toString(16);e.push(1==i.length?"0"+i:i),3!==t&&5!==t&&7!==t&&9!==t||e.push("-")}const r=o-16,l=new Uint8Array(r);for(let t=0;t<r;t++)l[t]=s[a++];t.push({payloadType:n,pts:i,uuid:e.join(""),userData:A(l),userDataBytes:l})}}else if(o<e)a+=o;else if(o>e)break}}function Ot(t){var e=t.byteLength,r=[];let i=1;for(;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var s=e-r.length,a=new Uint8Array(s);let n=0;for(i=0;i<s;n++,i++)n===r[0]&&(n++,r.shift()),a[i]=t[n];return a}let Ft={};class Nt{static clearKeyUriToKeyIdMap(){Ft={}}constructor(t,e,r,i=[1],s=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=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}isSupported(){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 at:case ot:case nt:case st:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(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||P.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const e=function(e){var r=new Uint8Array(16);for(let t=12;t<16;t++)r[t]=e>>8*(15-t)&255;return r}(t);return new Nt(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=function(t){const e=t.split(":");let r=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),a=t[t.length-1].split(",");if(2===a.length){const e="base64"===a[0],n=a[1];r=e?(t.splice(-1,1),rt(n)):(i=it(n).subarray(0,16),(s=new Uint8Array(16)).set(i,16-i.length),s)}}var i,s;return r}(this.uri);if(e)switch(this.keyFormat){case ot:22<=(this.pssh=e).length&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case nt:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(r,e,i){if(16!==r.byteLength)throw new RangeError("Invalid system id");let s,a,n;if(e){s=1,a=new Uint8Array(16*e.length);for(let t=0;t<e.length;t++){const i=e[t];if(16!==i.byteLength)throw new RangeError("Invalid key");a.set(i,16*t)}}else s=0,a=new Uint8Array;0<s?(n=new Uint8Array(4),0<e.length&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;var o=new Uint8Array(4);i&&0<i.byteLength&&new DataView(o.buffer).setUint32(0,i.byteLength,!1);{var l=[new Uint8Array([s,0,0,0]),r,n,a,o,i||new Uint8Array],h=l.length;let t=8,e=h;for(;e--;)t+=l[e].byteLength;var d=new Uint8Array(t);for(d[0]=t>>24&255,d[1]=t>>16&255,d[2]=t>>8&255,d[3]=255&t,d.set([112,115,115,104],4),e=0,t=8;e<h;e++)d.set(l[e],t),t+=l[e].byteLength;return d}}(t,null,e);var r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(r)),r=r.substring(r.indexOf("<"),r.length),r=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(r){const t=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(t){const e=rt(t).subarray(0,16);r=e,i(r,0,3),i(r,1,2),i(r,4,5),i(r,6,7),this.keyId=e}}break}default:{let t=e.subarray(0,16);if(16!==t.length){const e=new Uint8Array(16);e.set(t,16-t.length),t=e}this.keyId=t;break}}function i(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}if(!this.keyId||16!==this.keyId.byteLength){let t=Ft[this.uri];if(!t){const e=Object.keys(Ft).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16),new DataView(t.buffer,12,4).setUint32(0,e),Ft[this.uri]=t}this.keyId=t}return this}}const Ut=/\{\$([a-zA-Z0-9-_]+)\}/g;function Bt(t){return Ut.test(t)}function M(e,r,i){if(null!==e.variableList||e.hasVariableRefs)for(let t=i.length;t--;){var s=i[t],a=r[s];a&&(r[s]=Gt(e,a))}}function Gt(i,t){if(null!==i.variableList||i.hasVariableRefs){const s=i.variableList;return t.replace(Ut,t=>{var e=t.substring(2,t.length-1),r=null==s?void 0:s[e];return void 0===r?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${e}"`)),t):r})}return t}function $t(t,e,r){let i,s,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{const t=new self.URL(r).searchParams;if(!t.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);s=t.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else i=e.NAME,s=e.VALUE;i in a?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):a[i]=s||""}function Kt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Ht={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Vt=Kt();function Yt(t,e){return null!=(e=null==Vt?void 0:Vt.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))&&e}const Wt=/#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,jt=/#EXT-X-MEDIA:(.*)/g,qt=/^#EXT(?:INF|-X-TARGETDURATION):/m,Xt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),zt=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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class g{static findGroup(e,r){for(let t=0;t<e.length;t++){var i=e[t];if(i.id===r)return i}}static convertAVC1ToAVCOTI(t){var e,r=t.split(".");return 2<r.length?(e=r.shift()+".",(e+=parseInt(r.shift()).toString(16))+("000"+parseInt(r.shift()).toString(16)).slice(-4)):t}static resolve(t,e){return $.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return qt.test(t)}static parseMasterPlaylist(t,e){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Bt(t)},i=[];var s,a;for(Wt.lastIndex=0;null!=(s=Wt.exec(t));)if(s[1]){const t=new w(s[1]),n=(M(r,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]),Gt(r,s[2])),o={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:g.resolve(n,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),function(i,s){["video","audio","text"].forEach(r=>{const e=i.filter(t=>{var e=r;return!!(e=Ht[e])&&!0===e[t.slice(0,4)]});var t;e.length&&(t=e.filter(t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)),s[r+"Codec"]=(0<t.length?t:e)[0],i=i.filter(t=>-1===e.indexOf(t)))}),s.unknownCodecs=i}((t.CODECS||"").split(/[ ,]+/).filter(t=>t),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=g.convertAVC1ToAVCOTI(o.videoCodec)),null!=(a=o.unknownCodecs)&&a.length||i.push(o),r.levels.push(o)}else if(s[3]){const t=s[3],i=s[4];switch(t){case"SESSION-DATA":{const t=new w(i),e=(M(r,t,["DATA-ID","LANGUAGE","VALUE","URI"]),t["DATA-ID"]);e&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[e]=t);break}case"SESSION-KEY":{const t=Qt(i,e,r);t.encrypted&&t.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(t)):P.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const t=new w(i);M(r,t,["NAME","VALUE","QUERYPARAM"]),$t(r,t,e)}break;case"CONTENT-STEERING":{const t=new w(i);M(r,t,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:g.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Jt(i)}}const n=0<i.length&&i.length<r.levels.length;return r.levels=n?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(t,e,r){let i;const s={},a=r.levels,n={AUDIO:a.map(t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec})),SUBTITLES:a.map(t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(jt.lastIndex=0;null!==(i=jt.exec(t));){const t=new w(i[1]),a=t.TYPE;if(a){const i=n[a],h=s[a]||[];s[a]=h,M(r,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var l={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",instreamId:t["INSTREAM-ID"],name:t.NAME||t.LANGUAGE||"",type:a,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:t.LANGUAGE,url:t.URI?g.resolve(t.URI,e):""};if(null!=i&&i.length){const t=g.findGroup(i,l.groupId)||i[0];Zt(l,t,"audioCodec"),Zt(l,t,"textCodec")}h.push(l)}}return s}static parseLevelPlaylist(t,e,r,i,s,a){const n=new et(e),o=n.fragments;let l,h,d,u=null,c=0,f=0,g=0,m=0,p=null,v=new Z(i,e),y=-1,T=!1;for(Xt.lastIndex=0,n.m3u8=t,n.hasVariableRefs=Bt(t);null!==(l=Xt.exec(t));){T&&(T=!1,(v=new Z(i,e)).start=g,v.sn=c,v.cc=m,v.level=r,u)&&(v.initSegment=u,v.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null);const t=l[1];if(t){v.duration=parseFloat(t);const e=(" "+l[2]).slice(1);v.title=e||null,v.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(D(v.duration)){v.start=g,d&&re(v,d,n),v.sn=c,v.level=r,v.cc=m,v.urlId=s,o.push(v);const t=(" "+l[3]).slice(1);v.relurl=Gt(n,t),te(v,p),p=v,g+=v.duration,c++,f=0,T=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);p?v.setByteRange(t,p):v.setByteRange(t)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else if(l=l[0].match(zt)){for(h=1;h<l.length&&void 0===l[h];h++);const t=(" "+l[h]).slice(1),s=(" "+l[h+1]).slice(1),g=l[h+2]?(" "+l[h+2]).slice(1):"";switch(t){case"PLAYLIST-TYPE":n.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":c=n.startSN=parseInt(s);break;case"SKIP":{const t=new w(s),e=(M(n,t,["RECENTLY-REMOVED-DATERANGES"]),t.decimalInteger("SKIPPED-SEGMENTS"));if(D(e)){for(let t=n.skippedSegments=e;t--;)o.unshift(null);c+=e}const r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(n.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":n.targetduration=Math.max(parseInt(s),1);break;case"VERSION":n.version=parseInt(s);break;case"EXTM3U":break;case"ENDLIST":n.live=!1;break;case"#":(s||g)&&v.tagList.push(g?[s,g]:[s]);break;case"DISCONTINUITY":m++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([t]);break;case"BITRATE":v.tagList.push([t,s]);break;case"DATERANGE":{const t=new w(s),e=(M(n,t,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),M(n,t,t.clientAttrs),new X(t,n.dateRanges[t.ID]));e.isValid||n.skippedSegments?n.dateRanges[e.id]=e:P.warn(`Ignoring invalid DATERANGE tag: "${s}"`),v.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const t=new w(s);if(M(n,t,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in t){E=void 0;S=void 0;L=void 0;var E=n;var S=t;var L=a;if(S=S.IMPORT,L&&S in L){let t=E.variableList;t||(E.variableList=t={}),t[S]=L[S]}else E.playlistParsingError||(E.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${S}"`))}else $t(n,t,e)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(s);break;case"KEY":{const t=Qt(s,e,n);if(t.isSupported()){if("NONE"===t.method){d=void 0;break}(d=(d=d||{})[t.keyFormat]?k({},d):d)[t.keyFormat]=t}else P.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${s}"`);break}case"START":n.startTimeOffset=Jt(s);break;case"MAP":{const t=new w(s);if(M(n,t,["BYTERANGE","URI"]),v.duration){const s=new Z(i,e);ee(s,t,r,d),u=s,(v.initSegment=u).rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=u.rawProgramDateTime)}else ee(v,t,r,d),u=v,T=!0;break}case"SERVER-CONTROL":{const t=new w(s);n.canBlockReload=t.bool("CAN-BLOCK-RELOAD"),n.canSkipUntil=t.optionalFloat("CAN-SKIP-UNTIL",0),n.canSkipDateRanges=0<n.canSkipUntil&&t.bool("CAN-SKIP-DATERANGES"),n.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),n.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new w(s);n.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=n.partList;t=t||(n.partList=[]);const r=0<f?t[t.length-1]:void 0,i=f++,a=new w(s),o=(M(n,a,["BYTERANGE","URI"]),new tt(a,v,e,i,r));t.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new w(s);M(n,t,["URI"]),n.preloadHint=t;break}case"RENDITION-REPORT":{const t=new w(s);M(n,t,["URI"]),n.renditionReports=n.renditionReports||[],n.renditionReports.push(t);break}default:P.warn("line parsed but not handled: "+l)}}else P.warn("No matches on slow regex match for level playlist!")}p&&!p.relurl?(o.pop(),g-=p.duration,n.partList&&(n.fragmentHint=p)):n.partList&&(te(v,p),v.cc=m,n.fragmentHint=v,d)&&re(v,d,n);var b=o.length,A=o[0],R=o[b-1];if(0<(g+=n.skippedSegments*n.targetduration)&&b&&R){n.averagetargetduration=g/b;const t=R.sn;n.endSN="initSegment"!==t?t:0,n.live||(R.endList=!0),A&&(n.startCC=A.cc)}else n.endSN=0,n.startCC=0;return n.fragmentHint&&(g+=n.fragmentHint.duration),n.totalduration=g,n.endCC=m,0<y&&function(e,r){let i=e[r];for(let t=r;t--;){const r=e[t];if(!r)return;r.programDateTime=i.programDateTime-1e3*r.duration,i=r}}(o,y),n}}function Qt(t,e,r){var t=new w(t),r=(M(r,t,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]),null!=(r=t.METHOD)?r:""),i=t.URI,s=t.hexadecimalInteger("IV"),a=t.KEYFORMATVERSIONS,n=null!=(n=t.KEYFORMAT)?n:"identity",t=(i&&t.IV&&!s&&P.error("Invalid IV: "+t.IV),i?g.resolve(i,e):""),i=(a||"1").split("/").map(Number).filter(Number.isFinite);return new Nt(r,t,n,i,s)}function Jt(t){t=new w(t).decimalFloatingPoint("TIME-OFFSET");return D(t)?t:null}function Zt(t,e,r){e=e[r];e&&(t[r]=e)}function te(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),D(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function ee(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function re(t,e,r){t.levelkeys=e;r=r.encryptedFragments;r.length&&r[r.length-1].levelkeys===e||!Object.keys(e).some(t=>e[t].isCommonEncryption)||r.push(t)}var ie="manifest",se="level",p="audioTrack",v="subtitleTrack",y="main",L="audio",ae="subtitle";function ne(t){t=t.type;switch(t){case p:return L;case v:return ae;default:return y}}function oe(t,e){let r=t.url;return r=void 0!==r&&0!==r.indexOf("data:")?r:e.url}class le{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){var e=this.hls.config,r=e.pLoader,i=e.loader,r=new(r||i)(e);return this.loaders[t.type]=r}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){e=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie,url:e,deliveryDirectives:null})}onLevelLoading(t,e){var{id:e,level:r,url:i,deliveryDirectives:s}=e;this.load({id:e,level:r,responseType:"text",type:se,url:i,deliveryDirectives:s})}onAudioTrackLoading(t,e){var{id:e,groupId:r,url:i,deliveryDirectives:s}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:p,url:i,deliveryDirectives:s})}onSubtitleTrackLoading(t,e){var{id:e,groupId:r,url:i,deliveryDirectives:s}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:v,url:i,deliveryDirectives:s})}load(e){const r=this.hls.config;let i,t=this.getInternalLoader(e);if(t){const s=t.context;if(s&&s.url===e.url)return void P.trace("[playlist-loader]: playlist request ongoing");P.log("[playlist-loader]: aborting previous loader for type: "+e.type),t.abort()}if(i=e.type===ie?r.manifestLoadPolicy.default:k({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),t=this.createInternalLoader(e),null!=(s=e.deliveryDirectives)&&s.part){let t;if(e.type===se&&null!==e.level?t=this.hls.levels[e.level].details:e.type===p&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===v&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const s=1e3*Math.max(3*e,.8*r);i=k({},i,{maxTimeToFirstByteMs:Math.min(s,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(s,i.maxTimeToFirstByteMs)})}}}var s=i.errorRetry||i.timeoutRetry||{},s={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0};t.load(e,s,{onSuccess:(t,e,r,i)=>{var s=this.getInternalLoader(r),a=(this.resetInternalLoader(r.type),t.data);0===a.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),g.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(t,e,r,i||null,s):this.handleMasterPlaylist(t,e,r,i)):this.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:(t,e,r,i)=>{this.handleNetworkError(e,r,!1,t,i)},onTimeout:(t,e,r)=>{this.handleNetworkError(e,r,!0,void 0,t)}})}handleMasterPlaylist(t,e,r,i){var s,a,n,o,l,h=this.hls,d=t.data,u=oe(t,r),c=g.parseMasterPlaylist(d,u);c.playlistParsingError?this.handleManifestParsingError(t,r,c.playlistParsingError,i,e):({contentSteering:t,levels:r,sessionData:s,sessionKeys:a,startTimeOffset:n,variableList:o}=c,{AUDIO:d=[],SUBTITLES:c,"CLOSED-CAPTIONS":l}=(this.variableList=o,g.parseMasterPlaylistMedia(d,u,c)),d.length&&!d.some(t=>!t.url)&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(P.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new w({}),bitrate:0,url:""})),h.trigger(I.MANIFEST_LOADED,{levels:r,audioTracks:d,subtitles:c,captions:l,contentSteering:t,url:u,stats:e,networkDetails:i,sessionData:s,sessionKeys:a,startTimeOffset:n,variableList:o}))}handleTrackOrLevelPlaylist(t,e,r,i,s){var a=this.hls,{id:n,level:o,type:l}=r,h=oe(t,r),n=D(n)?n:0,o=D(o)?o:n,d=ne(r),o=g.parseLevelPlaylist(t.data,h,o,d,n,this.variableList);if(l===ie){const t={attrs:new w({}),bitrate:0,details:o,name:"",url:h};a.trigger(I.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:h,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=o,this.handlePlaylistLoaded(o,t,e,r,i,s)}handleManifestParsingError(t,e,r,i,s){this.hls.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.MANIFEST_PARSING_ERROR,fatal:e.type===ie,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:s})}handleNetworkError(t,e,r=!1,i,s){let a=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading `+t.type;t.type===se?a+=`: ${t.level} id: `+t.id:t.type!==p&&t.type!==v||(a+=` id: ${t.id} group-id: "${t.groupId}"`);var n=new Error(a);P.warn("[playlist-loader]: "+a);let o=C.UNKNOWN,l=!1;var h=this.getInternalLoader(t);switch(t.type){case ie:o=r?C.MANIFEST_LOAD_TIMEOUT:C.MANIFEST_LOAD_ERROR,l=!0;break;case se:o=r?C.LEVEL_LOAD_TIMEOUT:C.LEVEL_LOAD_ERROR,l=!1;break;case p:o=r?C.AUDIO_TRACK_LOAD_TIMEOUT:C.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case v:o=r?C.SUBTITLE_TRACK_LOAD_TIMEOUT:C.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(t.type);h={type:_.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:h,context:t,error:n,networkDetails:e,stats:s};if(i){const r=(null==e?void 0:e.url)||t.url;h.response=m({url:r,data:void 0},i)}this.hls.trigger(I.ERROR,h)}handlePlaylistLoaded(t,e,r,i,s,a){var n=this.hls,{type:o,level:l,id:h,groupId:d,deliveryDirectives:u}=i,c=oe(e,i),f=ne(i),g="number"==typeof i.level&&f===y?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));l=t.playlistParsingError;if(l)n.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:l,reason:l.message,response:e,context:i,level:g,parent:f,networkDetails:s,stats:r});else switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case ie:case se:n.trigger(I.LEVEL_LOADED,{details:t,level:g||0,id:h||0,stats:r,networkDetails:s,deliveryDirectives:u});break;case p:n.trigger(I.AUDIO_TRACK_LOADED,{details:t,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u});break;case v:n.trigger(I.SUBTITLE_TRACK_LOADED,{details:t,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u})}}else{const t=new Error("No Segments found in Playlist");void n.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:t,reason:t.message,response:e,context:i,level:g,parent:f,networkDetails:s,stats:r})}}}function he(t,e){let r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function de(t,e){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){P.debug("[texttrack-utils]: "+r);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,t.addCue(r)}catch(t){P.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+t)}}"disabled"===r&&(t.mode=r)}function ue(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function ce(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&0<e.cues.length){const s=function(r,i,s){const a=[],n=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;let i=0,s=r;for(;i<=s;){var a=Math.floor((s+i)/2);if(e<t[a].startTime)s=a-1;else{if(!(e>t[a].startTime&&i<r))return a;i=a+1}}return t[i].startTime-e<e-t[s].startTime?i:s}(r,i);if(-1<n)for(let t=n,e=r.length;t<e;t++){const n=r[t];if(n.startTime>=i&&n.endTime<=s)a.push(n);else if(n.startTime>s)return a}return a}(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}var fe="org.id3",ge="https://aomedia.org/emsg/ID3";function me(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const pe=(()=>{var t=me();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ve(t,e){return t.getTime()/1e3-e}class ye{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(ue(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){t=this.getID3Track(t.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return he(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(r,i){if(this.media){const{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:e}}=this["hls"];if(n||e){const o=i["samples"];this.id3Track||(this.id3Track=this.createTrack(this.media));var s=me();for(let t=0;t<o.length;t++){const i=o[t].type;if((i!==ge||n)&&e){var a=Tt(o[t].data);if(a){const n=o[t].pts;let e=n+o[t].duration;(e=e>pe?pe:e)-n<=0&&(e=n+.25);for(let t=0;t<a.length;t++){const o=a[t];if(!yt(o)){this.updateId3CueEnds(n,i);const r=new s(n,e,"");r.value=o,i&&(r.type=i),this.id3Track.addCue(r)}}}}}}}}updateId3CueEnds(e,r){var t,i=null==(t=this.id3Track)?void 0:t.cues;if(i)for(let t=i.length;t--;){var s=i[t];s.type===r&&s.startTime<e&&s.endTime===pe&&(s.endTime=e)}}onBufferFlushing(t,{startOffset:e,endOffset:r,type:i}){var{id3Track:s,hls:a}=this;if(a){const{enableEmsgMetadataCues:n,enableID3MetadataCues:o}=a["config"];s&&(n||o)&&ce(s,e,r,"audio"===i?t=>t.type===fe&&o:"video"===i?t=>t.type===ge&&n:t=>t.type===fe&&o||t.type===ge&&n)}}onLevelUpdated(e,{details:s}){if(this.media&&s.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:u,id3Track:c}=this,f=s["dateRanges"],g=Object.keys(f);if(c){const e=Object.keys(u).filter(t=>!g.includes(t));for(let t=e.length;t--;){const f=e[t];Object.keys(u[f].cues).forEach(t=>{c.removeCue(u[f].cues[t])}),delete u[f]}}const m=s.fragments[s.fragments.length-1];if(0!==g.length&&D(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var a,n=m.programDateTime/1e3-m.start,o=me();for(let t=0;t<g.length;t++){const s=g[t],c=f[s],m=u[s],D=(null==m?void 0:m.cues)||{};let r=(null==m?void 0:m.durationKnown)||!1;var l=ve(c.startDate,n);let i=pe;var h=c.endDate;if(h)i=ve(h,n),r=!0;else if(c.endOnNext&&!r){const e=g.reduce((t,e)=>{var r=f[e];return r.class===c.class&&r.id!==e&&r.startDate>c.startDate&&t.push(r),t},[]).sort((t,e)=>t.startDate.getTime()-e.startDate.getTime())[0];e&&(i=ve(e.startDate,n),r=!0)}var d=Object.keys(c.attr);for(let t=0;t<d.length;t++){const u=d[t];if("ID"!==(a=u)&&"CLASS"!==a&&"START-DATE"!==a&&"DURATION"!==a&&"END-DATE"!==a&&"END-ON-NEXT"!==a){let e=D[u];if(e)r&&!m.durationKnown&&(e.endTime=i);else{let t=c.attr[u];e=new o(l,i,""),"SCTE35-OUT"!==(a=u)&&"SCTE35-IN"!==a||(a=t,t=Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),e.value={key:u,data:t},e.type="com.apple.quicktime.HLS",e.id=s,this.id3Track.addCue(e),D[u]=e}}}u[s]={cues:D,dateRange:c,durationKnown:r}}}}}}class Te{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){var t=this["levelDetails"];if(null===t)return null;var{holdBack:t,partHoldBack:e,targetduration:r}=t,{liveSyncDuration:i,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,n=this.hls.userConfig;let o=a&&e||t;return(o=n.liveSyncDuration||n.liveSyncDurationCount||0===o?void 0!==i?i:s*r:o)+Math.min(+this.stallCount,r)}get liveSyncPosition(){var t,e=this.estimateLiveEdge(),r=this.targetLatency,i=this.levelDetails;return null===e||null===r||null===i?null:(t=i.edge,e=e-r-this.edgeStalled,r=t-i.totalduration,t=t-(this.config.lowLatencyMode&&i.partTarget||i.targetduration),Math.min(Math.max(r,e),t))}get drift(){var t=this["levelDetails"];return null===t?1:t.drift}get edgeStalled(){var t,e=this["levelDetails"];return null===e?0:(t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration),Math.max(e.age-t,0))}get forwardBufferLength(){var t,{media:e,levelDetails:r}=this;return e&&r?((t=e.buffered.length)?e.buffered.end(t-1):r.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(I.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){(this.levelDetails=e).advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){e.details===C.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(e=this.levelDetails))&&e.live&&P.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){const{media:t,levelDetails:e}=this;if(t&&e){this.currentTime=t.currentTime;const a=this.computeLatency();if(null!==a){this._latency=a;var{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(r&&1!==i){r=this.targetLatency;if(null!==r){var s=a-r,r=s<Math.min(this.maxLatency,r+e.targetduration);if(e.live&&r&&.05<s&&1<this.forwardBufferLength){const e=Math.min(2,Math.max(1,i)),a=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,a))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}}estimateLiveEdge(){var t=this["levelDetails"];return null===t?null:t.edge+t.age}computeLatency(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const Ee=["NONE","TYPE-0","TYPE-1",null];class Se{constructor(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}addDirectives(t){t=new self.URL(t);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}}class Le{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){t%=this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function be(r,i){var s=i.startPTS;if(D(s)){let t,e=0;(t=i.sn>r.sn?(e=s-r.start,r):(e=r.start-s,i)).duration!==e&&(t.duration=e)}else i.sn>r.sn?r.cc===i.cc&&r.minEndPTS?i.start=r.start+(r.minEndPTS-r.start):i.start=r.start+r.duration:i.start=Math.max(r.start-i.duration,0)}function Ae(t,e,r,i,s,a){i-r<=0&&(P.warn("Fragment should have a positive duration",e),i=r+e.duration,a=s+e.duration);let n=r,o=i;var l=e.startPTS,h=e.endPTS;if(D(l)){const t=Math.abs(l-r);D(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,n=Math.max(r,l),r=Math.min(r,l),s=Math.min(s,e.startDTS),o=Math.min(i,h),i=Math.max(i,h),a=Math.max(a,e.endDTS)}l=r-e.start,0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=n,e.startDTS=s,e.endPTS=i,e.minEndPTS=o,e.endDTS=a,h=e.sn;if(!t||h<t.startSN||h>t.endSN)return 0;let d;var r=h-t.startSN,u=t.fragments;for(u[r]=e,d=r;0<d;d--)be(u[d],u[d-1]);for(d=r;d<u.length-1;d++)be(u[d],u[d+1]);return t.fragmentHint&&be(u[u.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,l}function Re(t,r){let i=null;var e=t.fragments;for(let t=e.length-1;0<=t;t--){const r=e[t].initSegment;if(r){i=r;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let s,a=0;{var n,o,l=t,h=r;const m=h.skippedSegments,p=Math.max(l.startSN,h.startSN)-h.startSN,v=(l.fragmentHint?1:0)+(m?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,y=h.startSN-l.startSN,T=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,E=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;for(let e=p;e<=v;e++){const p=E[y+e];let t=T[e];m&&!t&&e<m&&(t=h.fragments[e]=p),p&&t&&(n=p,o=t,n.relurl&&(a=n.cc-o.cc),D(n.startPTS)&&D(n.endPTS)&&(o.start=o.startPTS=n.startPTS,o.startDTS=n.startDTS,o.maxStartPTS=n.maxStartPTS,o.endPTS=n.endPTS,o.endDTS=n.endDTS,o.minEndPTS=n.minEndPTS,o.duration=n.endPTS-n.startPTS,o.duration&&(s=o),r.PTSKnown=r.alignedSliding=!0),o.elementaryStreams=n.elementaryStreams,o.loader=n.loader,o.stats=n.stats,o.urlId=n.urlId,n.initSegment)&&(o.initSegment=n.initSegment,i=n.initSegment)}}if(i&&(r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments).forEach(t=>{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)}),r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(t=>!t),r.deltaUpdateFailed){P.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=r.skippedSegments;t--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(t,r,e){const i=k({},t);return e&&e.forEach(t=>{delete i[t]}),Object.keys(r).forEach(t=>{var e=new X(r[t].attr,i[t]);e.isValid?i[t]=e:P.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(r[t].attr)}"`)}),i}(t.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var d=r.fragments;if(a){P.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t<d.length;t++)d[t].cc+=a}r.skippedSegments&&(r.startCC=r.fragments[0].cc);var u=t.partList,c=r.partList;if(u&&c){let r=0;for(let t=0,e=u.length;t<=e;t++){var f=u[t],g=c[t+r];f&&g&&f.index===g.index&&f.fragment.sn===g.fragment.sn?(f=f,(g=g).elementaryStreams=f.elementaryStreams,g.stats=f.stats):r--}}s?Ae(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):De(t,r),d.length&&(r.totalduration=r.edge-d[0].start),r.driftStartTime=t.driftStartTime,r.driftStart=t.driftStart;l=r.advancedDateTime;if(r.advanced&&l){const t=r.edge;r.driftStart||(r.driftStartTime=l,r.driftStart=t),r.driftEndTime=l,r.driftEnd=t}else r.driftEndTime=t.driftEndTime,r.driftEnd=t.driftEnd,r.advancedDateTime=t.advancedDateTime}function De(t,e){var r=e.startSN+e.skippedSegments-t.startSN,t=t.fragments;r<0||r>=t.length||we(e,t[r].start)}function we(e,r){if(r){var i=e.fragments;for(let t=e.skippedSegments;t<i.length;t++)i[t].start+=r;e.fragmentHint&&(e.fragmentHint.start+=r)}}function ke(t,e,r){return null!=t&&t.details?Ie(null==(t=t.details)?void 0:t.partList,e,r):null}function Ie(e,r,i){if(e)for(let t=e.length;t--;){var s=e[t];if(s.index===i&&s.fragment.sn===r)return s}return null}function _e(t){switch(t.details){case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_TIMEOUT:case C.LEVEL_LOAD_TIMEOUT:case C.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ce(t,e){e=_e(e);return t.default[(e?"timeout":"error")+"Retry"]}function Pe(t,e){e="linear"===t.backoff?1:Math.pow(2,e);return Math.min(e*t.retryDelayMs,t.maxRetryDelayMs)}function xe(t){return m(m({},t),{errorRetry:null,timeoutRetry:null})}function Me(t,e,r,i){return t&&e<t.maxNumRetry&&(0===i&&!1===navigator.onLine||i&&(i<400||499<i)||r)}function Oe(t,e){let r=0,i=t.length-1,s,a;for(;r<=i;){var n=e(a=t[s=(r+i)/2|0]);if(0<n)r=1+s;else{if(!(n<0))return a;i=s-1}}return null}function Fe(t,e,r=0,i=0){let s=null;return t?s=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(s=e[0]),s&&0===Ne(r,i,s)||!(e=Oe(e,Ne.bind(null,r,i)))||e===t&&s?s:e}function Ne(t=0,e=0,r){return r.start<=t&&r.start+r.duration>t?0:(e=Math.min(e,r.duration+(r.deltaPTS||0)),r.start+r.duration-e<=t?1:r.start-e>t&&r.start?-1:0)}class Ue{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=P.log.bind(P,e+":"),this.warn=P.warn.bind(P,e+":"),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(i,s){var a=null==s?void 0:s.renditionReports;if(a){let r=-1;for(let e=0;e<a.length;e++){var n=a[e];let t;try{t=new self.URL(n.URI,s.url).href}catch(i){P.warn("Could not construct new URL for Rendition Report: "+i),t=n.URI||""}if(t===i){r=e;break}t===i.substring(0,t.length)&&(r=e)}if(-1!==r){const i=a[r],e=parseInt(i["LAST-MSN"])||(null==s?void 0:s.lastPartSn);let t=parseInt(i["LAST-PART"])||(null==s?void 0:s.lastPartIndex);if(this.hls.config.lowLatencyMode){const i=Math.min(s.age-s.partTarget,s.targetduration);0<=t&&i>s.partTarget&&(t+=1)}return new Se(e,0<=t?t:void 0,"")}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}playlistLoaded(s,a,n){const{details:o,stats:l}=a,h=self.performance.now(),t=l.loading.first?Math.max(0,h-l.loading.first):0;if(o.advancedDateTime=Date.now()-t,o.live||null!=n&&n.live){if(o.reloaded(n),n&&this.log(`live playlist ${s} `+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),n&&0<o.fragments.length&&Re(n,o),this.canLoad&&o.live){let e,r=void 0,i=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){const s=this.hls.config.lowLatencyMode,l=o.lastPartSn,h=o.endSN,c=o.lastPartIndex,f=l===h,g=s?0:c;-1!==c?(r=f?h+1:l,i=f?g:c+1):r=h+1;var d=o.age,u=d+o.ageHeader;let t=Math.min(u-o.partTarget,1.5*o.targetduration);if(0<t){if(n&&t>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${t} with playlist age: `+o.age),t=0;else{const s=Math.floor(t/o.targetduration);r+=s,void 0!==i&&(i+=Math.round(t%o.targetduration/o.partTarget)),this.log(`CDN Tune-in age: ${o.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${t} skip sn ${s} to part `+i)}o.tuneInGoal=t}if(e=this.getDeliveryDirectives(o,a.deliveryDirectives,r,i),s||!f)return void this.loadPlaylist(e)}else(o.canBlockReload||o.canSkipUntil)&&(e=this.getDeliveryDirectives(o,a.deliveryDirectives,r,i));u=this.hls.mainForwardBufferInfo,n=u?u.end-u.len:0,d=function(t,e){let r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){const t=1e3*i[i.length-1].duration;t<r&&(r=t)}}else r/=2;return Math.round(r)}(o,1e3*(o.edge-n)),a=(o.updated&&h>this.requestScheduled+d&&(this.requestScheduled=l.loading.start),void 0!==r&&o.canBlockReload?this.requestScheduled=l.loading.first+d-(1e3*o.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+d<h?this.requestScheduled=h:this.requestScheduled-h<=0&&(this.requestScheduled+=d),this.requestScheduled-h),a=Math.max(0,a);this.log(`reload live playlist ${s} in ${Math.round(a)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(e),a)}}else this.clearTimer()}getDeliveryDirectives(i,t,s,e){let r=function(){var{canSkipUntil:t,canSkipDateRanges:e,endSN:r}=i;return t&&(void 0!==s?s-r:0)<t?e?"v2":"YES":""}();return null!=t&&t.skip&&i.deltaUpdateFailed&&(s=t.msn,e=t.part,r=""),new Se(s,e,r)}checkRetry(t){var e=t.details,r=_e(t),i=t.errorAction,{action:s,retryCount:a=0,retryConfig:n}=i||{},s=!!i&&!!n&&(5===s||!i.resolved&&2===s);if(s){if(this.requestScheduled=-1,a>=n.maxNumRetry)return!1;if(r&&null!=(r=t.context)&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=Pe(n,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),t),this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,i.resolved=!0}return s}}let Be;class Ge extends Ue{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(I.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.ERROR,this.onError,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(I.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const o=[],l={};let h;e.levels.forEach(t=>{var e=t.attrs,{AUDIO:r,CODECS:e,"FRAME-RATE":i,"PATHWAY-ID":s,RESOLUTION:a,SUBTITLES:n}=(-1!==(null==(r=t.audioCodec)?void 0:r.indexOf("mp4a.40.34"))&&(Be=Be||/chrome|firefox/i.test(navigator.userAgent))&&(t.audioCodec=void 0),e),s=(s||".")+"-"+t.bitrate+`-${a}-${i}-`+e;(h=l[s])?h.addFallback(t):(h=new Le(t),l[s]=h,o.push(h)),$e(h,"audio",r),$e(h,"text",n)}),this.filterAndSortMediaOptions(o,e)}filterAndSortMediaOptions(t,r){let i=[],s=[],a=!1,n=!1,o=!1,l=t.filter(({audioCodec:t,videoCodec:e,width:r,height:i,unknownCodecs:s})=>(a=a||!(!r||!i),n=n||!!e,o=o||!!t,!(null!=s&&s.length)&&(!t||Yt(t,"audio"))&&(!e||Yt(e,"video"))));if(0===(l=(a||n)&&o?l.filter(({videoCodec:t,width:e,height:r})=>!!t||!(!e||!r)):l).length)Promise.resolve().then(()=>{var t;this.hls&&(t=new Error("no level with compatible codecs found in manifest"),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:t,reason:t.message}))});else{r.audioTracks&&Ke(i=r.audioTracks.filter(t=>!t.audioCodec||Yt(t.audioCodec,"audio"))),r.subtitles&&Ke(s=r.subtitles);var h=l.slice(0);l.sort((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):a&&t.height!==e.height?t.height-e.height:0);let e=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(let t=0;t<h.length;t++)if(h[t].pathwayId===l[0].pathwayId){e=h[t];break}this._levels=l;for(let t=0;t<l.length;t++)if(l[t]===e){this._firstLevel=t,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: `+e.bitrate);break}t=o&&!n,t={levels:l,audioTracks:i,subtitleTracks:s,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:n,altAudio:!t&&i.some(t=>!!t.url)};this.hls.trigger(I.MANIFEST_PARSED,t),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){const r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,a=e[t],n=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=a,r!==t||!a.details||!i||s!==n){this.log(`Switching to level ${t}${n?" with Pathway "+n:""} from level `+r+(s?" with Pathway "+s:""));e=k({},a,{level:t,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId}),t=(delete e._attrs,delete e._urlId,this.hls.trigger(I.LEVEL_SWITCHING,e),a.details);if(!t||t.live){const t=this.switchParams(a.uri,null==i?void 0:i.details);this.loadPlaylist(t)}}}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){var t;return void 0===this._startLevel?void 0!==(t=this.hls.config.startLevel)?t:this._firstLevel:this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===se&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(void 0!==e&&e.type===y){const t=this._levels[e.level];void 0!==t&&(t.loadError=0)}}onLevelLoaded(t,e){var{level:r,details:i}=e,s=this._levels[r];s?r===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(r,e,s.details)):null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0):(this.warn("Invalid level index "+r),null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0))}onAudioTrackSwitched(t,e){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let e=-1;for(let t=0;t<r.audioGroupIds.length;t++)if(r.audioGroupIds[t]===i){e=t;break}-1!==e&&e!==r.urlId&&(r.urlId=e,this.canLoad)&&this.startLoad()}}}loadPlaylist(e){super.loadPlaylist();var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var s=i.urlId;let t=i.uri;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${r}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${i.url.length} `+t),this.clearTimer(),this.hls.trigger(I.LEVEL_LOADING,{url:t,level:r,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(r,i){const s=(t,e)=>e!==i,t=this._levels.filter((t,e)=>e!==r||(1<t.url.length&&void 0!==i?(t.url=t.url.filter(s),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(s)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(s)),!(t.urlId=0)):(this.steering&&this.steering.removeLevel(t),!1)));this.hls.trigger(I.LEVELS_UPDATED,{levels:t})}onLevelsUpdated(t,{levels:e}){e.forEach((t,e)=>{t=t.details;null!=t&&t.fragments&&t.fragments.forEach(t=>{t.level=e})}),this._levels=e}}function $e(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function Ke(t){const r={};t.forEach(t=>{var e=t.groupId||"";t.id=r[e]=r[e]||0,r[e]++})}var He="NOT_LOADED",Ve="APPENDING",Ye="PARTIAL",We="OK";class je{constructor(t){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=t,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on(I.BUFFER_APPENDED,this.onBufferAppended,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var t=this["hls"];t.off(I.BUFFER_APPENDED,this.onBufferAppended,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){var r=this.activePartLists[t];if(r)for(let t=r.length;t--;){var i=r[t];if(!i)break;var s=i.end;if(i.start<=e&&null!==s&&e<=s)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,r){var i=this["fragments"],s=Object.keys(i);for(let t=s.length;t--;){var a=i[s[t]];if((null==a?void 0:a.body.type)===r&&a.buffered){const r=a.body;if(r.start<=e&&e<=r.end)return r}}return null}detectEvictedFragments(r,i,s,t){this.timeRanges&&(this.timeRanges[r]=i);const a=(null==t?void 0:t.fragment.sn)||-1;Object.keys(this.fragments).forEach(t=>{const e=this.fragments[t];!e||a>=e.body.sn||(e.buffered||e.loaded?(t=e.range[r])&&t.time.some(t=>{t=!this.isTimeBuffered(t.startPTS,t.endPTS,i);return t&&this.removeFragment(e.body),t}):e.body.type===s&&this.removeFragment(e.body))})}detectPartialFragments(t){const i=this.timeRanges,{frag:s,part:a}=t;if(i&&"initSegment"!==s.sn){const e=Xe(s),n=this.fragments[e];if(!(!n||n.buffered&&s.gap)){const o=!s.relurl;Object.keys(i).forEach(t=>{var e,r=s.elementaryStreams[t];r&&(e=i[t],r=o||!0===r.partial,n.range[t]=this.getBufferedTimes(s,a,r,e))}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=s.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),qe(n)||this.removeParts(s.sn-1,s.type)):this.removeFragment(n.body)}}}removeParts(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(t,e){var r=Xe(t);let i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap)&&(this.hasGaps=!0),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(t,e,r,i){var s={time:[],partial:r},a=t.start,n=t.end,o=t.minEndPTS||n,l=t.maxStartPTS||a;for(let t=0;t<i.length;t++){const e=i.start(t)-this.bufferPadding,r=i.end(t)+this.bufferPadding;if(l>=e&&o<=r){s.time.push({startPTS:Math.max(a,i.start(t)),endPTS:Math.min(n,i.end(t))});break}if(a<r&&n>e)s.partial=!0,s.time.push({startPTS:Math.max(a,i.start(t)),endPTS:Math.min(n,i.end(t))});else if(n<=e)break}return s}getPartialFragment(e){let r,i,s,a=null,n=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(t=>{t=l[t];t&&qe(t)&&(i=t.body.start-o,s=t.body.end+o,e>=i)&&e<=s&&(r=Math.min(e-i,s-e),n<=r)&&(a=t.body,n=r)}),a}isEndListAppended(t){t=this.endListFragments[t];return void 0!==t&&(t.buffered||qe(t))}getState(t){t=Xe(t),t=this.fragments[t];return t?t.buffered?qe(t)?Ye:We:Ve:He}isTimeBuffered(e,r,i){var s,a;for(let t=0;t<i.length;t++){if(s=i.start(t)-this.bufferPadding,a=i.end(t)+this.bufferPadding,s<=e&&r<=a)return!0;if(r<=s)return!1}return!1}onFragLoaded(t,e){var r,{frag:i,part:s}=e;"initSegment"===i.sn||i.bitrateTest||(r=Xe(i),this.fragments[r]={body:i,appendedPTS:null,loaded:s?null:e,buffered:!1,range:Object.create(null)})}onBufferAppended(t,e){const{frag:r,part:i,timeRanges:s}=e;if("initSegment"!==r.sn){const a=r.type;if(i){let t=this.activePartLists[a];t||(this.activePartLists[a]=t=[]),t.push(i)}this.timeRanges=s,Object.keys(s).forEach(t=>{var e=s[t];this.detectEvictedFragments(t,e,a,i)})}}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){t=Xe(t);return!!this.fragments[t]}hasParts(t){return!(null==(t=this.activePartLists[t])||!t.length)}removeFragmentsInRange(r,i,s,a,n){a&&!this.hasGaps||Object.keys(this.fragments).forEach(t=>{var e,t=this.fragments[t];!t||(e=t.body).type!==s||a&&!e.gap||e.start<i&&e.end>r&&(t.buffered||n)&&this.removeFragment(e)})}removeFragment(t){const e=Xe(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){const e=t.sn;this.activePartLists[t.type]=r.filter(t=>t.fragment.sn!==e)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function qe(t){var e;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(e=t.range.audio)?void 0:e.partial)||(null==(e=t.range.audiovideo)?void 0:e.partial))}function Xe(t){return`${t.type}_${t.level}_${t.urlId}_`+t.sn}const ze=Math.pow(2,17);class Qe{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const h=o.url;if(!h)return Promise.reject(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(h?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,d=r.fLoader,u=r.loader;return new Promise((a,s)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(t=>"GAP"===t[0]))return void s(Ze(o));o.gap=!1}const n=this.loader=o.loader=new(d||u)(r),t=Je(o),e=xe(r.fragLoadPolicy.default),i={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:ze};o.stats=n.stats,n.load(t,i,{onSuccess:(t,e,r,i)=>{this.resetLoader(o,n);let s=t.data;r.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:o,part:null,payload:s,networkDetails:i})},onError:(t,e,r,i)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:m({url:h,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:i}))},onAbort:(t,e,r)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:t}))},onProgress:(t,e,r,i)=>{l&&l({frag:o,part:null,payload:r,networkDetails:i})}})})}loadPart(l,h,d){this.abort();const e=this.config,r=e.fLoader,u=e.loader;return new Promise((s,a)=>{if(this.loader&&this.loader.destroy(),l.gap||h.gap)a(Ze(l,h));else{const n=this.loader=l.loader=new(r||u)(e),o=Je(l,h),t=xe(e.fragLoadPolicy.default),i={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ze};h.stats=n.stats,n.load(o,i,{onSuccess:(t,e,r,i)=>{this.resetLoader(l,n),this.updateStatsFromPart(l,h);t={frag:l,part:h,payload:t.data,networkDetails:i};d(t),s(t)},onError:(t,e,r,i)=>{this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:h,response:m({url:o.url,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:i}))},onAbort:(t,e,r)=>{l.stats.aborted=h.stats.aborted,this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:l,part:h,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:h,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:t}))}})}})}updateStatsFromPart(t,e){const r=t.stats,i=e.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(t.duration/e.duration),a=Math.min(Math.round(r.loaded/s),i),n=(i-a)*Math.round(r.loaded/a);r.total=r.loaded+n}else r.total=Math.max(r.loaded,r.total);const a=r.loading,n=i.loading;a.start?a.first+=n.first-n.start:(a.start=n.start,a.first=n.first),a.end=n.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Je(r,i=null){var s=i||r,i={frag:r,part:i,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},a=s.byteRangeStartOffset,s=s.byteRangeEndOffset;if(D(a)&&D(s)){let t=a,e=s;if("initSegment"===r.sn&&"AES-128"===(null==(r=r.decryptdata)?void 0:r.method)){const r=s-a;r%16&&(e=s+(16-r%16)),0!==a&&(i.resetIV=!0,t=a-16)}i.rangeStart=t,i.rangeEnd=e}return i}function Ze(t,e){var r=new Error(`GAP ${t.gap?"tag":"attribute"} found`),r={type:_.MEDIA_ERROR,details:C.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new T(r)}class T extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class tr{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const r in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[r].loader;if(e){if(t&&t!==e.context.frag.type)return;e.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=C.KEY_LOAD_ERROR,r,i,s){return new T({type:_.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:s,error:r,networkDetails:i})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){var{sn:r,cc:i}=t;for(let t=0;t<e.length;t++){const s=e[t];if(i<=s.cc&&("initSegment"===r||"initSegment"===s.sn||r<s.sn)){this.emeController.selectKeySystemFormat(s).then(t=>{s.setKeyFormat(t)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const 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,C.KEY_LOAD_ERROR,i))}var i,t=r.uri;if(!t)return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${t}"`)));let s=this.keyUriToKeyInfo[t];if(null!=(i=s)&&i.decryptdata.key)return r.key=s.decryptdata.key,Promise.resolve({frag:e,keyInfo:s});if(null!=(i=s)&&i.keyLoadPromise)switch(null==(i=s.mediaKeySessionContext)?void 0:i.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return s.keyLoadPromise.then(t=>(r.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:s}))}switch(s=this.keyUriToKeyInfo[t]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(s,e):this.loadKeyEME(s,e);case"AES-128":return this.loadKeyHTTP(s,e);default:return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(i,a){const l=this.config,h=new l.loader(l);return a.keyLoader=i.loader=h,i.keyLoadPromise=new Promise((n,o)=>{const s={keyInfo:i,frag:a,responseType:"arraybuffer",url:i.decryptdata.uri},t=l.keyLoadPolicy.default,e={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},r={onSuccess:(t,e,r,i)=>{var{frag:r,keyInfo:s,url:a}=r;if(!r.decryptdata||s!==this.keyUriToKeyInfo[a])return o(this.createKeyLoadError(r,C.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));s.decryptdata.key=r.decryptdata.key=new Uint8Array(t.data),r.keyLoader=null,s.loader=null,n({frag:r,keyInfo:s})},onError:(t,e,r,i)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key `+t.text),r,m({url:s.url,data:void 0},t)))},onTimeout:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};h.load(s,e,r)})}resetLoader(t){var{frag:t,keyInfo:e,url:r}=t,i=e.loader;t.keyLoader===i&&(t.keyLoader=null,e.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const er={length:0,start:()=>0,end:()=>0};class E{static isBuffered(t,e){try{if(t){var r=E.getBuffered(t);for(let t=0;t<r.length;t++)if(e>=r.start(t)&&e<=r.end(t))return!0}}catch(t){}return!1}static bufferInfo(e,r,i){try{if(e){var s=E.getBuffered(e),a=[];let t;for(t=0;t<s.length;t++)a.push({start:s.start(t),end:s.end(t)});return this.bufferedInfo(a,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}}static bufferedInfo(e,r,i){r=Math.max(0,r),e.sort(function(t,e){return t.start-e.start||e.end-t.end});let s=[];if(i)for(let t=0;t<e.length;t++){const a=s.length;if(a){const n=s[a-1].end;e[t].start-n<i?e[t].end>n&&(s[a-1].end=e[t].end):s.push(e[t])}else s.push(e[t])}else s=e;let a,n=0,o=r,l=r;for(let t=0;t<s.length;t++){var h=s[t].start,d=s[t].end;if(h<=r+i&&r<d)o=h,l=d,n=l-r;else if(r+i<h){a=h;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(t){try{return t.buffered}catch(t){return P.log("failed to get media.buffered",t),er}}}class rr{constructor(t,e,r,i=0,s=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=s,this.partial=a}}function ir(r,i){let s=null;for(let t=0,e=r.length;t<e;t++){var a=r[t];if(a&&a.cc===i){s=a;break}}return s}function sr(t,e){t&&(e=t.start+e,t.start=t.startPTS=e,t.endPTS=e+t.duration)}function ar(r,t){var i=t.fragments;for(let t=0,e=i.length;t<e;t++)sr(i[t],r);t.fragmentHint&&sr(t.fragmentHint,r),t.alignedSliding=!0}function nr(t,e){var r,i,s;t.hasProgramDateTime&&e.hasProgramDateTime&&(r=t.fragments,e=e.fragments,r.length)&&e.length&&(r=ir(r,(e=e[Math.round(e.length/2)-1]).cc)||r[Math.round(r.length/2)-1],i=e.programDateTime,s=r.programDateTime,null!==i)&&null!==s&&ar((s-i)/1e3-(r.start-e.start),t)}class or{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class lr{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class hr{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){var e=new DataView(t),r=new Uint32Array(4);for(let t=0;t<4;t++)r[t]=e.getUint32(4*t);return r}initTable(){const t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],s=r[1],a=r[2],n=r[3],o=this.invSubMix,l=o[0],h=o[1],d=o[2],u=o[3],c=new Uint32Array(256);let f=0,g=0,m=0;for(m=0;m<256;m++)c[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var p=(p=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&p^99;t[f]=p,e[p]=f;const o=c[f],m=c[o],y=c[m];var v=257*c[p]^16843008*p;i[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,a[f]=v<<8|v>>>24,n[f]=v,v=16843009*y^65537*m^257*o^16843008*f,l[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,d[p]=v<<8|v>>>24,u[p]=v,f?(f=o^c[c[c[y^o]]],g^=c[c[g]]):f=g=1}}expandKey(s){var a=this.uint8ArrayToUint32Array_(s);let t=!0,e=0;for(;e<a.length&&t;)t=a[e]===this.key[e],e++;if(!t){this.key=a;var n=this.keySize=a.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var o=this.ksRows=4*(n+6+1);let t,e;var l=this.keySchedule=new Uint32Array(o),h=this.invKeySchedule=new Uint32Array(o),d=this.sBox,u=this.rcon,s=this.invSubMix,c=s[0],f=s[1],g=s[2],m=s[3];let r,i;for(t=0;t<o;t++)t<n?r=l[t]=a[t]:(i=r,t%n==0?(i=d[(i=i<<8|i>>>24)>>>24]<<24|d[i>>>16&255]<<16|d[i>>>8&255]<<8|d[255&i],i^=u[t/n|0]<<24):6<n&&t%n==4&&(i=d[i>>>24]<<24|d[i>>>16&255]<<16|d[i>>>8&255]<<8|d[255&i]),l[t]=r=(l[t-n]^i)>>>0);for(e=0;e<o;e++)t=o-e,i=3&e?l[t]:l[t-4],h[e]=e<4||t<=4?i:c[d[i>>>24]]^f[d[i>>>16&255]]^g[d[i>>>8&255]]^m[d[255&i]],h[e]=h[e]>>>0}}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,r){var i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,n=this.invSubMix,o=n[0],l=n[1],h=n[2],d=n[3],n=this.uint8ArrayToUint32Array_(r);let u=n[0],c=n[1],f=n[2],g=n[3];var m=new Int32Array(t),p=new Int32Array(m.length);let v,y,T,E,S,L,b,A,R,D,w,k,I,_;for(var C=this.networkToHostOrderSwap;e<m.length;){for(R=C(m[e]),D=C(m[e+1]),w=C(m[e+2]),k=C(m[e+3]),S=R^s[0],L=k^s[1],b=w^s[2],A=D^s[3],I=4,_=1;_<i;_++)v=o[S>>>24]^l[L>>16&255]^h[b>>8&255]^d[255&A]^s[I],y=o[L>>>24]^l[b>>16&255]^h[A>>8&255]^d[255&S]^s[I+1],T=o[b>>>24]^l[A>>16&255]^h[S>>8&255]^d[255&L]^s[I+2],E=o[A>>>24]^l[S>>16&255]^h[L>>8&255]^d[255&b]^s[I+3],S=v,L=y,b=T,A=E,I+=4;v=a[S>>>24]<<24^a[L>>16&255]<<16^a[b>>8&255]<<8^a[255&A]^s[I],y=a[L>>>24]<<24^a[b>>16&255]<<16^a[A>>8&255]<<8^a[255&S]^s[I+1],T=a[b>>>24]<<24^a[A>>16&255]<<16^a[S>>8&255]<<8^a[255&L]^s[I+2],E=a[A>>>24]<<24^a[S>>16&255]<<16^a[L>>8&255]<<8^a[255&b]^s[I+3],p[e]=C(v^u),p[e+1]=C(E^c),p[e+2]=C(T^f),p[e+3]=C(y^g),u=R,c=D,f=w,g=k,e+=4}return p.buffer}}class dr{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){var t,e,{currentResult:r,remainderData:i}=this;return!r||i?(this.reset(),null):(i=new Uint8Array(r),this.reset(),this.removePKCS7Padding?(t=(r=i).byteLength,(e=t&&new DataView(r.buffer).getUint8(t-1))?ft(r,0,t-e):r):i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(i,s,a){return this.useSoftware?new Promise((t,e)=>{this.softwareDecrypt(new Uint8Array(i),s,a);var r=this.flush();r?t(r.buffer):e(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(i),s,a)}softwareDecrypt(t,e,r){var{currentIV:i,currentResult:s,remainderData:a}=this,a=(this.logOnce("JS AES decrypt"),a&&(t=Pt(a,t),this.remainderData=null),this.getValidChunk(t));if(!a.length)return null;i&&(r=i);let n=this.softwareDecrypter;(n=n||(this.softwareDecrypter=new hr)).expandKey(e);t=s;return this.currentResult=n.decrypt(a.buffer,0,r),this.currentIV=ft(a,-16).buffer,t||null}webCryptoDecrypt(e,r,i){const s=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new lr(s,r)),this.fastAesKey.expandKey().then(t=>s?(this.logOnce("WebCrypto AES decrypt"),new or(s,new Uint8Array(i)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(t=>(P.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${t.name}: `+t.message),this.onWebCryptoError(e,r,i)))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);t=this.flush();if(t)return t.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;var r=t.length-t.length%16;return r!==t.length&&(e=ft(t,0,r),this.remainderData=ft(t,r)),e}logOnce(t){this.logEnabled&&(P.log("[decrypter]: "+t),this.logEnabled=!1)}}const n="STOPPED",d="IDLE",ur="KEY_LOADING",cr="FRAG_LOADING",fr="FRAG_LOADING_WAITING_RETRY",gr="WAITING_TRACK",O="PARSING",mr="PARSED",pr="ENDED",vr="ERROR",yr="WAITING_INIT_PTS",Tr="WAITING_LEVEL";class Er extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(t,e,r,i,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=n,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=s,this.logPrefix=i,this.log=P.log.bind(P,i+":"),this.warn=P.warn.bind(P,i+":"),this.hls=t,this.fragmentLoader=new Qe(t.config),this.keyLoader=r,this.fragmentTracker=e,this.config=t.config,this.decrypter=new dr(t.config),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=n}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;var r=e.partList;if(null!=r&&r.length){const t=r[r.length-1];return E.isBuffered(this.media,t.start+t.duration/2)}t=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(t)}getLevelDetails(){var t;return!this.levels||null===this.levelLastLoaded||null==(t=this.levels[this.levelLastLoaded])?void 0:t.details}onMediaAttached(t,e){e=this.media=this.mediaBuffer=e.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended),e=this.config;this.levels&&e.autoStartLoad&&this.state===n&&this.startLoad(e.startPosition)}onMediaDetaching(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:r,mediaBuffer:i,state:s}=this,a=r?r.currentTime:0,n=E.bufferInfo(i||r,a,t.maxBufferHole);if(this.log(`media seeking to ${D(a)?a.toFixed(3):a}, state: `+s),this.state===pr)this.resetLoadingState();else if(e){const r=t.maxFragLookUpTolerance,i=e.start-r,s=e.start+e.duration+r;if(!n.len||s<n.start||i>n.end){const t=a>s;(a<i||t)&&(t&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||n.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=n,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,r){this._loadFragForPlayback(t,e,r)}_loadFragForPlayback(r,t,e){this._doFragLoad(r,t,e,t=>{this.fragContextChanged(r)?(this.warn(`Fragment ${r.sn}${t.part?" p: "+t.part.index:""} of level ${r.level} was dropped during download.`),this.fragmentTracker.removeFragment(r)):(r.stats.chunkCount++,this._handleFragmentLoadProgress(t))}).then(t=>{var e;t&&(e=this.state,this.fragContextChanged(r)?e!==cr&&(this.fragCurrent||e!==O)||(this.fragmentTracker.removeFragment(r),this.state=d):("payload"in t&&(this.log(`Loaded fragment ${r.sn} of level `+r.level),this.hls.trigger(I.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t)))}).catch(t=>{this.state!==n&&this.state!==vr&&(this.warn(t),this.resetFragmentLoading(r))})}clearTrackerIfNeeded(t){var e,r=this["fragmentTracker"];if(r.getState(t)===Ve){const e=t.type,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=Math.max(t.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(s)&&r.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===Ye)&&r.removeFragment(t)}checkLiveUpdate(t){var e;t.updated&&!t.live&&(e=t.fragments[t.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})),t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,r=null){t-e&&(t={startOffset:t,endOffset:e,type:r},this.hls.trigger(I.BUFFER_FLUSHING,t))}_loadInitSegment(a,s){this._doFragLoad(a,s).then(t=>{if(t&&!this.fragContextChanged(a)&&this.levels)return t;throw new Error("init load aborted")}).then(r=>{const i=this["hls"],t=r["payload"],e=a.decryptdata;if(t&&0<t.byteLength&&e&&e.key&&e.iv&&"AES-128"===e.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(t),e.key.buffer,e.iv.buffer).catch(t=>{throw i.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:a}),t}).then(t=>{var e=self.performance.now();return i.trigger(I.FRAG_DECRYPTED,{frag:a,payload:t,stats:{tstart:s,tdecrypt:e}}),r.payload=t,r})}return r}).then(t=>{var{fragCurrent:e,hls:r,levels:i}=this;if(!i)throw new Error("init load aborted, missing levels");i=a.stats;this.state=d,s.fragmentError=0,a.data=new Uint8Array(t.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),t.frag===e&&r.trigger(I.FRAG_BUFFERED,{stats:i,frag:e,part:null,id:a.type}),this.tick()}).catch(t=>{this.state!==n&&this.state!==vr&&(this.warn(t),this.resetFragmentLoading(a))})}fragContextChanged(t){var e=this["fragCurrent"];return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var r=this.mediaBuffer||this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===y?"level":"track"} ${t.level} (frag:[${(null!=(e=t.startPTS)?e:NaN).toFixed(3)}-${(null!=(e=t.endPTS)?e:NaN).toFixed(3)}] > buffer:${r?function(e){let r="";var i=e.length;for(let t=0;t<i;t++)r+=`[${e.start(t).toFixed(3)}-${e.end(t).toFixed(3)}]`;return r}(E.getBuffered(r)):"(detached)"})`),this.state=d,r&&(!this.loadedmetadata&&t.type==y&&r.buffered.length&&(null==(e=this.fragCurrent)?void 0:e.sn)===(null==(t=this.fragPrevious)?void 0:t.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){var e,r,i=this["transmuxer"];i&&({frag:t,part:e,partsLoaded:r}=t,r=!r||0===r.length||r.some(t=>!t),t=new rr(t.level,t.sn,t.stats.chunkCount+1,0,e?e.index:-1,!r),i.flush(t))}_handleFragmentLoadProgress(t){}_doFragLoad(e,r,t=null,i){var s,a,n=null==r?void 0:r.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key?!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+e.level),this.state=ur,this.fragCurrent=e,o=this.keyLoader.load(e).then(t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(I.KEY_LOADED,t),this.state===ur&&(this.state=d),t}),this.hls.trigger(I.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),t=Math.max(e.start,t||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const s=n.partList;if(s&&i){t>e.end&&n.fragmentHint&&(e=n.fragmentHint);const l=this.getNextPart(s,e,t);if(-1<l){const h=s[l];return this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${l}-${s.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: `+parseFloat(t.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=cr,a=o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.doFragPartsLoad(e,h,r,i)).catch(t=>this.handleFragLoadError(t)):this.doFragPartsLoad(e,h,r,i).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(I.FRAG_LOADING,{frag:e,part:h,targetBufferTime:t}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):a}if(!e.url||this.loadedEndOfParts(s,t))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: `+parseFloat(t.toFixed(3))),D(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=cr;const l=this.config.progressive;let h;return h=l&&o?o.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i)).catch(t=>this.handleFragLoadError(t)):Promise.all([this.fragmentLoader.load(e,l?i:void 0),o]).then(([t])=>(!l&&t&&i&&i(t),t)).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(I.FRAG_LOADING,{frag:e,targetBufferTime:t}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(o,r,l,h){return new Promise((i,t)=>{var e;const s=[],a=null==(e=l.details)?void 0:e.partList,n=r=>{this.fragmentLoader.loadPart(o,r,h).then(t=>{var e=(s[r.index]=t).part,t=(this.hls.trigger(I.FRAG_LOADED,t),ke(l,o.sn,r.index+1)||Ie(a,o.sn,r.index+1));if(!t)return i({frag:o,part:e,partsLoaded:s});n(t)}).catch(t)};n(r)})}handleFragLoadError(t){var e;return"data"in t?(e=t.data,t.data&&e.details===C.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(I.ERROR,e)):this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0}),null}_handleTransmuxerFlush(t){var e,r,i,s=this.getCurrentContext(t);s&&this.state===O?({frag:s,part:e,level:r}=s,i=self.performance.now(),s.stats.parsing.end=i,e&&(e.stats.parsing.end=i),this.updateLevelTiming(s,e,r,t.partial)):this.fragCurrent||this.state===n||this.state===vr||(this.state=d)}getCurrentContext(t){var{levels:e,fragCurrent:r}=this,{level:t,sn:i,part:s}=t;if(null==e||!e[t])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${t}. The current chunk will not be buffered.`),null;const a=e[t],n=-1<s?ke(a,i,s):null,o=n?n.fragment:null!=a&&a.details?(e=a.details).fragments[i-e.startSN]||((t=e.fragmentHint)&&t.sn===i?t:i<e.startSN&&r&&r.sn===i?r:null):null;return o?(r&&r!==o&&(o.stats=r.stats),{frag:o,part:n,level:a}):null}bufferFragmentData(e,r,i,s,a){if(e&&this.state===O){var{data1:n,data2:o}=e;let t=n;null!=(n=t=n&&o?Pt(n,o):t)&&n.length&&(o={type:e.type,frag:r,part:i,chunkMeta:s,parent:r.type,data:t},this.hls.trigger(I.BUFFER_APPENDING,o),e.dropped)&&e.independent&&!i&&!a&&this.flushBufferGap(r)}}flushBufferGap(t){var e,r,i=this.media;i&&(E.isBuffered(i,i.currentTime)?(e=i.currentTime,i=E.bufferInfo(i,e,0),r=t.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),i=Math.max(Math.min(t.start-r,i.end-r),e+r),t.start-i>r&&this.flushMainBuffer(i,t.start)):this.flushMainBuffer(0,t.start))}getFwdBufferInfo(t,e){var r=this.getLoadPosition();return D(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){var i=this["config"]["maxBufferHole"],s=E.bufferInfo(t,e,i);if(0===s.len&&void 0!==s.nextStart){r=this.fragmentTracker.getBufferedFrag(e,r);if(r&&s.nextStart<r.end)return E.bufferInfo(t,e,Math.max(s.nextStart,i))}return s}getMaxBufferLength(t){var e=this["config"],t=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength;return Math.min(t,e.maxMaxBufferLength)}reduceMaxBufferLength(t){var e=this.config,t=t||e.maxBufferLength;return e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0)}getAppendedFrag(t,e=0){t=this.fragmentTracker.getAppendedFrag(t,y);return t&&"fragment"in t?t.fragment:t}getNextFragment(t,e){const r=e.fragments,i=r.length;if(!i)return null;const s=this["config"],a=r[0].start;let n;if(e.live){const a=s.initialLiveManifestSize;if(i<a)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${a})`),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(e,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:t)}else t<=a&&(n=r[0]);if(!n){const r=s.lowLatencyMode?e.partEnd:e.fragmentEnd;n=this.getFragmentAtPosition(t,r,e)}return this.mapToInitFragWhenRequired(n)}isLoopLoading(t,e){var r=this.fragmentTracker.getState(t);return(r===We||r===Ye&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,r,i,s){var a=t.gap,e=this.getNextFragment(this.nextLoadPosition,e);if(null===e)return e;if(t=e,a&&t&&!t.gap&&r.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,r.nextStart,i);if(null!==e&&r.len+e.len>=s)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: `+t.sn),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(r,i,s){let a=-1,n=!1,o=!0;for(let t=0,e=r.length;t<e;t++){var l=r[t];if(o=o&&!l.independent,-1<a&&s<l.start)break;var h=l.loaded;h?a=-1:(n||l.independent||o)&&l.fragment===i&&(a=t),n=h}return a}loadedEndOfParts(t,e){t=t[t.length-1];return t&&e>t.start&&t.loaded}getInitialLiveFragment(t,e){var r,i,s=this.fragPrevious;let a=null;if(s)t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+s.programDateTime),a=function(e,r,i){if(null!==r&&Array.isArray(e)&&e.length&&D(r)&&!(r<(e[0].programDateTime||0)||r>=(e[e.length-1].endProgramDateTime||0))){i=i||0;for(let t=0;t<e.length;++t){var s=e[t];if(a=r,n=i,o=s,n=1e3*Math.min(i,o.duration+(o.deltaPTS||0)),(o.endProgramDateTime||0)-n>a)return s}var a,n,o}return null}(e,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),a||((r=s.sn+1)>=t.startSN&&r<=t.endSN&&(r=e[r-t.startSN],s.cc===r.cc)&&(a=r,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn)),a)||(a=(r=e,i=s.cc,Oe(r,t=>t.cc<i?1:t.cc>i?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn);else{const e=this.hls.liveSyncPosition;null!==e&&(a=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a}getFragmentAtPosition(t,e,r){var i=this["config"];let s=this["fragPrevious"],{fragments:a,endSN:n}=r;var o=r["fragmentHint"],l=i.maxFragLookUpTolerance,h=r.partList,i=!!(i.lowLatencyMode&&null!=h&&h.length&&o);let d;if(i&&o&&!this.bitrateTest&&(a=a.concat(o),n=o.sn),d=t<e?Fe(s,a,t,e-l<t?0:l):a[a.length-1]){const t=d.sn-r.startSN,e=this.fragmentTracker.getState(d);if((s=e===We||e===Ye&&d.gap?d:s)&&d.sn===s.sn&&(!i||h[0].fragment.sn>d.sn)&&s&&d.level===s.level){const e=a[1+t];d=d.sn<n&&this.fragmentTracker.getState(e)!==We?e:null}}return d}synchronizeToLiveEdge(t){var{config:e,media:r}=this;if(r){const i=this.hls.liveSyncPosition,s=r.currentTime,a=t.fragments[0].start,n=t.edge,o=s>=a-e.maxFragLookUpTolerance&&s<=n;if(null!==i&&r.duration>i&&(s<i||!o)){const a=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&r.readyState<4||s<n-a)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState)&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : `+i.toFixed(3)),r.currentTime=i)}}}alignPlaylists(t,e){const{levels:r,levelLastLoaded:i,fragPrevious:s}=this,a=null!==i?r[i]:null,n=t.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,l=!e,h=t.alignedSliding&&D(o);if(l||!h&&!o){var d,l=s,h=a,u=t;if(h){var c=l,f=(l=u,h);if(f.details&&(l.endCC>l.startCC||c&&c.cc<l.startCC)){f=f.details.fragments;const c=(d=l.fragments).length&&f.length?(f=ir(f,d[0].cc))&&f.startPTS?f:void P.log("No frag in previous level to align on"):void P.log("No fragments to align");c&&D(c.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+l.url),ar(c.start,l))}!u.alignedSliding&&h.details&&(c=u,(d=h.details).fragments.length)&&c.hasProgramDateTime&&d.hasProgramDateTime&&(f=d.fragments[0].programDateTime,d=((l=c.fragments[0].programDateTime)-f)/1e3+d.fragments[0].start)&&D(d)&&(P.log(`Adjusting PTS using programDateTime delta ${l-f}ms, sliding:${d.toFixed(3)} ${c.url} `),ar(d,c)),u.alignedSliding||!h.details||u.skippedSegments||De(h.details,u)}const r=t.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${s?s.sn:"na"} fragments: `+n),r}return o}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let r=this.startPosition;var i,s;-1!==(r=r<e?-1:r)&&-1!==this.lastCurrentTime||(null!==(s=((i=null!==this.startTimeOffset)?this:t).startTimeOffset)&&D(s)?(r=e+s,s<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log(`Start time offset ${s} found in ${i?"multivariant":"media"} playlist, adjust startPosition to `+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r),this.nextLoadPosition=r}getLoadPosition(){var t=this["media"];let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===fr)||(this.state=d)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}var r=e.frag;if(r&&r.type===t&&this.levels)if(this.fragContextChanged(r))this.warn(`Frag load error must match current frag to retry ${r.url} > `+(null==(i=this.fragCurrent)?void 0:i.url));else{var i=e.details===C.FRAG_GAP,s=(i&&this.fragmentTracker.fragBuffered(r,!0),e.errorAction),{action:a,retryCount:n=0,retryConfig:o}=s||{};if(s&&5===a&&o){this.resetStartWhenNotLoaded(null!=(a=this.levelLastLoaded)?a:r.level);const i=Pe(o,n);this.warn(`Fragment ${r.sn} of ${t} ${r.level} errored with ${e.details}, retrying loading ${n+1}/${o.maxNumRetry} in ${i}ms`),s.resolved=!0,this.retryDate=self.performance.now()+i,this.state=fr}else o&&s?(this.resetFragmentErrors(t),n<o.maxNumRetry?i||(s.resolved=!0):P.warn(e.details+` reached or exceeded max retry (${n})`)):2===(null==s?void 0:s.action)?this.state=Tr:this.state=vr;this.tickImmediate()}}reduceLengthAndFlushBuffer(t){var e,r,i;return(this.state===O||this.state===mr)&&(e=t.parent,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,e))&&.5<i.len)&&this.reduceMaxBufferLength(i.len),(i=!r)&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),i)}resetFragmentErrors(t){t===L&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==n&&(this.state=d)}afterBufferFlushed(t,e,r){t&&(t=E.getBuffered(t),this.fragmentTracker.detectEvictedFragments(e,t,r),this.state===pr)&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=d}resetStartWhenNotLoaded(t){this.loadedmetadata||(this.startFragRequested=!1,null!=(t=this.levels?this.levels[t].details:null)&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition)}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(s,t,a,n){var e;const o=a.details;if(o){if(Object.keys(s.elementaryStreams).reduce((t,e)=>{var r,i=s.elementaryStreams[e];return i?(r=i.endPTS-i.startPTS)<=0?(this.warn(`Could not parse fragment ${s.sn} ${e} duration reliably (${r})`),t||!1):(r=n?0:Ae(o,s,i.startPTS,i.endPTS,i.startDTS,i.endDTS),this.hls.trigger(I.LEVEL_PTS_UPDATED,{details:o,level:a,drift:r,type:e,frag:s,start:i.startPTS,end:i.endPTS}),!0):t},!1))a.fragmentError=0;else if(null===(null==(e=this.transmuxer)?void 0:e.error)){const t=new Error(`Found no media in fragment ${s.sn} of level ${s.level} resetting transmuxer to fallback to playlist timing`);if(0===a.fragmentError&&(a.fragmentError++,s.gap=!0,this.fragmentTracker.removeFragment(s),this.fragmentTracker.fragBuffered(s,!0)),this.warn(t.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:s,reason:`Found no media in msn ${s.sn} of level "${a.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=mr,this.hls.trigger(I.FRAG_PARSED,{frag:s,part:t})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(t=this.levelLastLoaded)?t:null==(t=this.fragCurrent)?void 0:t.level)?t:0),this.resetLoadingState())}set state(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}get state(){return this._state}}function Sr(){return self.SourceBuffer||self.WebKitSourceBuffer}function F(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Lr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,r){}demux(t,e){this.cachedData&&(t=Pt(this.cachedData,t),this.cachedData=null);let r,i=pt(t,0),s=i?i.length:0;var a,n,o=this._audioTrack,l=this._id3Track,h=i?(t=>{var e=Tt(t);for(let t=0;t<e.length;t++){var r=e[t];if(yt(r)){if(8===r.data.byteLength){var r=new Uint8Array(r.data),i=1&r[3];let t=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];return t/=45,i&&(t+=47721858.84),Math.round(t)}return}}})(i):void 0,d=t.length;for((null===this.basePTS||0===this.frameIndex&&D(h))&&(this.basePTS=br(h,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&0<i.length&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:fe,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(t,s)){const e=this.appendFrame(o,t,s);e?(this.frameIndex++,this.lastPTS=e.sample.pts,s+=e.length,r=s):s=d}else a=t,n=s,gt(a,n)&&vt(a,n+6)+10<=a.length-n?(i=pt(t,s),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:fe,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===d&&r!==d){const e=ft(t,r);this.cachedData?this.cachedData=Pt(this.cachedData,e):this.cachedData=e}}return{audioTrack:o,videoTrack:F(),id3Track:l,textTrack:F()}}demuxSampleAes(t,e,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:F(),id3Track:this._id3Track,textTrack:F()}}destroy(){}}const br=(t,e,r)=>D(t)?90*t:9e4*e+(r?9e4*r.baseTime/r.timescale:0);function Ar(t,e){return 255===t[e]&&240==(246&t[e+1])}function Rr(t,e){return 1&t[e+1]?7:9}function Dr(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function wr(t,e){return e+1<t.length&&Ar(t,e)}function kr(t,e,r,i,s){t.samplerate||(e=function(t,e,r,i){let s,a,n,o;var l=navigator.userAgent.toLowerCase(),h=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],u=(s=1+((192&e[r+2])>>>6),(60&e[r+2])>>>2);if(!(d.length-1<u))return n=(1&e[r+2])<<2,n|=(192&e[r+3])>>>6,P.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:`+u),a=/firefox/i.test(l)?6<=u?(s=5,o=new Array(4),u-3):(s=2,o=new Array(2),u):-1!==l.indexOf("android")?(s=2,o=new Array(2),u):(s=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=u?u-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=u&&1==n||/vivaldi/i.test(l))||!i&&1==n)&&(s=2,o=new Array(2)),u)),o[0]=s<<3,o[0]|=(14&u)>>1,o[1]|=(1&u)<<7,o[1]|=n<<3,5===s&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[u],channelCount:n,codec:"mp4a.40."+s,manifestCodec:h};t.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+u})}(e,r,i,s))&&(t.config=e.config,t.samplerate=e.samplerate,t.channelCount=e.channelCount,t.codec=e.codec,t.manifestCodec=e.manifestCodec,P.log(`parsed codec:${t.codec}, rate:${e.samplerate}, channels:`+e.channelCount))}function Ir(t){return 9216e4/t}function _r(t,r,i,e,s){var a=e+s*Ir(t.samplerate),n=function(){var t=Rr(r,i);if(i+t<=r.length){var e=Dr(r,i)-t;if(0<e)return{headerLength:t,frameLength:e}}}();let o;if(n){const{frameLength:e,headerLength:s}=n,l=s+e,h=Math.max(0,i+l-r.length);h?(o=new Uint8Array(l-s)).set(r.subarray(i+s,r.length),0):o=r.subarray(i+s,i+l);n={unit:o,pts:a};return h||t.samples.push(n),{sample:n,length:l,missing:h}}const l=r.length-i;return(o=new Uint8Array(l)).set(r.subarray(i,r.length),0),{sample:{unit:o,pts:a},length:l,missing:-1}}const Cr=/\/emsg[-/]ID3/i;let Pr=null;const xr=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Mr=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Or=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Fr=[0,1,1,4];function Nr(t,e,r,i,s){var a;return!(r+24>e.length)&&(a=Ur(e,r))&&r+a.frameLength<=e.length?(i=i+s*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:e.subarray(r,r+a.frameLength),pts:i,dts:i},t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(s),{sample:s,length:a.frameLength,missing:0}):void 0}function Ur(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,s=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!=r&&0!=s&&15!=s&&3!=a){var n=t[e+2]>>1&1,o=t[e+3]>>6,s=1e3*xr[14*(3==r?3-i:3==i?3:4)+s-1],a=Mr[3*(3==r?0:2==r?1:2)+a],l=3==o?1:2,r=Or[r][i],h=Fr[i],d=8*r*h,r=Math.floor(r*s/a+n)*h;if(null===Pr){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pr=t?parseInt(t[1]):0}return Pr&&Pr<=87&&2==i&&224e3<=s&&0==o&&(t[e+3]=128|t[e+3]),{sampleRate:a,channelCount:l,frameLength:r,samplesPerFrame:d}}}function Br(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Gr(t,e){return e+1<t.length&&Br(t,e)}class $r{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),e=Math.min(4,e);if(0===e)throw new Error("no bytes available");i.set(t.subarray(r,r+e)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}skipBits(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t||(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord()),this.word<<=t,this.bitsAvailable-=t}readBits(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(32<t&&P.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,0<this.bitsAvailable)this.word<<=e;else{if(!(0<this.bytesAvailable))throw new Error("no bits available");this.loadWord()}return 0<(e=t-e)&&this.bitsAvailable?r<<e|this.readBits(e):r}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var t=this.skipLZ();return this.readBits(t+1)-1}readEG(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let r,i=8,s=8;for(let t=0;t<e;t++)0!==s&&(r=this.readEG(),s=(i+r+256)%256),i=0===s?i:s}readSPS(){let t,e,r,i=0,s=0,a=0,n=0;var o=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),u=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this),m=(o(),o());if(l(5),u(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const t=h();if(3===t&&u(1),f(),f(),u(1),d())for(e=3!==t?8:12,r=0;r<e;r++)d()&&g(r<6?16:64)}f();m=h();if(0===m)h();else if(1===m)for(u(1),c(),c(),t=h(),r=0;r<t;r++)c();f(),u(1);m=h(),f=h(),l=l(1);0===l&&u(1),u(1),d()&&(i=h(),s=h(),a=h(),n=h());let p=[1,1];if(d()&&d())switch(o()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:p=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(m+1)-2*i-2*s),height:(2-l)*(f+1)*16-(l?2:4)*(a+n),pixelRatio:p}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Kr{constructor(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new dr(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,r,i){const s=e[r].unit;var t;s.length<=16||(t=(t=s.subarray(16,s.length-s.length%16)).buffer.slice(t.byteOffset,t.byteOffset+t.length),this.decryptBuffer(t).then(t=>{t=new Uint8Array(t);s.set(t,16),this.decrypter.isSync()||this.decryptAacSamples(e,r+1,i)}))}decryptAacSamples(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}}getAvcEncryptedData(e){var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){var r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,r,i,s,a){const n=Ot(a.data),t=this.getAvcEncryptedData(n);this.decryptBuffer(t.buffer).then(t=>{a.data=this.getAvcDecryptedUnit(n,t),this.decrypter.isSync()||this.decryptAvcSamples(e,r,i+1,s)})}decryptAvcSamples(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var s=t[e].units;!(r>=s.length);r++){var a=s[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,i,a),this.decrypter.isSync())))return}}}}class Hr{constructor(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}static probe(t){t=Hr.syncOffset(t);return 0<t&&P.warn("MPEG2-TS detected but first sync word found @ offset "+t),-1!==t}static syncOffset(s){var a=s.length;let n=Math.min(940,s.length-188)+1,o=0;for(;o<n;){let e=!1,r=-1,i=0;for(let t=o;t<a;t+=188){if(71!==s[t]){if(i)return-1;break}if(i++,-1===r&&0!==(r=t)&&(n=Math.min(r+18612,s.length-188)+1),(e=e||0===Yr(s,t))&&1<i&&(0===r&&2<i||t+188>n))return r}o++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Dt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Hr.createTrack("video"),this._audioTrack=Hr.createTrack("audio",i),this._id3Track=Hr.createTrack("id3"),this._txtTrack=Hr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){var{_audioTrack:t,_avcTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(r,t,i=!1,s=!1){let a;i||(this.sampleAes=null);var n=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let d=n.pid,u=n.pesData,c=o.pid,f=l.pid,g=o.pesData,m=l.pesData,p=null,v=this.pmtParsed,y=this._pmtId,T=r.length;if(this.remainderData&&(T=(r=Pt(this.remainderData,r)).length,this.remainderData=null),T<188&&!s)return this.remainderData=r,{audioTrack:o,videoTrack:n,id3Track:l,textTrack:h};var E,S,L=Math.max(0,Hr.syncOffset(r));(T-=(T-L)%188)<r.byteLength&&!s&&(this.remainderData=new Uint8Array(r.buffer,T,r.buffer.byteLength-T));let b=0;for(let e=L;e<T;e+=188)if(71===r[e]){const s=!!(64&r[e+1]),I=Yr(r,e);let t;if(1<(48&r[e+3])>>4){if((t=e+5+r[e+4])===e+188)continue}else t=e+4;switch(I){case d:s&&(u&&(a=Wr(u))&&this.parseAVCPES(n,h,a,!1),u={data:[],size:0}),u&&(u.data.push(r.subarray(t,e+188)),u.size+=e+188-t);break;case c:if(s){if(g&&(a=Wr(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}g={data:[],size:0}}g&&(g.data.push(r.subarray(t,e+188)),g.size+=e+188-t);break;case f:s&&(m&&(a=Wr(m))&&this.parseID3PES(l,a),m={data:[],size:0}),m&&(m.data.push(r.subarray(t,e+188)),m.size+=e+188-t);break;case 0:s&&(t+=r[t]+1),y=this._pmtId=(E=r,S=t,(31&E[S+10])<<8|E[S+11]);break;case y:{s&&(t+=r[t]+1);const a=function(t,e,r,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<a;){const a=Yr(t,e);switch(t[e]){case 207:if(!i){P.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===s.audio&&(s.audio=a);break;case 21:-1===s.id3&&(s.id3=a);break;case 219:if(!i){P.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===s.avc&&(s.avc=a);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?P.log("MPEG audio found, not supported in this browser"):-1===s.audio&&(s.audio=a,s.segmentCodec="mp3");break;case 36:P.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return s}(r,t,this.typeSupported,i);0<(d=a.avc)&&(n.pid=d),0<(c=a.audio)&&(o.pid=c,o.segmentCodec=a.segmentCodec),0<(f=a.id3)&&(l.pid=f),null===p||v||(P.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${L} to parse all TS packets.`),p=null,e=L-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=I}}else b++;if(0<b){const r=new Error(`Found ${b} TS packet/s that do not start with 0x47`);this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:r,reason:r.message})}n.pesData=u,o.pesData=g,l.pesData=m;var e={audioTrack:o,videoTrack:n,id3Track:l,textTrack:h};return s&&this.extractRemainingSamples(e),e}flush(){var t=this["remainderData"];return this.remainderData=null,t=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(t){var{audioTrack:e,videoTrack:t,id3Track:r,textTrack:i}=t,s=t.pesData,a=e.pesData,n=r.pesData;let o;if(s&&(o=Wr(s))?(this.parseAVCPES(t,i,o,!0),t.pesData=null):t.pesData=s,a&&(o=Wr(a))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,o);break;case"mp3":this.parseMPEGPES(e,o)}e.pesData=null}else null!=a&&a.size&&P.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;n&&(o=Wr(n))?(this.parseID3PES(r,o),r.pesData=null):r.pesData=n}demuxSampleAes(t,e,r){t=this.demux(t,r,!0,!this.config.progressive),r=this.sampleAes=new Kr(this.observer,this.config,e);return this.decrypt(t,r)}decrypt(i,s){return new Promise(t=>{const{audioTrack:e,videoTrack:r}=i;e.samples&&"aac"===e.segmentCodec?s.decryptAacSamples(e.samples,0,()=>{r.samples?s.decryptAvcSamples(r.samples,0,0,()=>{t(i)}):t(i)}):r.samples&&s.decryptAvcSamples(r.samples,0,0,()=>{t(i)})})}destroy(){this._duration=0}parseAVCPES(s,t,a,e){var r=this.parseAVCNALu(s,a.data);let n,o=this.avcSample,l=!1;a.data=null,o&&r.length&&!s.audFound&&(jr(o,s),o=this.avcSample=Vr(!1,a.pts,a.dts,"")),r.forEach(e=>{var i,r;switch(e.type){case 1:{let t=!1;n=!0;const i=e.data;if(l&&4<i.length){const s=new $r(i).readSliceType();2!==s&&4!==s&&7!==s&&9!==s||(t=!0)}t&&null!=(r=o)&&r.frame&&!o.key&&(jr(o,s),o=this.avcSample=null),(o=o||(this.avcSample=Vr(!0,a.pts,a.dts,""))).frame=!0,o.key=t;break}case 5:n=!0,null!=(i=o)&&i.frame&&!o.key&&(jr(o,s),o=this.avcSample=null),(o=o||(this.avcSample=Vr(!0,a.pts,a.dts,""))).key=!0,o.frame=!0;break;case 6:n=!0,Mt(e.data,1,a.pts,t.samples);break;case 7:if(n=!0,l=!0,!s.sps){const t=e.data,a=new $r(t).readSPS(),i=(s.width=a.width,s.height=a.height,s.pixelRatio=a.pixelRatio,s.sps=[t],s.duration=this._duration,t.subarray(1,4));let r="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),r+=t}s.codec=r}break;case 8:n=!0,s.pps||(s.pps=[e.data]);break;case 9:n=!1,s.audFound=!0,o&&jr(o,s),o=this.avcSample=Vr(!1,a.pts,a.dts,"");break;case 12:n=!0;break;default:n=!1,o&&(o.debug+="unknown NAL "+e.type+" ")}o&&n&&o.units.push(e)}),e&&o&&(jr(o,s),this.avcSample=null)}getLastNalUnit(t){let e,r=this.avcSample;if(null!=(t=r=r&&0!==r.units.length?r:t[t.length-1])&&t.units){const t=r.units;e=t[t.length-1]}return e}parseAVCNALu(t,e){const r=e.byteLength;let i=t.naluState||0;var s=i,a=[];let n,o,l,h=0,d=-1,u=0;for(-1===i&&(d=0,u=31&e[0],i=0,h=1);h<r;)if(n=e[h++],i)if(1!==i)if(n)if(1===n){if(0<=d){const t={data:e.subarray(d,h-i-1),type:u};a.push(t)}else{const r=this.getLastNalUnit(t.samples);if(r&&(s&&h<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),0<(o=h-i-1))){const t=new Uint8Array(r.data.byteLength+o);t.set(r.data,0),t.set(e.subarray(0,o),r.data.byteLength),r.data=t,r.state=0}}i=h<r?(l=31&e[h],d=h,u=l,0):-1}else i=0;else i=3;else i=n?0:2;else i=n?0:1;if(0<=d&&0<=i){const t={data:e.subarray(d,r),type:u,state:i};a.push(t)}if(0===a.length){const r=this.getLastNalUnit(t.samples);if(r){const t=new Uint8Array(r.data.byteLength+e.byteLength);t.set(r.data,0),t.set(e,r.data.byteLength),r.data=t}}return t.naluState=i,a}parseAACPES(t,e){let r=0;var i,s=this.aacOverFlow;let a,n,o,l=e.data;if(s){this.aacOverFlow=null;const e=s.missing,a=s.sample.unit.byteLength;if(-1===e){const t=new Uint8Array(a+l.byteLength);t.set(s.sample.unit,0),t.set(l,a),l=t}else{const n=a-e;s.sample.unit.set(l.subarray(0,e),n),t.samples.push(s.sample),r=s.missing}}for(a=r,n=l.length;a<n-1&&!wr(l,a);a++);if(a!==r){const e=a<n-1,r=(i=e?"AAC PES did not start with ADTS header,offset:"+a:"No ADTS header found in AAC PES",new Error(i));if(P.warn("parsing error: "+i),this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,levelRetry:e,error:r,reason:i}),!e)return}if(kr(t,this.observer,l,a,this.audioCodec),void 0!==e.pts)o=e.pts;else{if(!s)return void P.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=Ir(t.samplerate);o=s.sample.pts+e}}let h,d=0;for(;a<n;){if(h=_r(t,l,a,o,d),a+=h.length,h.missing){this.aacOverFlow=h;break}for(d++;a<n-1&&!wr(l,a);a++);}}parseMPEGPES(t,e){var r=e.data,i=r.length;let s=0,a=0;var n=e.pts;if(void 0!==n)for(;a<i;)if(Gr(r,a)){const e=Nr(t,r,a,n,s);if(!e)break;a+=e.length,s++}else a++;else P.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(t,e){void 0===e.pts?P.warn("[tsdemuxer]: ID3 PES unknown PTS"):(e=k({},e,{type:this._avcTrack?ge:fe,duration:Number.POSITIVE_INFINITY}),t.samples.push(e))}}function Vr(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function Yr(t,e){return((31&t[e+1])<<8)+t[e+2]}function Wr(t){let i,e,s,a,n,o=0;var l=t.data;if(!t||0===t.size)return null;for(;l[0].length<19&&1<l.length;){const t=new Uint8Array(l[0].length+l[1].length);t.set(l[0]),t.set(l[1],l[0].length),l[0]=t,l.splice(1,1)}if(1!==((i=l[0])[0]<<16)+(i[1]<<8)+i[2])return null;{if((e=(i[4]<<8)+i[5])&&e>t.size-6)return null;var h=i[7];192&h&&(a=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&h?(n=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,54e5<a-n&&(P.warn(Math.round((a-n)/9e4)+"s delta between PTS and DTS, align them"),a=n)):n=a);let r=(s=i[8])+9;if(t.size<=r)return null;t.size-=r;var d=new Uint8Array(t.size);for(let e=0,t=l.length;e<t;e++){let t=(i=l[e]).byteLength;if(r){if(r>t){r-=t;continue}i=i.subarray(r),t-=r,r=0}d.set(i,o),o+=t}return e&&(e-=s+3),{data:d,pts:a,dts:n,len:e}}}function jr(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return e.dropped++;{const e=r[i-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&P.log(t.pts+"/"+t.dts+":"+t.debug)}class qr{static getSilentFrame(t,e){return"mp4a.40.2"===t?1===e?new Uint8Array([0,200,0,128,35,128]):2===e?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===e?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]):void 0:1===e?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]):2===e||3===e?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]):void 0}}const Xr=Math.pow(2,32)-1;class N{static init(){let t;for(t in N.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},N.types)N.types.hasOwnProperty(t)&&(N.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var e=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=(N.HDLR_TYPES={video:e,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(N.STTS=N.STSC=N.STCO=r,N.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),N.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),N.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),N.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);N.FTYP=N.box(N.types.ftyp,r,s,r,i),N.DINF=N.box(N.types.dinf,N.box(N.types.dref,e))}static box(t,...e){let r=8,i=e.length;for(var s=i;i--;)r+=e[i].byteLength;var a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(t,4),i=0,r=8;i<s;i++)a.set(e[i],r),r+=e[i].byteLength;return a}static hdlr(t){return N.box(N.types.hdlr,N.HDLR_TYPES[t])}static mdat(t){return N.box(N.types.mdat,t)}static mdhd(t,e){e*=t;var r=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr));return N.box(N.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,85,196,0,0]))}static mdia(t){return N.box(N.types.mdia,N.mdhd(t.timescale,t.duration),N.hdlr(t.type),N.minf(t))}static mfhd(t){return N.box(N.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?N.box(N.types.minf,N.box(N.types.smhd,N.SMHD),N.DINF,N.stbl(t)):N.box(N.types.minf,N.box(N.types.vmhd,N.VMHD),N.DINF,N.stbl(t))}static moof(t,e,r){return N.box(N.types.moof,N.mfhd(t),N.traf(r,e))}static moov(t){let e=t.length;for(var r=[];e--;)r[e]=N.trak(t[e]);return N.box.apply(null,[N.types.moov,N.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(N.mvex(t)))}static mvex(t){let e=t.length;for(var r=[];e--;)r[e]=N.trex(t[e]);return N.box.apply(null,[N.types.mvex,...r])}static mvhd(t,e){e*=t;var r=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr)),t=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,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 N.box(N.types.mvhd,t)}static sdtp(t){var e=t.samples||[],r=new Uint8Array(4+e.length);let i,s;for(i=0;i<e.length;i++)s=e[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return N.box(N.types.sdtp,r)}static stbl(t){return N.box(N.types.stbl,N.stsd(t),N.box(N.types.stts,N.STTS),N.box(N.types.stsc,N.STSC),N.box(N.types.stsz,N.STSZ),N.box(N.types.stco,N.STCO))}static avc1(t){let e,r,i,s=[],a=[];for(e=0;e<t.sps.length;e++)r=t.sps[e],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(e=0;e<t.pps.length;e++)r=t.pps[e],i=r.byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(r));var n=N.box(N.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|t.sps.length].concat(s).concat([t.pps.length]).concat(a))),o=t.width,l=t.height,h=t.pixelRatio[0],d=t.pixelRatio[1];return N.box(N.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,o>>8&255,255&o,l>>8&255,255&l,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]),n,N.box(N.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),N.box(N.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){var e=t.samplerate;return N.box(N.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),N.box(N.types.esds,N.esds(t)))}static mp3(t){var e=t.samplerate;return N.box(N.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?N.box(N.types.stsd,N.STSD,N.mp3(t)):N.box(N.types.stsd,N.STSD,N.mp4a(t)):N.box(N.types.stsd,N.STSD,N.avc1(t))}static tkhd(t){var e=t.id,r=t.duration*t.timescale,i=t.width,t=t.height,s=Math.floor(r/(1+Xr)),r=Math.floor(r%(1+Xr));return N.box(N.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,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,i>>8&255,255&i,0,0,t>>8&255,255&t,0,0]))}static traf(t,e){var r=N.sdtp(t),i=t.id,s=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr));return N.box(N.types.traf,N.box(N.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),N.box(N.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,e>>24,e>>16&255,e>>8&255,255&e])),N.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,N.box(N.types.trak,N.tkhd(t),N.mdia(t))}static trex(t){t=t.id;return N.box(N.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){var r=t.samples||[],i=r.length,s=12+16*i,a=new Uint8Array(s);let n,o,l,h,d,u;for(a.set(["video"===t.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,(e+=8+s)>>>24&255,e>>>16&255,e>>>8&255,255&e],0),n=0;n<i;n++)l=(o=r[n]).duration,h=o.size,d=o.flags,u=o.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return N.box(N.types.trun,a)}static initSegment(t){N.types||N.init();var t=N.moov(t),e=new Uint8Array(N.FTYP.byteLength+t.byteLength);return e.set(N.FTYP),e.set(t,N.FTYP.byteLength),e}}function zr(t,e,r=1,i=!1){t=t*e*r;return i?Math.round(t):t}function Qr(t,e=!1){return zr(t,1e3,1/9e4,e)}N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0;let Jr,Zr=null,ti=null;class ei{constructor(t,e,r,i=0){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.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Zr){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zr=t?parseInt(t[1]):0}if(null===ti){const t=navigator.userAgent.match(/Safari\/(\d+)/i);ti=t?parseInt(t[1]):0}}destroy(){}resetTimeStamp(t){P.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){P.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){P.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let i=!1;t=t.reduce((t,e)=>{var r=e.pts-t;return r<-4294967296?(i=!0,U(t,e.pts)):0<r?t:e.pts},t[0].pts);return i&&P.debug("PTS rollover detected"),t}remux(r,i,s,a,n,o,t,l){let h,d,u,e,c,f,g=n,m=n;var p=-1<r.pid,v=-1<i.pid,y=i.samples.length,T=0<r.samples.length,E=t&&0<y||1<y;if((!p||T)&&(!v||E)||this.ISGenerated||t){this.ISGenerated||(u=this.generateIS(r,i,n,o));const s=this.isVideoContiguous;let t,e=-1;if(E&&(e=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(i.samples),!s)&&this.config.forceKeyFrameOnDiscontinuity)if(f=!0,0<e){P.warn(`[mp4-remuxer]: Dropped ${e} out of ${y} video samples due to a missing keyframe`);const r=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(e),i.dropped+=e,m+=(i.samples[0].pts-r)/i.inputTimeScale,t=m}else-1===e&&(P.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(T&&E){const s=this.getVideoStartPts(i.samples),a=(U(r.samples[0].pts,s)-s)/i.inputTimeScale;g+=Math.max(0,a),m+=Math.max(0,-a)}if(T){if(r.samplerate||(P.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(r,i,n,o)),d=this.remuxAudio(r,g,this.isAudioContiguous,o,v||E||l===L?m:void 0),E){const a=d?d.endPTS-d.startPTS:0;i.inputTimeScale||(P.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(r,i,n,o)),h=this.remuxVideo(i,m,s,a)}}else E&&(h=this.remuxVideo(i,m,s,0));h&&(h.firstKeyFrame=e,h.independent=-1!==e,h.firstKeyFramePTS=t)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(c=ri(s,n,this._initPTS,this._initDTS)),a.samples.length)&&(e=ii(a,n,this._initPTS)),{audio:d,video:h,initSegment:u,independent:f,text:e,id3:c}}generateIS(t,e,r,i){var s=t.samples,a=e.samples,n=this.typeSupported,o={},l=this._initPTS;let h,d,u,c=!l||i,f="audio/mp4";if(c&&(h=d=1/0),t.config&&s.length&&("mp3"===(t.timescale=t.samplerate,t.segmentCodec)&&(n.mpeg?(f="audio/mpeg",t.codec=""):n.mp3&&(t.codec="mp3")),o.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&n.mpeg?new Uint8Array(0):N.initSegment([t]),metadata:{channelCount:t.channelCount}},c)&&(u=t.inputTimeScale,l&&u===l.timescale?c=!1:h=d=s[0].pts-Math.round(u*r)),e.sps&&e.pps&&a.length&&(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:N.initSegment([e]),metadata:{width:e.width,height:e.height}},c))if(u=e.inputTimeScale,l&&u===l.timescale)c=!1;else{const t=this.getVideoStartPts(a),e=Math.round(u*r);d=Math.min(d,U(a[0].dts,t)-e),h=Math.min(h,t-e)}if(Object.keys(o).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:u},this._initDTS={baseTime:d,timescale:u}):h=u=void 0,{tracks:o,initPTS:h,timescale:u}}remuxVideo(i,s,a,n){const o=i.inputTimeScale,l=i.samples,h=[],d=l.length,t=this._initPTS;let u,e,r=this.nextAvcDts,c=8,f=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;a&&null!==r||(r=s*o-(l[0].pts-U(l[0].dts,l[0].pts)));var v=t.baseTime*o/t.timescale;for(let t=0;t<d;t++){const s=l[t];s.pts=U(s.pts-v,r),s.dts=U(s.dts-v,r),s.dts<l[0<t?t-1:t].dts&&(p=!0)}p&&l.sort(function(t,e){var r=t.dts-e.dts,t=t.pts-e.pts;return r||t}),u=l[0].dts;var s=l[l.length-1].dts-u,y=s?Math.round(s/(d-1)):f||i.inputTimeScale/30;if(a){const i=u-r,s=i>y,a=i<-1;if((s||a)&&(s?P.warn(`AVC: ${Qr(i,!0)} ms (${i}dts) hole between fragments detected, filling it`):P.warn(`AVC: ${Qr(-i,!0)} ms (${i}dts) overlapping between fragments detected`),!a||r>=l[0].pts)){u=r;const s=l[0].pts-i;l[0].dts=u,l[0].pts=s,P.log(`Video: First PTS/DTS adjusted: ${Qr(s,!0)}/${Qr(u,!0)}, delta: ${Qr(i,!0)} ms`)}}u=Math.max(0,u);let T=0,E=0;for(let t=0;t<d;t++){const s=l[t],a=s.units,n=a.length;let e=0;for(let t=0;t<n;t++)e+=a[t].data.length;E+=e,T+=n,s.length=e,s.dts=Math.max(s.dts,u),g=Math.min(s.pts,g),m=Math.max(s.pts,m)}e=l[d-1].dts;s=E+4*T+8;let S;try{S=new Uint8Array(s)}catch(i){return void this.observer.emit(I.ERROR,I.ERROR,{type:_.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:i,bytes:s,reason:"fail allocating video mdat "+s})}var L=new DataView(S.buffer);L.setUint32(0,s),S.set(N.types.mdat,4);let b=!1,A=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,w=Number.NEGATIVE_INFINITY;for(let e=0;e<d;e++){const s=l[e],a=s.units;let t,r=0;for(let t=0,e=a.length;t<e;t++){const s=a[t],n=s.data,o=s.data.byteLength;L.setUint32(c,o),c+=4,S.set(n,c),c+=o,r+=4+o}if(e<d-1)f=l[e+1].dts-s.dts,t=l[e+1].pts-s.pts;else{const a=this.config,h=0<e?s.dts-l[e-1].dts:y;if(t=0<e?s.pts-l[e-1].pts:y,a.stretchShortVideoTrack&&null!==this.nextAudioPts){const i=Math.floor(a.maxBufferHole*o),l=(n?g+n*o:this.nextAudioPts)-s.pts;l>i?((f=l-h)<0?f=h:b=!0,P.log(`[mp4-remuxer]: It is approximately ${l/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=h}else f=h}const u=Math.round(s.pts-s.dts);A=Math.min(A,f),D=Math.max(D,f),R=Math.min(R,t),w=Math.max(w,t),h.push(new si(s.key,f,r,u))}if(h.length)if(Zr){if(Zr<70){const i=h[0].flags;i.dependsOn=2,i.isNonSync=0}}else if(ti&&w-R<D-A&&y/D<.025&&0===h[0].cts){P.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let r=u;for(let t=0,e=h.length;t<e;t++){const n=r+h[t].duration,o=r+h[t].cts;if(t<e-1){const i=n+h[t+1].cts;h[t].duration=i-o}else h[t].duration=t?h[t-1].duration:y;h[t].cts=0,r=n}}f=b||!f?y:f,this.nextAvcDts=r=e+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;a={data1:N.moof(i.sequenceNumber++,u,k({},i,{samples:h})),data2:S,startPTS:g/o,endPTS:(m+f)/o,startDTS:u/o,endDTS:r/o,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:i.dropped};return i.samples=[],i.dropped=0,a}remuxAudio(s,a,r,i,n){const t=s.inputTimeScale,o=t/(s.samplerate||t),l="aac"===s.segmentCodec?1024:1152,h=l*o,e=this._initPTS,d="mp3"===s.segmentCodec&&this.typeSupported.mpeg,u=[],c=void 0!==n;let f=s.samples,g=d?0:8,m=this.nextAudioPts||-1;const p=a*t,v=e.baseTime*t/e.timescale;if(this.isAudioContiguous=r=r||f.length&&0<m&&(i&&Math.abs(p-m)<9e3||Math.abs(U(f[0].pts-v,p)-m)<20*h),f.forEach(function(t){t.pts=U(t.pts-v,p)}),!r||m<0){if(!(f=f.filter(t=>0<=t.pts)).length)return;m=0===n?0:i&&!c?Math.max(0,p):f[0].pts}if("aac"===s.segmentCodec){const a=this.config.maxAudioFramesDrift;for(let r=0,i=m;r<f.length;r++){const n=f[r],o=n.pts,l=o-i,k=Math.abs(1e3*l/t);if(l<=-a*h&&c)0===r&&(P.warn(`Audio frame @ ${(o/t).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*l/t)} ms.`),this.nextAudioPts=m=i=o);else if(l>=a*h&&k<1e4&&c){let e=Math.round(l/h);(i=o-e*h)<0&&(e--,i+=h),0===r&&(this.nextAudioPts=m=i),P.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(i/t).toFixed(3)}s due to ${Math.round(1e3*l/t)} ms gap.`);for(let t=0;t<e;t++){const a=Math.max(i,0);let t=qr.getSilentFrame(s.manifestCodec||s.codec,s.channelCount);t||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),t=n.unit.subarray()),f.splice(r,0,{unit:t,pts:a}),i+=h,r++}}n.pts=i,i+=h}}let y,T=null,E=null,S=0,L=f.length;for(;L--;)S+=f[L].unit.byteLength;for(let e=0,t=f.length;e<t;e++){const i=f[e],n=i.unit;let t=i.pts;if(null!==E)u[e-1].duration=Math.round((t-E)/o);else{if(r&&"aac"===s.segmentCodec&&(t=m),T=t,!(0<S))return;S+=g;try{y=new Uint8Array(S)}catch(s){return void this.observer.emit(I.ERROR,I.ERROR,{type:_.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:s,bytes:S,reason:"fail allocating audio mdat "+S})}d||(new DataView(y.buffer).setUint32(0,S),y.set(N.types.mdat,4))}y.set(n,g);const h=n.byteLength;g+=h,u.push(new si(!0,l,h,0)),E=t}var b,a=u.length;if(a)return this.nextAudioPts=m=E+o*u[u.length-1].duration,n=d?new Uint8Array(0):N.moof(s.sequenceNumber++,T/o,k({},s,{samples:u})),s.samples=[],i=T/t,b=m/t,n={data1:n,data2:y,startPTS:i,endPTS:b,startDTS:i,endDTS:b,type:"audio",hasAudio:!0,hasVideo:!1,nb:a},this.isAudioContiguous=!0,n}remuxEmptyAudio(t,e,r,i){var s=t.inputTimeScale,a=s/(t.samplerate||s),n=this.nextAudioPts,o=this._initDTS,o=9e4*o.baseTime/o.timescale,l=(null!==n?n:i.startDTS*s)+o,n=i.endDTS*s+o,h=1024*a,d=Math.ceil((n-l)/h),u=qr.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(P.warn("[mp4-remuxer]: remux empty Audio"),u){var c=[];for(let t=0;t<d;t++){const e=l+t*h;c.push({unit:u,pts:e,dts:e})}return t.samples=c,this.remuxAudio(t,e,r,!1)}P.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")}}function U(t,e){var r;if(null!==e)for(r=e<t?-8589934592:8589934592;4294967296<Math.abs(t-e);)t+=r;return t}function ri(e,r,i,s){const a=e.samples.length;if(a){var n=e.inputTimeScale;for(let t=0;t<a;t++){const a=e.samples[t];a.pts=U(a.pts-i.baseTime*n/i.timescale,r*n)/n,a.dts=U(a.dts-s.baseTime*n/s.timescale,r*n)/n}var t=e.samples;return e.samples=[],{samples:t}}}function ii(e,r,i){const s=e.samples.length;if(s){var a=e.inputTimeScale;for(let t=0;t<s;t++){const s=e.samples[t];s.pts=U(s.pts-i.baseTime*a/i.timescale,r*a)/a}e.samples.sort((t,e)=>t.pts-e.pts);var t=e.samples;return e.samples=[],{samples:t}}}class si{constructor(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new ai(t)}}class ai{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function ni(t,e){t=null==t?void 0:t.codec;return t&&4<t.length?t:"hvc1"===t||"hev1"===t?"hvc1.1.6.L120.90":"av01"===t?"av01.0.04M.08":"avc1"===t||e===b?"avc1.42e01e":"mp4a.40.5"}try{Jr=self.performance.now.bind(self.performance)}catch(i){P.debug("Unable to use Performance API on this environment"),Jr="undefined"!=typeof self&&self.Date.now}const oi=[{demux:class{constructor(t,e){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=e}resetTimeStamp(){}resetInitSegment(t,e,r,i){var s=this.videoTrack=F("video",1),a=this.audioTrack=F("audio",1),n=this.txtTrack=F("text",1);if(this.id3Track=F("id3",1),this.timeOffset=0,null!=t&&t.byteLength){var o=_t(t);if(o.video){const{id:t,timescale:e,codec:r}=o.video;s.id=t,s.timescale=n.timescale=e,s.codec=r}if(o.audio){const{id:t,timescale:e,codec:r}=o.audio;a.id=t,a.timescale=e,a.codec=r}n.id=Dt.text,s.sampleDuration=0,s.duration=a.duration=i}}resetContiguity(){this.remainderData=null}static probe(t){return 0<x(t=16384<t.length?t.subarray(0,16384):t,["moof"]).length}demux(t,e){this.timeOffset=e;let r=t;var i,s,a=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Pt(this.remainderData,t));t=r,i={valid:null,remainder:null},(s=x(t,["moof"]))&&(s.length<2?i.remainder=t:(s=s[s.length-1],i.valid=ft(t,0,s.byteOffset-8),i.remainder=ft(t,s.byteOffset-8)));const e=i;this.remainderData=e.remainder,a.samples=e.valid||new Uint8Array}else a.samples=r;t=this.extractID3Track(a,e);return n.samples=xt(e,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:t,textTrack:this.txtTrack}}flush(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack,i=(e.samples=this.remainderData||new Uint8Array,this.remainderData=null,this.extractID3Track(e,this.timeOffset));return r.samples=xt(t,e),{videoTrack:e,audioTrack:F(),id3Track:i,textTrack:F()}}extractID3Track(t,i){const s=this.id3Track;return t.samples.length&&(t=x(t.samples,["emsg"]))&&t.forEach(e=>{var r=function(t){const e=t[0];let r="",i="",s=0,a=0,n=0,o=0,l=0,h=0;if(0===e){for(;"\0"!==f(t.subarray(h,h+1));)r+=f(t.subarray(h,h+1)),h+=1;for(r+=f(t.subarray(h,h+1)),h+=1;"\0"!==f(t.subarray(h,h+1));)i+=f(t.subarray(h,h+1)),h+=1;i+=f(t.subarray(h,h+1)),h+=1,s=R(t,12),a=R(t,16),o=R(t,20),l=R(t,24),h=28}else if(1===e){h+=4,s=R(t,h);const e=R(t,h+=4),a=R(t,h+=4);for(h+=4,n=2**32*e+a,Number.isSafeInteger(n)||(n=Number.MAX_SAFE_INTEGER,P.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=R(t,h),h+=4,l=R(t,h),h+=4;"\0"!==f(t.subarray(h,h+1));)r+=f(t.subarray(h,h+1)),h+=1;for(r+=f(t.subarray(h,h+1)),h+=1;"\0"!==f(t.subarray(h,h+1));)i+=f(t.subarray(h,h+1)),h+=1;i+=f(t.subarray(h,h+1)),h+=1}return{schemeIdUri:r,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:o,id:l,payload:t.subarray(h,t.byteLength)}}(e);if(Cr.test(r.schemeIdUri)){const e=D(r.presentationTime)?r.presentationTime/r.timeScale:i+r.presentationTimeDelta/r.timeScale;let t=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;t<=.001&&(t=Number.POSITIVE_INFINITY);r=r.payload;s.samples.push({data:r,len:r.byteLength,dts:e,pts:e,type:ge,duration:t})}}),s}demuxSampleAes(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(function(t,e){if(t&&e){const i=e.keyId;i&&e.isCommonEncryption&&x(t,["moov","trak"]).forEach(t=>{t=x(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let e=x(t,["enca"]);const r=0<e.length;(e=r?e:x(t,["encv"])).forEach(t=>{x(r?t.subarray(28):t.subarray(78),["sinf"]).forEach(t=>{var e=Ct(t);if(e){const t=e.subarray(8,24);t.some(t=>0!==t)||(P.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${c(t)} -> `+c(i)),e.set(i,8))}})})})}return t}(t,i)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;var i,s;null!=t&&t.byteLength?(i=this.initData=_t(t),e=e||ni(i.audio,S),r=r||ni(i.video,b),s={},i.audio&&i.video?s.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?s.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?s.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:P.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s):(this.initTracks=void 0,this.initData=void 0)}remux(r,i,s,a,n,o){let{initPTS:l,lastEndTime:h}=this;var d={audio:void 0,video:void 0,text:a,id3:s,initSegment:void 0},i=(D(h)||(h=this.lastEndTime=n||0),i.samples);if(null!=i&&i.length){var u={initPTS:void 0,timescale:1};let e=this.initData;if(null!=(m=e)&&m.length||(this.generateInitSegment(i),e=this.initData),null!=(m=e)&&m.length){this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var c,f,g,m=function(t,e){let r=0,i=0,s=0;var a=x(t,["moof","traf"]);for(let t=0;t<a.length;t++){var n=a[t],o=x(n,["tfhd"])[0],l=e[R(o,4)];if(l){var h=l.default,d=R(o,0)|(null==h?void 0:h.flags);let e=null==h?void 0:h.duration;8&d&&(e=R(o,2&d?12:8));var u=l.timescale||9e4,c=x(n,["trun"]);for(let t=0;t<c.length;t++)!(r=function(e){var r=R(e,0);let i=8,s=(1&r&&(i+=4),4&r&&(i+=4),0);var a=R(e,4);for(let t=0;t<a;t++)256&r&&(s+=R(e,i),i+=4),512&r&&(i+=4),1024&r&&(i+=4),2048&r&&(i+=4);return s}(c[t]))&&e&&(r=e*R(c[t],4)),l.type===b?i+=r/u:l.type===S&&(s+=r/u)}}if(0!==i||0!==s)return i||s;{let e=0;const r=x(t,["sidx"]);for(let t=0;t<r.length;t++){const i=function(e){var r=[],t=e[0];let i=8;var s=R(e,i);i=(i+=4)+(0===t?8:16)+2;let a=e.length+0;const n=wt(e,i);i+=2;for(let t=0;t<n;t++){var o=i;const n=R(e,o);o+=4;var l=2147483647&n;if(1==(2147483648&n)>>>31)return P.warn("SIDX has hierarchical references (not supported)"),null;var h=R(e,o);o+=4,r.push({referenceSize:l,subsegmentDuration:h,info:{duration:h/s,start:a,end:a+l-1}}),a+=l,o+=4,i=o}return{earliestPresentationTime:0,timescale:s,version:t,referencesCount:n,references:r}}(r[t]);null!=i&&i.references&&(e+=i.references.reduce((t,e)=>t+e.info.duration||0,0))}return e}}(i,e),p=(c=e,x(i,["moof","traf"]).reduce((t,e)=>{const s=x(e,["tfdt"])[0],a=s[0],r=x(e,["tfhd"]).reduce((e,r)=>{var r=R(r,4),i=c[r];if(i){let t=R(s,4);if(1===a){if(t===At)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t=(t*=1+At)+R(s,8)}const r=t/(i.timescale||9e4);if(isFinite(r)&&(null===e||r<e))return r}return e},null);return null!==r&&isFinite(r)&&(null===t||r<t)?r:t},null)),p=null===p?n:p,v=(v=l,y=p,T=n,(null===v||(E=Math.max(m,1),y=y-v.baseTime/v.timescale,Math.abs(y-T)>E)||u.timescale!==l.timescale&&o)&&(u.initPTS=p-n,l&&1===l.timescale&&P.warn("Adjusting initPTS by "+(u.initPTS-l.baseTime)),this.initPTS=l={baseTime:u.initPTS,timescale:1}),r?p-l.baseTime/l.timescale:h),y=v+m,T=(f=e,g=l.baseTime/l.timescale,x(i,["moof","traf"]).forEach(e=>{x(e,["tfhd"]).forEach(t=>{t=R(t,4),t=f[t];if(t){const s=t.timescale||9e4;x(e,["tfdt"]).forEach(t=>{const e=t[0];let r=R(t,4);if(0===e)r-=g*s,It(t,4,r=Math.max(r,0));else{r=(r=(r*=Math.pow(2,32))+R(t,8))-g*s,r=Math.max(r,0);const e=Math.floor(r/(1+At)),i=Math.floor(r%(1+At));It(t,4,e),It(t,8,i)}})}})}),0<m?this.lastEndTime=y:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp()),!!e.audio),E=!!e.video;let t="";T&&(t+="audio"),E&&(t+="video");o={data1:i,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:t,hasAudio:T,hasVideo:E,nb:1,dropped:0};d.audio="audio"===o.type?o:void 0,d.video="audio"!==o.type?o:void 0,d.initSegment=u,d.id3=ri(s,n,l,l),a.samples.length&&(d.text=ii(a,n,l))}else P.warn("[passthrough-remuxer.ts]: Failed to generate initSegment.")}return d}}},{demux:Hr,remux:ei},{demux:class extends Lr{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,r,i){super.resetInitSegment(t,e,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(e){let t=(pt(e,0)||[]).length;for(var r,i,s,a,n=e.length;t<n;t++)if(r=e,i=t,a=s=void 0,!wr(r,i)||i+(a=Rr(r,i))>=r.length?void 0:!((s=Dr(r,i))<=a)&&((a=i+s)===r.length||wr(r,a)))return P.log("ADTS sync word found !"),!0}return!1}canParse(t,e){return(e=e)+5<(t=t).length&&Ar(t,e)&&Dr(t,e)<=t.length-e}appendFrame(t,e,r){kr(t,this.observer,e,r,t.manifestCodec);t=_r(t,e,r,this.basePTS,this.frameIndex);if(t&&0===t.missing)return t}},remux:ei},{demux:class extends Lr{resetInitSegment(t,e,r,i){super.resetInitSegment(t,e,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(e){let t=(pt(e,0)||[]).length;for(var r=e.length;t<r;t++)if(function(e,r){if(r+1<e.length&&Br(e,r)){var i=Ur(e,r);let t=4;r=r+(t=null!=i&&i.frameLength?i.frameLength:t);return r===e.length||Gr(e,r)}}(e,t))return P.log("MPEG Audio sync word found !"),!0}return!1}canParse(t,e){return Br(t,e)&&4<=t.length-e}appendFrame(t,e,r){if(null!==this.basePTS)return Nr(t,e,r,this.basePTS,this.frameIndex)}},remux:ei}];class li{constructor(t,e,r,i,s){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=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=s}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(e,r,i,t){var s=i.transmuxing;s.executeStart=Jr();let a=new Uint8Array(e);var{currentTransmuxState:e,transmuxConfig:n}=this,{contiguous:t,discontinuity:e,trackSwitch:o,accurateTimeOffset:l,timeOffset:h,initSegmentChange:d}=(t&&(this.currentTransmuxState=t),t||e),{audioCodec:n,videoCodec:u,defaultInitPts:c,duration:f,initSegmentData:g}=n,m=function(t){let e=null;return e=0<t.byteLength&&null!=r&&null!=r.key&&null!==r.iv&&null!=r.method?r:e}(a);if(m&&"AES-128"===m.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(a,m.key.buffer,m.iv.buffer).then(t=>{t=this.push(t,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(a,m.key.buffer,m.iv.buffer);if(!(t=-1<i.part?e.flush():t))return s.executeEnd=Jr(),hi(i);a=new Uint8Array(t)}}var p=this.needsProbing(e,o);if(p){const e=this.configureTransmuxer(a);if(e)return P.warn("[transmuxer] "+e.message),this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=Jr(),hi(i)}(e||o||d||p)&&this.resetInitSegment(g,n,u,f,r),(e||d||p)&&this.resetInitialTimestamp(c),t||this.resetContiguity();o=this.transmux(a,m,h,l,i),g=this.currentTransmuxState;return g.contiguous=!0,g.discontinuity=!1,g.trackSwitch=!1,s.executeEnd=Jr(),o}flush(e){const t=e.transmuxing;t.executeStart=Jr();var{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return s.then(()=>this.flush(e));const a=[],n=i["timeOffset"];if(r){const t=r.flush();t&&a.push(this.push(t,null,e))}var{demuxer:s,remuxer:i}=this;return s&&i?di(r=s.flush(n))?r.then(t=>(this.flushRemux(a,t,e),a)):(this.flushRemux(a,r,e),a):(t.executeEnd=Jr(),[hi(e)])}flushRemux(t,e,r){var{audioTrack:e,videoTrack:i,id3Track:s,textTrack:a}=e,{accurateTimeOffset:n,timeOffset:o}=this.currentTransmuxState,e=(P.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${-1<r.part?" p: "+r.part:""} of level `+r.level),this.remuxer.remux(e,i,s,a,o,n,!0,this.id));t.push({remuxResult:e,chunkMeta:r}),r.transmuxing.executeEnd=Jr()}resetInitialTimestamp(t){var{demuxer:e,remuxer:r}=this;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))}resetContiguity(){var{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,r,i,s){var{demuxer:a,remuxer:n}=this;a&&n&&(a.resetInitSegment(t,e,r,i),n.resetInitSegment(t,e,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,r,i,s){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,s):this.transmuxUnencrypted(t,r,i,s)}transmuxUnencrypted(t,e,r,i){var{audioTrack:t,videoTrack:s,id3Track:a,textTrack:n}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(t,s,a,n,e,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(t,e,r,i,s){return this.demuxer.demuxSampleAes(t,e,r).then(t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,this.id),chunkMeta:s}))}configureTransmuxer(r){var{config:t,observer:e,typeSupported:i,vendor:s}=this;let a;for(let t=0,e=oi.length;t<e;t++)if(oi[t].demux.probe(r)){a=oi[t];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");var n=this.demuxer,o=this.remuxer,l=a.remux,h=a.demux;o&&o instanceof l||(this.remuxer=new l(e,t,i,s)),n&&n instanceof h||(this.demuxer=new h(e,t,i),this.probe=h.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t=t||(this.decrypter=new dr(this.config))}}const hi=t=>({remuxResult:{},chunkMeta:t});function di(t){return"then"in t&&t.then instanceof Function}class ui{constructor(t,e,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class ci{constructor(t,e,r,i,s,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=a}}var fi,B,t={exports:{}};function gi(){}function mi(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function pi(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new mi(r,i||t,s),i=B?B+e:e;return t._events[i]?t._events[i].fn?t._events[i]=[t._events[i],r]:t._events[i].push(r):(t._events[i]=r,t._eventsCount++),t}function vi(t,e){0==--t._eventsCount?t._events=new gi:delete t._events[e]}function r(){this._events=new gi,this._eventsCount=0}e=t,fi=Object.prototype.hasOwnProperty,B="~",Object.create&&(gi.prototype=Object.create(null),(new gi).__proto__||(B=!1)),r.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)fi.call(t,e)&&r.push(B?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},r.prototype.listeners=function(t){var t=B?B+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,i=e.length,s=new Array(i);r<i;r++)s[r]=e[r].fn;return s},r.prototype.listenerCount=function(t){t=B?B+t:t,t=this._events[t];return t?t.fn?1:t.length:0},r.prototype.emit=function(t,e,r,i,s,a){var n=B?B+t:t;if(!this._events[n])return!1;var o,l=this._events[n],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,s),!0;case 6:return l.fn.call(l.context,e,r,i,s,a),!0}for(c=1,o=new Array(h-1);c<h;c++)o[c-1]=arguments[c];l.fn.apply(l.context,o)}else for(var d,u=l.length,c=0;c<u;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,r);break;case 4:l[c].fn.call(l[c].context,e,r,i);break;default:if(!o)for(d=1,o=new Array(h-1);d<h;d++)o[d-1]=arguments[d];l[c].fn.apply(l[c].context,o)}return!0},r.prototype.on=function(t,e,r){return pi(this,t,e,r,!1)},r.prototype.once=function(t,e,r){return pi(this,t,e,r,!0)},r.prototype.removeListener=function(t,e,r,i){t=B?B+t:t;if(this._events[t])if(e){var s=this._events[t];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||vi(this,t);else{for(var a=0,n=[],o=s.length;a<o;a++)(s[a].fn!==e||i&&!s[a].once||r&&s[a].context!==r)&&n.push(s[a]);n.length?this._events[t]=1===n.length?n[0]:n:vi(this,t)}}else vi(this,t);return this},r.prototype.removeAllListeners=function(t){return t?(t=B?B+t:t,this._events[t]&&vi(this,t)):(this._events=new gi,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=B,e.exports=r.EventEmitter=r;var yi=(e=t.exports)&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;const Ti=Kt()||{isTypeSupported:()=>!1};class Ei{constructor(t,e,r,i){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;const s=t.config;this.hls=t,this.id=e,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var a,r=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===I.ERROR&&(this.error=e.error),this.hls.trigger(t,e)},i=(this.observer=new yi,this.observer.on(I.FRAG_DECRYPTED,r),this.observer.on(I.ERROR,r),{mp4:Ti.isTypeSupported("video/mp4"),mpeg:Ti.isTypeSupported("audio/mpeg"),mp3:Ti.isTypeSupported('audio/mp4; codecs="mp3"')}),r=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__))try{s.workerPath?(P.log(`loading Web Worker ${s.workerPath} for "${e}"`),this.workerContext=function(t){t=new self.URL(t,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(s.workerPath)):(P.log(`injecting Web Worker for "${e}"`),this.workerContext=(a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),a=self.URL.createObjectURL(a),{worker:new self.Worker(a),objectURL:a})),this.onwmsg=t=>this.onWorkerMessage(t);const t=this.workerContext["worker"];t.addEventListener("message",this.onwmsg),t.onerror=t=>{t=new Error(`${t.message} (${t.filename}:${t.lineno})`);s.enableWorker=!1,P.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},t.postMessage({cmd:"init",typeSupported:i,vendor:r,id:e,config:JSON.stringify(s)})}catch(t){P.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new li(this.observer,i,s,r,e)}else this.transmuxer=new li(this.observer,i,s,r,e)}resetWorker(){var t,e;this.workerContext&&({worker:t,objectURL:e}=this.workerContext,e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null)}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,i,s,a,n,o,l,h){var d=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],u=(a||s).start,c=s.decryptdata,f=this.frag,g=!(f&&s.cc===f.cc),m=!(f&&l.level===f.level),p=f?l.sn-f.sn:-1,v=this.part?l.part-this.part.index:-1,y=0==p&&1<l.id&&l.id===(null==f?void 0:f.stats.chunkCount),y=!m&&(1==p||0==p&&(1==v||y&&v<=0)),T=self.performance.now(),T=((m||p||0===s.stats.parsing.start)&&(s.stats.parsing.start=T),!a||!v&&y||(a.stats.parsing.start=T),!(f&&(null==(p=s.initSegment)?void 0:p.url)===(null==(v=f.initSegment)?void 0:v.url))),p=new ci(g,y,o,m,u,T);if(!y||g||T){P.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}
|
|
1
|
+
(window.webpackJsonpfeffery_utils_components=window.webpackJsonpfeffery_utils_components||[]).push([[0],{556:function(t,_,C){"use strict";!function(t){var A=C(750),a=C(751),l=C(752);function r(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t,e){if(r()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(t=null===t?new u(e):t).length=e,t}function u(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"!=typeof t)return i(this,t,e,r);if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return n(this,t)}function i(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var s=t,a=e,n=r;if(a.byteLength,n<0||a.byteLength<n)throw new RangeError("'offset' is out of bounds");if(a.byteLength<n+(i||0))throw new RangeError("'length' is out of bounds");return a=void 0===n&&void 0===i?new Uint8Array(a):void 0===i?new Uint8Array(a,n):new Uint8Array(a,n,i),u.TYPED_ARRAY_SUPPORT?(s=a).__proto__=u.prototype:s=d(s,a),s}if("string"==typeof e){n=t,i=e,a=r;if(u.isEncoding(a="string"==typeof a&&""!==a?a:"utf8"))return(i=(n=h(n,s=0|f(i,a))).write(i,a))!==s?n.slice(0,i):n;throw new TypeError('"encoding" must be a valid string encoding')}var o,r=t,i=e;if(u.isBuffer(i))return 0!==(r=h(r,o=0|c(i.length))).length&&i.copy(r,0,0,o),r;if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||(o=i.length)!=o?h(r,0):d(r,i);if("Buffer"===i.type&&l(i.data))return d(r,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function n(t,e){if(s(e),t=h(t,e<0?0:0|c(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|c(e.length);t=h(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function c(t){if(t>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function f(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;var r=(t="string"!=typeof t?""+t:t).length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return w(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return k(t).length;default:if(i)return w(t).length;e=(""+e).toLowerCase(),i=!0}}function e(t,e,r){var i,s=!1;if((e=void 0===e||e<0?0:e)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":var a=this,n=e,o=r,l=a.length;(!o||o<0||l<o)&&(o=l);for(var h="",d=n=!n||n<0?0:n;d<o;++d)h+=function(t){return t<16?"0"+t.toString(16):t.toString(16)}(a[d]);return h;case"utf8":case"utf-8":return R(this,e,r);case"ascii":var u=this,l=e,c=r,f="";c=Math.min(u.length,c);for(var g=l;g<c;++g)f+=String.fromCharCode(127&u[g]);return f;case"latin1":case"binary":var m=this,n=e,p=r,v="";p=Math.min(m.length,p);for(var y=n;y<p;++y)v+=String.fromCharCode(m[y]);return v;case"base64":return T=this,i=r,0===(E=e)&&i===T.length?A.fromByteArray(T):A.fromByteArray(T.slice(E,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var T=e,E=r,S=this.slice(T,E),L="",b=0;b<S.length;b+=2)L+=String.fromCharCode(S[b]+256*S[b+1]);return L;default:if(s)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),s=!0}}function o(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,s){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,(r=(r=isNaN(r)?s?0:t.length-1:r)<0?t.length+r:r)>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,i,s);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(s?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(t,e,r):m(t,[e],r,i,s);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,i,s){var a=1,n=t.length,o=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;n/=a=2,o/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(s)for(var h=-1,d=r;d<n;d++)if(l(t,d)===l(e,-1===h?0:d-h)){if(d-(h=-1===h?d:h)+1===o)return h*a}else-1!==h&&(d-=d-h),h=-1;else for(d=r=n<r+o?n-o:r;0<=d;d--){for(var u=!0,c=0;c<o;c++)if(l(t,d+c)!==l(e,c)){u=!1;break}if(u)return d}return-1}function y(t,e,r,i){return I(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function R(t,e,r){r=Math.min(t.length,r);for(var i=[],s=e;s<r;){var a,n,o,l,h=t[s],d=null,u=239<h?4:223<h?3:191<h?2:1;if(s+u<=r)switch(u){case 1:h<128&&(d=h);break;case 2:128==(192&(a=t[s+1]))&&127<(l=(31&h)<<6|63&a)&&(d=l);break;case 3:a=t[s+1],n=t[s+2],128==(192&a)&&128==(192&n)&&2047<(l=(15&h)<<12|(63&a)<<6|63&n)&&(l<55296||57343<l)&&(d=l);break;case 4:a=t[s+1],n=t[s+2],o=t[s+3],128==(192&a)&&128==(192&n)&&128==(192&o)&&65535<(l=(15&h)<<18|(63&a)<<12|(63&n)<<6|63&o)&&l<1114112&&(d=l)}null===d?(d=65533,u=1):65535<d&&(i.push((d-=65536)>>>10&1023|55296),d=56320|1023&d),i.push(d),s+=u}var c=i,f=c.length;if(f<=4096)return String.fromCharCode.apply(String,c);for(var g="",m=0;m<f;)g+=String.fromCharCode.apply(String,c.slice(m,m+=4096));return g}function p(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function v(t,e,r,i,s,a){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(s<e||e<a)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function T(t,e,r,i){e<0&&(e=65535+e+1);for(var s=0,a=Math.min(t.length-r,2);s<a;++s)t[r+s]=(e&255<<8*(i?s:1-s))>>>8*(i?s:1-s)}function E(t,e,r,i){e<0&&(e=4294967295+e+1);for(var s=0,a=Math.min(t.length-r,4);s<a;++s)t[r+s]=e>>>8*(i?s:3-s)&255}function S(t,e,r,i){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,i,s){return s||S(t,0,r,4),a.write(t,e,r,i,23,4),r+4}function b(t,e,r,i,s){return s||S(t,0,r,8),a.write(t,e,r,i,52,8),r+8}_.Buffer=u,_.SlowBuffer=function(t){return u.alloc(+(t=+t!=t?0:t))},_.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),_.kMaxLength=r(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return i(null,t,e,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol)&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0}),u.alloc=function(t,e,r){return e=e,r=r,s(t=t),!(t<=0)&&void 0!==e?"string"==typeof r?h(null,t).fill(e,r):h(null,t).fill(e):h(null,t)},u.allocUnsafe=function(t){return n(null,t)},u.allocUnsafeSlow=function(t){return n(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,s=0,a=Math.min(r,i);s<a;++s)if(t[s]!==e[s]){r=t[s],i=e[s];break}return r<i?-1:i<r?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!l(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);if(void 0===e)for(s=e=0;s<t.length;++s)e+=t[s].length;for(var r=u.allocUnsafe(e),i=0,s=0;s<t.length;++s){var a=t[s];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=f,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)o(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)o(this,e,e+3),o(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)o(this,e,e+7),o(this,e+1,e+6),o(this,e+2,e+5),o(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?R(this,0,t):e.apply(this,arguments)},u.prototype.equals=function(t){if(u.isBuffer(t))return this===t||0===u.compare(this,t);throw new TypeError("Argument must be a Buffer")},u.prototype.inspect=function(){var t="",e=_.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e)&&(t+=" ... "),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,i,s){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),(e=void 0===e?0:e)<0||r>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(s<=i&&r<=e)return 0;if(s<=i)return-1;if(r<=e)return 1;if(this===t)return 0;for(var a=(s>>>=0)-(i>>>=0),n=(r>>>=0)-(e>>>=0),o=Math.min(a,n),l=this.slice(i,s),h=t.slice(e,r),d=0;d<o;++d)if(l[d]!==h[d]){a=l[d],n=h[d];break}return a<n?-1:n<a?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},u.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var s=this.length-e;if((void 0===r||s<r)&&(r=s),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i=i||"utf8";for(var a,n,o,l,h,d=!1;;)switch(i){case"hex":var u=this,c=t,f=e,g=r,m=(f=Number(f)||0,u.length-f);if((!g||(g=Number(g))>m)&&(g=m),(m=c.length)%2!=0)throw new TypeError("Invalid hex string");m/2<g&&(g=m/2);for(var p=0;p<g;++p){var v=parseInt(c.substr(2*p,2),16);if(isNaN(v))return p;u[f+p]=v}return p;case"utf8":case"utf-8":return m=e,h=r,I(w(t,(l=this).length-m),l,m,h);case"ascii":return y(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return l=this,h=e,o=r,I(k(t),l,h,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o=e,n=r,I(function(t,e){for(var r,i,s=[],a=0;a<t.length&&!((e-=2)<0);++a)i=(r=t.charCodeAt(a))>>8,s.push(r%256),s.push(i);return s}(t,(a=this).length-o),a,o,n);default:if(d)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),d=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},u.prototype.slice=function(t,e){var r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(s=this.subarray(t,e)).__proto__=u.prototype;else for(var i=e-t,s=new u(i,void 0),a=0;a<i;++a)s[a]=this[a+t];return s},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t],s=1,a=0;++a<e&&(s*=256);)i+=this[t+a]*s;return i},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t+--e],s=1;0<e&&(s*=256);)i+=this[t+--e]*s;return i},u.prototype.readUInt8=function(t,e){return e||p(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||p(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||p(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||p(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||p(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=this[t],s=1,a=0;++a<e&&(s*=256);)i+=this[t+a]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||p(t,e,this.length);for(var i=e,s=1,a=this[t+--i];0<i&&(s*=256);)a+=this[t+--i]*s;return a>=(s*=128)&&(a-=Math.pow(2,8*e)),a},u.prototype.readInt8=function(t,e){return e||p(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||p(t,2,this.length);e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt16BE=function(t,e){e||p(t,2,this.length);e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},u.prototype.readInt32LE=function(t,e){return e||p(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||p(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||p(t,4,this.length),a.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||p(t,4,this.length),a.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||p(t,8,this.length),a.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||p(t,8,this.length),a.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){t=+t,e|=0,r|=0,i||v(this,t,e,r,Math.pow(2,8*r)-1,0);var s=1,a=0;for(this[e]=255&t;++a<r&&(s*=256);)this[e+a]=t/s&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,i){t=+t,e|=0,r|=0,i||v(this,t,e,r,Math.pow(2,8*r)-1,0);var s=r-1,a=1;for(this[e+s]=255&t;0<=--s&&(a*=256);)this[e+s]=t/a&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):T(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):T(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):E(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){t=+t,e|=0,i||v(this,t,e,r,(i=Math.pow(2,8*r-1))-1,-i);var s=0,a=1,n=0;for(this[e]=255&t;++s<r&&(a*=256);)t<0&&0===n&&0!==this[e+s-1]&&(n=1),this[e+s]=(t/a>>0)-n&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){t=+t,e|=0,i||v(this,t,e,r,(i=Math.pow(2,8*r-1))-1,-i);var s=r-1,a=1,n=0;for(this[e+s]=255&t;0<=--s&&(a*=256);)t<0&&0===n&&0!==this[e+s+1]&&(n=1),this[e+s]=(t/a>>0)-n&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&(t=t<0?255+t+1:t),e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):T(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):T(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):E(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||v(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):E(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return b(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return b(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r=r||0,i||0===i||(i=this.length),e>=t.length&&(e=t.length),(i=0<i&&i<r?r:i)===r)return 0;if(0===t.length||0===this.length)return 0;if((e=e||0)<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length);var s,a=(i=t.length-e<i-r?t.length-e+r:i)-r;if(this===t&&r<e&&e<i)for(s=a-1;0<=s;--s)t[s+e]=this[s+r];else if(a<1e3||!u.TYPED_ARRAY_SUPPORT)for(s=0;s<a;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+a),e);return a},u.prototype.fill=function(t,e,r,i){if("string"==typeof t){var s;if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length&&(s=t.charCodeAt(0))<256&&(t=s),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(!(r<=e))if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(o=e;o<r;++o)this[o]=t;else for(var a=u.isBuffer(t)?t:w(new u(t,i).toString()),n=a.length,o=0;o<r-e;++o)this[o+e]=a[o%n];return this};var D=/[^+\/0-9A-Za-z-_]/g;function w(t,e){var r;e=e||1/0;for(var i=t.length,s=null,a=[],n=0;n<i;++n){if(55295<(r=t.charCodeAt(n))&&r<57344){if(!s){if(56319<r){-1<(e-=3)&&a.push(239,191,189);continue}if(n+1===i){-1<(e-=3)&&a.push(239,191,189);continue}s=r;continue}if(r<56320){-1<(e-=3)&&a.push(239,191,189),s=r;continue}r=65536+(s-55296<<10|r-56320)}else s&&-1<(e-=3)&&a.push(239,191,189);if(s=null,r<128){if(--e<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function k(t){return A.toByteArray(function(t){if((t=((e=t).trim?e.trim():e.replace(/^\s+|\s+$/g,"")).replace(D,"")).length<2)return"";for(var e;t.length%4!=0;)t+="=";return t}(t))}function I(t,e,r,i){for(var s=0;s<i&&!(s+r>=e.length||s>=t.length);++s)e[s+r]=t[s];return s}}.call(this,C(30))},559:function(t,e){function r(){return t.exports=r=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},t.exports.__esModule=!0,t.exports.default=t.exports,r.apply(this,arguments)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},564:function(t,e,r){var i=r(685);t.exports=function(t){return null==t?"":i(t)}},566:function(t,s,a){!function(t){var e=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function i(t,e){this._id=t,this._clearFn=e}s.setTimeout=function(){return new i(r.call(setTimeout,e,arguments),clearTimeout)},s.setInterval=function(){return new i(r.call(setInterval,e,arguments),clearInterval)},s.clearTimeout=s.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(e,this._id)},s.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},s.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},s._unrefActive=s.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;0<=e&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a(747),s.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,s.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}.call(this,a(30))},573:function(t,e,r){"use strict";var{default:r,DraggableCore:i}=r(707);t.exports=r,t.exports.default=r,t.exports.DraggableCore=i},574:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.dontSetMe=function(t,e,r){if(t[e])return new Error("Invalid prop ".concat(e," passed to ").concat(r," - do not set this, set it on the child."))},e.findInArray=function(r,i){for(let t=0,e=r.length;t<e;t++)if(i.apply(i,[r[t],t,r]))return r[t]},e.int=function(t){return parseInt(t,10)},e.isFunction=function(t){return"function"==typeof t||"[object Function]"===Object.prototype.toString.call(t)},e.isNum=function(t){return"number"==typeof t&&!isNaN(t)}},579:function(t,e,r){"use strict";t.exports=r(660)},582:function(t,e){t.exports=function(t,e){if(null==t)return{};for(var r,i={},s=Object.keys(t),a=0;a<s.length;a++)r=s[a],0<=e.indexOf(r)||(i[r]=t[r]);return i},t.exports.__esModule=!0,t.exports.default=t.exports},586:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.addClassName=h,e.addEvent=function(t,e,r,i){t&&(i={capture:!0,...i},t.addEventListener?t.addEventListener(e,r,i):t.attachEvent?t.attachEvent("on"+e,r):t["on"+e]=r)},e.addUserSelectStyles=function(t){var e;t&&((e=t.getElementById("react-draggable-style-el"))||((e=t.createElement("style")).type="text/css",e.id="react-draggable-style-el",e.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",e.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",t.getElementsByTagName("head")[0].appendChild(e)),t.body)&&h(t.body,"react-draggable-transparent-selection")},e.createCSSTransform=function(t,e){t=l(t,e,"px");return{[(0,s.browserPrefixToKey)("transform",s.default)]:t}},e.createSVGTransform=function(t,e){return l(t,e,"")},e.getTouch=function(t,e){return t.targetTouches&&(0,i.findInArray)(t.targetTouches,t=>e===t.identifier)||t.changedTouches&&(0,i.findInArray)(t.changedTouches,t=>e===t.identifier)},e.getTouchIdentifier=function(t){return t.targetTouches&&t.targetTouches[0]?t.targetTouches[0].identifier:t.changedTouches&&t.changedTouches[0]?t.changedTouches[0].identifier:void 0},e.getTranslation=l,e.innerHeight=function(t){var e=t.clientHeight,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e-=(0,i.int)(t.paddingTop))-(0,i.int)(t.paddingBottom)},e.innerWidth=function(t){var e=t.clientWidth,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e-=(0,i.int)(t.paddingLeft))-(0,i.int)(t.paddingRight)},e.matchesSelector=o,e.matchesSelectorAndParentsTo=function(t,e,r){let i=t;do{if(o(i,e))return!0;if(i===r)return!1}while(i=i.parentNode);return!1},e.offsetXYFromParent=function(t,e,r){var i=e===e.ownerDocument.body?{left:0,top:0}:e.getBoundingClientRect();return{x:(t.clientX+e.scrollLeft-i.left)/r,y:(t.clientY+e.scrollTop-i.top)/r}},e.outerHeight=function(t){var e=t.clientHeight,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e+=(0,i.int)(t.borderTopWidth))+(0,i.int)(t.borderBottomWidth)},e.outerWidth=function(t){var e=t.clientWidth,t=t.ownerDocument.defaultView.getComputedStyle(t);return(e+=(0,i.int)(t.borderLeftWidth))+(0,i.int)(t.borderRightWidth)},e.removeClassName=d,e.removeEvent=function(t,e,r,i){t&&(i={capture:!0,...i},t.removeEventListener?t.removeEventListener(e,r,i):t.detachEvent?t.detachEvent("on"+e,r):t["on"+e]=null)},e.removeUserSelectStyles=function(t){if(t)try{var e;t.body&&d(t.body,"react-draggable-transparent-selection"),t.selection?t.selection.empty():(e=(t.defaultView||window).getSelection())&&"Caret"!==e.type&&e.removeAllRanges()}catch(t){}};var i=r(574),s=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=n(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(708));function n(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(n=function(t){return t?r:e})(t))}let a="";function o(e,t){return a=a||(0,i.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(t){return(0,i.isFunction)(e[t])}),!!(0,i.isFunction)(e[a])&&e[a](t)}function l(t,e,r){let{x:i,y:s}=t,a="translate(".concat(i).concat(r,",").concat(s).concat(r,")");if(e){const t="".concat("string"==typeof e.x?e.x:e.x+r),i="".concat("string"==typeof e.y?e.y:e.y+r);a="translate(".concat(t,", ").concat(i,")")+a}return a}function h(t,e){t.classList?t.classList.add(e):t.className.match(new RegExp("(?:^|\\s)".concat(e,"(?!\\S)")))||(t.className+=" ".concat(e))}function d(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(?:^|\\s)".concat(e,"(?!\\S)"),"g"),"")}},601:function(t,e,r){"use strict";e.a={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},602:function(t,e,r){"use strict";r.r(e),e.default=function(e){var r={};return function(t){return void 0===r[t]&&(r[t]=e(t)),r[t]}}},605:function(t,e){t.exports=function(t,e){for(var r=-1,i=null==t?0:t.length,s=Array(i);++r<i;)s[r]=e(t[r],r,t);return s}},611:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.canDragX=function(t){return"both"===t.props.axis||"x"===t.props.axis},e.canDragY=function(t){return"both"===t.props.axis||"y"===t.props.axis},e.createCoreData=function(t,e,r){var i=!(0,l.isNum)(t.lastX),s=d(t);return i?{node:s,deltaX:0,deltaY:0,lastX:e,lastY:r,x:e,y:r}:{node:s,deltaX:e-t.lastX,deltaY:r-t.lastY,lastX:t.lastX,lastY:t.lastY,x:e,y:r}},e.createDraggableData=function(t,e){var r=t.props.scale;return{node:e.node,x:t.state.x+e.deltaX/r,y:t.state.y+e.deltaY/r,deltaX:e.deltaX/r,deltaY:e.deltaY/r,lastX:t.state.x,lastY:t.state.y}},e.getBoundPosition=function(e,r,i){if(e.props.bounds){let t=e.props["bounds"];t="string"==typeof t?t:{left:(s=t).left,top:s.top,right:s.right,bottom:s.bottom};var s=d(e);if("string"==typeof t){const e=s["ownerDocument"],r=e.defaultView;var a="parent"===t?s.parentNode:e.querySelector(t);if(!(a instanceof r.HTMLElement))throw new Error('Bounds selector "'+t+'" could not find an element.');const d=a,n=r.getComputedStyle(s),o=r.getComputedStyle(d);t={left:-s.offsetLeft+(0,l.int)(o.paddingLeft)+(0,l.int)(n.marginLeft),top:-s.offsetTop+(0,l.int)(o.paddingTop)+(0,l.int)(n.marginTop),right:(0,h.innerWidth)(d)-(0,h.outerWidth)(s)-s.offsetLeft+(0,l.int)(o.paddingRight)-(0,l.int)(n.marginRight),bottom:(0,h.innerHeight)(d)-(0,h.outerHeight)(s)-s.offsetTop+(0,l.int)(o.paddingBottom)-(0,l.int)(n.marginBottom)}}(0,l.isNum)(t.right)&&(r=Math.min(r,t.right)),(0,l.isNum)(t.bottom)&&(i=Math.min(i,t.bottom)),(0,l.isNum)(t.left)&&(r=Math.max(r,t.left)),(0,l.isNum)(t.top)&&(i=Math.max(i,t.top))}return[r,i]},e.getControlPosition=function(t,e,r){var i="number"==typeof e?(0,h.getTouch)(t,e):null;return"number"!=typeof e||i?(e=d(r),e=r.props.offsetParent||e.offsetParent||e.ownerDocument.body,(0,h.offsetXYFromParent)(i||t,e,r.props.scale)):null},e.snapToGrid=function(t,e,r){return[Math.round(e/t[0])*t[0],Math.round(r/t[1])*t[1]]};var l=r(574),h=r(586);function d(t){t=t.findDOMNode();if(t)return t;throw new Error("<DraggableCore>: Unmounted during event!")}},612:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){}},643:function(i,t,e){"use strict";e.d(t,"a",function(){return xs});s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,o=/^(?=([^\/?#]*))\1([^]*)$/,l=/(?:\/|^)\.(?=\/)/g,h=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var i=a.parseURL(t);if(i)return i.path=a.normalizePath(i.path),a.buildURLFromParts(i);throw new Error("Error trying to parse base URL.")}i=a.parseURL(e);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):e;e=a.parseURL(t);if(!e)throw new Error("Error trying to parse base URL.");!e.netLoc&&e.path&&"/"!==e.path[0]&&(t=o.exec(e.path),e.netLoc=t[1],e.path=t[2]),e.netLoc&&!e.path&&(e.path="/");var s,t={scheme:e.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(t.netLoc=e.netLoc,"/"===i.path[0])||(i.path?(s=(s=e.path).substring(0,s.lastIndexOf("/")+1)+i.path,t.path=a.normalizePath(s)):(t.path=e.path,i.params||(t.params=e.params,i.query)||(t.query=e.query))),null===t.path&&(t.path=r.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(t)},parseURL:function(t){t=s.exec(t);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(l,"");t.length!==(t=t.replace(h,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};var s,o,l,h,a,$=a;function K(e,t){var r,i=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)),i}function m(i){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?K(Object(s),!0).forEach(function(t){var e,r;e=i,t=s[r=t],(r=function(){var t=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(r);return"symbol"==typeof t?t:String(t)}())in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(s)):K(Object(s)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(s,t))})}return i}function k(){return(k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}const D=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)};(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.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached";let I=e,_=((t={}).NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t),C=((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);function H(){}const V={trace:H,debug:H,log:H,warn:H,info:H,error:H};let Y=V;function W(r,...t){t.forEach(function(t){var e;Y[t]=r[t]?r[t].bind(r):(e=self.console[t])?e.bind(self.console,`[${t}] >`):H})}const P=Y,j=/^(\d+)x(\d+)$/,q=/(.+?)=(".*?"|.*?)(?:,|$)/g;class w{constructor(t){for(const e in t="string"==typeof t?w.parseAttrList(t):t)t.hasOwnProperty(e)&&("X-"===e.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){t=parseInt(this[t],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(t){if(this[t]){var e=(1&(e=(this[t]||"0x").slice(2)).length?"0":"")+e,r=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)r[t]=parseInt(e.slice(2*t,2*t+2),16);return r}return null}hexadecimalIntegerAsNumber(t){t=parseInt(this[t],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){t=this[t];return t?parseFloat(t):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){t=j.exec(this[t]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(t){var e,r={};for(q.lastIndex=0;null!==(e=q.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1)),r[e[1].trim()]=t}return r}}class X{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(const e in r)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==r[e]){P.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=k(new w({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);D(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var t;return this._endDate||(null!==(t=this.duration)?new Date(this._startDate.getTime()+1e3*t):null)}get duration(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(D(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&D(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class z{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var S="audio",b="video",Q="audiovideo";class J{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={audio:null,video:null,audiovideo:null},this.baseurl=t}setByteRange(t,e){var t=t.split("@",2),r=[];1===t.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=$.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Z extends J{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new z,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const t=this["levelkeys"];if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var t;return null!==this.programDateTime&&D(this.programDateTime)?(t=D(this.duration)?this.duration:0,this.programDateTime+1e3*t):null}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(1<e||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(t){this.levelkeys&&(t=this.levelkeys[t])&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}abortRequests(){var t;null!=(t=this.loader)&&t.abort(),null!=(t=this.keyLoader)&&t.abort()}setElementaryStreamInfo(t,e,r,i,s,a=!1){var n=this["elementaryStreams"],o=n[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):n[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:s,partial:a}}clearElementaryStreamInfo(){var t=this["elementaryStreams"];t[S]=null,t[b]=null,t[Q]=null}}class tt extends J{constructor(t,e,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new z,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=i;r=t.enumeratedString("BYTERANGE");r&&this.setByteRange(r,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){var t=this["elementaryStreams"];return!!(t.audio||t.video||t.audiovideo)}}class et{constructor(t){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=t}reloaded(t){var e,r;t?(e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex,this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||0<e||0==e&&0<r,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay):(this.advanced=!0,this.updated=!0)}get hasProgramDateTime(){return!!this.fragments.length&&D(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){var t=this.driftEndTime-this.driftStartTime;return 0<t?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function rt(t){return Uint8Array.from(atob(t),t=>t.charCodeAt(0))}function it(t){return Uint8Array.from(unescape(encodeURIComponent(t)),t=>t.charCodeAt(0))}var u={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},st="org.w3.clearkey",at="com.apple.streamingkeydelivery",nt="com.microsoft.playready",ot="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function lt(t){switch(t){case at:return u.FAIRPLAY;case nt:return u.PLAYREADY;case ot:return u.WIDEVINE;case st:return u.CLEARKEY}}var ht="edef8ba979d64acea3c827dcd51d21ed";function dt(t){switch(t){case u.FAIRPLAY:return at;case u.PLAYREADY:return nt;case u.WIDEVINE:return ot;case u.CLEARKEY:return st}}function ut(t){const{drmSystems:e,widevineLicenseUrl:r}=t,i=e?[u.FAIRPLAY,u.WIDEVINE,u.PLAYREADY,u.CLEARKEY].filter(t=>!!e[t]):[];return!i[u.WIDEVINE]&&r&&i.push(u.WIDEVINE),i}const ct="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ft(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}const gt=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,mt=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,pt=(t,e)=>{var r=e;let i=0;for(;gt(t,e);)i=(i+=10)+vt(t,e+6),mt(t,e+10)&&(i+=10),e+=i;if(0<i)return t.subarray(r,r+i)},vt=(t,e)=>{var r=(127&t[e])<<21;return(r|=(127&t[e+1])<<14)|(127&t[e+2])<<7|127&t[e+3]},yt=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,Tt=t=>{let e=0;for(var r,i=[];gt(t,e);){for(var s=vt(t,e+6),a=(e+=10)+s;e+8<a;){r=t.subarray(e),o=n=void 0,n=String.fromCharCode(r[0],r[1],r[2],r[3]),o=vt(r,4);var n={type:n,size:o,data:r.subarray(10,10+o)},o=("PRIV"===(r=n).type?Et:"W"===r.type[0]?Lt:St)(r);o&&i.push(o),e+=n.size+10}mt(t,e)&&(e+=10)}return i},Et=t=>{var e,r;if(!(t.size<2))return e=A(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1)),{key:t.type,info:e,data:r.buffer}},St=t=>{var e,r;if(!(t.size<2))return"TXXX"===t.type?(e=1,e+=(r=A(t.data.subarray(1),!0)).length+1,e=A(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=A(t.data.subarray(1)),{key:t.type,data:r})},Lt=t=>{var e,r;return"WXXX"===t.type?t.size<2?void 0:(e=1,e+=(r=A(t.data.subarray(1),!0)).length+1,e=A(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=A(t.data),{key:t.type,data:r})},A=(t,e=!1)=>{var r=bt=bt||void 0===self.TextDecoder?bt:new self.TextDecoder("utf-8");if(r){const i=r.decode(t);if(e){const t=i.indexOf("\0");return-1!==t?i.substring(0,t):i}return i.replace(/\0/g,"")}const i=t.length;let s,a,n,o="",l=0;for(;l<i;){if(0===(s=t[l++])&&e)return o;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:a=t[l++],o+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[l++],n=t[l++],o+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&n)<<0)}}return o};let bt;function c(r){let i="";for(let e=0;e<r.length;e++){let t=r[e].toString(16);t.length<2&&(t="0"+t),i+=t}return i}const At=Math.pow(2,32)-1,Rt=[].push,Dt={video:1,audio:2,id3:3,text:4};function f(t){return String.fromCharCode.apply(null,t)}function wt(t,e){t=t[e]<<8|t[e+1];return t<0?65536+t:t}function R(t,e){t=kt(t,e);return t<0?4294967296+t:t}function kt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function It(t,e,r){t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function x(e,r){var i=[];if(r.length){const a=e.byteLength;for(let t=0;t<a;){var s=R(e,t),s=1<s?t+s:a;if(f(e.subarray(t+4,t+8))===r[0])if(1===r.length)i.push(e.subarray(t+8,s));else{const a=x(e.subarray(t+8,s),r.slice(1));a.length&&Rt.apply(i,a)}t=s}}return i}function _t(e){const r=[],i=x(e,["moov","trak"]);for(let t=0;t<i.length;t++){var s=i[t],a=x(s,["tkhd"])[0];if(a){var a=R(a,0===a[0]?12:20),n=x(s,["mdia","mdhd"])[0];if(n){var n=R(n,0===n[0]?12:20),o=x(s,["mdia","hdlr"])[0];if(o){const e=f(o.subarray(8,12)),i={soun:S,vide:b}[e];if(i){const e=x(s,["mdia","minf","stbl","stsd"])[0];let t;e&&(t=f(e.subarray(12,16))),r[a]={timescale:n,type:i},r[i]={timescale:n,id:a,codec:t}}}}}}return x(e,["moov","mvex","trex"]).forEach(t=>{var e=R(t,4),e=r[e];e&&(e.default={duration:R(t,12),flags:R(t,20)})}),r}function Ct(t){var e=x(t,["schm"])[0];if(e){e=f(e.subarray(4,8));if("cbcs"===e||"cenc"===e)return x(t,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function Pt(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function xt(v,y){const T=[],E=y.samples,S=y.timescale,o=y.id;let L=!1;return x(E,["moof"]).map(t=>{const p=t.byteOffset-8;x(t,["traf"]).map(n=>{var t=x(n,["tfdt"]).map(t=>{var e=t[0];let r=R(t,4);return(r=1===e?(r*=Math.pow(2,32))+R(t,8):r)/S})[0];return void 0!==t&&(v=t),x(n,["tfhd"]).map(t=>{var e=R(t,4),r=16777215&R(t,0);let g=0;var i=0!=(16&r);let m=0;var s=0!=(32&r);let a=8;e===o&&(0!=(1&r)&&(a+=8),0!=(2&r)&&(a+=4),0!=(8&r)&&(g=R(t,a),a+=4),i&&(m=R(t,a),a+=4),s&&(a+=4),"video"===y.type&&(L=!!(e=y.codec)&&("hvc1"===(e=(r=e.indexOf("."))<0?e:e.substring(0,r))||"hev1"===e||"dvh1"===e||"dvhe"===e)),x(n,["trun"]).map(e=>{var r=e[0],t=16777215&R(e,0);let i=0;var s=0!=(256&t);let a=0;var n=0!=(512&t);let o=0;var l=0!=(1024&t),h=0!=(2048&t);let d=0;var u=R(e,4);let c=8,f=(0!=(1&t)&&(i=R(e,c),c+=4),0!=(4&t)&&(c+=4),i+p);for(let t=0;t<u;t++){if(s?(a=R(e,c),c+=4):a=g,n?(o=R(e,c),c+=4):o=m,l&&(c+=4),h&&(d=(0===r?R:kt)(e,c),c+=4),y.type===b){let t=0;for(;t<o;){const e=R(E,f);f+=4,function(t,e){if(t){const t=e>>1&63;return 39==t||40==t}return 6==(31&e)}(L,E[f])&&Mt(E.subarray(f,f+e),L?2:1,v+d/S,T),f+=e,t+=e+4}}v+=a/S}}))})})}),T}function Mt(e,r,i,t){var s=Ot(e);let a=0,n=(a+=r,0),o=0,l=!1,h=0;for(;a<s.length;){for(n=0;!(a>=s.length)&&(h=s[a++],n+=h,255===h););for(o=0;!(a>=s.length)&&(h=s[a++],o+=h,255===h););const e=s.length-a;if(!l&&4===n&&a<s.length){if(l=!0,181===s[a++]){const e=wt(s,a);if(a+=2,49===e){const e=R(s,a);if(a+=4,1195456820===e){const e=s[a++];if(3===e){const r=s[a++],o=31&r,l=64&r,h=l?2+3*o:0,d=new Uint8Array(h);if(l){d[0]=r;for(let t=1;t<h;t++)d[t]=s[a++]}t.push({type:e,payloadType:n,pts:i,bytes:d})}}}}}else if(5===n&&o<e){if(l=!0,16<o){const e=[];for(let t=0;t<16;t++){const i=s[a++].toString(16);e.push(1==i.length?"0"+i:i),3!==t&&5!==t&&7!==t&&9!==t||e.push("-")}const r=o-16,l=new Uint8Array(r);for(let t=0;t<r;t++)l[t]=s[a++];t.push({payloadType:n,pts:i,uuid:e.join(""),userData:A(l),userDataBytes:l})}}else if(o<e)a+=o;else if(o>e)break}}function Ot(t){var e=t.byteLength,r=[];let i=1;for(;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return t;var s=e-r.length,a=new Uint8Array(s);let n=0;for(i=0;i<s;n++,i++)n===r[0]&&(n++,r.shift()),a[i]=t[n];return a}let Ft={};class Nt{static clearKeyUriToKeyIdMap(){Ft={}}constructor(t,e,r,i=[1],s=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=t,this.uri=e,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}isSupported(){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 at:case ot:case nt:case st:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(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||P.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const e=function(e){var r=new Uint8Array(16);for(let t=12;t<16;t++)r[t]=e>>8*(15-t)&255;return r}(t);return new Nt(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=function(t){const e=t.split(":");let r=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),a=t[t.length-1].split(",");if(2===a.length){const e="base64"===a[0],n=a[1];r=e?(t.splice(-1,1),rt(n)):(i=it(n).subarray(0,16),(s=new Uint8Array(16)).set(i,16-i.length),s)}}var i,s;return r}(this.uri);if(e)switch(this.keyFormat){case ot:22<=(this.pssh=e).length&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case nt:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(r,e,i){if(16!==r.byteLength)throw new RangeError("Invalid system id");let s,a,n;if(e){s=1,a=new Uint8Array(16*e.length);for(let t=0;t<e.length;t++){const i=e[t];if(16!==i.byteLength)throw new RangeError("Invalid key");a.set(i,16*t)}}else s=0,a=new Uint8Array;0<s?(n=new Uint8Array(4),0<e.length&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;var o=new Uint8Array(4);i&&0<i.byteLength&&new DataView(o.buffer).setUint32(0,i.byteLength,!1);{var l=[new Uint8Array([s,0,0,0]),r,n,a,o,i||new Uint8Array],h=l.length;let t=8,e=h;for(;e--;)t+=l[e].byteLength;var d=new Uint8Array(t);for(d[0]=t>>24&255,d[1]=t>>16&255,d[2]=t>>8&255,d[3]=255&t,d.set([112,115,115,104],4),e=0,t=8;e<h;e++)d.set(l[e],t),t+=l[e].byteLength;return d}}(t,null,e);var r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(r)),r=r.substring(r.indexOf("<"),r.length),r=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(r){const t=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(t){const e=rt(t).subarray(0,16);r=e,i(r,0,3),i(r,1,2),i(r,4,5),i(r,6,7),this.keyId=e}}break}default:{let t=e.subarray(0,16);if(16!==t.length){const e=new Uint8Array(16);e.set(t,16-t.length),t=e}this.keyId=t;break}}function i(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}if(!this.keyId||16!==this.keyId.byteLength){let t=Ft[this.uri];if(!t){const e=Object.keys(Ft).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16),new DataView(t.buffer,12,4).setUint32(0,e),Ft[this.uri]=t}this.keyId=t}return this}}const Ut=/\{\$([a-zA-Z0-9-_]+)\}/g;function Bt(t){return Ut.test(t)}function M(e,r,i){if(null!==e.variableList||e.hasVariableRefs)for(let t=i.length;t--;){var s=i[t],a=r[s];a&&(r[s]=Gt(e,a))}}function Gt(i,t){if(null!==i.variableList||i.hasVariableRefs){const s=i.variableList;return t.replace(Ut,t=>{var e=t.substring(2,t.length-1),r=null==s?void 0:s[e];return void 0===r?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${e}"`)),t):r})}return t}function $t(t,e,r){let i,s,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{const t=new self.URL(r).searchParams;if(!t.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);s=t.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else i=e.NAME,s=e.VALUE;i in a?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):a[i]=s||""}function Kt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Ht={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Vt=Kt();function Yt(t,e){return null!=(e=null==Vt?void 0:Vt.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))&&e}const Wt=/#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,jt=/#EXT-X-MEDIA:(.*)/g,qt=/^#EXT(?:INF|-X-TARGETDURATION):/m,Xt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),zt=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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class g{static findGroup(e,r){for(let t=0;t<e.length;t++){var i=e[t];if(i.id===r)return i}}static convertAVC1ToAVCOTI(t){var e,r=t.split(".");return 2<r.length?(e=r.shift()+".",(e+=parseInt(r.shift()).toString(16))+("000"+parseInt(r.shift()).toString(16)).slice(-4)):t}static resolve(t,e){return $.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return qt.test(t)}static parseMasterPlaylist(t,e){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Bt(t)},i=[];var s,a;for(Wt.lastIndex=0;null!=(s=Wt.exec(t));)if(s[1]){const t=new w(s[1]),n=(M(r,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]),Gt(r,s[2])),o={attrs:t,bitrate:t.decimalInteger("AVERAGE-BANDWIDTH")||t.decimalInteger("BANDWIDTH"),name:t.NAME,url:g.resolve(n,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),function(i,s){["video","audio","text"].forEach(r=>{const e=i.filter(t=>{var e=r;return!!(e=Ht[e])&&!0===e[t.slice(0,4)]});var t;e.length&&(t=e.filter(t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)),s[r+"Codec"]=(0<t.length?t:e)[0],i=i.filter(t=>-1===e.indexOf(t)))}),s.unknownCodecs=i}((t.CODECS||"").split(/[ ,]+/).filter(t=>t),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=g.convertAVC1ToAVCOTI(o.videoCodec)),null!=(a=o.unknownCodecs)&&a.length||i.push(o),r.levels.push(o)}else if(s[3]){const t=s[3],i=s[4];switch(t){case"SESSION-DATA":{const t=new w(i),e=(M(r,t,["DATA-ID","LANGUAGE","VALUE","URI"]),t["DATA-ID"]);e&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[e]=t);break}case"SESSION-KEY":{const t=Qt(i,e,r);t.encrypted&&t.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(t)):P.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const t=new w(i);M(r,t,["NAME","VALUE","QUERYPARAM"]),$t(r,t,e)}break;case"CONTENT-STEERING":{const t=new w(i);M(r,t,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:g.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Jt(i)}}const n=0<i.length&&i.length<r.levels.length;return r.levels=n?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(t,e,r){let i;const s={},a=r.levels,n={AUDIO:a.map(t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec})),SUBTITLES:a.map(t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(jt.lastIndex=0;null!==(i=jt.exec(t));){const t=new w(i[1]),a=t.TYPE;if(a){const i=n[a],h=s[a]||[];s[a]=h,M(r,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var l={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",instreamId:t["INSTREAM-ID"],name:t.NAME||t.LANGUAGE||"",type:a,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:t.LANGUAGE,url:t.URI?g.resolve(t.URI,e):""};if(null!=i&&i.length){const t=g.findGroup(i,l.groupId)||i[0];Zt(l,t,"audioCodec"),Zt(l,t,"textCodec")}h.push(l)}}return s}static parseLevelPlaylist(t,e,r,i,s,a){const n=new et(e),o=n.fragments;let l,h,d,u=null,c=0,f=0,g=0,m=0,p=null,v=new Z(i,e),y=-1,T=!1;for(Xt.lastIndex=0,n.m3u8=t,n.hasVariableRefs=Bt(t);null!==(l=Xt.exec(t));){T&&(T=!1,(v=new Z(i,e)).start=g,v.sn=c,v.cc=m,v.level=r,u)&&(v.initSegment=u,v.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null);const t=l[1];if(t){v.duration=parseFloat(t);const e=(" "+l[2]).slice(1);v.title=e||null,v.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(D(v.duration)){v.start=g,d&&re(v,d,n),v.sn=c,v.level=r,v.cc=m,v.urlId=s,o.push(v);const t=(" "+l[3]).slice(1);v.relurl=Gt(n,t),te(v,p),p=v,g+=v.duration,c++,f=0,T=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);p?v.setByteRange(t,p):v.setByteRange(t)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else if(l=l[0].match(zt)){for(h=1;h<l.length&&void 0===l[h];h++);const t=(" "+l[h]).slice(1),s=(" "+l[h+1]).slice(1),g=l[h+2]?(" "+l[h+2]).slice(1):"";switch(t){case"PLAYLIST-TYPE":n.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":c=n.startSN=parseInt(s);break;case"SKIP":{const t=new w(s),e=(M(n,t,["RECENTLY-REMOVED-DATERANGES"]),t.decimalInteger("SKIPPED-SEGMENTS"));if(D(e)){for(let t=n.skippedSegments=e;t--;)o.unshift(null);c+=e}const r=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(n.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":n.targetduration=Math.max(parseInt(s),1);break;case"VERSION":n.version=parseInt(s);break;case"EXTM3U":break;case"ENDLIST":n.live=!1;break;case"#":(s||g)&&v.tagList.push(g?[s,g]:[s]);break;case"DISCONTINUITY":m++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([t]);break;case"BITRATE":v.tagList.push([t,s]);break;case"DATERANGE":{const t=new w(s),e=(M(n,t,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),M(n,t,t.clientAttrs),new X(t,n.dateRanges[t.ID]));e.isValid||n.skippedSegments?n.dateRanges[e.id]=e:P.warn(`Ignoring invalid DATERANGE tag: "${s}"`),v.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const t=new w(s);if(M(n,t,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in t){E=void 0;S=void 0;L=void 0;var E=n;var S=t;var L=a;if(S=S.IMPORT,L&&S in L){let t=E.variableList;t||(E.variableList=t={}),t[S]=L[S]}else E.playlistParsingError||(E.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${S}"`))}else $t(n,t,e)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(s);break;case"KEY":{const t=Qt(s,e,n);if(t.isSupported()){if("NONE"===t.method){d=void 0;break}(d=(d=d||{})[t.keyFormat]?k({},d):d)[t.keyFormat]=t}else P.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${s}"`);break}case"START":n.startTimeOffset=Jt(s);break;case"MAP":{const t=new w(s);if(M(n,t,["BYTERANGE","URI"]),v.duration){const s=new Z(i,e);ee(s,t,r,d),u=s,(v.initSegment=u).rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=u.rawProgramDateTime)}else ee(v,t,r,d),u=v,T=!0;break}case"SERVER-CONTROL":{const t=new w(s);n.canBlockReload=t.bool("CAN-BLOCK-RELOAD"),n.canSkipUntil=t.optionalFloat("CAN-SKIP-UNTIL",0),n.canSkipDateRanges=0<n.canSkipUntil&&t.bool("CAN-SKIP-DATERANGES"),n.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),n.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new w(s);n.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=n.partList;t=t||(n.partList=[]);const r=0<f?t[t.length-1]:void 0,i=f++,a=new w(s),o=(M(n,a,["BYTERANGE","URI"]),new tt(a,v,e,i,r));t.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new w(s);M(n,t,["URI"]),n.preloadHint=t;break}case"RENDITION-REPORT":{const t=new w(s);M(n,t,["URI"]),n.renditionReports=n.renditionReports||[],n.renditionReports.push(t);break}default:P.warn("line parsed but not handled: "+l)}}else P.warn("No matches on slow regex match for level playlist!")}p&&!p.relurl?(o.pop(),g-=p.duration,n.partList&&(n.fragmentHint=p)):n.partList&&(te(v,p),v.cc=m,n.fragmentHint=v,d)&&re(v,d,n);var b=o.length,A=o[0],R=o[b-1];if(0<(g+=n.skippedSegments*n.targetduration)&&b&&R){n.averagetargetduration=g/b;const t=R.sn;n.endSN="initSegment"!==t?t:0,n.live||(R.endList=!0),A&&(n.startCC=A.cc)}else n.endSN=0,n.startCC=0;return n.fragmentHint&&(g+=n.fragmentHint.duration),n.totalduration=g,n.endCC=m,0<y&&function(e,r){let i=e[r];for(let t=r;t--;){const r=e[t];if(!r)return;r.programDateTime=i.programDateTime-1e3*r.duration,i=r}}(o,y),n}}function Qt(t,e,r){var t=new w(t),r=(M(r,t,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]),null!=(r=t.METHOD)?r:""),i=t.URI,s=t.hexadecimalInteger("IV"),a=t.KEYFORMATVERSIONS,n=null!=(n=t.KEYFORMAT)?n:"identity",t=(i&&t.IV&&!s&&P.error("Invalid IV: "+t.IV),i?g.resolve(i,e):""),i=(a||"1").split("/").map(Number).filter(Number.isFinite);return new Nt(r,t,n,i,s)}function Jt(t){t=new w(t).decimalFloatingPoint("TIME-OFFSET");return D(t)?t:null}function Zt(t,e,r){e=e[r];e&&(t[r]=e)}function te(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),D(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function ee(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function re(t,e,r){t.levelkeys=e;r=r.encryptedFragments;r.length&&r[r.length-1].levelkeys===e||!Object.keys(e).some(t=>e[t].isCommonEncryption)||r.push(t)}var ie="manifest",se="level",p="audioTrack",v="subtitleTrack",y="main",L="audio",ae="subtitle";function ne(t){t=t.type;switch(t){case p:return L;case v:return ae;default:return y}}function oe(t,e){let r=t.url;return r=void 0!==r&&0!==r.indexOf("data:")?r:e.url}class le{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){var e=this.hls.config,r=e.pLoader,i=e.loader,r=new(r||i)(e);return this.loaders[t.type]=r}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){e=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ie,url:e,deliveryDirectives:null})}onLevelLoading(t,e){var{id:e,level:r,url:i,deliveryDirectives:s}=e;this.load({id:e,level:r,responseType:"text",type:se,url:i,deliveryDirectives:s})}onAudioTrackLoading(t,e){var{id:e,groupId:r,url:i,deliveryDirectives:s}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:p,url:i,deliveryDirectives:s})}onSubtitleTrackLoading(t,e){var{id:e,groupId:r,url:i,deliveryDirectives:s}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:v,url:i,deliveryDirectives:s})}load(e){const r=this.hls.config;let i,t=this.getInternalLoader(e);if(t){const s=t.context;if(s&&s.url===e.url)return void P.trace("[playlist-loader]: playlist request ongoing");P.log("[playlist-loader]: aborting previous loader for type: "+e.type),t.abort()}if(i=e.type===ie?r.manifestLoadPolicy.default:k({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),t=this.createInternalLoader(e),null!=(s=e.deliveryDirectives)&&s.part){let t;if(e.type===se&&null!==e.level?t=this.hls.levels[e.level].details:e.type===p&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===v&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const s=1e3*Math.max(3*e,.8*r);i=k({},i,{maxTimeToFirstByteMs:Math.min(s,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(s,i.maxTimeToFirstByteMs)})}}}var s=i.errorRetry||i.timeoutRetry||{},s={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0};t.load(e,s,{onSuccess:(t,e,r,i)=>{var s=this.getInternalLoader(r),a=(this.resetInternalLoader(r.type),t.data);0===a.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),g.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(t,e,r,i||null,s):this.handleMasterPlaylist(t,e,r,i)):this.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:(t,e,r,i)=>{this.handleNetworkError(e,r,!1,t,i)},onTimeout:(t,e,r)=>{this.handleNetworkError(e,r,!0,void 0,t)}})}handleMasterPlaylist(t,e,r,i){var s,a,n,o,l,h=this.hls,d=t.data,u=oe(t,r),c=g.parseMasterPlaylist(d,u);c.playlistParsingError?this.handleManifestParsingError(t,r,c.playlistParsingError,i,e):({contentSteering:t,levels:r,sessionData:s,sessionKeys:a,startTimeOffset:n,variableList:o}=c,{AUDIO:d=[],SUBTITLES:c,"CLOSED-CAPTIONS":l}=(this.variableList=o,g.parseMasterPlaylistMedia(d,u,c)),d.length&&!d.some(t=>!t.url)&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(P.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new w({}),bitrate:0,url:""})),h.trigger(I.MANIFEST_LOADED,{levels:r,audioTracks:d,subtitles:c,captions:l,contentSteering:t,url:u,stats:e,networkDetails:i,sessionData:s,sessionKeys:a,startTimeOffset:n,variableList:o}))}handleTrackOrLevelPlaylist(t,e,r,i,s){var a=this.hls,{id:n,level:o,type:l}=r,h=oe(t,r),n=D(n)?n:0,o=D(o)?o:n,d=ne(r),o=g.parseLevelPlaylist(t.data,h,o,d,n,this.variableList);if(l===ie){const t={attrs:new w({}),bitrate:0,details:o,name:"",url:h};a.trigger(I.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:h,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=o,this.handlePlaylistLoaded(o,t,e,r,i,s)}handleManifestParsingError(t,e,r,i,s){this.hls.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.MANIFEST_PARSING_ERROR,fatal:e.type===ie,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:s})}handleNetworkError(t,e,r=!1,i,s){let a=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading `+t.type;t.type===se?a+=`: ${t.level} id: `+t.id:t.type!==p&&t.type!==v||(a+=` id: ${t.id} group-id: "${t.groupId}"`);var n=new Error(a);P.warn("[playlist-loader]: "+a);let o=C.UNKNOWN,l=!1;var h=this.getInternalLoader(t);switch(t.type){case ie:o=r?C.MANIFEST_LOAD_TIMEOUT:C.MANIFEST_LOAD_ERROR,l=!0;break;case se:o=r?C.LEVEL_LOAD_TIMEOUT:C.LEVEL_LOAD_ERROR,l=!1;break;case p:o=r?C.AUDIO_TRACK_LOAD_TIMEOUT:C.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case v:o=r?C.SUBTITLE_TRACK_LOAD_TIMEOUT:C.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(t.type);h={type:_.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:h,context:t,error:n,networkDetails:e,stats:s};if(i){const r=(null==e?void 0:e.url)||t.url;h.response=m({url:r,data:void 0},i)}this.hls.trigger(I.ERROR,h)}handlePlaylistLoaded(t,e,r,i,s,a){var n=this.hls,{type:o,level:l,id:h,groupId:d,deliveryDirectives:u}=i,c=oe(e,i),f=ne(i),g="number"==typeof i.level&&f===y?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));l=t.playlistParsingError;if(l)n.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:l,reason:l.message,response:e,context:i,level:g,parent:f,networkDetails:s,stats:r});else switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case ie:case se:n.trigger(I.LEVEL_LOADED,{details:t,level:g||0,id:h||0,stats:r,networkDetails:s,deliveryDirectives:u});break;case p:n.trigger(I.AUDIO_TRACK_LOADED,{details:t,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u});break;case v:n.trigger(I.SUBTITLE_TRACK_LOADED,{details:t,id:h||0,groupId:d||"",stats:r,networkDetails:s,deliveryDirectives:u})}}else{const t=new Error("No Segments found in Playlist");void n.trigger(I.ERROR,{type:_.NETWORK_ERROR,details:C.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:t,reason:t.message,response:e,context:i,level:g,parent:f,networkDetails:s,stats:r})}}}function he(t,e){let r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function de(t,e){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){P.debug("[texttrack-utils]: "+r);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,t.addCue(r)}catch(t){P.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+t)}}"disabled"===r&&(t.mode=r)}function ue(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function ce(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&0<e.cues.length){const s=function(r,i,s){const a=[],n=function(t,e){if(e<t[0].startTime)return 0;var r=t.length-1;if(e>t[r].endTime)return-1;let i=0,s=r;for(;i<=s;){var a=Math.floor((s+i)/2);if(e<t[a].startTime)s=a-1;else{if(!(e>t[a].startTime&&i<r))return a;i=a+1}}return t[i].startTime-e<e-t[s].startTime?i:s}(r,i);if(-1<n)for(let t=n,e=r.length;t<e;t++){const n=r[t];if(n.startTime>=i&&n.endTime<=s)a.push(n);else if(n.startTime>s)return a}return a}(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}var fe="org.id3",ge="https://aomedia.org/emsg/ID3";function me(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const pe=(()=>{var t=me();try{new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ve(t,e){return t.getTime()/1e3-e}class ye{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(ue(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){t=this.getID3Track(t.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return he(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(r,i){if(this.media){const{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:e}}=this["hls"];if(n||e){const o=i["samples"];this.id3Track||(this.id3Track=this.createTrack(this.media));var s=me();for(let t=0;t<o.length;t++){const i=o[t].type;if((i!==ge||n)&&e){var a=Tt(o[t].data);if(a){const n=o[t].pts;let e=n+o[t].duration;(e=e>pe?pe:e)-n<=0&&(e=n+.25);for(let t=0;t<a.length;t++){const o=a[t];if(!yt(o)){this.updateId3CueEnds(n,i);const r=new s(n,e,"");r.value=o,i&&(r.type=i),this.id3Track.addCue(r)}}}}}}}}updateId3CueEnds(e,r){var t,i=null==(t=this.id3Track)?void 0:t.cues;if(i)for(let t=i.length;t--;){var s=i[t];s.type===r&&s.startTime<e&&s.endTime===pe&&(s.endTime=e)}}onBufferFlushing(t,{startOffset:e,endOffset:r,type:i}){var{id3Track:s,hls:a}=this;if(a){const{enableEmsgMetadataCues:n,enableID3MetadataCues:o}=a["config"];s&&(n||o)&&ce(s,e,r,"audio"===i?t=>t.type===fe&&o:"video"===i?t=>t.type===ge&&n:t=>t.type===fe&&o||t.type===ge&&n)}}onLevelUpdated(e,{details:s}){if(this.media&&s.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:u,id3Track:c}=this,f=s["dateRanges"],g=Object.keys(f);if(c){const e=Object.keys(u).filter(t=>!g.includes(t));for(let t=e.length;t--;){const f=e[t];Object.keys(u[f].cues).forEach(t=>{c.removeCue(u[f].cues[t])}),delete u[f]}}const m=s.fragments[s.fragments.length-1];if(0!==g.length&&D(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var a,n=m.programDateTime/1e3-m.start,o=me();for(let t=0;t<g.length;t++){const s=g[t],c=f[s],m=u[s],D=(null==m?void 0:m.cues)||{};let r=(null==m?void 0:m.durationKnown)||!1;var l=ve(c.startDate,n);let i=pe;var h=c.endDate;if(h)i=ve(h,n),r=!0;else if(c.endOnNext&&!r){const e=g.reduce((t,e)=>{var r=f[e];return r.class===c.class&&r.id!==e&&r.startDate>c.startDate&&t.push(r),t},[]).sort((t,e)=>t.startDate.getTime()-e.startDate.getTime())[0];e&&(i=ve(e.startDate,n),r=!0)}var d=Object.keys(c.attr);for(let t=0;t<d.length;t++){const u=d[t];if("ID"!==(a=u)&&"CLASS"!==a&&"START-DATE"!==a&&"DURATION"!==a&&"END-DATE"!==a&&"END-ON-NEXT"!==a){let e=D[u];if(e)r&&!m.durationKnown&&(e.endTime=i);else{let t=c.attr[u];e=new o(l,i,""),"SCTE35-OUT"!==(a=u)&&"SCTE35-IN"!==a||(a=t,t=Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),e.value={key:u,data:t},e.type="com.apple.quicktime.HLS",e.id=s,this.id3Track.addCue(e),D[u]=e}}}u[s]={cues:D,dateRange:c,durationKnown:r}}}}}}class Te{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){var t=this["levelDetails"];if(null===t)return null;var{holdBack:t,partHoldBack:e,targetduration:r}=t,{liveSyncDuration:i,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,n=this.hls.userConfig;let o=a&&e||t;return(o=n.liveSyncDuration||n.liveSyncDurationCount||0===o?void 0!==i?i:s*r:o)+Math.min(+this.stallCount,r)}get liveSyncPosition(){var t,e=this.estimateLiveEdge(),r=this.targetLatency,i=this.levelDetails;return null===e||null===r||null===i?null:(t=i.edge,e=e-r-this.edgeStalled,r=t-i.totalduration,t=t-(this.config.lowLatencyMode&&i.partTarget||i.targetduration),Math.min(Math.max(r,e),t))}get drift(){var t=this["levelDetails"];return null===t?1:t.drift}get edgeStalled(){var t,e=this["levelDetails"];return null===e?0:(t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration),Math.max(e.age-t,0))}get forwardBufferLength(){var t,{media:e,levelDetails:r}=this;return e&&r?((t=e.buffered.length)?e.buffered.end(t-1):r.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(I.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){(this.levelDetails=e).advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){e.details===C.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(e=this.levelDetails))&&e.live&&P.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){const{media:t,levelDetails:e}=this;if(t&&e){this.currentTime=t.currentTime;const a=this.computeLatency();if(null!==a){this._latency=a;var{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(r&&1!==i){r=this.targetLatency;if(null!==r){var s=a-r,r=s<Math.min(this.maxLatency,r+e.targetduration);if(e.live&&r&&.05<s&&1<this.forwardBufferLength){const e=Math.min(2,Math.max(1,i)),a=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,a))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}}estimateLiveEdge(){var t=this["levelDetails"];return null===t?null:t.edge+t.age}computeLatency(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const Ee=["NONE","TYPE-0","TYPE-1",null];class Se{constructor(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}addDirectives(t){t=new self.URL(t);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}}class Le{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){t%=this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function be(r,i){var s=i.startPTS;if(D(s)){let t,e=0;(t=i.sn>r.sn?(e=s-r.start,r):(e=r.start-s,i)).duration!==e&&(t.duration=e)}else i.sn>r.sn?r.cc===i.cc&&r.minEndPTS?i.start=r.start+(r.minEndPTS-r.start):i.start=r.start+r.duration:i.start=Math.max(r.start-i.duration,0)}function Ae(t,e,r,i,s,a){i-r<=0&&(P.warn("Fragment should have a positive duration",e),i=r+e.duration,a=s+e.duration);let n=r,o=i;var l=e.startPTS,h=e.endPTS;if(D(l)){const t=Math.abs(l-r);D(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,n=Math.max(r,l),r=Math.min(r,l),s=Math.min(s,e.startDTS),o=Math.min(i,h),i=Math.max(i,h),a=Math.max(a,e.endDTS)}l=r-e.start,0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=n,e.startDTS=s,e.endPTS=i,e.minEndPTS=o,e.endDTS=a,h=e.sn;if(!t||h<t.startSN||h>t.endSN)return 0;let d;var r=h-t.startSN,u=t.fragments;for(u[r]=e,d=r;0<d;d--)be(u[d],u[d-1]);for(d=r;d<u.length-1;d++)be(u[d],u[d+1]);return t.fragmentHint&&be(u[u.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,l}function Re(t,r){let i=null;var e=t.fragments;for(let t=e.length-1;0<=t;t--){const r=e[t].initSegment;if(r){i=r;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let s,a=0;{var n,o,l=t,h=r;const m=h.skippedSegments,p=Math.max(l.startSN,h.startSN)-h.startSN,v=(l.fragmentHint?1:0)+(m?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,y=h.startSN-l.startSN,T=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,E=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;for(let e=p;e<=v;e++){const p=E[y+e];let t=T[e];m&&!t&&e<m&&(t=h.fragments[e]=p),p&&t&&(n=p,o=t,n.relurl&&(a=n.cc-o.cc),D(n.startPTS)&&D(n.endPTS)&&(o.start=o.startPTS=n.startPTS,o.startDTS=n.startDTS,o.maxStartPTS=n.maxStartPTS,o.endPTS=n.endPTS,o.endDTS=n.endDTS,o.minEndPTS=n.minEndPTS,o.duration=n.endPTS-n.startPTS,o.duration&&(s=o),r.PTSKnown=r.alignedSliding=!0),o.elementaryStreams=n.elementaryStreams,o.loader=n.loader,o.stats=n.stats,o.urlId=n.urlId,n.initSegment)&&(o.initSegment=n.initSegment,i=n.initSegment)}}if(i&&(r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments).forEach(t=>{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)}),r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(t=>!t),r.deltaUpdateFailed){P.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=r.skippedSegments;t--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(t,r,e){const i=k({},t);return e&&e.forEach(t=>{delete i[t]}),Object.keys(r).forEach(t=>{var e=new X(r[t].attr,i[t]);e.isValid?i[t]=e:P.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(r[t].attr)}"`)}),i}(t.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var d=r.fragments;if(a){P.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t<d.length;t++)d[t].cc+=a}r.skippedSegments&&(r.startCC=r.fragments[0].cc);var u=t.partList,c=r.partList;if(u&&c){let r=0;for(let t=0,e=u.length;t<=e;t++){var f=u[t],g=c[t+r];f&&g&&f.index===g.index&&f.fragment.sn===g.fragment.sn?(f=f,(g=g).elementaryStreams=f.elementaryStreams,g.stats=f.stats):r--}}s?Ae(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):De(t,r),d.length&&(r.totalduration=r.edge-d[0].start),r.driftStartTime=t.driftStartTime,r.driftStart=t.driftStart;l=r.advancedDateTime;if(r.advanced&&l){const t=r.edge;r.driftStart||(r.driftStartTime=l,r.driftStart=t),r.driftEndTime=l,r.driftEnd=t}else r.driftEndTime=t.driftEndTime,r.driftEnd=t.driftEnd,r.advancedDateTime=t.advancedDateTime}function De(t,e){var r=e.startSN+e.skippedSegments-t.startSN,t=t.fragments;r<0||r>=t.length||we(e,t[r].start)}function we(e,r){if(r){var i=e.fragments;for(let t=e.skippedSegments;t<i.length;t++)i[t].start+=r;e.fragmentHint&&(e.fragmentHint.start+=r)}}function ke(t,e,r){return null!=t&&t.details?Ie(null==(t=t.details)?void 0:t.partList,e,r):null}function Ie(e,r,i){if(e)for(let t=e.length;t--;){var s=e[t];if(s.index===i&&s.fragment.sn===r)return s}return null}function _e(t){switch(t.details){case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_TIMEOUT:case C.LEVEL_LOAD_TIMEOUT:case C.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ce(t,e){e=_e(e);return t.default[(e?"timeout":"error")+"Retry"]}function Pe(t,e){e="linear"===t.backoff?1:Math.pow(2,e);return Math.min(e*t.retryDelayMs,t.maxRetryDelayMs)}function xe(t){return m(m({},t),{errorRetry:null,timeoutRetry:null})}function Me(t,e,r,i){return t&&e<t.maxNumRetry&&(0===i&&!1===navigator.onLine||i&&(i<400||499<i)||r)}function Oe(t,e){let r=0,i=t.length-1,s,a;for(;r<=i;){var n=e(a=t[s=(r+i)/2|0]);if(0<n)r=1+s;else{if(!(n<0))return a;i=s-1}}return null}function Fe(t,e,r=0,i=0){let s=null;return t?s=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(s=e[0]),s&&0===Ne(r,i,s)||!(e=Oe(e,Ne.bind(null,r,i)))||e===t&&s?s:e}function Ne(t=0,e=0,r){return r.start<=t&&r.start+r.duration>t?0:(e=Math.min(e,r.duration+(r.deltaPTS||0)),r.start+r.duration-e<=t?1:r.start-e>t&&r.start?-1:0)}class Ue{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=P.log.bind(P,e+":"),this.warn=P.warn.bind(P,e+":"),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(i,s){var a=null==s?void 0:s.renditionReports;if(a){let r=-1;for(let e=0;e<a.length;e++){var n=a[e];let t;try{t=new self.URL(n.URI,s.url).href}catch(i){P.warn("Could not construct new URL for Rendition Report: "+i),t=n.URI||""}if(t===i){r=e;break}t===i.substring(0,t.length)&&(r=e)}if(-1!==r){const i=a[r],e=parseInt(i["LAST-MSN"])||(null==s?void 0:s.lastPartSn);let t=parseInt(i["LAST-PART"])||(null==s?void 0:s.lastPartIndex);if(this.hls.config.lowLatencyMode){const i=Math.min(s.age-s.partTarget,s.targetduration);0<=t&&i>s.partTarget&&(t+=1)}return new Se(e,0<=t?t:void 0,"")}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}playlistLoaded(s,a,n){const{details:o,stats:l}=a,h=self.performance.now(),t=l.loading.first?Math.max(0,h-l.loading.first):0;if(o.advancedDateTime=Date.now()-t,o.live||null!=n&&n.live){if(o.reloaded(n),n&&this.log(`live playlist ${s} `+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),n&&0<o.fragments.length&&Re(n,o),this.canLoad&&o.live){let e,r=void 0,i=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){const s=this.hls.config.lowLatencyMode,l=o.lastPartSn,h=o.endSN,c=o.lastPartIndex,f=l===h,g=s?0:c;-1!==c?(r=f?h+1:l,i=f?g:c+1):r=h+1;var d=o.age,u=d+o.ageHeader;let t=Math.min(u-o.partTarget,1.5*o.targetduration);if(0<t){if(n&&t>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${t} with playlist age: `+o.age),t=0;else{const s=Math.floor(t/o.targetduration);r+=s,void 0!==i&&(i+=Math.round(t%o.targetduration/o.partTarget)),this.log(`CDN Tune-in age: ${o.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${t} skip sn ${s} to part `+i)}o.tuneInGoal=t}if(e=this.getDeliveryDirectives(o,a.deliveryDirectives,r,i),s||!f)return void this.loadPlaylist(e)}else(o.canBlockReload||o.canSkipUntil)&&(e=this.getDeliveryDirectives(o,a.deliveryDirectives,r,i));u=this.hls.mainForwardBufferInfo,n=u?u.end-u.len:0,d=function(t,e){let r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){const t=1e3*i[i.length-1].duration;t<r&&(r=t)}}else r/=2;return Math.round(r)}(o,1e3*(o.edge-n)),a=(o.updated&&h>this.requestScheduled+d&&(this.requestScheduled=l.loading.start),void 0!==r&&o.canBlockReload?this.requestScheduled=l.loading.first+d-(1e3*o.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+d<h?this.requestScheduled=h:this.requestScheduled-h<=0&&(this.requestScheduled+=d),this.requestScheduled-h),a=Math.max(0,a);this.log(`reload live playlist ${s} in ${Math.round(a)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(e),a)}}else this.clearTimer()}getDeliveryDirectives(i,t,s,e){let r=function(){var{canSkipUntil:t,canSkipDateRanges:e,endSN:r}=i;return t&&(void 0!==s?s-r:0)<t?e?"v2":"YES":""}();return null!=t&&t.skip&&i.deltaUpdateFailed&&(s=t.msn,e=t.part,r=""),new Se(s,e,r)}checkRetry(t){var e=t.details,r=_e(t),i=t.errorAction,{action:s,retryCount:a=0,retryConfig:n}=i||{},s=!!i&&!!n&&(5===s||!i.resolved&&2===s);if(s){if(this.requestScheduled=-1,a>=n.maxNumRetry)return!1;if(r&&null!=(r=t.context)&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=Pe(n,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),t),this.warn(`Retrying playlist loading ${a+1}/${n.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,i.resolved=!0}return s}}let Be;class Ge extends Ue{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(I.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.ERROR,this.onError,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(I.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const o=[],l={};let h;e.levels.forEach(t=>{var e=t.attrs,{AUDIO:r,CODECS:e,"FRAME-RATE":i,"PATHWAY-ID":s,RESOLUTION:a,SUBTITLES:n}=(-1!==(null==(r=t.audioCodec)?void 0:r.indexOf("mp4a.40.34"))&&(Be=Be||/chrome|firefox/i.test(navigator.userAgent))&&(t.audioCodec=void 0),e),s=(s||".")+"-"+t.bitrate+`-${a}-${i}-`+e;(h=l[s])?h.addFallback(t):(h=new Le(t),l[s]=h,o.push(h)),$e(h,"audio",r),$e(h,"text",n)}),this.filterAndSortMediaOptions(o,e)}filterAndSortMediaOptions(t,r){let i=[],s=[],a=!1,n=!1,o=!1,l=t.filter(({audioCodec:t,videoCodec:e,width:r,height:i,unknownCodecs:s})=>(a=a||!(!r||!i),n=n||!!e,o=o||!!t,!(null!=s&&s.length)&&(!t||Yt(t,"audio"))&&(!e||Yt(e,"video"))));if(0===(l=(a||n)&&o?l.filter(({videoCodec:t,width:e,height:r})=>!!t||!(!e||!r)):l).length)Promise.resolve().then(()=>{var t;this.hls&&(t=new Error("no level with compatible codecs found in manifest"),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:t,reason:t.message}))});else{r.audioTracks&&Ke(i=r.audioTracks.filter(t=>!t.audioCodec||Yt(t.audioCodec,"audio"))),r.subtitles&&Ke(s=r.subtitles);var h=l.slice(0);l.sort((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):a&&t.height!==e.height?t.height-e.height:0);let e=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(let t=0;t<h.length;t++)if(h[t].pathwayId===l[0].pathwayId){e=h[t];break}this._levels=l;for(let t=0;t<l.length;t++)if(l[t]===e){this._firstLevel=t,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: `+e.bitrate);break}t=o&&!n,t={levels:l,audioTracks:i,subtitleTracks:s,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:n,altAudio:!t&&i.some(t=>!!t.url)};this.hls.trigger(I.MANIFEST_PARSED,t),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){const r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,a=e[t],n=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=a,r!==t||!a.details||!i||s!==n){this.log(`Switching to level ${t}${n?" with Pathway "+n:""} from level `+r+(s?" with Pathway "+s:""));e=k({},a,{level:t,maxBitrate:a.maxBitrate,attrs:a.attrs,uri:a.uri,urlId:a.urlId}),t=(delete e._attrs,delete e._urlId,this.hls.trigger(I.LEVEL_SWITCHING,e),a.details);if(!t||t.live){const t=this.switchParams(a.uri,null==i?void 0:i.details);this.loadPlaylist(t)}}}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){var t;return void 0===this._startLevel?void 0!==(t=this.hls.config.startLevel)?t:this._firstLevel:this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===se&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(void 0!==e&&e.type===y){const t=this._levels[e.level];void 0!==t&&(t.loadError=0)}}onLevelLoaded(t,e){var{level:r,details:i}=e,s=this._levels[r];s?r===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(r,e,s.details)):null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0):(this.warn("Invalid level index "+r),null!=(s=e.deliveryDirectives)&&s.skip&&(i.deltaUpdateFailed=!0))}onAudioTrackSwitched(t,e){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let e=-1;for(let t=0;t<r.audioGroupIds.length;t++)if(r.audioGroupIds[t]===i){e=t;break}-1!==e&&e!==r.urlId&&(r.urlId=e,this.canLoad)&&this.startLoad()}}}loadPlaylist(e){super.loadPlaylist();var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var s=i.urlId;let t=i.uri;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}var a=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${r}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} URI ${s+1}/${i.url.length} `+t),this.clearTimer(),this.hls.trigger(I.LEVEL_LOADING,{url:t,level:r,id:s,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(r,i){const s=(t,e)=>e!==i,t=this._levels.filter((t,e)=>e!==r||(1<t.url.length&&void 0!==i?(t.url=t.url.filter(s),t.audioGroupIds&&(t.audioGroupIds=t.audioGroupIds.filter(s)),t.textGroupIds&&(t.textGroupIds=t.textGroupIds.filter(s)),!(t.urlId=0)):(this.steering&&this.steering.removeLevel(t),!1)));this.hls.trigger(I.LEVELS_UPDATED,{levels:t})}onLevelsUpdated(t,{levels:e}){e.forEach((t,e)=>{t=t.details;null!=t&&t.fragments&&t.fragments.forEach(t=>{t.level=e})}),this._levels=e}}function $e(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function Ke(t){const r={};t.forEach(t=>{var e=t.groupId||"";t.id=r[e]=r[e]||0,r[e]++})}var He="NOT_LOADED",Ve="APPENDING",Ye="PARTIAL",We="OK";class je{constructor(t){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=t,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on(I.BUFFER_APPENDED,this.onBufferAppended,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var t=this["hls"];t.off(I.BUFFER_APPENDED,this.onBufferAppended,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){var r=this.activePartLists[t];if(r)for(let t=r.length;t--;){var i=r[t];if(!i)break;var s=i.end;if(i.start<=e&&null!==s&&e<=s)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,r){var i=this["fragments"],s=Object.keys(i);for(let t=s.length;t--;){var a=i[s[t]];if((null==a?void 0:a.body.type)===r&&a.buffered){const r=a.body;if(r.start<=e&&e<=r.end)return r}}return null}detectEvictedFragments(r,i,s,t){this.timeRanges&&(this.timeRanges[r]=i);const a=(null==t?void 0:t.fragment.sn)||-1;Object.keys(this.fragments).forEach(t=>{const e=this.fragments[t];!e||a>=e.body.sn||(e.buffered||e.loaded?(t=e.range[r])&&t.time.some(t=>{t=!this.isTimeBuffered(t.startPTS,t.endPTS,i);return t&&this.removeFragment(e.body),t}):e.body.type===s&&this.removeFragment(e.body))})}detectPartialFragments(t){const i=this.timeRanges,{frag:s,part:a}=t;if(i&&"initSegment"!==s.sn){const e=Xe(s),n=this.fragments[e];if(!(!n||n.buffered&&s.gap)){const o=!s.relurl;Object.keys(i).forEach(t=>{var e,r=s.elementaryStreams[t];r&&(e=i[t],r=o||!0===r.partial,n.range[t]=this.getBufferedTimes(s,a,r,e))}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=s.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),qe(n)||this.removeParts(s.sn-1,s.type)):this.removeFragment(n.body)}}}removeParts(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(t,e){var r=Xe(t);let i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap)&&(this.hasGaps=!0),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(t,e,r,i){var s={time:[],partial:r},a=t.start,n=t.end,o=t.minEndPTS||n,l=t.maxStartPTS||a;for(let t=0;t<i.length;t++){const e=i.start(t)-this.bufferPadding,r=i.end(t)+this.bufferPadding;if(l>=e&&o<=r){s.time.push({startPTS:Math.max(a,i.start(t)),endPTS:Math.min(n,i.end(t))});break}if(a<r&&n>e)s.partial=!0,s.time.push({startPTS:Math.max(a,i.start(t)),endPTS:Math.min(n,i.end(t))});else if(n<=e)break}return s}getPartialFragment(e){let r,i,s,a=null,n=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(t=>{t=l[t];t&&qe(t)&&(i=t.body.start-o,s=t.body.end+o,e>=i)&&e<=s&&(r=Math.min(e-i,s-e),n<=r)&&(a=t.body,n=r)}),a}isEndListAppended(t){t=this.endListFragments[t];return void 0!==t&&(t.buffered||qe(t))}getState(t){t=Xe(t),t=this.fragments[t];return t?t.buffered?qe(t)?Ye:We:Ve:He}isTimeBuffered(e,r,i){var s,a;for(let t=0;t<i.length;t++){if(s=i.start(t)-this.bufferPadding,a=i.end(t)+this.bufferPadding,s<=e&&r<=a)return!0;if(r<=s)return!1}return!1}onFragLoaded(t,e){var r,{frag:i,part:s}=e;"initSegment"===i.sn||i.bitrateTest||(r=Xe(i),this.fragments[r]={body:i,appendedPTS:null,loaded:s?null:e,buffered:!1,range:Object.create(null)})}onBufferAppended(t,e){const{frag:r,part:i,timeRanges:s}=e;if("initSegment"!==r.sn){const a=r.type;if(i){let t=this.activePartLists[a];t||(this.activePartLists[a]=t=[]),t.push(i)}this.timeRanges=s,Object.keys(s).forEach(t=>{var e=s[t];this.detectEvictedFragments(t,e,a,i)})}}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){t=Xe(t);return!!this.fragments[t]}hasParts(t){return!(null==(t=this.activePartLists[t])||!t.length)}removeFragmentsInRange(r,i,s,a,n){a&&!this.hasGaps||Object.keys(this.fragments).forEach(t=>{var e,t=this.fragments[t];!t||(e=t.body).type!==s||a&&!e.gap||e.start<i&&e.end>r&&(t.buffered||n)&&this.removeFragment(e)})}removeFragment(t){const e=Xe(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){const e=t.sn;this.activePartLists[t.type]=r.filter(t=>t.fragment.sn!==e)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function qe(t){var e;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(e=t.range.audio)?void 0:e.partial)||(null==(e=t.range.audiovideo)?void 0:e.partial))}function Xe(t){return`${t.type}_${t.level}_${t.urlId}_`+t.sn}const ze=Math.pow(2,17);class Qe{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const h=o.url;if(!h)return Promise.reject(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(h?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,d=r.fLoader,u=r.loader;return new Promise((a,s)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(t=>"GAP"===t[0]))return void s(Ze(o));o.gap=!1}const n=this.loader=o.loader=new(d||u)(r),t=Je(o),e=xe(r.fragLoadPolicy.default),i={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:ze};o.stats=n.stats,n.load(t,i,{onSuccess:(t,e,r,i)=>{this.resetLoader(o,n);let s=t.data;r.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:o,part:null,payload:s,networkDetails:i})},onError:(t,e,r,i)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:m({url:h,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:i}))},onAbort:(t,e,r)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(o,n),s(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:t}))},onProgress:(t,e,r,i)=>{l&&l({frag:o,part:null,payload:r,networkDetails:i})}})})}loadPart(l,h,d){this.abort();const e=this.config,r=e.fLoader,u=e.loader;return new Promise((s,a)=>{if(this.loader&&this.loader.destroy(),l.gap||h.gap)a(Ze(l,h));else{const n=this.loader=l.loader=new(r||u)(e),o=Je(l,h),t=xe(e.fragLoadPolicy.default),i={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ze};h.stats=n.stats,n.load(o,i,{onSuccess:(t,e,r,i)=>{this.resetLoader(l,n),this.updateStatsFromPart(l,h);t={frag:l,part:h,payload:t.data,networkDetails:i};d(t),s(t)},onError:(t,e,r,i)=>{this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:h,response:m({url:o.url,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:i}))},onAbort:(t,e,r)=>{l.stats.aborted=h.stats.aborted,this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:l,part:h,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(l,n),a(new T({type:_.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:h,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:t}))}})}})}updateStatsFromPart(t,e){const r=t.stats,i=e.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(t.duration/e.duration),a=Math.min(Math.round(r.loaded/s),i),n=(i-a)*Math.round(r.loaded/a);r.total=r.loaded+n}else r.total=Math.max(r.loaded,r.total);const a=r.loading,n=i.loading;a.start?a.first+=n.first-n.start:(a.start=n.start,a.first=n.first),a.end=n.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Je(r,i=null){var s=i||r,i={frag:r,part:i,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},a=s.byteRangeStartOffset,s=s.byteRangeEndOffset;if(D(a)&&D(s)){let t=a,e=s;if("initSegment"===r.sn&&"AES-128"===(null==(r=r.decryptdata)?void 0:r.method)){const r=s-a;r%16&&(e=s+(16-r%16)),0!==a&&(i.resetIV=!0,t=a-16)}i.rangeStart=t,i.rangeEnd=e}return i}function Ze(t,e){var r=new Error(`GAP ${t.gap?"tag":"attribute"} found`),r={type:_.MEDIA_ERROR,details:C.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new T(r)}class T extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class tr{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const r in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[r].loader;if(e){if(t&&t!==e.context.frag.type)return;e.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=C.KEY_LOAD_ERROR,r,i,s){return new T({type:_.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:s,error:r,networkDetails:i})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){var{sn:r,cc:i}=t;for(let t=0;t<e.length;t++){const s=e[t];if(i<=s.cc&&("initSegment"===r||"initSegment"===s.sn||r<s.sn)){this.emeController.selectKeySystemFormat(s).then(t=>{s.setKeyFormat(t)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const 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,C.KEY_LOAD_ERROR,i))}var i,t=r.uri;if(!t)return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${t}"`)));let s=this.keyUriToKeyInfo[t];if(null!=(i=s)&&i.decryptdata.key)return r.key=s.decryptdata.key,Promise.resolve({frag:e,keyInfo:s});if(null!=(i=s)&&i.keyLoadPromise)switch(null==(i=s.mediaKeySessionContext)?void 0:i.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return s.keyLoadPromise.then(t=>(r.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:s}))}switch(s=this.keyUriToKeyInfo[t]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(s,e):this.loadKeyEME(s,e);case"AES-128":return this.loadKeyHTTP(s,e);default:return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(i,a){const l=this.config,h=new l.loader(l);return a.keyLoader=i.loader=h,i.keyLoadPromise=new Promise((n,o)=>{const s={keyInfo:i,frag:a,responseType:"arraybuffer",url:i.decryptdata.uri},t=l.keyLoadPolicy.default,e={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},r={onSuccess:(t,e,r,i)=>{var{frag:r,keyInfo:s,url:a}=r;if(!r.decryptdata||s!==this.keyUriToKeyInfo[a])return o(this.createKeyLoadError(r,C.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));s.decryptdata.key=r.decryptdata.key=new Uint8Array(t.data),r.keyLoader=null,s.loader=null,n({frag:r,keyInfo:s})},onError:(t,e,r,i)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key `+t.text),r,m({url:s.url,data:void 0},t)))},onTimeout:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,C.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};h.load(s,e,r)})}resetLoader(t){var{frag:t,keyInfo:e,url:r}=t,i=e.loader;t.keyLoader===i&&(t.keyLoader=null,e.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const er={length:0,start:()=>0,end:()=>0};class E{static isBuffered(t,e){try{if(t){var r=E.getBuffered(t);for(let t=0;t<r.length;t++)if(e>=r.start(t)&&e<=r.end(t))return!0}}catch(t){}return!1}static bufferInfo(e,r,i){try{if(e){var s=E.getBuffered(e),a=[];let t;for(t=0;t<s.length;t++)a.push({start:s.start(t),end:s.end(t)});return this.bufferedInfo(a,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}}static bufferedInfo(e,r,i){r=Math.max(0,r),e.sort(function(t,e){return t.start-e.start||e.end-t.end});let s=[];if(i)for(let t=0;t<e.length;t++){const a=s.length;if(a){const n=s[a-1].end;e[t].start-n<i?e[t].end>n&&(s[a-1].end=e[t].end):s.push(e[t])}else s.push(e[t])}else s=e;let a,n=0,o=r,l=r;for(let t=0;t<s.length;t++){var h=s[t].start,d=s[t].end;if(h<=r+i&&r<d)o=h,l=d,n=l-r;else if(r+i<h){a=h;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(t){try{return t.buffered}catch(t){return P.log("failed to get media.buffered",t),er}}}class rr{constructor(t,e,r,i=0,s=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=r,this.size=i,this.part=s,this.partial=a}}function ir(r,i){let s=null;for(let t=0,e=r.length;t<e;t++){var a=r[t];if(a&&a.cc===i){s=a;break}}return s}function sr(t,e){t&&(e=t.start+e,t.start=t.startPTS=e,t.endPTS=e+t.duration)}function ar(r,t){var i=t.fragments;for(let t=0,e=i.length;t<e;t++)sr(i[t],r);t.fragmentHint&&sr(t.fragmentHint,r),t.alignedSliding=!0}function nr(t,e){var r,i,s;t.hasProgramDateTime&&e.hasProgramDateTime&&(r=t.fragments,e=e.fragments,r.length)&&e.length&&(r=ir(r,(e=e[Math.round(e.length/2)-1]).cc)||r[Math.round(r.length/2)-1],i=e.programDateTime,s=r.programDateTime,null!==i)&&null!==s&&ar((s-i)/1e3-(r.start-e.start),t)}class or{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class lr{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class hr{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){var e=new DataView(t),r=new Uint32Array(4);for(let t=0;t<4;t++)r[t]=e.getUint32(4*t);return r}initTable(){const t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],s=r[1],a=r[2],n=r[3],o=this.invSubMix,l=o[0],h=o[1],d=o[2],u=o[3],c=new Uint32Array(256);let f=0,g=0,m=0;for(m=0;m<256;m++)c[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var p=(p=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&p^99;t[f]=p,e[p]=f;const o=c[f],m=c[o],y=c[m];var v=257*c[p]^16843008*p;i[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,a[f]=v<<8|v>>>24,n[f]=v,v=16843009*y^65537*m^257*o^16843008*f,l[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,d[p]=v<<8|v>>>24,u[p]=v,f?(f=o^c[c[c[y^o]]],g^=c[c[g]]):f=g=1}}expandKey(s){var a=this.uint8ArrayToUint32Array_(s);let t=!0,e=0;for(;e<a.length&&t;)t=a[e]===this.key[e],e++;if(!t){this.key=a;var n=this.keySize=a.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var o=this.ksRows=4*(n+6+1);let t,e;var l=this.keySchedule=new Uint32Array(o),h=this.invKeySchedule=new Uint32Array(o),d=this.sBox,u=this.rcon,s=this.invSubMix,c=s[0],f=s[1],g=s[2],m=s[3];let r,i;for(t=0;t<o;t++)t<n?r=l[t]=a[t]:(i=r,t%n==0?(i=d[(i=i<<8|i>>>24)>>>24]<<24|d[i>>>16&255]<<16|d[i>>>8&255]<<8|d[255&i],i^=u[t/n|0]<<24):6<n&&t%n==4&&(i=d[i>>>24]<<24|d[i>>>16&255]<<16|d[i>>>8&255]<<8|d[255&i]),l[t]=r=(l[t-n]^i)>>>0);for(e=0;e<o;e++)t=o-e,i=3&e?l[t]:l[t-4],h[e]=e<4||t<=4?i:c[d[i>>>24]]^f[d[i>>>16&255]]^g[d[i>>>8&255]]^m[d[255&i]],h[e]=h[e]>>>0}}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,r){var i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,n=this.invSubMix,o=n[0],l=n[1],h=n[2],d=n[3],n=this.uint8ArrayToUint32Array_(r);let u=n[0],c=n[1],f=n[2],g=n[3];var m=new Int32Array(t),p=new Int32Array(m.length);let v,y,T,E,S,L,b,A,R,D,w,k,I,_;for(var C=this.networkToHostOrderSwap;e<m.length;){for(R=C(m[e]),D=C(m[e+1]),w=C(m[e+2]),k=C(m[e+3]),S=R^s[0],L=k^s[1],b=w^s[2],A=D^s[3],I=4,_=1;_<i;_++)v=o[S>>>24]^l[L>>16&255]^h[b>>8&255]^d[255&A]^s[I],y=o[L>>>24]^l[b>>16&255]^h[A>>8&255]^d[255&S]^s[I+1],T=o[b>>>24]^l[A>>16&255]^h[S>>8&255]^d[255&L]^s[I+2],E=o[A>>>24]^l[S>>16&255]^h[L>>8&255]^d[255&b]^s[I+3],S=v,L=y,b=T,A=E,I+=4;v=a[S>>>24]<<24^a[L>>16&255]<<16^a[b>>8&255]<<8^a[255&A]^s[I],y=a[L>>>24]<<24^a[b>>16&255]<<16^a[A>>8&255]<<8^a[255&S]^s[I+1],T=a[b>>>24]<<24^a[A>>16&255]<<16^a[S>>8&255]<<8^a[255&L]^s[I+2],E=a[A>>>24]<<24^a[S>>16&255]<<16^a[L>>8&255]<<8^a[255&b]^s[I+3],p[e]=C(v^u),p[e+1]=C(E^c),p[e+2]=C(T^f),p[e+3]=C(y^g),u=R,c=D,f=w,g=k,e+=4}return p.buffer}}class dr{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(t){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){var t,e,{currentResult:r,remainderData:i}=this;return!r||i?(this.reset(),null):(i=new Uint8Array(r),this.reset(),this.removePKCS7Padding?(t=(r=i).byteLength,(e=t&&new DataView(r.buffer).getUint8(t-1))?ft(r,0,t-e):r):i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(i,s,a){return this.useSoftware?new Promise((t,e)=>{this.softwareDecrypt(new Uint8Array(i),s,a);var r=this.flush();r?t(r.buffer):e(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(i),s,a)}softwareDecrypt(t,e,r){var{currentIV:i,currentResult:s,remainderData:a}=this,a=(this.logOnce("JS AES decrypt"),a&&(t=Pt(a,t),this.remainderData=null),this.getValidChunk(t));if(!a.length)return null;i&&(r=i);let n=this.softwareDecrypter;(n=n||(this.softwareDecrypter=new hr)).expandKey(e);t=s;return this.currentResult=n.decrypt(a.buffer,0,r),this.currentIV=ft(a,-16).buffer,t||null}webCryptoDecrypt(e,r,i){const s=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new lr(s,r)),this.fastAesKey.expandKey().then(t=>s?(this.logOnce("WebCrypto AES decrypt"),new or(s,new Uint8Array(i)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(t=>(P.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${t.name}: `+t.message),this.onWebCryptoError(e,r,i)))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);t=this.flush();if(t)return t.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;var r=t.length-t.length%16;return r!==t.length&&(e=ft(t,0,r),this.remainderData=ft(t,r)),e}logOnce(t){this.logEnabled&&(P.log("[decrypter]: "+t),this.logEnabled=!1)}}const n="STOPPED",d="IDLE",ur="KEY_LOADING",cr="FRAG_LOADING",fr="FRAG_LOADING_WAITING_RETRY",gr="WAITING_TRACK",O="PARSING",mr="PARSED",pr="ENDED",vr="ERROR",yr="WAITING_INIT_PTS",Tr="WAITING_LEVEL";class Er extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(t,e,r,i,s){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=n,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=s,this.logPrefix=i,this.log=P.log.bind(P,i+":"),this.warn=P.warn.bind(P,i+":"),this.hls=t,this.fragmentLoader=new Qe(t.config),this.keyLoader=r,this.fragmentTracker=e,this.config=t.config,this.decrypter=new dr(t.config),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=n}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;var r=e.partList;if(null!=r&&r.length){const t=r[r.length-1];return E.isBuffered(this.media,t.start+t.duration/2)}t=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(t)}getLevelDetails(){var t;return!this.levels||null===this.levelLastLoaded||null==(t=this.levels[this.levelLastLoaded])?void 0:t.details}onMediaAttached(t,e){e=this.media=this.mediaBuffer=e.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended),e=this.config;this.levels&&e.autoStartLoad&&this.state===n&&this.startLoad(e.startPosition)}onMediaDetaching(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:r,mediaBuffer:i,state:s}=this,a=r?r.currentTime:0,n=E.bufferInfo(i||r,a,t.maxBufferHole);if(this.log(`media seeking to ${D(a)?a.toFixed(3):a}, state: `+s),this.state===pr)this.resetLoadingState();else if(e){const r=t.maxFragLookUpTolerance,i=e.start-r,s=e.start+e.duration+r;if(!n.len||s<n.start||i>n.end){const t=a>s;(a<i||t)&&(t&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),this.loadedmetadata||n.len||(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=n,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,r){this._loadFragForPlayback(t,e,r)}_loadFragForPlayback(r,t,e){this._doFragLoad(r,t,e,t=>{this.fragContextChanged(r)?(this.warn(`Fragment ${r.sn}${t.part?" p: "+t.part.index:""} of level ${r.level} was dropped during download.`),this.fragmentTracker.removeFragment(r)):(r.stats.chunkCount++,this._handleFragmentLoadProgress(t))}).then(t=>{var e;t&&(e=this.state,this.fragContextChanged(r)?e!==cr&&(this.fragCurrent||e!==O)||(this.fragmentTracker.removeFragment(r),this.state=d):("payload"in t&&(this.log(`Loaded fragment ${r.sn} of level `+r.level),this.hls.trigger(I.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t)))}).catch(t=>{this.state!==n&&this.state!==vr&&(this.warn(t),this.resetFragmentLoading(r))})}clearTrackerIfNeeded(t){var e,r=this["fragmentTracker"];if(r.getState(t)===Ve){const e=t.type,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=Math.max(t.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(s)&&r.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===Ye)&&r.removeFragment(t)}checkLiveUpdate(t){var e;t.updated&&!t.live&&(e=t.fragments[t.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})),t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,r=null){t-e&&(t={startOffset:t,endOffset:e,type:r},this.hls.trigger(I.BUFFER_FLUSHING,t))}_loadInitSegment(a,s){this._doFragLoad(a,s).then(t=>{if(t&&!this.fragContextChanged(a)&&this.levels)return t;throw new Error("init load aborted")}).then(r=>{const i=this["hls"],t=r["payload"],e=a.decryptdata;if(t&&0<t.byteLength&&e&&e.key&&e.iv&&"AES-128"===e.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(t),e.key.buffer,e.iv.buffer).catch(t=>{throw i.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:a}),t}).then(t=>{var e=self.performance.now();return i.trigger(I.FRAG_DECRYPTED,{frag:a,payload:t,stats:{tstart:s,tdecrypt:e}}),r.payload=t,r})}return r}).then(t=>{var{fragCurrent:e,hls:r,levels:i}=this;if(!i)throw new Error("init load aborted, missing levels");i=a.stats;this.state=d,s.fragmentError=0,a.data=new Uint8Array(t.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),t.frag===e&&r.trigger(I.FRAG_BUFFERED,{stats:i,frag:e,part:null,id:a.type}),this.tick()}).catch(t=>{this.state!==n&&this.state!==vr&&(this.warn(t),this.resetFragmentLoading(a))})}fragContextChanged(t){var e=this["fragCurrent"];return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var r=this.mediaBuffer||this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===y?"level":"track"} ${t.level} (frag:[${(null!=(e=t.startPTS)?e:NaN).toFixed(3)}-${(null!=(e=t.endPTS)?e:NaN).toFixed(3)}] > buffer:${r?function(e){let r="";var i=e.length;for(let t=0;t<i;t++)r+=`[${e.start(t).toFixed(3)}-${e.end(t).toFixed(3)}]`;return r}(E.getBuffered(r)):"(detached)"})`),this.state=d,r&&(!this.loadedmetadata&&t.type==y&&r.buffered.length&&(null==(e=this.fragCurrent)?void 0:e.sn)===(null==(t=this.fragPrevious)?void 0:t.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){var e,r,i=this["transmuxer"];i&&({frag:t,part:e,partsLoaded:r}=t,r=!r||0===r.length||r.some(t=>!t),t=new rr(t.level,t.sn,t.stats.chunkCount+1,0,e?e.index:-1,!r),i.flush(t))}_handleFragmentLoadProgress(t){}_doFragLoad(e,r,t=null,i){var s,a,n=null==r?void 0:r.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key?!e.encrypted&&n.encryptedFragments.length&&this.keyLoader.loadClear(e,n.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+e.level),this.state=ur,this.fragCurrent=e,o=this.keyLoader.load(e).then(t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(I.KEY_LOADED,t),this.state===ur&&(this.state=d),t}),this.hls.trigger(I.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),t=Math.max(e.start,t||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const s=n.partList;if(s&&i){t>e.end&&n.fragmentHint&&(e=n.fragmentHint);const l=this.getNextPart(s,e,t);if(-1<l){const h=s[l];return this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${n.startSN}-${n.endSN}] parts [0-${l}-${s.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: `+parseFloat(t.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=cr,a=o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.doFragPartsLoad(e,h,r,i)).catch(t=>this.handleFragLoadError(t)):this.doFragPartsLoad(e,h,r,i).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(I.FRAG_LOADING,{frag:e,part:h,targetBufferTime:t}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):a}if(!e.url||this.loadedEndOfParts(s,t))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${n?"of ["+n.startSN+"-"+n.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: `+parseFloat(t.toFixed(3))),D(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=cr;const l=this.config.progressive;let h;return h=l&&o?o.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i)).catch(t=>this.handleFragLoadError(t)):Promise.all([this.fragmentLoader.load(e,l?i:void 0),o]).then(([t])=>(!l&&t&&i&&i(t),t)).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(I.FRAG_LOADING,{frag:e,targetBufferTime:t}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(o,r,l,h){return new Promise((i,t)=>{var e;const s=[],a=null==(e=l.details)?void 0:e.partList,n=r=>{this.fragmentLoader.loadPart(o,r,h).then(t=>{var e=(s[r.index]=t).part,t=(this.hls.trigger(I.FRAG_LOADED,t),ke(l,o.sn,r.index+1)||Ie(a,o.sn,r.index+1));if(!t)return i({frag:o,part:e,partsLoaded:s});n(t)}).catch(t)};n(r)})}handleFragLoadError(t){var e;return"data"in t?(e=t.data,t.data&&e.details===C.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(I.ERROR,e)):this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0}),null}_handleTransmuxerFlush(t){var e,r,i,s=this.getCurrentContext(t);s&&this.state===O?({frag:s,part:e,level:r}=s,i=self.performance.now(),s.stats.parsing.end=i,e&&(e.stats.parsing.end=i),this.updateLevelTiming(s,e,r,t.partial)):this.fragCurrent||this.state===n||this.state===vr||(this.state=d)}getCurrentContext(t){var{levels:e,fragCurrent:r}=this,{level:t,sn:i,part:s}=t;if(null==e||!e[t])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${t}. The current chunk will not be buffered.`),null;const a=e[t],n=-1<s?ke(a,i,s):null,o=n?n.fragment:null!=a&&a.details?(e=a.details).fragments[i-e.startSN]||((t=e.fragmentHint)&&t.sn===i?t:i<e.startSN&&r&&r.sn===i?r:null):null;return o?(r&&r!==o&&(o.stats=r.stats),{frag:o,part:n,level:a}):null}bufferFragmentData(e,r,i,s,a){if(e&&this.state===O){var{data1:n,data2:o}=e;let t=n;null!=(n=t=n&&o?Pt(n,o):t)&&n.length&&(o={type:e.type,frag:r,part:i,chunkMeta:s,parent:r.type,data:t},this.hls.trigger(I.BUFFER_APPENDING,o),e.dropped)&&e.independent&&!i&&!a&&this.flushBufferGap(r)}}flushBufferGap(t){var e,r,i=this.media;i&&(E.isBuffered(i,i.currentTime)?(e=i.currentTime,i=E.bufferInfo(i,e,0),r=t.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),i=Math.max(Math.min(t.start-r,i.end-r),e+r),t.start-i>r&&this.flushMainBuffer(i,t.start)):this.flushMainBuffer(0,t.start))}getFwdBufferInfo(t,e){var r=this.getLoadPosition();return D(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){var i=this["config"]["maxBufferHole"],s=E.bufferInfo(t,e,i);if(0===s.len&&void 0!==s.nextStart){r=this.fragmentTracker.getBufferedFrag(e,r);if(r&&s.nextStart<r.end)return E.bufferInfo(t,e,Math.max(s.nextStart,i))}return s}getMaxBufferLength(t){var e=this["config"],t=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength;return Math.min(t,e.maxMaxBufferLength)}reduceMaxBufferLength(t){var e=this.config,t=t||e.maxBufferLength;return e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0)}getAppendedFrag(t,e=0){t=this.fragmentTracker.getAppendedFrag(t,y);return t&&"fragment"in t?t.fragment:t}getNextFragment(t,e){const r=e.fragments,i=r.length;if(!i)return null;const s=this["config"],a=r[0].start;let n;if(e.live){const a=s.initialLiveManifestSize;if(i<a)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${a})`),null;e.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(e,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:t)}else t<=a&&(n=r[0]);if(!n){const r=s.lowLatencyMode?e.partEnd:e.fragmentEnd;n=this.getFragmentAtPosition(t,r,e)}return this.mapToInitFragWhenRequired(n)}isLoopLoading(t,e){var r=this.fragmentTracker.getState(t);return(r===We||r===Ye&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,r,i,s){var a=t.gap,e=this.getNextFragment(this.nextLoadPosition,e);if(null===e)return e;if(t=e,a&&t&&!t.gap&&r.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,r.nextStart,i);if(null!==e&&r.len+e.len>=s)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: `+t.sn),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(r,i,s){let a=-1,n=!1,o=!0;for(let t=0,e=r.length;t<e;t++){var l=r[t];if(o=o&&!l.independent,-1<a&&s<l.start)break;var h=l.loaded;h?a=-1:(n||l.independent||o)&&l.fragment===i&&(a=t),n=h}return a}loadedEndOfParts(t,e){t=t[t.length-1];return t&&e>t.start&&t.loaded}getInitialLiveFragment(t,e){var r,i,s=this.fragPrevious;let a=null;if(s)t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+s.programDateTime),a=function(e,r,i){if(null!==r&&Array.isArray(e)&&e.length&&D(r)&&!(r<(e[0].programDateTime||0)||r>=(e[e.length-1].endProgramDateTime||0))){i=i||0;for(let t=0;t<e.length;++t){var s=e[t];if(a=r,n=i,o=s,n=1e3*Math.min(i,o.duration+(o.deltaPTS||0)),(o.endProgramDateTime||0)-n>a)return s}var a,n,o}return null}(e,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),a||((r=s.sn+1)>=t.startSN&&r<=t.endSN&&(r=e[r-t.startSN],s.cc===r.cc)&&(a=r,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn)),a)||(a=(r=e,i=s.cc,Oe(r,t=>t.cc<i?1:t.cc>i?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn);else{const e=this.hls.liveSyncPosition;null!==e&&(a=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a}getFragmentAtPosition(t,e,r){var i=this["config"];let s=this["fragPrevious"],{fragments:a,endSN:n}=r;var o=r["fragmentHint"],l=i.maxFragLookUpTolerance,h=r.partList,i=!!(i.lowLatencyMode&&null!=h&&h.length&&o);let d;if(i&&o&&!this.bitrateTest&&(a=a.concat(o),n=o.sn),d=t<e?Fe(s,a,t,e-l<t?0:l):a[a.length-1]){const t=d.sn-r.startSN,e=this.fragmentTracker.getState(d);if((s=e===We||e===Ye&&d.gap?d:s)&&d.sn===s.sn&&(!i||h[0].fragment.sn>d.sn)&&s&&d.level===s.level){const e=a[1+t];d=d.sn<n&&this.fragmentTracker.getState(e)!==We?e:null}}return d}synchronizeToLiveEdge(t){var{config:e,media:r}=this;if(r){const i=this.hls.liveSyncPosition,s=r.currentTime,a=t.fragments[0].start,n=t.edge,o=s>=a-e.maxFragLookUpTolerance&&s<=n;if(null!==i&&r.duration>i&&(s<i||!o)){const a=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&r.readyState<4||s<n-a)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState)&&(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${n}, reset currentTime to : `+i.toFixed(3)),r.currentTime=i)}}}alignPlaylists(t,e){const{levels:r,levelLastLoaded:i,fragPrevious:s}=this,a=null!==i?r[i]:null,n=t.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,l=!e,h=t.alignedSliding&&D(o);if(l||!h&&!o){var d,l=s,h=a,u=t;if(h){var c=l,f=(l=u,h);if(f.details&&(l.endCC>l.startCC||c&&c.cc<l.startCC)){f=f.details.fragments;const c=(d=l.fragments).length&&f.length?(f=ir(f,d[0].cc))&&f.startPTS?f:void P.log("No frag in previous level to align on"):void P.log("No fragments to align");c&&D(c.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+l.url),ar(c.start,l))}!u.alignedSliding&&h.details&&(c=u,(d=h.details).fragments.length)&&c.hasProgramDateTime&&d.hasProgramDateTime&&(f=d.fragments[0].programDateTime,d=((l=c.fragments[0].programDateTime)-f)/1e3+d.fragments[0].start)&&D(d)&&(P.log(`Adjusting PTS using programDateTime delta ${l-f}ms, sliding:${d.toFixed(3)} ${c.url} `),ar(d,c)),u.alignedSliding||!h.details||u.skippedSegments||De(h.details,u)}const r=t.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${s?s.sn:"na"} fragments: `+n),r}return o}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let r=this.startPosition;var i,s;-1!==(r=r<e?-1:r)&&-1!==this.lastCurrentTime||(null!==(s=((i=null!==this.startTimeOffset)?this:t).startTimeOffset)&&D(s)?(r=e+s,s<0&&(r+=t.totalduration),r=Math.min(Math.max(e,r),e+t.totalduration),this.log(`Start time offset ${s} found in ${i?"multivariant":"media"} playlist, adjust startPosition to `+r),this.startPosition=r):t.live?r=this.hls.liveSyncPosition||e:this.startPosition=r=0,this.lastCurrentTime=r),this.nextLoadPosition=r}getLoadPosition(){var t=this["media"];let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===fr)||(this.state=d)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}var r=e.frag;if(r&&r.type===t&&this.levels)if(this.fragContextChanged(r))this.warn(`Frag load error must match current frag to retry ${r.url} > `+(null==(i=this.fragCurrent)?void 0:i.url));else{var i=e.details===C.FRAG_GAP,s=(i&&this.fragmentTracker.fragBuffered(r,!0),e.errorAction),{action:a,retryCount:n=0,retryConfig:o}=s||{};if(s&&5===a&&o){this.resetStartWhenNotLoaded(null!=(a=this.levelLastLoaded)?a:r.level);const i=Pe(o,n);this.warn(`Fragment ${r.sn} of ${t} ${r.level} errored with ${e.details}, retrying loading ${n+1}/${o.maxNumRetry} in ${i}ms`),s.resolved=!0,this.retryDate=self.performance.now()+i,this.state=fr}else o&&s?(this.resetFragmentErrors(t),n<o.maxNumRetry?i||(s.resolved=!0):P.warn(e.details+` reached or exceeded max retry (${n})`)):2===(null==s?void 0:s.action)?this.state=Tr:this.state=vr;this.tickImmediate()}}reduceLengthAndFlushBuffer(t){var e,r,i;return(this.state===O||this.state===mr)&&(e=t.parent,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,e))&&.5<i.len)&&this.reduceMaxBufferLength(i.len),(i=!r)&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),i)}resetFragmentErrors(t){t===L&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==n&&(this.state=d)}afterBufferFlushed(t,e,r){t&&(t=E.getBuffered(t),this.fragmentTracker.detectEvictedFragments(e,t,r),this.state===pr)&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=d}resetStartWhenNotLoaded(t){this.loadedmetadata||(this.startFragRequested=!1,null!=(t=this.levels?this.levels[t].details:null)&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition)}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(s,t,a,n){var e;const o=a.details;if(o){if(Object.keys(s.elementaryStreams).reduce((t,e)=>{var r,i=s.elementaryStreams[e];return i?(r=i.endPTS-i.startPTS)<=0?(this.warn(`Could not parse fragment ${s.sn} ${e} duration reliably (${r})`),t||!1):(r=n?0:Ae(o,s,i.startPTS,i.endPTS,i.startDTS,i.endDTS),this.hls.trigger(I.LEVEL_PTS_UPDATED,{details:o,level:a,drift:r,type:e,frag:s,start:i.startPTS,end:i.endPTS}),!0):t},!1))a.fragmentError=0;else if(null===(null==(e=this.transmuxer)?void 0:e.error)){const t=new Error(`Found no media in fragment ${s.sn} of level ${s.level} resetting transmuxer to fallback to playlist timing`);if(0===a.fragmentError&&(a.fragmentError++,s.gap=!0,this.fragmentTracker.removeFragment(s),this.fragmentTracker.fragBuffered(s,!0)),this.warn(t.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:s,reason:`Found no media in msn ${s.sn} of level "${a.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=mr,this.hls.trigger(I.FRAG_PARSED,{frag:s,part:t})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(t=this.levelLastLoaded)?t:null==(t=this.fragCurrent)?void 0:t.level)?t:0),this.resetLoadingState())}set state(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}get state(){return this._state}}function Sr(){return self.SourceBuffer||self.WebKitSourceBuffer}function F(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Lr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,r){}demux(t,e){this.cachedData&&(t=Pt(this.cachedData,t),this.cachedData=null);let r,i=pt(t,0),s=i?i.length:0;var a,n,o=this._audioTrack,l=this._id3Track,h=i?(t=>{var e=Tt(t);for(let t=0;t<e.length;t++){var r=e[t];if(yt(r)){if(8===r.data.byteLength){var r=new Uint8Array(r.data),i=1&r[3];let t=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];return t/=45,i&&(t+=47721858.84),Math.round(t)}return}}})(i):void 0,d=t.length;for((null===this.basePTS||0===this.frameIndex&&D(h))&&(this.basePTS=br(h,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&0<i.length&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:fe,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(t,s)){const e=this.appendFrame(o,t,s);e?(this.frameIndex++,this.lastPTS=e.sample.pts,s+=e.length,r=s):s=d}else a=t,n=s,gt(a,n)&&vt(a,n+6)+10<=a.length-n?(i=pt(t,s),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:fe,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===d&&r!==d){const e=ft(t,r);this.cachedData?this.cachedData=Pt(this.cachedData,e):this.cachedData=e}}return{audioTrack:o,videoTrack:F(),id3Track:l,textTrack:F()}}demuxSampleAes(t,e,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){var e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:F(),id3Track:this._id3Track,textTrack:F()}}destroy(){}}const br=(t,e,r)=>D(t)?90*t:9e4*e+(r?9e4*r.baseTime/r.timescale:0);function Ar(t,e){return 255===t[e]&&240==(246&t[e+1])}function Rr(t,e){return 1&t[e+1]?7:9}function Dr(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function wr(t,e){return e+1<t.length&&Ar(t,e)}function kr(t,e,r,i,s){t.samplerate||(e=function(t,e,r,i){let s,a,n,o;var l=navigator.userAgent.toLowerCase(),h=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],u=(s=1+((192&e[r+2])>>>6),(60&e[r+2])>>>2);if(!(d.length-1<u))return n=(1&e[r+2])<<2,n|=(192&e[r+3])>>>6,P.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:`+u),a=/firefox/i.test(l)?6<=u?(s=5,o=new Array(4),u-3):(s=2,o=new Array(2),u):-1!==l.indexOf("android")?(s=2,o=new Array(2),u):(s=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=u?u-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=u&&1==n||/vivaldi/i.test(l))||!i&&1==n)&&(s=2,o=new Array(2)),u)),o[0]=s<<3,o[0]|=(14&u)>>1,o[1]|=(1&u)<<7,o[1]|=n<<3,5===s&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[u],channelCount:n,codec:"mp4a.40."+s,manifestCodec:h};t.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+u})}(e,r,i,s))&&(t.config=e.config,t.samplerate=e.samplerate,t.channelCount=e.channelCount,t.codec=e.codec,t.manifestCodec=e.manifestCodec,P.log(`parsed codec:${t.codec}, rate:${e.samplerate}, channels:`+e.channelCount))}function Ir(t){return 9216e4/t}function _r(t,r,i,e,s){var a=e+s*Ir(t.samplerate),n=function(){var t=Rr(r,i);if(i+t<=r.length){var e=Dr(r,i)-t;if(0<e)return{headerLength:t,frameLength:e}}}();let o;if(n){const{frameLength:e,headerLength:s}=n,l=s+e,h=Math.max(0,i+l-r.length);h?(o=new Uint8Array(l-s)).set(r.subarray(i+s,r.length),0):o=r.subarray(i+s,i+l);n={unit:o,pts:a};return h||t.samples.push(n),{sample:n,length:l,missing:h}}const l=r.length-i;return(o=new Uint8Array(l)).set(r.subarray(i,r.length),0),{sample:{unit:o,pts:a},length:l,missing:-1}}const Cr=/\/emsg[-/]ID3/i;let Pr=null;const xr=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Mr=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Or=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Fr=[0,1,1,4];function Nr(t,e,r,i,s){var a;return!(r+24>e.length)&&(a=Ur(e,r))&&r+a.frameLength<=e.length?(i=i+s*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:e.subarray(r,r+a.frameLength),pts:i,dts:i},t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(s),{sample:s,length:a.frameLength,missing:0}):void 0}function Ur(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,s=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!=r&&0!=s&&15!=s&&3!=a){var n=t[e+2]>>1&1,o=t[e+3]>>6,s=1e3*xr[14*(3==r?3-i:3==i?3:4)+s-1],a=Mr[3*(3==r?0:2==r?1:2)+a],l=3==o?1:2,r=Or[r][i],h=Fr[i],d=8*r*h,r=Math.floor(r*s/a+n)*h;if(null===Pr){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pr=t?parseInt(t[1]):0}return Pr&&Pr<=87&&2==i&&224e3<=s&&0==o&&(t[e+3]=128|t[e+3]),{sampleRate:a,channelCount:l,frameLength:r,samplesPerFrame:d}}}function Br(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Gr(t,e){return e+1<t.length&&Br(t,e)}class $r{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),e=Math.min(4,e);if(0===e)throw new Error("no bytes available");i.set(t.subarray(r,r+e)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}skipBits(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t||(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord()),this.word<<=t,this.bitsAvailable-=t}readBits(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(32<t&&P.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,0<this.bitsAvailable)this.word<<=e;else{if(!(0<this.bytesAvailable))throw new Error("no bits available");this.loadWord()}return 0<(e=t-e)&&this.bitsAvailable?r<<e|this.readBits(e):r}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var t=this.skipLZ();return this.readBits(t+1)-1}readEG(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let r,i=8,s=8;for(let t=0;t<e;t++)0!==s&&(r=this.readEG(),s=(i+r+256)%256),i=0===s?i:s}readSPS(){let t,e,r,i=0,s=0,a=0,n=0;var o=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),d=this.readBoolean.bind(this),u=this.skipBits.bind(this),c=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this),m=(o(),o());if(l(5),u(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const t=h();if(3===t&&u(1),f(),f(),u(1),d())for(e=3!==t?8:12,r=0;r<e;r++)d()&&g(r<6?16:64)}f();m=h();if(0===m)h();else if(1===m)for(u(1),c(),c(),t=h(),r=0;r<t;r++)c();f(),u(1);m=h(),f=h(),l=l(1);0===l&&u(1),u(1),d()&&(i=h(),s=h(),a=h(),n=h());let p=[1,1];if(d()&&d())switch(o()){case 1:p=[1,1];break;case 2:p=[12,11];break;case 3:p=[10,11];break;case 4:p=[16,11];break;case 5:p=[40,33];break;case 6:p=[24,11];break;case 7:p=[20,11];break;case 8:p=[32,11];break;case 9:p=[80,33];break;case 10:p=[18,11];break;case 11:p=[15,11];break;case 12:p=[64,33];break;case 13:p=[160,99];break;case 14:p=[4,3];break;case 15:p=[3,2];break;case 16:p=[2,1];break;case 255:p=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(m+1)-2*i-2*s),height:(2-l)*(f+1)*16-(l?2:4)*(a+n),pixelRatio:p}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Kr{constructor(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new dr(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,r,i){const s=e[r].unit;var t;s.length<=16||(t=(t=s.subarray(16,s.length-s.length%16)).buffer.slice(t.byteOffset,t.byteOffset+t.length),this.decryptBuffer(t).then(t=>{t=new Uint8Array(t);s.set(t,16),this.decrypter.isSync()||this.decryptAacSamples(e,r+1,i)}))}decryptAacSamples(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}}getAvcEncryptedData(e){var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){var r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,r,i,s,a){const n=Ot(a.data),t=this.getAvcEncryptedData(n);this.decryptBuffer(t.buffer).then(t=>{a.data=this.getAvcDecryptedUnit(n,t),this.decrypter.isSync()||this.decryptAvcSamples(e,r,i+1,s)})}decryptAvcSamples(t,e,r,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void i();for(var s=t[e].units;!(r>=s.length);r++){var a=s[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,i,a),this.decrypter.isSync())))return}}}}class Hr{constructor(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}static probe(t){t=Hr.syncOffset(t);return 0<t&&P.warn("MPEG2-TS detected but first sync word found @ offset "+t),-1!==t}static syncOffset(s){var a=s.length;let n=Math.min(940,s.length-188)+1,o=0;for(;o<n;){let e=!1,r=-1,i=0;for(let t=o;t<a;t+=188){if(71!==s[t]){if(i)return-1;break}if(i++,-1===r&&0!==(r=t)&&(n=Math.min(r+18612,s.length-188)+1),(e=e||0===Yr(s,t))&&1<i&&(0===r&&2<i||t+188>n))return r}o++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Dt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Hr.createTrack("video"),this._audioTrack=Hr.createTrack("audio",i),this._id3Track=Hr.createTrack("id3"),this._txtTrack=Hr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){var{_audioTrack:t,_avcTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(r,t,i=!1,s=!1){let a;i||(this.sampleAes=null);var n=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let d=n.pid,u=n.pesData,c=o.pid,f=l.pid,g=o.pesData,m=l.pesData,p=null,v=this.pmtParsed,y=this._pmtId,T=r.length;if(this.remainderData&&(T=(r=Pt(this.remainderData,r)).length,this.remainderData=null),T<188&&!s)return this.remainderData=r,{audioTrack:o,videoTrack:n,id3Track:l,textTrack:h};var E,S,L=Math.max(0,Hr.syncOffset(r));(T-=(T-L)%188)<r.byteLength&&!s&&(this.remainderData=new Uint8Array(r.buffer,T,r.buffer.byteLength-T));let b=0;for(let e=L;e<T;e+=188)if(71===r[e]){const s=!!(64&r[e+1]),I=Yr(r,e);let t;if(1<(48&r[e+3])>>4){if((t=e+5+r[e+4])===e+188)continue}else t=e+4;switch(I){case d:s&&(u&&(a=Wr(u))&&this.parseAVCPES(n,h,a,!1),u={data:[],size:0}),u&&(u.data.push(r.subarray(t,e+188)),u.size+=e+188-t);break;case c:if(s){if(g&&(a=Wr(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}g={data:[],size:0}}g&&(g.data.push(r.subarray(t,e+188)),g.size+=e+188-t);break;case f:s&&(m&&(a=Wr(m))&&this.parseID3PES(l,a),m={data:[],size:0}),m&&(m.data.push(r.subarray(t,e+188)),m.size+=e+188-t);break;case 0:s&&(t+=r[t]+1),y=this._pmtId=(E=r,S=t,(31&E[S+10])<<8|E[S+11]);break;case y:{s&&(t+=r[t]+1);const a=function(t,e,r,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<a;){const a=Yr(t,e);switch(t[e]){case 207:if(!i){P.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===s.audio&&(s.audio=a);break;case 21:-1===s.id3&&(s.id3=a);break;case 219:if(!i){P.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===s.avc&&(s.avc=a);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?P.log("MPEG audio found, not supported in this browser"):-1===s.audio&&(s.audio=a,s.segmentCodec="mp3");break;case 36:P.warn("Unsupported HEVC stream type found")}e+=5+((15&t[e+3])<<8|t[e+4])}return s}(r,t,this.typeSupported,i);0<(d=a.avc)&&(n.pid=d),0<(c=a.audio)&&(o.pid=c,o.segmentCodec=a.segmentCodec),0<(f=a.id3)&&(l.pid=f),null===p||v||(P.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${L} to parse all TS packets.`),p=null,e=L-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=I}}else b++;if(0<b){const r=new Error(`Found ${b} TS packet/s that do not start with 0x47`);this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:r,reason:r.message})}n.pesData=u,o.pesData=g,l.pesData=m;var e={audioTrack:o,videoTrack:n,id3Track:l,textTrack:h};return s&&this.extractRemainingSamples(e),e}flush(){var t=this["remainderData"];return this.remainderData=null,t=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(t){var{audioTrack:e,videoTrack:t,id3Track:r,textTrack:i}=t,s=t.pesData,a=e.pesData,n=r.pesData;let o;if(s&&(o=Wr(s))?(this.parseAVCPES(t,i,o,!0),t.pesData=null):t.pesData=s,a&&(o=Wr(a))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,o);break;case"mp3":this.parseMPEGPES(e,o)}e.pesData=null}else null!=a&&a.size&&P.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;n&&(o=Wr(n))?(this.parseID3PES(r,o),r.pesData=null):r.pesData=n}demuxSampleAes(t,e,r){t=this.demux(t,r,!0,!this.config.progressive),r=this.sampleAes=new Kr(this.observer,this.config,e);return this.decrypt(t,r)}decrypt(i,s){return new Promise(t=>{const{audioTrack:e,videoTrack:r}=i;e.samples&&"aac"===e.segmentCodec?s.decryptAacSamples(e.samples,0,()=>{r.samples?s.decryptAvcSamples(r.samples,0,0,()=>{t(i)}):t(i)}):r.samples&&s.decryptAvcSamples(r.samples,0,0,()=>{t(i)})})}destroy(){this._duration=0}parseAVCPES(s,t,a,e){var r=this.parseAVCNALu(s,a.data);let n,o=this.avcSample,l=!1;a.data=null,o&&r.length&&!s.audFound&&(jr(o,s),o=this.avcSample=Vr(!1,a.pts,a.dts,"")),r.forEach(e=>{var i,r;switch(e.type){case 1:{let t=!1;n=!0;const i=e.data;if(l&&4<i.length){const s=new $r(i).readSliceType();2!==s&&4!==s&&7!==s&&9!==s||(t=!0)}t&&null!=(r=o)&&r.frame&&!o.key&&(jr(o,s),o=this.avcSample=null),(o=o||(this.avcSample=Vr(!0,a.pts,a.dts,""))).frame=!0,o.key=t;break}case 5:n=!0,null!=(i=o)&&i.frame&&!o.key&&(jr(o,s),o=this.avcSample=null),(o=o||(this.avcSample=Vr(!0,a.pts,a.dts,""))).key=!0,o.frame=!0;break;case 6:n=!0,Mt(e.data,1,a.pts,t.samples);break;case 7:if(n=!0,l=!0,!s.sps){const t=e.data,a=new $r(t).readSPS(),i=(s.width=a.width,s.height=a.height,s.pixelRatio=a.pixelRatio,s.sps=[t],s.duration=this._duration,t.subarray(1,4));let r="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),r+=t}s.codec=r}break;case 8:n=!0,s.pps||(s.pps=[e.data]);break;case 9:n=!1,s.audFound=!0,o&&jr(o,s),o=this.avcSample=Vr(!1,a.pts,a.dts,"");break;case 12:n=!0;break;default:n=!1,o&&(o.debug+="unknown NAL "+e.type+" ")}o&&n&&o.units.push(e)}),e&&o&&(jr(o,s),this.avcSample=null)}getLastNalUnit(t){let e,r=this.avcSample;if(null!=(t=r=r&&0!==r.units.length?r:t[t.length-1])&&t.units){const t=r.units;e=t[t.length-1]}return e}parseAVCNALu(t,e){const r=e.byteLength;let i=t.naluState||0;var s=i,a=[];let n,o,l,h=0,d=-1,u=0;for(-1===i&&(d=0,u=31&e[0],i=0,h=1);h<r;)if(n=e[h++],i)if(1!==i)if(n)if(1===n){if(0<=d){const t={data:e.subarray(d,h-i-1),type:u};a.push(t)}else{const r=this.getLastNalUnit(t.samples);if(r&&(s&&h<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),0<(o=h-i-1))){const t=new Uint8Array(r.data.byteLength+o);t.set(r.data,0),t.set(e.subarray(0,o),r.data.byteLength),r.data=t,r.state=0}}i=h<r?(l=31&e[h],d=h,u=l,0):-1}else i=0;else i=3;else i=n?0:2;else i=n?0:1;if(0<=d&&0<=i){const t={data:e.subarray(d,r),type:u,state:i};a.push(t)}if(0===a.length){const r=this.getLastNalUnit(t.samples);if(r){const t=new Uint8Array(r.data.byteLength+e.byteLength);t.set(r.data,0),t.set(e,r.data.byteLength),r.data=t}}return t.naluState=i,a}parseAACPES(t,e){let r=0;var i,s=this.aacOverFlow;let a,n,o,l=e.data;if(s){this.aacOverFlow=null;const e=s.missing,a=s.sample.unit.byteLength;if(-1===e){const t=new Uint8Array(a+l.byteLength);t.set(s.sample.unit,0),t.set(l,a),l=t}else{const n=a-e;s.sample.unit.set(l.subarray(0,e),n),t.samples.push(s.sample),r=s.missing}}for(a=r,n=l.length;a<n-1&&!wr(l,a);a++);if(a!==r){const e=a<n-1,r=(i=e?"AAC PES did not start with ADTS header,offset:"+a:"No ADTS header found in AAC PES",new Error(i));if(P.warn("parsing error: "+i),this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,levelRetry:e,error:r,reason:i}),!e)return}if(kr(t,this.observer,l,a,this.audioCodec),void 0!==e.pts)o=e.pts;else{if(!s)return void P.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=Ir(t.samplerate);o=s.sample.pts+e}}let h,d=0;for(;a<n;){if(h=_r(t,l,a,o,d),a+=h.length,h.missing){this.aacOverFlow=h;break}for(d++;a<n-1&&!wr(l,a);a++);}}parseMPEGPES(t,e){var r=e.data,i=r.length;let s=0,a=0;var n=e.pts;if(void 0!==n)for(;a<i;)if(Gr(r,a)){const e=Nr(t,r,a,n,s);if(!e)break;a+=e.length,s++}else a++;else P.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(t,e){void 0===e.pts?P.warn("[tsdemuxer]: ID3 PES unknown PTS"):(e=k({},e,{type:this._avcTrack?ge:fe,duration:Number.POSITIVE_INFINITY}),t.samples.push(e))}}function Vr(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}}function Yr(t,e){return((31&t[e+1])<<8)+t[e+2]}function Wr(t){let i,e,s,a,n,o=0;var l=t.data;if(!t||0===t.size)return null;for(;l[0].length<19&&1<l.length;){const t=new Uint8Array(l[0].length+l[1].length);t.set(l[0]),t.set(l[1],l[0].length),l[0]=t,l.splice(1,1)}if(1!==((i=l[0])[0]<<16)+(i[1]<<8)+i[2])return null;{if((e=(i[4]<<8)+i[5])&&e>t.size-6)return null;var h=i[7];192&h&&(a=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&h?(n=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,54e5<a-n&&(P.warn(Math.round((a-n)/9e4)+"s delta between PTS and DTS, align them"),a=n)):n=a);let r=(s=i[8])+9;if(t.size<=r)return null;t.size-=r;var d=new Uint8Array(t.size);for(let e=0,t=l.length;e<t;e++){let t=(i=l[e]).byteLength;if(r){if(r>t){r-=t;continue}i=i.subarray(r),t-=r,r=0}d.set(i,o),o+=t}return e&&(e-=s+3),{data:d,pts:a,dts:n,len:e}}}function jr(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return e.dropped++;{const e=r[i-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&P.log(t.pts+"/"+t.dts+":"+t.debug)}class qr{static getSilentFrame(t,e){return"mp4a.40.2"===t?1===e?new Uint8Array([0,200,0,128,35,128]):2===e?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===e?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===e?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]):void 0:1===e?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]):2===e||3===e?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]):void 0}}const Xr=Math.pow(2,32)-1;class N{static init(){let t;for(t in N.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},N.types)N.types.hasOwnProperty(t)&&(N.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var e=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=(N.HDLR_TYPES={video:e,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(N.STTS=N.STSC=N.STCO=r,N.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),N.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),N.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),N.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);N.FTYP=N.box(N.types.ftyp,r,s,r,i),N.DINF=N.box(N.types.dinf,N.box(N.types.dref,e))}static box(t,...e){let r=8,i=e.length;for(var s=i;i--;)r+=e[i].byteLength;var a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(t,4),i=0,r=8;i<s;i++)a.set(e[i],r),r+=e[i].byteLength;return a}static hdlr(t){return N.box(N.types.hdlr,N.HDLR_TYPES[t])}static mdat(t){return N.box(N.types.mdat,t)}static mdhd(t,e){e*=t;var r=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr));return N.box(N.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,85,196,0,0]))}static mdia(t){return N.box(N.types.mdia,N.mdhd(t.timescale,t.duration),N.hdlr(t.type),N.minf(t))}static mfhd(t){return N.box(N.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?N.box(N.types.minf,N.box(N.types.smhd,N.SMHD),N.DINF,N.stbl(t)):N.box(N.types.minf,N.box(N.types.vmhd,N.VMHD),N.DINF,N.stbl(t))}static moof(t,e,r){return N.box(N.types.moof,N.mfhd(t),N.traf(r,e))}static moov(t){let e=t.length;for(var r=[];e--;)r[e]=N.trak(t[e]);return N.box.apply(null,[N.types.moov,N.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(N.mvex(t)))}static mvex(t){let e=t.length;for(var r=[];e--;)r[e]=N.trex(t[e]);return N.box.apply(null,[N.types.mvex,...r])}static mvhd(t,e){e*=t;var r=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr)),t=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,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 N.box(N.types.mvhd,t)}static sdtp(t){var e=t.samples||[],r=new Uint8Array(4+e.length);let i,s;for(i=0;i<e.length;i++)s=e[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return N.box(N.types.sdtp,r)}static stbl(t){return N.box(N.types.stbl,N.stsd(t),N.box(N.types.stts,N.STTS),N.box(N.types.stsc,N.STSC),N.box(N.types.stsz,N.STSZ),N.box(N.types.stco,N.STCO))}static avc1(t){let e,r,i,s=[],a=[];for(e=0;e<t.sps.length;e++)r=t.sps[e],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(e=0;e<t.pps.length;e++)r=t.pps[e],i=r.byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(r));var n=N.box(N.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|t.sps.length].concat(s).concat([t.pps.length]).concat(a))),o=t.width,l=t.height,h=t.pixelRatio[0],d=t.pixelRatio[1];return N.box(N.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,o>>8&255,255&o,l>>8&255,255&l,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]),n,N.box(N.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),N.box(N.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){var e=t.samplerate;return N.box(N.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),N.box(N.types.esds,N.esds(t)))}static mp3(t){var e=t.samplerate;return N.box(N.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?N.box(N.types.stsd,N.STSD,N.mp3(t)):N.box(N.types.stsd,N.STSD,N.mp4a(t)):N.box(N.types.stsd,N.STSD,N.avc1(t))}static tkhd(t){var e=t.id,r=t.duration*t.timescale,i=t.width,t=t.height,s=Math.floor(r/(1+Xr)),r=Math.floor(r%(1+Xr));return N.box(N.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,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,i>>8&255,255&i,0,0,t>>8&255,255&t,0,0]))}static traf(t,e){var r=N.sdtp(t),i=t.id,s=Math.floor(e/(1+Xr)),e=Math.floor(e%(1+Xr));return N.box(N.types.traf,N.box(N.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),N.box(N.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,e>>24,e>>16&255,e>>8&255,255&e])),N.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,N.box(N.types.trak,N.tkhd(t),N.mdia(t))}static trex(t){t=t.id;return N.box(N.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){var r=t.samples||[],i=r.length,s=12+16*i,a=new Uint8Array(s);let n,o,l,h,d,u;for(a.set(["video"===t.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,(e+=8+s)>>>24&255,e>>>16&255,e>>>8&255,255&e],0),n=0;n<i;n++)l=(o=r[n]).duration,h=o.size,d=o.flags,u=o.cts,a.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return N.box(N.types.trun,a)}static initSegment(t){N.types||N.init();var t=N.moov(t),e=new Uint8Array(N.FTYP.byteLength+t.byteLength);return e.set(N.FTYP),e.set(t,N.FTYP.byteLength),e}}function zr(t,e,r=1,i=!1){t=t*e*r;return i?Math.round(t):t}function Qr(t,e=!1){return zr(t,1e3,1/9e4,e)}N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0;let Jr,Zr=null,ti=null;class ei{constructor(t,e,r,i=0){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.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Zr){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zr=t?parseInt(t[1]):0}if(null===ti){const t=navigator.userAgent.match(/Safari\/(\d+)/i);ti=t?parseInt(t[1]):0}}destroy(){}resetTimeStamp(t){P.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){P.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){P.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let i=!1;t=t.reduce((t,e)=>{var r=e.pts-t;return r<-4294967296?(i=!0,U(t,e.pts)):0<r?t:e.pts},t[0].pts);return i&&P.debug("PTS rollover detected"),t}remux(r,i,s,a,n,o,t,l){let h,d,u,e,c,f,g=n,m=n;var p=-1<r.pid,v=-1<i.pid,y=i.samples.length,T=0<r.samples.length,E=t&&0<y||1<y;if((!p||T)&&(!v||E)||this.ISGenerated||t){this.ISGenerated||(u=this.generateIS(r,i,n,o));const s=this.isVideoContiguous;let t,e=-1;if(E&&(e=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(i.samples),!s)&&this.config.forceKeyFrameOnDiscontinuity)if(f=!0,0<e){P.warn(`[mp4-remuxer]: Dropped ${e} out of ${y} video samples due to a missing keyframe`);const r=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(e),i.dropped+=e,m+=(i.samples[0].pts-r)/i.inputTimeScale,t=m}else-1===e&&(P.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(T&&E){const s=this.getVideoStartPts(i.samples),a=(U(r.samples[0].pts,s)-s)/i.inputTimeScale;g+=Math.max(0,a),m+=Math.max(0,-a)}if(T){if(r.samplerate||(P.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(r,i,n,o)),d=this.remuxAudio(r,g,this.isAudioContiguous,o,v||E||l===L?m:void 0),E){const a=d?d.endPTS-d.startPTS:0;i.inputTimeScale||(P.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(r,i,n,o)),h=this.remuxVideo(i,m,s,a)}}else E&&(h=this.remuxVideo(i,m,s,0));h&&(h.firstKeyFrame=e,h.independent=-1!==e,h.firstKeyFramePTS=t)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(c=ri(s,n,this._initPTS,this._initDTS)),a.samples.length)&&(e=ii(a,n,this._initPTS)),{audio:d,video:h,initSegment:u,independent:f,text:e,id3:c}}generateIS(t,e,r,i){var s=t.samples,a=e.samples,n=this.typeSupported,o={},l=this._initPTS;let h,d,u,c=!l||i,f="audio/mp4";if(c&&(h=d=1/0),t.config&&s.length&&("mp3"===(t.timescale=t.samplerate,t.segmentCodec)&&(n.mpeg?(f="audio/mpeg",t.codec=""):n.mp3&&(t.codec="mp3")),o.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&n.mpeg?new Uint8Array(0):N.initSegment([t]),metadata:{channelCount:t.channelCount}},c)&&(u=t.inputTimeScale,l&&u===l.timescale?c=!1:h=d=s[0].pts-Math.round(u*r)),e.sps&&e.pps&&a.length&&(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:N.initSegment([e]),metadata:{width:e.width,height:e.height}},c))if(u=e.inputTimeScale,l&&u===l.timescale)c=!1;else{const t=this.getVideoStartPts(a),e=Math.round(u*r);d=Math.min(d,U(a[0].dts,t)-e),h=Math.min(h,t-e)}if(Object.keys(o).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:u},this._initDTS={baseTime:d,timescale:u}):h=u=void 0,{tracks:o,initPTS:h,timescale:u}}remuxVideo(i,s,a,n){const o=i.inputTimeScale,l=i.samples,h=[],d=l.length,t=this._initPTS;let u,e,r=this.nextAvcDts,c=8,f=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;a&&null!==r||(r=s*o-(l[0].pts-U(l[0].dts,l[0].pts)));var v=t.baseTime*o/t.timescale;for(let t=0;t<d;t++){const s=l[t];s.pts=U(s.pts-v,r),s.dts=U(s.dts-v,r),s.dts<l[0<t?t-1:t].dts&&(p=!0)}p&&l.sort(function(t,e){var r=t.dts-e.dts,t=t.pts-e.pts;return r||t}),u=l[0].dts;var s=l[l.length-1].dts-u,y=s?Math.round(s/(d-1)):f||i.inputTimeScale/30;if(a){const i=u-r,s=i>y,a=i<-1;if((s||a)&&(s?P.warn(`AVC: ${Qr(i,!0)} ms (${i}dts) hole between fragments detected, filling it`):P.warn(`AVC: ${Qr(-i,!0)} ms (${i}dts) overlapping between fragments detected`),!a||r>=l[0].pts)){u=r;const s=l[0].pts-i;l[0].dts=u,l[0].pts=s,P.log(`Video: First PTS/DTS adjusted: ${Qr(s,!0)}/${Qr(u,!0)}, delta: ${Qr(i,!0)} ms`)}}u=Math.max(0,u);let T=0,E=0;for(let t=0;t<d;t++){const s=l[t],a=s.units,n=a.length;let e=0;for(let t=0;t<n;t++)e+=a[t].data.length;E+=e,T+=n,s.length=e,s.dts=Math.max(s.dts,u),g=Math.min(s.pts,g),m=Math.max(s.pts,m)}e=l[d-1].dts;s=E+4*T+8;let S;try{S=new Uint8Array(s)}catch(i){return void this.observer.emit(I.ERROR,I.ERROR,{type:_.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:i,bytes:s,reason:"fail allocating video mdat "+s})}var L=new DataView(S.buffer);L.setUint32(0,s),S.set(N.types.mdat,4);let b=!1,A=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY,w=Number.NEGATIVE_INFINITY;for(let e=0;e<d;e++){const s=l[e],a=s.units;let t,r=0;for(let t=0,e=a.length;t<e;t++){const s=a[t],n=s.data,o=s.data.byteLength;L.setUint32(c,o),c+=4,S.set(n,c),c+=o,r+=4+o}if(e<d-1)f=l[e+1].dts-s.dts,t=l[e+1].pts-s.pts;else{const a=this.config,h=0<e?s.dts-l[e-1].dts:y;if(t=0<e?s.pts-l[e-1].pts:y,a.stretchShortVideoTrack&&null!==this.nextAudioPts){const i=Math.floor(a.maxBufferHole*o),l=(n?g+n*o:this.nextAudioPts)-s.pts;l>i?((f=l-h)<0?f=h:b=!0,P.log(`[mp4-remuxer]: It is approximately ${l/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=h}else f=h}const u=Math.round(s.pts-s.dts);A=Math.min(A,f),D=Math.max(D,f),R=Math.min(R,t),w=Math.max(w,t),h.push(new si(s.key,f,r,u))}if(h.length)if(Zr){if(Zr<70){const i=h[0].flags;i.dependsOn=2,i.isNonSync=0}}else if(ti&&w-R<D-A&&y/D<.025&&0===h[0].cts){P.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let r=u;for(let t=0,e=h.length;t<e;t++){const n=r+h[t].duration,o=r+h[t].cts;if(t<e-1){const i=n+h[t+1].cts;h[t].duration=i-o}else h[t].duration=t?h[t-1].duration:y;h[t].cts=0,r=n}}f=b||!f?y:f,this.nextAvcDts=r=e+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;a={data1:N.moof(i.sequenceNumber++,u,k({},i,{samples:h})),data2:S,startPTS:g/o,endPTS:(m+f)/o,startDTS:u/o,endDTS:r/o,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:i.dropped};return i.samples=[],i.dropped=0,a}remuxAudio(s,a,r,i,n){const t=s.inputTimeScale,o=t/(s.samplerate||t),l="aac"===s.segmentCodec?1024:1152,h=l*o,e=this._initPTS,d="mp3"===s.segmentCodec&&this.typeSupported.mpeg,u=[],c=void 0!==n;let f=s.samples,g=d?0:8,m=this.nextAudioPts||-1;const p=a*t,v=e.baseTime*t/e.timescale;if(this.isAudioContiguous=r=r||f.length&&0<m&&(i&&Math.abs(p-m)<9e3||Math.abs(U(f[0].pts-v,p)-m)<20*h),f.forEach(function(t){t.pts=U(t.pts-v,p)}),!r||m<0){if(!(f=f.filter(t=>0<=t.pts)).length)return;m=0===n?0:i&&!c?Math.max(0,p):f[0].pts}if("aac"===s.segmentCodec){const a=this.config.maxAudioFramesDrift;for(let r=0,i=m;r<f.length;r++){const n=f[r],o=n.pts,l=o-i,k=Math.abs(1e3*l/t);if(l<=-a*h&&c)0===r&&(P.warn(`Audio frame @ ${(o/t).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*l/t)} ms.`),this.nextAudioPts=m=i=o);else if(l>=a*h&&k<1e4&&c){let e=Math.round(l/h);(i=o-e*h)<0&&(e--,i+=h),0===r&&(this.nextAudioPts=m=i),P.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(i/t).toFixed(3)}s due to ${Math.round(1e3*l/t)} ms gap.`);for(let t=0;t<e;t++){const a=Math.max(i,0);let t=qr.getSilentFrame(s.manifestCodec||s.codec,s.channelCount);t||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),t=n.unit.subarray()),f.splice(r,0,{unit:t,pts:a}),i+=h,r++}}n.pts=i,i+=h}}let y,T=null,E=null,S=0,L=f.length;for(;L--;)S+=f[L].unit.byteLength;for(let e=0,t=f.length;e<t;e++){const i=f[e],n=i.unit;let t=i.pts;if(null!==E)u[e-1].duration=Math.round((t-E)/o);else{if(r&&"aac"===s.segmentCodec&&(t=m),T=t,!(0<S))return;S+=g;try{y=new Uint8Array(S)}catch(s){return void this.observer.emit(I.ERROR,I.ERROR,{type:_.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:s,bytes:S,reason:"fail allocating audio mdat "+S})}d||(new DataView(y.buffer).setUint32(0,S),y.set(N.types.mdat,4))}y.set(n,g);const h=n.byteLength;g+=h,u.push(new si(!0,l,h,0)),E=t}var b,a=u.length;if(a)return this.nextAudioPts=m=E+o*u[u.length-1].duration,n=d?new Uint8Array(0):N.moof(s.sequenceNumber++,T/o,k({},s,{samples:u})),s.samples=[],i=T/t,b=m/t,n={data1:n,data2:y,startPTS:i,endPTS:b,startDTS:i,endDTS:b,type:"audio",hasAudio:!0,hasVideo:!1,nb:a},this.isAudioContiguous=!0,n}remuxEmptyAudio(t,e,r,i){var s=t.inputTimeScale,a=s/(t.samplerate||s),n=this.nextAudioPts,o=this._initDTS,o=9e4*o.baseTime/o.timescale,l=(null!==n?n:i.startDTS*s)+o,n=i.endDTS*s+o,h=1024*a,d=Math.ceil((n-l)/h),u=qr.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(P.warn("[mp4-remuxer]: remux empty Audio"),u){var c=[];for(let t=0;t<d;t++){const e=l+t*h;c.push({unit:u,pts:e,dts:e})}return t.samples=c,this.remuxAudio(t,e,r,!1)}P.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")}}function U(t,e){var r;if(null!==e)for(r=e<t?-8589934592:8589934592;4294967296<Math.abs(t-e);)t+=r;return t}function ri(e,r,i,s){const a=e.samples.length;if(a){var n=e.inputTimeScale;for(let t=0;t<a;t++){const a=e.samples[t];a.pts=U(a.pts-i.baseTime*n/i.timescale,r*n)/n,a.dts=U(a.dts-s.baseTime*n/s.timescale,r*n)/n}var t=e.samples;return e.samples=[],{samples:t}}}function ii(e,r,i){const s=e.samples.length;if(s){var a=e.inputTimeScale;for(let t=0;t<s;t++){const s=e.samples[t];s.pts=U(s.pts-i.baseTime*a/i.timescale,r*a)/a}e.samples.sort((t,e)=>t.pts-e.pts);var t=e.samples;return e.samples=[],{samples:t}}}class si{constructor(t,e,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=i,this.flags=new ai(t)}}class ai{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function ni(t,e){t=null==t?void 0:t.codec;return t&&4<t.length?t:"hvc1"===t||"hev1"===t?"hvc1.1.6.L120.90":"av01"===t?"av01.0.04M.08":"avc1"===t||e===b?"avc1.42e01e":"mp4a.40.5"}try{Jr=self.performance.now.bind(self.performance)}catch(i){P.debug("Unable to use Performance API on this environment"),Jr="undefined"!=typeof self&&self.Date.now}const oi=[{demux:class{constructor(t,e){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=e}resetTimeStamp(){}resetInitSegment(t,e,r,i){var s=this.videoTrack=F("video",1),a=this.audioTrack=F("audio",1),n=this.txtTrack=F("text",1);if(this.id3Track=F("id3",1),this.timeOffset=0,null!=t&&t.byteLength){var o=_t(t);if(o.video){const{id:t,timescale:e,codec:r}=o.video;s.id=t,s.timescale=n.timescale=e,s.codec=r}if(o.audio){const{id:t,timescale:e,codec:r}=o.audio;a.id=t,a.timescale=e,a.codec=r}n.id=Dt.text,s.sampleDuration=0,s.duration=a.duration=i}}resetContiguity(){this.remainderData=null}static probe(t){return 0<x(t=16384<t.length?t.subarray(0,16384):t,["moof"]).length}demux(t,e){this.timeOffset=e;let r=t;var i,s,a=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Pt(this.remainderData,t));t=r,i={valid:null,remainder:null},(s=x(t,["moof"]))&&(s.length<2?i.remainder=t:(s=s[s.length-1],i.valid=ft(t,0,s.byteOffset-8),i.remainder=ft(t,s.byteOffset-8)));const e=i;this.remainderData=e.remainder,a.samples=e.valid||new Uint8Array}else a.samples=r;t=this.extractID3Track(a,e);return n.samples=xt(e,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:t,textTrack:this.txtTrack}}flush(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack,i=(e.samples=this.remainderData||new Uint8Array,this.remainderData=null,this.extractID3Track(e,this.timeOffset));return r.samples=xt(t,e),{videoTrack:e,audioTrack:F(),id3Track:i,textTrack:F()}}extractID3Track(t,i){const s=this.id3Track;return t.samples.length&&(t=x(t.samples,["emsg"]))&&t.forEach(e=>{var r=function(t){const e=t[0];let r="",i="",s=0,a=0,n=0,o=0,l=0,h=0;if(0===e){for(;"\0"!==f(t.subarray(h,h+1));)r+=f(t.subarray(h,h+1)),h+=1;for(r+=f(t.subarray(h,h+1)),h+=1;"\0"!==f(t.subarray(h,h+1));)i+=f(t.subarray(h,h+1)),h+=1;i+=f(t.subarray(h,h+1)),h+=1,s=R(t,12),a=R(t,16),o=R(t,20),l=R(t,24),h=28}else if(1===e){h+=4,s=R(t,h);const e=R(t,h+=4),a=R(t,h+=4);for(h+=4,n=2**32*e+a,Number.isSafeInteger(n)||(n=Number.MAX_SAFE_INTEGER,P.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=R(t,h),h+=4,l=R(t,h),h+=4;"\0"!==f(t.subarray(h,h+1));)r+=f(t.subarray(h,h+1)),h+=1;for(r+=f(t.subarray(h,h+1)),h+=1;"\0"!==f(t.subarray(h,h+1));)i+=f(t.subarray(h,h+1)),h+=1;i+=f(t.subarray(h,h+1)),h+=1}return{schemeIdUri:r,value:i,timeScale:s,presentationTime:n,presentationTimeDelta:a,eventDuration:o,id:l,payload:t.subarray(h,t.byteLength)}}(e);if(Cr.test(r.schemeIdUri)){const e=D(r.presentationTime)?r.presentationTime/r.timeScale:i+r.presentationTimeDelta/r.timeScale;let t=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;t<=.001&&(t=Number.POSITIVE_INFINITY);r=r.payload;s.samples.push({data:r,len:r.byteLength,dts:e,pts:e,type:ge,duration:t})}}),s}demuxSampleAes(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,r,i){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(function(t,e){if(t&&e){const i=e.keyId;i&&e.isCommonEncryption&&x(t,["moov","trak"]).forEach(t=>{t=x(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let e=x(t,["enca"]);const r=0<e.length;(e=r?e:x(t,["encv"])).forEach(t=>{x(r?t.subarray(28):t.subarray(78),["sinf"]).forEach(t=>{var e=Ct(t);if(e){const t=e.subarray(8,24);t.some(t=>0!==t)||(P.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${c(t)} -> `+c(i)),e.set(i,8))}})})})}return t}(t,i)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;var i,s;null!=t&&t.byteLength?(i=this.initData=_t(t),e=e||ni(i.audio,S),r=r||ni(i.video,b),s={},i.audio&&i.video?s.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?s.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?s.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:P.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s):(this.initTracks=void 0,this.initData=void 0)}remux(r,i,s,a,n,o){let{initPTS:l,lastEndTime:h}=this;var d={audio:void 0,video:void 0,text:a,id3:s,initSegment:void 0},i=(D(h)||(h=this.lastEndTime=n||0),i.samples);if(null!=i&&i.length){var u={initPTS:void 0,timescale:1};let e=this.initData;if(null!=(m=e)&&m.length||(this.generateInitSegment(i),e=this.initData),null!=(m=e)&&m.length){this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var c,f,g,m=function(t,e){let r=0,i=0,s=0;var a=x(t,["moof","traf"]);for(let t=0;t<a.length;t++){var n=a[t],o=x(n,["tfhd"])[0],l=e[R(o,4)];if(l){var h=l.default,d=R(o,0)|(null==h?void 0:h.flags);let e=null==h?void 0:h.duration;8&d&&(e=R(o,2&d?12:8));var u=l.timescale||9e4,c=x(n,["trun"]);for(let t=0;t<c.length;t++)!(r=function(e){var r=R(e,0);let i=8,s=(1&r&&(i+=4),4&r&&(i+=4),0);var a=R(e,4);for(let t=0;t<a;t++)256&r&&(s+=R(e,i),i+=4),512&r&&(i+=4),1024&r&&(i+=4),2048&r&&(i+=4);return s}(c[t]))&&e&&(r=e*R(c[t],4)),l.type===b?i+=r/u:l.type===S&&(s+=r/u)}}if(0!==i||0!==s)return i||s;{let e=0;const r=x(t,["sidx"]);for(let t=0;t<r.length;t++){const i=function(e){var r=[],t=e[0];let i=8;var s=R(e,i);i=(i+=4)+(0===t?8:16)+2;let a=e.length+0;const n=wt(e,i);i+=2;for(let t=0;t<n;t++){var o=i;const n=R(e,o);o+=4;var l=2147483647&n;if(1==(2147483648&n)>>>31)return P.warn("SIDX has hierarchical references (not supported)"),null;var h=R(e,o);o+=4,r.push({referenceSize:l,subsegmentDuration:h,info:{duration:h/s,start:a,end:a+l-1}}),a+=l,o+=4,i=o}return{earliestPresentationTime:0,timescale:s,version:t,referencesCount:n,references:r}}(r[t]);null!=i&&i.references&&(e+=i.references.reduce((t,e)=>t+e.info.duration||0,0))}return e}}(i,e),p=(c=e,x(i,["moof","traf"]).reduce((t,e)=>{const s=x(e,["tfdt"])[0],a=s[0],r=x(e,["tfhd"]).reduce((e,r)=>{var r=R(r,4),i=c[r];if(i){let t=R(s,4);if(1===a){if(t===At)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t=(t*=1+At)+R(s,8)}const r=t/(i.timescale||9e4);if(isFinite(r)&&(null===e||r<e))return r}return e},null);return null!==r&&isFinite(r)&&(null===t||r<t)?r:t},null)),p=null===p?n:p,v=(v=l,y=p,T=n,(null===v||(E=Math.max(m,1),y=y-v.baseTime/v.timescale,Math.abs(y-T)>E)||u.timescale!==l.timescale&&o)&&(u.initPTS=p-n,l&&1===l.timescale&&P.warn("Adjusting initPTS by "+(u.initPTS-l.baseTime)),this.initPTS=l={baseTime:u.initPTS,timescale:1}),r?p-l.baseTime/l.timescale:h),y=v+m,T=(f=e,g=l.baseTime/l.timescale,x(i,["moof","traf"]).forEach(e=>{x(e,["tfhd"]).forEach(t=>{t=R(t,4),t=f[t];if(t){const s=t.timescale||9e4;x(e,["tfdt"]).forEach(t=>{const e=t[0];let r=R(t,4);if(0===e)r-=g*s,It(t,4,r=Math.max(r,0));else{r=(r=(r*=Math.pow(2,32))+R(t,8))-g*s,r=Math.max(r,0);const e=Math.floor(r/(1+At)),i=Math.floor(r%(1+At));It(t,4,e),It(t,8,i)}})}})}),0<m?this.lastEndTime=y:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp()),!!e.audio),E=!!e.video;let t="";T&&(t+="audio"),E&&(t+="video");o={data1:i,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:t,hasAudio:T,hasVideo:E,nb:1,dropped:0};d.audio="audio"===o.type?o:void 0,d.video="audio"!==o.type?o:void 0,d.initSegment=u,d.id3=ri(s,n,l,l),a.samples.length&&(d.text=ii(a,n,l))}else P.warn("[passthrough-remuxer.ts]: Failed to generate initSegment.")}return d}}},{demux:Hr,remux:ei},{demux:class extends Lr{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,r,i){super.resetInitSegment(t,e,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(e){let t=(pt(e,0)||[]).length;for(var r,i,s,a,n=e.length;t<n;t++)if(r=e,i=t,a=s=void 0,!wr(r,i)||i+(a=Rr(r,i))>=r.length?void 0:!((s=Dr(r,i))<=a)&&((a=i+s)===r.length||wr(r,a)))return P.log("ADTS sync word found !"),!0}return!1}canParse(t,e){return(e=e)+5<(t=t).length&&Ar(t,e)&&Dr(t,e)<=t.length-e}appendFrame(t,e,r){kr(t,this.observer,e,r,t.manifestCodec);t=_r(t,e,r,this.basePTS,this.frameIndex);if(t&&0===t.missing)return t}},remux:ei},{demux:class extends Lr{resetInitSegment(t,e,r,i){super.resetInitSegment(t,e,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(e){let t=(pt(e,0)||[]).length;for(var r=e.length;t<r;t++)if(function(e,r){if(r+1<e.length&&Br(e,r)){var i=Ur(e,r);let t=4;r=r+(t=null!=i&&i.frameLength?i.frameLength:t);return r===e.length||Gr(e,r)}}(e,t))return P.log("MPEG Audio sync word found !"),!0}return!1}canParse(t,e){return Br(t,e)&&4<=t.length-e}appendFrame(t,e,r){if(null!==this.basePTS)return Nr(t,e,r,this.basePTS,this.frameIndex)}},remux:ei}];class li{constructor(t,e,r,i,s){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=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=s}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(e,r,i,t){var s=i.transmuxing;s.executeStart=Jr();let a=new Uint8Array(e);var{currentTransmuxState:e,transmuxConfig:n}=this,{contiguous:t,discontinuity:e,trackSwitch:o,accurateTimeOffset:l,timeOffset:h,initSegmentChange:d}=(t&&(this.currentTransmuxState=t),t||e),{audioCodec:n,videoCodec:u,defaultInitPts:c,duration:f,initSegmentData:g}=n,m=function(t){let e=null;return e=0<t.byteLength&&null!=r&&null!=r.key&&null!==r.iv&&null!=r.method?r:e}(a);if(m&&"AES-128"===m.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(a,m.key.buffer,m.iv.buffer).then(t=>{t=this.push(t,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(a,m.key.buffer,m.iv.buffer);if(!(t=-1<i.part?e.flush():t))return s.executeEnd=Jr(),hi(i);a=new Uint8Array(t)}}var p=this.needsProbing(e,o);if(p){const e=this.configureTransmuxer(a);if(e)return P.warn("[transmuxer] "+e.message),this.observer.emit(I.ERROR,I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=Jr(),hi(i)}(e||o||d||p)&&this.resetInitSegment(g,n,u,f,r),(e||d||p)&&this.resetInitialTimestamp(c),t||this.resetContiguity();o=this.transmux(a,m,h,l,i),g=this.currentTransmuxState;return g.contiguous=!0,g.discontinuity=!1,g.trackSwitch=!1,s.executeEnd=Jr(),o}flush(e){const t=e.transmuxing;t.executeStart=Jr();var{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return s.then(()=>this.flush(e));const a=[],n=i["timeOffset"];if(r){const t=r.flush();t&&a.push(this.push(t,null,e))}var{demuxer:s,remuxer:i}=this;return s&&i?di(r=s.flush(n))?r.then(t=>(this.flushRemux(a,t,e),a)):(this.flushRemux(a,r,e),a):(t.executeEnd=Jr(),[hi(e)])}flushRemux(t,e,r){var{audioTrack:e,videoTrack:i,id3Track:s,textTrack:a}=e,{accurateTimeOffset:n,timeOffset:o}=this.currentTransmuxState,e=(P.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${-1<r.part?" p: "+r.part:""} of level `+r.level),this.remuxer.remux(e,i,s,a,o,n,!0,this.id));t.push({remuxResult:e,chunkMeta:r}),r.transmuxing.executeEnd=Jr()}resetInitialTimestamp(t){var{demuxer:e,remuxer:r}=this;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))}resetContiguity(){var{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,r,i,s){var{demuxer:a,remuxer:n}=this;a&&n&&(a.resetInitSegment(t,e,r,i),n.resetInitSegment(t,e,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,r,i,s){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,s):this.transmuxUnencrypted(t,r,i,s)}transmuxUnencrypted(t,e,r,i){var{audioTrack:t,videoTrack:s,id3Track:a,textTrack:n}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(t,s,a,n,e,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(t,e,r,i,s){return this.demuxer.demuxSampleAes(t,e,r).then(t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,this.id),chunkMeta:s}))}configureTransmuxer(r){var{config:t,observer:e,typeSupported:i,vendor:s}=this;let a;for(let t=0,e=oi.length;t<e;t++)if(oi[t].demux.probe(r)){a=oi[t];break}if(!a)return new Error("Failed to find demuxer by probing fragment data");var n=this.demuxer,o=this.remuxer,l=a.remux,h=a.demux;o&&o instanceof l||(this.remuxer=new l(e,t,i,s)),n&&n instanceof h||(this.demuxer=new h(e,t,i),this.probe=h.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t=t||(this.decrypter=new dr(this.config))}}const hi=t=>({remuxResult:{},chunkMeta:t});function di(t){return"then"in t&&t.then instanceof Function}class ui{constructor(t,e,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class ci{constructor(t,e,r,i,s,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=a}}var fi,B,t={exports:{}};function gi(){}function mi(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function pi(t,e,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new mi(r,i||t,s),i=B?B+e:e;return t._events[i]?t._events[i].fn?t._events[i]=[t._events[i],r]:t._events[i].push(r):(t._events[i]=r,t._eventsCount++),t}function vi(t,e){0==--t._eventsCount?t._events=new gi:delete t._events[e]}function r(){this._events=new gi,this._eventsCount=0}e=t,fi=Object.prototype.hasOwnProperty,B="~",Object.create&&(gi.prototype=Object.create(null),(new gi).__proto__||(B=!1)),r.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)fi.call(t,e)&&r.push(B?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},r.prototype.listeners=function(t){var t=B?B+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,i=e.length,s=new Array(i);r<i;r++)s[r]=e[r].fn;return s},r.prototype.listenerCount=function(t){t=B?B+t:t,t=this._events[t];return t?t.fn?1:t.length:0},r.prototype.emit=function(t,e,r,i,s,a){var n=B?B+t:t;if(!this._events[n])return!1;var o,l=this._events[n],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,s),!0;case 6:return l.fn.call(l.context,e,r,i,s,a),!0}for(c=1,o=new Array(h-1);c<h;c++)o[c-1]=arguments[c];l.fn.apply(l.context,o)}else for(var d,u=l.length,c=0;c<u;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,r);break;case 4:l[c].fn.call(l[c].context,e,r,i);break;default:if(!o)for(d=1,o=new Array(h-1);d<h;d++)o[d-1]=arguments[d];l[c].fn.apply(l[c].context,o)}return!0},r.prototype.on=function(t,e,r){return pi(this,t,e,r,!1)},r.prototype.once=function(t,e,r){return pi(this,t,e,r,!0)},r.prototype.removeListener=function(t,e,r,i){t=B?B+t:t;if(this._events[t])if(e){var s=this._events[t];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||vi(this,t);else{for(var a=0,n=[],o=s.length;a<o;a++)(s[a].fn!==e||i&&!s[a].once||r&&s[a].context!==r)&&n.push(s[a]);n.length?this._events[t]=1===n.length?n[0]:n:vi(this,t)}}else vi(this,t);return this},r.prototype.removeAllListeners=function(t){return t?(t=B?B+t:t,this._events[t]&&vi(this,t)):(this._events=new gi,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=B,e.exports=r.EventEmitter=r;var yi=(e=t.exports)&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;const Ti=Kt()||{isTypeSupported:()=>!1};class Ei{constructor(t,e,r,i){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;const s=t.config;this.hls=t,this.id=e,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var a,r=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===I.ERROR&&(this.error=e.error),this.hls.trigger(t,e)},i=(this.observer=new yi,this.observer.on(I.FRAG_DECRYPTED,r),this.observer.on(I.ERROR,r),{mp4:Ti.isTypeSupported("video/mp4"),mpeg:Ti.isTypeSupported("audio/mpeg"),mp3:Ti.isTypeSupported('audio/mp4; codecs="mp3"')}),r=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__))try{s.workerPath?(P.log(`loading Web Worker ${s.workerPath} for "${e}"`),this.workerContext=function(t){t=new self.URL(t,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(s.workerPath)):(P.log(`injecting Web Worker for "${e}"`),this.workerContext=(a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),a=self.URL.createObjectURL(a),{worker:new self.Worker(a),objectURL:a})),this.onwmsg=t=>this.onWorkerMessage(t);const t=this.workerContext["worker"];t.addEventListener("message",this.onwmsg),t.onerror=t=>{t=new Error(`${t.message} (${t.filename}:${t.lineno})`);s.enableWorker=!1,P.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},t.postMessage({cmd:"init",typeSupported:i,vendor:r,id:e,config:JSON.stringify(s)})}catch(t){P.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new li(this.observer,i,s,r,e)}else this.transmuxer=new li(this.observer,i,s,r,e)}resetWorker(){var t,e;this.workerContext&&({worker:t,objectURL:e}=this.workerContext,e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null)}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,i,s,a,n,o,l,h){var d=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],u=(a||s).start,c=s.decryptdata,f=this.frag,g=!(f&&s.cc===f.cc),m=!(f&&l.level===f.level),p=f?l.sn-f.sn:-1,v=this.part?l.part-this.part.index:-1,y=0==p&&1<l.id&&l.id===(null==f?void 0:f.stats.chunkCount),y=!m&&(1==p||0==p&&(1==v||y&&v<=0)),T=self.performance.now(),T=((m||p||0===s.stats.parsing.start)&&(s.stats.parsing.start=T),!a||!v&&y||(a.stats.parsing.start=T),!(f&&(null==(p=s.initSegment)?void 0:p.url)===(null==(v=f.initSegment)?void 0:v.url))),p=new ci(g,y,o,m,u,T);if(!y||g||T){P.log(`[transmuxer-interface, ${s.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}
|
|
2
2
|
discontinuity: ${g}
|
|
3
3
|
trackSwitch: ${m}
|
|
4
4
|
contiguous: ${y}
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
TTFB estimate: ${l}
|
|
13
13
|
Current BW estimate: ${D(c)?(c/1024).toFixed(3):"Unknown"} Kb/s
|
|
14
14
|
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
|
15
|
-
Aborting and switching to level `+t),r.loader&&(this.fragCurrent=this.partCurrent=null,r.abortRequests()),s.trigger(I.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:n}))}}}}}}}onFragLoaded(t,{frag:e,part:r}){var i=(r||e).stats;if(e.type===y&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const t=(r||e).duration,s=this.hls.levels[e.level],a=(s.loaded?s.loaded.bytes:0)+i.loaded,n=(s.loaded?s.loaded.duration:0)+t;s.loaded={bytes:a,duration:n},s.realBitrate=Math.round(8*a/n)}if(e.bitrateTest){const t={stats:i,frag:e,part:r,id:e.type};this.onFragBuffered(I.FRAG_BUFFERED,t),e.bitrateTest=!1}}}onFragBuffered(t,e){var r,{frag:e,part:i}=e,i=(null!=i&&i.stats.loaded?i:e).stats;i.aborted||this.ignoreFragment(e)||(r=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(r,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0)}ignoreFragment(t){return t.type!==y||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let r=this.getNextABRAutoLevel();if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,r)&&e[t].loadError<=e[r].loadError)return t}return r=-1!==t?Math.min(t,r):r}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{maxAutoLevel:i,config:s,minAutoLevel:a,media:n}=r,o=e?e.duration:t?t.duration:0,l=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,u=(d?d.len:0)/l;var c=this.findBestLevel(h,a,i,u,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(0<=c)return c;P.trace(`[abr] ${u?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=o?Math.min(o,s.maxStarvationDelay):s.maxStarvationDelay,g=s.abrBandWidthFactor,m=s.abrBandWidthUpFactor;if(!u){const t=this.bitrateTestDelay;t&&(f=(o?Math.min(o,s.maxLoadingDelay):s.maxLoadingDelay)-t,P.trace(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),g=m=1)}return c=this.findBestLevel(h,a,i,u+f,g,m),Math.max(c,0)}findBestLevel(e,r,i,s,a,n){var t;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:h}=this,d=this.hls["levels"],u=d[h],c=!(null==u||null==(t=u.details)||!t.live),f=null==u?void 0:u.codecSet,g=l?l.duration:o?o.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let p=r,v=-1;for(let t=i;t>=r;t--){const r=d[t];if(!r||f&&r.codecSet!==f)r&&(p=Math.min(t,p),v=Math.max(t,v));else{-1!==v&&P.trace(`[abr] Skipped level(s) ${p}-${v} with CODECS:"${d[v].attrs.CODECS}"; not compatible with "${u.attrs.CODECS}"`);const i=r.details,o=(l?null==i?void 0:i.partTarget:null==i?void 0:i.averagetargetduration)||g;var y=t<=h?a*e:n*e,T=d[t].maxBitrate,E=this.getTimeToLoadFrag(m,y,T*o,void 0===i);if(P.trace(`[abr] level:${t} adjustedbw-bitrate:${Math.round(y-T)} avgDuration:${o.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:`+E.toFixed(1)),T<y&&(0===E||!D(E)||c&&!this.bitrateTestDelay||E<s))return t}}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}},bufferController:class{constructor(t){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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{var{media:t,mediaSource:e}=this;P.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(I.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{P.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{P.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:t,_objectUrl:e}=this;t&&t.src!==e&&P.error(`Media element src was set while attaching MediaSource (${e} > ${t.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.BUFFER_RESET,this.onBufferReset,this),t.on(I.BUFFER_APPENDING,this.onBufferAppending,this),t.on(I.BUFFER_CODECS,this.onBufferCodecs,this),t.on(I.BUFFER_EOS,this.onBufferEos,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(I.FRAG_PARSED,this.onFragParsed,this),t.on(I.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.BUFFER_RESET,this.onBufferReset,this),t.off(I.BUFFER_APPENDING,this.onBufferAppending,this),t.off(I.BUFFER_CODECS,this.onBufferCodecs,this),t.off(I.BUFFER_EOS,this.onBufferEos,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(I.FRAG_PARSED,this.onFragParsed,this),t.off(I.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ii(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let r=2;(!e.audio||e.video)&&e.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,P.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(t,e){e=this.media=e.media;if(e&&Ci){const t=this.mediaSource=new Ci;t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),e.src=self.URL.createObjectURL(t),this._objectUrl=e.src,e.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){var{media:t,mediaSource:e,_objectUrl:r}=this;if(e){if(P.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){P.warn(`[buffer-controller]: onMediaDetaching: ${t.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):P.warn("[buffer-controller]: media.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(I.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{var e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(e){P.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,e)}}),this._initSourceBuffer()}onBufferCodecs(t,l){const h=this.getSourceBufferTypes().length;Object.keys(l).forEach(t=>{if(h){const h=this.tracks[t];if(h&&"function"==typeof h.buffer.changeType){var{id:e,codec:r,levelCodec:i,container:s,metadata:a}=l[t],n=(h.levelCodec||h.codec).replace(Pi,"$1"),o=(i||r).replace(Pi,"$1");if(n!==o){const l=s+";codecs="+(i||r);this.appendChangeType(t,l),P.log(`[buffer-controller]: switching codec ${n} to `+o),this.tracks[t]={buffer:h.buffer,codec:r,container:s,levelCodec:i,metadata:a,id:e}}}}else this.pendingTracks[t]=l[t]}),h||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,r){const i=this["operationQueue"],t={execute:()=>{var t=this.sourceBuffer[e];t&&(P.log(`[buffer-controller]: changing ${e} sourceBuffer type to `+r),t.changeType(r)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{P.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}};i.append(t,e)}onBufferAppending(t,e){const{hls:r,operationQueue:i,tracks:s}=this,{data:a,type:n,frag:o,part:l,chunkMeta:h}=e,d=h.buffering[n],u=self.performance.now(),c=(d.start=u,o.stats.buffering),f=l?l.stats.buffering:null;0===c.start&&(c.start=u),f&&0===f.start&&(f.start=u);e=s.audio;let g=!1;"audio"===n&&"audio/mpeg"===(null==e?void 0:e.container)&&(g=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const m=o.start,p={execute:()=>{var t,e;d.executeStart=self.performance.now(),g&&(t=this.sourceBuffer[n])&&(e=m-t.timestampOffset,.1<=Math.abs(e))&&(P.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${m} (delta: ${e}) sn: ${o.sn})`),t.timestampOffset=m),this.appendExecutor(a,n)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();d.executeEnd=d.end=t,0===c.first&&(c.first=t),f&&0===f.first&&(f.first=t);var e=this["sourceBuffer"],r={};for(const t in e)r[t]=E.getBuffered(e[t]);this.appendError=0,this.hls.trigger(I.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:h,parent:o.type,timeRanges:r})},onError:t=>{P.error(`[buffer-controller]: Error encountered while trying to append to the ${n} SourceBuffer`,t);var e={type:_.MEDIA_ERROR,parent:o.type,details:C.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:h,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=C.BUFFER_FULL_ERROR:(this.appendError++,e.details=C.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(P.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),e.fatal=!0)),r.trigger(I.ERROR,e)}};i.append(p,n)}onBufferFlushing(t,r){const e=this["operationQueue"],i=e=>({execute:this.removeExecutor.bind(this,e,r.startOffset,r.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(I.BUFFER_FLUSHED,{type:e})},onError:t=>{P.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});r.type?e.append(i(r.type),r.type):this.getSourceBufferTypes().forEach(t=>{e.append(i(t),t)})}onFragParsed(t,e){const{frag:r,part:i}=e,s=[],a=(i||r).elementaryStreams;a[Q]?s.push("audiovideo"):(a[S]&&s.push("audio"),a[b]&&s.push("video")),0===s.length&&P.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: `+r.sn),this.blockBuffers(()=>{var t=self.performance.now(),t=(r.stats.buffering.end=t,i&&(i.stats.buffering.end=t),(i||r).stats);this.hls.trigger(I.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},s)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,i){this.getSourceBufferTypes().reduce((t,e)=>{var r=this.sourceBuffer[e];return!r||i.type&&i.type!==e||(r.ending=!0,r.ended)||(r.ended=!0,P.log(`[buffer-controller]: ${e} sourceBuffer now EOS`)),t&&!(r&&!r.ended)},!0)&&(P.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(t=>{t=this.sourceBuffer[t];t&&(t.ending=!1)});var t=this["mediaSource"];t&&"open"===t.readyState?(P.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&P.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:r,details:i,media:t,sourceBuffer:s}=this;if(t&&null!==i){var e=this.getSourceBufferTypes();if(e.length){var a=i.live&&null!==r.config.liveBackBufferLength?r.config.liveBackBufferLength:r.config.backBufferLength;if(D(a)&&!(a<0)){const n=t.currentTime,o=i.levelTargetDuration,l=Math.max(a,o),h=Math.floor(n/o)*o-l;e.forEach(t=>{var e=s[t];if(e){const s=E.getBuffered(e);if(0<s.length&&h>s.start(0)){if(r.trigger(I.BACK_BUFFER_REACHED,{bufferEnd:h}),i.live)r.trigger(I.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(e.ended&&s.end(s.length-1)-n<2*o)return void P.info(`[buffer-controller]: Cannot flush ${t} back buffer while SourceBuffer is in ended state`);r.trigger(I.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:t})}}})}}}}updateMediaElementDuration(){var t,e,r,i,s,a;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:t,hls:e,media:s,mediaSource:r}=this,i=t.fragments[0].start+t.totalduration,s=s.duration,a=D(r.duration)?r.duration:0,t.live&&e.config.liveDurationInfinity?(P.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(a<i&&s<i||!D(s))&&(P.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),r.duration=i))}updateSeekableRange(t){var e=this.mediaSource,r=t.fragments;r.length&&t.live&&null!=e&&e.setLiveSeekableRange&&(r=Math.max(0,r[0].start),t=Math.max(r,r+t.totalduration),e.setLiveSeekableRange(r,t))}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(I.BUFFER_CREATED,{tracks:this.tracks}),t.forEach(t=>{e.executeNext(t)});else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){var{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){var i=t[n];if(!i)throw Error(`source buffer exists for track ${n}, however track does not`);var s=i.levelCodec||i.codec,a=i.container+";codecs="+s;P.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{const t=e[n]=r.addSourceBuffer(a),o=n;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[n]={buffer:t,codec:s,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(t){P.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:a})}}}_onSBUpdateStart(t){var e=this["operationQueue"];e.current(t).onStart()}_onSBUpdateEnd(t){var e=this["operationQueue"];e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var r=new Error(t+" SourceBuffer error"),r=(P.error("[buffer-controller]: "+r,e),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_APPENDING_ERROR,error:r,fatal:!1}),this.operationQueue.current(t));r&&r.onError(e)}removeExecutor(t,e,r){var{media:i,mediaSource:s,operationQueue:a,sourceBuffer:n}=this,n=n[t];i&&s&&n?(i=D(i.duration)?i.duration:1/0,s=D(s.duration)?s.duration:1/0,(e=Math.max(0,e))<(r=Math.min(r,i,s))&&!n.ending?(n.ended=!1,P.log(`[buffer-controller]: Removing [${e},${r}] from the ${t} SourceBuffer`),n.remove(e,r)):a.shiftAndExecuteNext(t)):(P.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t))}appendExecutor(t,e){var{operationQueue:r,sourceBuffer:i}=this,i=i[e];i?(i.ended=!1,i.appendBuffer(t)):(P.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(e))}blockBuffers(t,e=this.getSourceBufferTypes()){if(e.length){const r=this["operationQueue"],i=e.map(t=>r.appendBlocker(t));Promise.all(i).then(()=>{t(),e.forEach(t=>{var e=this.sourceBuffer[t];null!=e&&e.updating||r.shiftAndExecuteNext(t)})})}else P.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){var i=this.sourceBuffer[t];i&&(r=r.bind(this,t),this.listeners[t].push({event:e,listener:r}),i.addEventListener(e,r))}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(t=>{e.removeEventListener(t.event,t.listener)})}},capLevelController:ys,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=P.log.bind(P,"[info]:"),this.warn=P.warn.bind(P,"[warning]:"),this.error=P.error.bind(P,"[error]:"),this.registerListeners()}registerListeners(){var t=this.hls;t.on(I.ERROR,this.onError,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var t=this.hls;t&&(t.off(I.ERROR,this.onError,this),t.off(I.ERROR,this.onErrorOut,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===y?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){if(!e.fatal){var r,i=this.hls,s=e.context;switch(e.details){case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case C.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:0,flags:0});case C.FRAG_GAP:case C.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case C.LEVEL_EMPTY_ERROR:case C.LEVEL_PARSING_ERROR:{const t=e.parent===y?e.level:i.loadLevel;e.details===C.LEVEL_EMPTY_ERROR&&null!=(r=e.context)&&null!=(r=r.levelDetails)&&r.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.level)));case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.SUBTITLE_LOAD_ERROR:case C.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const t=i.levels[i.loadLevel];if(t&&(s.type===p&&s.groupId===t.audioGroupId||s.type===v&&s.groupId===t.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=i.levels[i.loadLevel],r=null==t?void 0:t.attrs["HDCP-LEVEL"];r&&(e.errorAction={action:2,flags:2,hdcpLevel:r})}return;case C.BUFFER_ADD_CODEC_ERROR:case C.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case C.INTERNAL_EXCEPTION:case C.BUFFER_APPENDING_ERROR:case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:case C.LEVEL_SWITCH_ERROR:case C.BUFFER_STALLED_ERROR:case C.BUFFER_SEEK_OVER_HOLE:case C.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:0,flags:0})}if(e.type===_.KEY_SYSTEM_ERROR){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}}}getPlaylistRetryOrSwitchAction(t,e){var r=Ce(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++,s=null==(s=t.response)?void 0:s.code;return Me(r,i,_e(t),s)?{action:5,flags:0,retryConfig:r,retryCount:i}:(s=this.getLevelSwitchAction(t,e),r&&(s.retryConfig=r,s.retryCount=i),s)}getFragRetryOrSwitchAction(t){const e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],{fragLoadPolicy:s,keyLoadPolicy:a}=e.config,n=Ce(t.details.startsWith("key")?a:s,t),o=e.levels.reduce((t,e)=>t+e.fragmentError,0);if(i){t.details!==C.FRAG_GAP&&i.fragmentError++;const e=null==(l=t.response)?void 0:l.code;if(Me(n,o,_e(t),e))return{action:5,flags:0,retryConfig:n,retryCount:o}}var l=this.getLevelSwitchAction(t,r);return n&&(l.retryConfig=n,l.retryCount=o),l}getLevelSwitchAction(r,i){const s=this.hls;null==i&&(i=s.loadLevel);var a,n=this.hls.levels[i];if(n&&(n.loadError++,s.autoLevelEnabled)){let e=-1;var{levels:o,loadLevel:l,minAutoLevel:h,maxAutoLevel:d}=s,u=null==(a=r.frag)?void 0:a.type,{type:c,groupId:f}=null!=(i=r.context)?i:{};for(let t=o.length;t--;){const a=(t+l)%o.length;if(a!==l&&a>=h&&a<=d&&0===o[a].loadError){const s=o[a];if(r.details===C.FRAG_GAP&&r.frag){const i=o[a].details;if(i){const s=Fe(r.frag,i.fragments,r.frag.start);if(null!=s&&s.gap)continue}}else{if(c===p&&f===s.audioGroupId||c===v&&f===s.textGroupId)continue;if(u===L&&n.audioGroupId===s.audioGroupId||u===ae&&n.textGroupId===s.textGroupId)continue}e=a;break}}if(-1<e&&s.loadLevel!==e)return r.levelRetry=!0,{action:2,flags:this.playlistError=0,nextAutoLevel:e}}return{action:2,flags:1}}onErrorOut(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===C.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){var e=this.hls,r=t.errorAction;if(r){var{flags:i,hdcpLevel:s,nextAutoLevel:a}=r;switch(i){case 0:this.switchLevel(t,a);break;case 1:r.resolved||(r.resolved=this.redundantFailover(t));break;case 2:s&&(e.maxHdcpLevel=Ee[Ee.indexOf(s)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(t,a)}}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after `+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){var{hls:r,penalizedRenditions:i}=this,s=e.parent===y?e.level:r.loadLevel,a=r.levels[s],n=a.url.length,o=(e.frag||a).urlId;a.urlId!==o||e.frag&&!a.details||this.penalizeRendition(a,e);for(let t=1;t<n;t++){const l=(o+t)%n,h=i[l];if(!h||function(t,e,r){if(3e5<performance.now()-t.lastErrorPerfMs)return 1;var i=t.details;if(e.details===C.FRAG_GAP&&i&&e.frag){const t=e.frag.start,r=Fe(null,i.fragments,t);if(r&&!r.gap)return 1}if(r&&t.errors.length<r.errors.length){const r=t.errors[t.errors.length-1];if(i&&r.frag&&e.frag&&Math.abs(r.frag.start-e.frag.start)>3*i.targetduration)return 1}}(h,e,i[o]))return this.warn(`Switching to Redundant Stream ${1+l}/${n}: "${a.url[l]}" after `+e.details),this.playlistError=0,r.levels.forEach(t=>{t.urlId=l}),r.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){var r=this["penalizedRenditions"],i=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(e),i.details=t.details,r[t.urlId]=i}},fpsController:class{constructor(t){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=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;(this.media=t)&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,r){var i,s=performance.now();if(e){if(this.lastTime){const t=s-this.lastTime,a=r-this.lastDroppedFrames,n=e-this.lastDecodedFrames,o=1e3*a/t,l=this.hls;l.trigger(I.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:r}),0<o&&a>l.config.fpsDroppedMonitoringThreshold*n&&(i=l.currentLevel,P.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),0<i)&&(-1===l.autoLevelCapping||l.autoLevelCapping>=i)&&(--i,l.trigger(I.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:l.currentLevel}),l.autoLevelCapping=i,this.streamController.nextLevelSwitch())}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=e}}checkFPSInterval(){var t,e=this.media;e&&(this.isVideoPlaybackQualityAvailable?(t=e.getVideoPlaybackQuality(),this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)):this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ct,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!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},{cueHandler:_s,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:class extends Er{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",ae),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.ERROR,this.onError,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.ERROR,this.onError,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=d,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,r){var{frag:r,success:i}=r;if(this.fragPrevious=r,this.state=d,i){var s=this.tracksBuffered[this.currentTrackId];if(s){let e;var a=r.start;for(let t=0;t<s.length;t++)if(a>=s[t].start&&a<=s[t].end){e=s[t];break}i=r.start+r.duration;e?e.end=i:(e={start:a,end:i},s.push(e)),this.fragmentTracker.fragBuffered(r)}}}onBufferFlushing(r,t){var{startOffset:e,endOffset:i}=t;if(0===e&&i!==Number.POSITIVE_INFINITY){const r=i-1;r<=0||(t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(e=>{for(let t=0;t<e.length;)if(e[t].end<=r)e.shift();else{if(!(e[t].start<r))break;e[t].start=r,t++}}),this.fragmentTracker.removeFragmentsInRange(e,r,ae))}}onFragBuffered(t,e){this.loadedmetadata||e.frag.type!==y||null!=(e=this.media)&&e.buffered.length&&(this.loadedmetadata=!0)}onError(t,e){e=e.frag;(null==e?void 0:e.type)===ae&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==n)&&(this.state=d)}onSubtitleTracksUpdated(t,{subtitleTracks:e}){Di(this.levels,e)?this.levels=e.map(t=>new Le(t)):(this.tracksBuffered=[],this.levels=e.map(t=>{t=new Le(t);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ae),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId?(null!=(e=this.levels[this.currentTrackId])&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(e,r){var{details:i,id:r}=r,{currentTrackId:t,levels:s}=this;if(s.length){var a=s[t];if(!(r>=s.length||r!==t)&&a){this.mediaBuffer=this.mediaBufferTimeRanges;let t=0;if(i.live||null!=(s=a.details)&&s.live){const e=this.mainDetails;if(i.deltaUpdateFailed||!e)return;const r=e.fragments[0];a.details?0===(t=this.alignPlaylists(i,a.details))&&r&&we(i,t=r.start):i.hasProgramDateTime&&e.hasProgramDateTime?(nr(i,e),t=i.fragments[0].start):r&&we(i,t=r.start)}a.details=i,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(a.details,t),this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==d||Fe(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0)}}}_handleFragmentLoadComplete(r){const{frag:i,payload:t}=r,e=i.decryptdata,s=this.hls;if(!this.fragContextChanged(i)&&t&&0<t.byteLength&&e&&e.key&&e.iv&&"AES-128"===e.method){const r=performance.now();this.decrypter.decrypt(new Uint8Array(t),e.key.buffer,e.iv.buffer).catch(t=>{throw s.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:i}),t}).then(t=>{var e=performance.now();s.trigger(I.FRAG_DECRYPTED,{frag:i,payload:t,stats:{tstart:r,tdecrypt:e}})}).catch(t=>{this.warn(t.name+": "+t.message),this.state=d})}}doTick(){if(this.media){if(this.state===d){var{currentTrackId:e,levels:r}=this,e=r[e];if(r.length&&e&&e.details){var r=this["config"],i=this.getLoadPosition(),{end:i,len:s}=E.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),a=this.getFwdBufferInfo(this.media,y),n=e.details;if(!(s>this.getMaxBufferLength(null==a?void 0:a.len)+n.levelTargetDuration)){var s=n.fragments,a=s.length,o=n.edge;let t=null;var l=this.fragPrevious;i<o?(r=o-(o=r.maxFragLookUpTolerance)<i?0:o,!(t=Fe(l,s,Math.max(s[0].start,i),r))&&l&&l.start<s[0].start&&(t=s[0])):t=s[a-1],t&&("initSegment"!==(t=this.mapToInitFragWhenRequired(t)).sn&&(o=s[t.sn-n.startSN-1])&&o.cc===t.cc&&this.fragmentTracker.getState(o)===He&&(t=o),this.fragmentTracker.getState(t)===He)&&this.loadFragment(t,e,i)}}}}else this.state=d}getMaxBufferLength(t){var e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,r){"initSegment"===(this.fragCurrent=t).sn?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,r))}get mediaBufferTimeRanges(){return new wi(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Ue{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,-1<this.trackId&&this.toggleTrackModes(this.trackId)}registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId),ki(this.media.textTracks).forEach(t=>{ue(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){var r,{id:i,details:s}=e,a=this["trackId"],a=this.tracksInGroup[a];a?(r=a.details,a.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,r)):this.warn("Invalid subtitle track id "+i)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null!=e&&e.textGroupIds){const i=e.textGroupIds[e.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const t=this.tracks.filter(t=>!i||t.groupId===i),e=(this.tracksInGroup=t,this.findTrackId(null==s?void 0:s.name)||this.findTrackId());this.groupId=i||null;var r={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${i}" group-id`),this.hls.trigger(I.SUBTITLE_TRACKS_UPDATED,r),-1!==e&&this.setSubtitleTrack(e,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}}findTrackId(e){var r=this.tracksInGroup;for(let t=0;t<r.length;t++){var i=r[t];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1}onError(t,e){!e.fatal&&e.context&&e.context.type===v&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(e){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,s=r.groupId;let t=r.url;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(I.SUBTITLE_TRACK_LOADING,{url:t,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(t){var{media:e,trackId:r}=this;if(e){var e=ki(e.textTracks),i=e.filter(t=>t.groupId===this.groupId);if(-1===t)[].slice.call(e).forEach(t=>{t.mode="disabled"});else{const t=i[r];t&&(t.mode="disabled")}e=i[t];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}}setSubtitleTrack(t,e){var r;const i=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!=(r=i[t])&&r.details)||t<-1||t>=i.length)){this.clearTimer();var s=i[t];if(this.log("Switching to subtitle-track "+t+(s?` "${s.name}" lang:${s.lang} group:`+s.groupId:"")),this.trackId=t,s){const{id:t,groupId:r="",name:i,type:a,url:n}=s;this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:t,groupId:r,name:i,type:a,url:n});s=this.switchParams(s.url,null==e?void 0:e.details);this.loadPlaylist(s)}else this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let e=-1;var r=ki(this.media.textTracks);for(let t=0;t<r.length;t++)if("hidden"===r[t].mode)e=t;else if("showing"===r[t].mode){e=t;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}},timelineController:class{constructor(t){if(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.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){const t=new Xi(this,"textTrack1"),e=new Xi(this,"textTrack2"),r=new Xi(this,"textTrack3"),i=new Xi(this,"textTrack4");this.cea608Parser1=new Wi(1,t,e),this.cea608Parser2=new Wi(3,r,i)}t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.FRAG_LOADING,this.onFragLoading,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){var t=this["hls"];t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.FRAG_LOADING,this.onFragLoading,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,r,i,s){let a=!1;for(let t=s.length;t--;){const i=s[t],h=(n=i[0],o=i[1],l=e,Math.min(o,r)-Math.max(n,l));if(0<=h&&(i[0]=Math.min(i[0],e),i[1]=Math.max(i[1],r),a=!0,.5<h/(r-e)))return}var n,o,l;if(a||s.push([e,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[t];this.Cues.newCue(s,e,r,i)}else{const s=this.Cues.newCue(null,e,r,i);this.hls.trigger(I.CUES_PARSED,{type:"captions",cues:s,track:t})}}onInitPtsFound(t,{frag:e,id:r,initPTS:i,timescale:s}){var a=this["unparsedVttFrags"];"main"===r&&(this.initPTS[e.cc]={baseTime:i,timescale:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(t=>{this.onFragLoaded(I.FRAG_LOADED,t)}))}getExistingTrack(e){var r=this["media"];if(r)for(let t=0;t<r.textTracks.length;t++){var i=r.textTracks[t];if(i[e])return i}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(!this.captionsTracks[t]){const{captionsProperties:e,captionsTracks:r,media:i}=this,{label:s,languageCode:a}=e[t],n=this.getExistingTrack(t);if(n)r[t]=n,ue(r[t]),he(r[t],i);else{const e=this.createTextTrack("captions",s,a);e&&(e[t]=!0,r[t]=e)}}}createNonNativeTrack(t){var e;this.nonNativeCaptionsTracks[t]||(e=this.captionsProperties[t])&&(e={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media},this.nonNativeCaptionsTracks[t]=e,this.hls.trigger(I.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[e]}))}createTextTrack(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const e=this["captionsTracks"];Object.keys(e).forEach(t=>{ue(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var t=this["media"];if(t){var e=t.textTracks;if(e)for(let t=0;t<e.length;t++)ue(e[t])}}onSubtitleTracksUpdated(n,t){var t=t.subtitleTracks||[],e=t.some(t=>"stpp.ttml.im1t"===t.textCodec);if(this.config.enableWebVTT||e&&this.config.enableIMSC1)if(Di(this.tracks,t))this.tracks=t;else if(this.textTracks=[],this.tracks=t,this.config.renderTextTracksNatively){const n=this.media?this.media.textTracks:null;this.tracks.forEach((r,t)=>{let i;if(n&&t<n.length){let e=null;for(let t=0;t<n.length;t++)if(s=n[t],a=r,s&&s.label===a.name&&!s.textTrack1&&!s.textTrack2){e=n[t];break}e&&(i=e)}var s,a;if(i)ue(i);else{const n=this._captionsOrSubtitlesFromCharacteristics(r);(i=this.createTextTrack(n,r.name,r.lang))&&(i.mode="disabled")}i&&(i.groupId=r.groupId,this.textTracks.push(i))})}else if(this.tracks.length){const n=this.tracks.map(t=>({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}));this.hls.trigger(I.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){var e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),t=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&t)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(t=>{var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);e&&(e="textTrack"+e[1],e=this.captionsProperties[e])&&(e.label=t.name,t.lang&&(e.languageCode=t.lang),e.media=t)})}closedCaptionsForLevel(t){t=this.hls.levels[t.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){var{cea608Parser1:r,cea608Parser2:i,lastSn:s,lastPartIndex:a}=this;if(this.enabled&&r&&i&&e.frag.type===y){const t=e.frag.sn,n=null!=(e=null==e||null==(e=e.part)?void 0:e.index)?e:-1;t===s+1||t===s&&n===a+1||(r.reset(),i.reset()),this.lastSn=t,this.lastPartIndex=n}}onFragLoaded(t,e){var{frag:r,payload:i}=e;if(r.type===ae)if(i.byteLength){const t=r.decryptdata,s="stats"in e;if(null==t||!t.encrypted||s){const t=this.tracks[r.level],a=this.vttCCs;a[r.cc]||(a[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),t&&"stpp.ttml.im1t"===t.textCodec?this._parseIMSC1(r,i):this._parseVTTs(e)}}else this.hls.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;cs(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{P.log("Failed to parse IMSC1: "+t),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(i){var t;const{frag:o,payload:l}=i,{initPTS:e,unparsedVttFrags:h}=this,d=e.length-1;if(e[o.cc]||-1!=d){const y=this.hls;{var u=null!=(u=o.initSegment)&&u.data?Pt(o.initSegment.data,new Uint8Array(l)):l;var c=this.initPTS[o.cc];var f=this.vttCCs;var g=o.cc;var m=o.start;var p=t=>{this._appendCues(t,o.level),y.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})};var v=t=>{var e="Missing initPTS for VTT MPEGTS"===t.message;e?h.push(i):this._fallbackToIMSC1(o,l),P.log("Failed to parse VTT cue: "+t),e&&d>o.cc||y.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:t})};const T=new ss,E=A(new Uint8Array(u)).trim().replace(os,"\n").split("\n"),S=[],L=c?([u,t=1]=[c.baseTime,c.timescale],zr(u,9e4,1/t)):0;let s,e="00:00.000",a=0,n=0,r=!0;T.oncue=function(t){var e=f[g];let r=f.ccOffset;var i=(a-L)/9e4;if(null!=e&&e.new&&(void 0!==n?r=f.ccOffset=e.start:function(t,e){let r=t[g],i=t[r.prevCC];if(!i||!i.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,r.new=!1;for(;null!=(s=i)&&s.new;){var s;t.ccOffset+=r.start-i.start,r.new=!1,i=t[(r=i).prevCC]}t.presentationOffset=e}(f,i)),i){if(!c)return void(s=new Error("Missing initPTS for VTT MPEGTS"));r=i-f.presentationOffset}e=t.endTime-t.startTime,i=U(9e4*(t.startTime+r-n),9e4*m)/9e4,t.startTime=Math.max(i,0),t.endTime=Math.max(i+e,0),i=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(i)),t.id||(t.id=ls(t.startTime,t.endTime,i)),0<t.endTime&&S.push(t)},T.onparsingerror=function(t){s=t},T.onflush=function(){s?v(s):p(S)},E.forEach(t=>{if(r){if(as(t,"X-TIMESTAMP-MAP=")){r=!1,t.slice(16).split(",").forEach(t=>{as(t,"LOCAL:")?e=t.slice(6):as(t,"MPEGTS:")&&(a=parseInt(t.slice(7)))});try{n=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),s=9<t.length?parseInt(t.substring(0,t.indexOf(":"))):0;if(D(e)&&D(r)&&D(i)&&D(s))return(e+=1e3*r)+6e4*i+36e5*s;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t)}(e)/1e3}catch(t){s=t}return}""===t&&(r=!1)}T.parse(t+"\n")}),T.flush()}}else h.push(i)}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||cs(e,this.initPTS[t.cc],()=>{r.textCodec="stpp.ttml.im1t",this._parseIMSC1(t,e)},()=>{r.textCodec="wvtt"})}_appendCues(t,e){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[e];r&&"disabled"!==r.mode&&t.forEach(t=>de(r,t))}else{var i=this.tracks[e];i&&(i=i.default?"default":"subtitles"+e,r.trigger(I.CUES_PARSED,{type:"subtitles",cues:t,track:i}))}}onFragDecrypted(t,e){var r=e["frag"];r.type===ae&&this.onFragLoaded(I.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){var{cea608Parser1:r,cea608Parser2:i}=this;if(this.enabled&&r&&i){const{frag:s,samples:a}=e;if(s.type!==y||"NONE"!==this.closedCaptionsForLevel(s))for(let t=0;t<a.length;t++){const e=a[t].bytes;if(e){const s=this.extractCea608Data(e);r.addData(a[t].pts,s[0]),i.addData(a[t].pts,s[1])}}}}onBufferFlushing(e,{startOffset:r,endOffset:i,endOffsetSubtitles:s,type:t}){var a=this["media"];if(a&&!(a.currentTime<i)){if(!t||"video"===t){const e=this["captionsTracks"];Object.keys(e).forEach(t=>ce(e[t],r,i))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==s){const e=this["textTracks"];Object.keys(e).forEach(t=>ce(e[t],r,s))}}}extractCea608Data(e){const r=[[],[]],i=31&e[0];let s=2;for(let t=0;t<i;t++){const i=e[s++],a=127&e[s++],n=127&e[s++];if((0!=a||0!=n)&&0!=(4&i)){const e=3&i;0!=e&&1!=e||(r[e].push(a),r[e].push(n))}}return r}},audioStreamController:class extends Er{constructor(t,e,r){super(t,e,r,"[audio-stream-controller]",L),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(I.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(I.ERROR,this.onError,this),t.on(I.BUFFER_RESET,this.onBufferReset,this),t.on(I.BUFFER_CREATED,this.onBufferCreated,this),t.on(I.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(I.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(I.ERROR,this.onError,this),t.off(I.BUFFER_RESET,this.onBufferReset,this),t.off(I.BUFFER_CREATED,this.onBufferCreated,this),t.off(I.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:r,initPTS:i,timescale:s}){if("main"===r){const t=e.cc;this.initPTS[e.cc]={baseTime:i,timescale:s},this.log(`InitPTS for cc: ${t} found from main: `+i),this.videoTrackCC=t,this.state===yr&&this.tick()}}startLoad(t){var e;this.levels?(e=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),0<e&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=d):(this.loadedmetadata=!1,this.state=gr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()):(this.startPosition=t,this.state=n)}doTick(){switch(this.state){case d:this.doTickIdle();break;case gr:{var t;const{levels:e,trackId:r}=this,i=null==e||null==(t=e[r])?void 0:t.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=yr}break}case fr:{var e;const t=performance.now(),s=this.retryDate;(!s||t>=s||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=d);break}case yr:{const t=this.waitingData;if(t){const{frag:e,part:a,cache:n,complete:o}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=cr;const t={frag:e,part:a,payload:n.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),o&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc `+this.videoTrackCC),this.clearWaitingFragment();else{const t=this.getLoadPosition(),l=E.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);Ne(l.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${l.end} is needed`),this.clearWaitingFragment())}}else this.state=d}}this.onTickEnd()}clearWaitingFragment(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=d)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){var t=this["media"];null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:i,levels:t,media:s,trackId:e}=this,r=i.config;if(null!=t&&t[e]&&(s||!this.startFragRequested&&r.startFragPrefetch)){var a=t[e],n=a.details;if(!n||n.live&&this.levelLastLoaded!==e||this.waitForCdnTuneIn(n))this.state=gr;else{var o=this.mediaBuffer||this.media,o=(this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,S,L)),this.getFwdBufferInfo(o,L));if(null!==o){var{bufferedTrack:l,switchingTrack:h}=this;if(!h&&this._streamEnded(o,n))i.trigger(I.BUFFER_EOS,{type:"audio"}),this.state=pr;else{var d=this.getFwdBufferInfo(this.videoBuffer||this.media,y),u=o.len,c=this.getMaxBufferLength(null==d?void 0:d.len);if(!(c<=u)||h){u=n.fragments[0].start;let t=o.end;if(h&&s){const i=this.getLoadPosition();l&&h.attrs!==l.attrs&&(t=i),n.PTSKnown&&i<u&&(o.end>u||o.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=u+.05)}let e=this.getNextFragment(t,n),r=!1;if(e&&this.isLoopLoading(e,t)&&(r=!!e.gap,e=this.getNextFragmentLoopLoading(e,n,o,y,c)),e){h=d&&e.start>d.end+n.targetduration;if(h||(null==d||!d.len)&&o.len){const i=this.getAppendedFrag(e.start,y);if(null===i)return;if(r=r||!!i.gap||!!h&&0===d.len,h&&!r||r&&o.nextStart&&o.nextStart<i.end)return}this.loadFragment(e,a,t)}else this.bufferFlushed=!0}}}}}}getMaxBufferLength(t){var e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(t=>new Le(t))}onAudioTrackSwitching(t,e){var r=!!e.url,i=(this.trackId=e.id,this)["fragCurrent"];i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=d):(this.switchingTrack=null,this.bufferedTrack=e,this.state=n),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(I.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,r){var i;if(null==this.mainDetails)this.cachedTrackLoadedData=r;else{var s=this["levels"],{details:r,id:a}=r;if(s){this.log(`Track ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:`+r.totalduration);s=s[a];let t=0;if(r.live||null!=(i=s.details)&&i.live){this.checkLiveUpdate(r);const e=this.mainDetails;if(r.deltaUpdateFailed||!e)return;t=!s.details&&r.hasProgramDateTime&&e.hasProgramDateTime?(nr(r,e),r.fragments[0].start):this.alignPlaylists(r,s.details)}s.details=r,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(s.details,t),this.state!==gr||this.waitForCdnTuneIn(r)||(this.state=d),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)}}_handleFragmentLoadProgress(e){var r;const{frag:i,part:s,payload:a}=e,{config:n,trackId:o,levels:t}=this;if(t){e=t[o];if(e){var l=e.details;if(l){var h=n.defaultAudioCodec||e.audioCodec||"mp4a.40.2";let t=this.transmuxer;t=t||(this.transmuxer=new Ei(this.hls,L,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var d=this.initPTS[i.cc],u=null==(r=i.initSegment)?void 0:r.data;if(void 0!==d){const e=!1,r=s?s.index:-1,n=-1!==r,o=new rr(i.level,i.sn,i.stats.chunkCount,a.byteLength,r,n);t.push(a,u,h,"",i,s,l.totalduration,!1,o,d)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track `+o);const e=(this.waitingData=this.waitingData||{frag:i,part:s,cache:new Ri,complete:!1})["cache"];e.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=yr}}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){var{frag:e,part:r}=e;if(e.type===L)if(this.fragContextChanged(e))this.warn(`Fragment ${e.sn}${r?" p: "+r.index:""} of level ${e.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==e.sn){this.fragPrevious=e;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(I.AUDIO_TRACK_SWITCHED,m({},t)))}this.fragBufferedComplete(e,r)}else if(!this.loadedmetadata&&e.type===y){const t=this.videoBuffer||this.media;t&&E.getBuffered(t).length&&(this.loadedmetadata=!0)}}onError(t,e){var r;if(e.fatal)this.state=vr;else switch(e.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L,e);break;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==gr||(null==(r=e.context)?void 0:r.type)!==p||(this.state=d);break;case C.BUFFER_FULL_ERROR:e.parent&&"audio"===e.parent&&this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,{type:e}){e===S&&(this.bufferFlushed=!0,this.state===pr)&&(this.state=d)}_handleTransmuxComplete(t){var e;const r="audio",i=this["hls"],{remuxResult:s,chunkMeta:a}=t,n=this.getCurrentContext(a);if(n){var{frag:o,part:l,level:t}=n,h=t["details"],{audio:d,text:u,id3:c,initSegment:f}=s;if(!this.fragContextChanged(o)&&h){if(this.state=O,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const t=o.initSegment||o;this._bufferInitSegment(f.tracks,t,a),i.trigger(I.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:r,tracks:f.tracks})}if(d){const{startPTS:t,endPTS:e,startDTS:r,endDTS:i}=d;l&&(l.elementaryStreams[S]={startPTS:t,endPTS:e,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(S,t,e,r,i),this.bufferFragmentData(d,o,l,a)}if(null!=c&&null!=(e=c.samples)&&e.length){const t=k({id:r,frag:o,details:h},c);i.trigger(I.FRAG_PARSING_METADATA,t)}if(u){const t=k({id:r,frag:o,details:h},u);i.trigger(I.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(a)}_bufferInitSegment(t,e,r){if(this.state===O){t.video&&delete t.video;var i=t.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(I.BUFFER_CODECS,t);i=i.initSegment;if(null!=i&&i.byteLength){const t={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:i};this.hls.trigger(I.BUFFER_APPENDING,t)}this.tick()}}}loadFragment(t,e,r){var i=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||i===He||i===Ye?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(i=e.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=yr):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){var{hls:e,media:r,bufferedTrack:i}=this,i=null==i?void 0:i.attrs,s=t.attrs;r&&i&&(i.CHANNELS!==s.CHANNELS||i.NAME!==s.NAME||i.LANGUAGE!==s.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(I.AUDIO_TRACK_SWITCHED,m({},t))}},audioTrackController:class extends Ue{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(I.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){var r,{id:i,groupId:s,details:a}=e,n=this.tracksInGroup[i];n&&n.groupId===s?(r=n.details,n.details=e.details,this.log(`audio-track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,r)):this.warn(`Track with id:${i} and group:${s} not found in active group `+n.groupId)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){const r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r||null;const t=this.tracks.filter(t=>!r||t.groupId===r),e=(this.selectDefaultTrack&&!t.some(t=>t.default)&&(this.selectDefaultTrack=!1),{audioTracks:this.tracksInGroup=t});this.log(`Updating audio tracks, ${t.length} track(s) found in group:`+r),this.hls.trigger(I.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(t,e){!e.fatal&&e.context&&e.context.type===p&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){var e,r,i,s=this.tracksInGroup;t<0||t>=s.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),e=this.currentTrack,s[this.trackId],{groupId:r,name:i}=s=s[t],this.log(`Switching to audio-track ${t} "${i}" lang:${s.lang} group:`+r),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(I.AUDIO_TRACK_SWITCHING,m({},s)),s.details&&!s.details.live||(i=this.switchParams(s.url,null==e?void 0:e.details),this.loadPlaylist(i)))}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{const e=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+t.length);this.warn(e.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}findTrackId(e){var r=this.tracksInGroup;for(let t=0;t<r.length;t++){var i=r[t];if(!this.selectDefaultTrack||i.default){if(!e||void 0!==e.attrs["STABLE-RENDITION-ID"]&&e.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(e.name===i.name&&e.lang===i.lang)return i.id}}return-1}loadPlaylist(e){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,s=r.groupId;let t=r.url;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log(`loading audio-track playlist ${i} "${r.name}" lang:${r.lang} group:`+s),this.clearTimer(),this.hls.trigger(I.AUDIO_TRACK_LOADING,{url:t,id:i,groupId:s,deliveryDirectives:e||null})}}},emeController:Ts,cmcdController:Es,contentSteeringController:class{constructor(t){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=t,this.log=P.log.bind(P,"[content-steering]:"),this.registerListeners()}registerListeners(){var t=this.hls;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this.hls;t&&(t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.ERROR,this.onError,this))}startLoad(){var t;this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri&&(this.updated?(t=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0),this.scheduleRefresh(this.uri,t)):this.loadSteeringManifest(this.uri))}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){e=e.contentSteering;null!==e&&(this.pathwayId=e.pathwayId,this.uri=e.uri,this.started)&&this.startLoad()}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){var r=e["errorAction"];if(2===(null==r?void 0:r.action)&&1===r.flags){let t=this.pathwayPriority;const e=this.pathwayId;this.penalizedPathways[e]||(this.penalizedPathways[e]=performance.now()),(t=!t&&this.levels?this.levels.reduce((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t),[]):t)&&1<t.length&&(this.updatePathwayPriority(t),r.resolved=this.pathwayId!==e)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);var r;return 0===e.length&&(r=t[0].pathwayId,this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),e=this.getLevelsForPathway(r),this.pathwayId=r),e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(t=>{3e5<i-r[t]&&delete r[t]});for(let t=0;t<e.length;t++){var s=e[t];if(!r[s]){if(s===this.pathwayId)return;var a,n=this.hls.nextLoadLevel,o=this.hls.levels[n];if(0<(a=this.getLevelsForPathway(s)).length){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,this.hls.trigger(I.LEVELS_UPDATED,{levels:a});const e=this.hls.levels[n];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to `+e.bitrate),this.hls.nextLoadLevel=n);break}}}}clonePathways(t){const r=this.levels;if(r){const n={},o={};t.forEach(t=>{const{ID:s,"BASE-ID":e,"URI-REPLACEMENT":a}=t;r.some(t=>t.pathwayId===s)||(t=this.getLevelsForPathway(e).map(t=>{var e=k({},t),t=(e.details=void 0,e.url=Ls(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),new w(t.attrs)),r=(t["PATHWAY-ID"]=s,t.AUDIO&&t.AUDIO+"_clone_"+s),i=t.SUBTITLES&&t.SUBTITLES+"_clone_"+s,t=(r&&(n[t.AUDIO]=r,t.AUDIO=r),i&&(o[t.SUBTITLES]=i,t.SUBTITLES=i),e.attrs=t,new Le(e));return $e(t,"audio",r),$e(t,"text",i),t}),r.push(...t),Ss(this.audioTracks,n,a,s),Ss(this.subtitleTracks,o,a,s))})}}loadSteeringManifest(t){var e=this.hls.config,r=e.loader;let o;this.loader&&this.loader.destroy(),this.loader=new r(e);try{o=new self.URL(t)}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if("data:"!==o.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+t)}var r={responseType:"json",url:o.href},t=e.steeringManifestLoadPolicy.default,i=t.errorRetry||t.timeoutRetry||{},t={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},i={onSuccess:(t,e,r,i)=>{this.log(`Loaded steering manifest: "${o}"`);var s=t.data;if(1!==s.VERSION)this.log(`Steering VERSION ${s.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=s.TTL;var{"RELOAD-URI":s,"PATHWAY-CLONES":a,"PATHWAY-PRIORITY":n}=s;if(s)try{this.uri=new self.URL(s,o).href}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+s)}this.scheduleRefresh(this.uri||r.url),a&&this.clonePathways(a),n&&this.updatePathwayPriority(n)}},onError:(t,e,r,i)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)this.enabled=!1,this.log(`Steering manifest ${e.url} no longer available`);else{var s=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,s);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&parseFloat(e)}this.log(`Steering manifest ${e.url} rate limited`)}}},onTimeout:(t,e,r)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(r,t,i)}scheduleRefresh(t,e=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}});function Ps(r){return r&&"object"==typeof r?Array.isArray(r)?r.map(Ps):Object.keys(r).reduce((t,e)=>(t[e]=Ps(r[e]),t),{}):r}class xs{static get version(){return"1.4.12"}static isSupported(){return!!(e=Kt())&&(t=Sr(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove,!!e)&&!!t;var t,e}static get Events(){return I}static get ErrorTypes(){return _}static get ErrorDetails(){return C}static get DefaultConfig(){return xs.defaultConfig||Cs}static set DefaultConfig(t){xs.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new yi,this._autoLevelCapping=void 0,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;var e=t.debug||!1;if(self.console&&!0===e||"object"==typeof e){W(e,"debug","log","info","warn","error");try{Y.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(e){Y=V}}else Y=V;var r=this.config=function(t,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==o.liveMaxLatencyDurationCount&&(void 0===o.liveSyncDurationCount||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==o.liveMaxLatencyDuration&&(void 0===o.liveSyncDuration||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const l=Ps(t),e=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(i=>{const s=("level"===i?"playlist":i)+"LoadPolicy",a=void 0===o[s],n=[];e.forEach(t=>{var e=i+"Loading"+t,r=o[e];if(void 0!==r&&a){n.push(e);const i=l[s].default;switch(o[s]={default:i},t){case"TimeOut":i.maxLoadTimeMs=r,i.maxTimeToFirstByteMs=r;break;case"MaxRetry":i.errorRetry.maxNumRetry=r,i.timeoutRetry.maxNumRetry=r;break;case"RetryDelay":i.errorRetry.retryDelayMs=r,i.timeoutRetry.retryDelayMs=r;break;case"MaxRetryTimeout":i.errorRetry.maxRetryDelayMs=r,i.timeoutRetry.maxRetryDelayMs=r}}}),n.length&&P.warn(`hls.js config: "${n.join('", "')}" setting(s) are deprecated, use "${s}": `+JSON.stringify(o[s]))}),m(m({},l),o)}(xs.DefaultConfig,t),{abrController:i,bufferController:t,capLevelController:s,errorController:a,fpsController:n}=(this.userConfig=t,this._autoLevelCapping=-1,r.progressive&&((i=(t=r).loader)!==Ds&&i!==As?(P.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),1}catch(t){}}()&&(t.loader=Ds,t.progressive=!0,t.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))),r),a=new a(this),o=this.abrController=new i(this),t=this.bufferController=new t(this),s=this.capLevelController=new s(this),n=new n(this),l=new le(this),h=new ye(this),d=r.contentSteeringController,d=d?new d(this):null,u=this.levelController=new Ge(this,d),c=new je(this),f=new tr(this.config),g=this.streamController=new Li(this,c,f),l=(s.setStreamController(g),n.setStreamController(g),[l,u,g]),u=(d&&l.splice(1,0,d),this.networkControllers=l,[o,t,s,n,h,c]),g=(this.audioTrackController=this.createController(r.audioTrackController,l),r.audioStreamController),d=(g&&l.push(new g(this,c,f)),this.subtitleTrackController=this.createController(r.subtitleTrackController,l),r.subtitleStreamController),o=(d&&l.push(new d(this,c,f)),this.createController(r.timelineController,u),f.emeController=this.emeController=this.createController(r.emeController,u),this.cmcdController=this.createController(r.cmcdController,u),this.latencyController=this.createController(Te,u),this.coreComponents=u,l.push(a),a.onErrorOut);"function"==typeof o&&this.on(I.ERROR,o,a)}createController(t,e){return t?(t=new t(this),e&&e.push(t),t):null}on(t,e,r=this){this._emitter.on(t,e,r)}once(t,e,r=this){this._emitter.once(t,e,r)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,r=this,i){this._emitter.off(t,e,r,i)}listeners(t){return this._emitter.listeners(t)}emit(t,e,r){return this._emitter.emit(t,e,r)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){P.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){P.log("destroy"),this.trigger(I.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){P.log("attachMedia"),this._media=t,this.trigger(I.MEDIA_ATTACHING,{media:t})}detachMedia(){P.log("detachMedia"),this.trigger(I.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=$.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});P.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(I.MANIFEST_LOADING,{url:t})}startLoad(e=-1){P.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){P.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){P.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){P.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){P.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){P.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){P.log("set loadLevel:"+t),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){P.log("set firstLevel:"+t),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){P.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){t=!!t;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimate():NaN}get ttfbEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(P.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){-1<Ee.indexOf(t)&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){var{levels:e,config:{minAutoBitrate:r}}=this;if(e){var i=e.length;for(let t=0;t<i;t++)if(e[t].maxBitrate>=r)return t}return 0}get maxAutoLevel(){var{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){var t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}xs.defaultConfig=void 0},656:function(t,e,r){"use strict";var i="function"==typeof Symbol&&Symbol.for,s=i?Symbol.for("react.element"):60103,a=i?Symbol.for("react.portal"):60106,n=i?Symbol.for("react.fragment"):60107,o=i?Symbol.for("react.strict_mode"):60108,l=i?Symbol.for("react.profiler"):60114,h=i?Symbol.for("react.provider"):60109,d=i?Symbol.for("react.context"):60110,u=i?Symbol.for("react.async_mode"):60111,c=i?Symbol.for("react.concurrent_mode"):60111,f=i?Symbol.for("react.forward_ref"):60112,g=i?Symbol.for("react.suspense"):60113,m=i?Symbol.for("react.suspense_list"):60120,p=i?Symbol.for("react.memo"):60115,v=i?Symbol.for("react.lazy"):60116,y=i?Symbol.for("react.block"):60121,T=i?Symbol.for("react.fundamental"):60117,E=i?Symbol.for("react.responder"):60118,S=i?Symbol.for("react.scope"):60119;function L(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case s:switch(t=t.type){case u:case c:case n:case l:case o:case g:return t;default:switch(t=t&&t.$$typeof){case d:case f:case v:case p:case h:return t;default:return e}}case a:return e}}}function b(t){return L(t)===c}e.AsyncMode=u,e.ConcurrentMode=c,e.ContextConsumer=d,e.ContextProvider=h,e.Element=s,e.ForwardRef=f,e.Fragment=n,e.Lazy=v,e.Memo=p,e.Portal=a,e.Profiler=l,e.StrictMode=o,e.Suspense=g,e.isAsyncMode=function(t){return b(t)||L(t)===u},e.isConcurrentMode=b,e.isContextConsumer=function(t){return L(t)===d},e.isContextProvider=function(t){return L(t)===h},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===s},e.isForwardRef=function(t){return L(t)===f},e.isFragment=function(t){return L(t)===n},e.isLazy=function(t){return L(t)===v},e.isMemo=function(t){return L(t)===p},e.isPortal=function(t){return L(t)===a},e.isProfiler=function(t){return L(t)===l},e.isStrictMode=function(t){return L(t)===o},e.isSuspense=function(t){return L(t)===g},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===c||t===l||t===o||t===g||t===m||"object"==typeof t&&null!==t&&(t.$$typeof===v||t.$$typeof===p||t.$$typeof===h||t.$$typeof===d||t.$$typeof===f||t.$$typeof===T||t.$$typeof===E||t.$$typeof===S||t.$$typeof===y)},e.typeOf=L},681:function(t,e,r){var i=r(93),s=r(601),a=r(89),n=r(316),r=i?i.prototype:void 0,o=r?r.toString:void 0;t.exports=function t(e){var r;return"string"==typeof e?e:a(e)?s(e,t)+"":n(e)?o?o.call(e):"":"0"==(r=e+"")&&1/e==-1/0?"-0":r}},703:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return T.default}}),e.default=void 0;var m=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=l(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(1)),i=o(r(0)),s=o(r(29)),p=o(r(43)),v=r(583),y=r(607),a=r(571),T=o(r(705)),n=o(r(608));function o(t){return t&&t.__esModule?t:{default:t}}function l(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(l=function(t){return t?r:e})(t))}function E(){return(E=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function h(t,e,r){var i;i=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(e),(e="symbol"==typeof i?i:String(i))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}class d extends m.Component{static getDerivedStateFromProps(t,e){t=t.position,e=e.prevPropsPosition;return!t||e&&t.x===e.x&&t.y===e.y?null:((0,n.default)("Draggable: getDerivedStateFromProps %j",{position:t,prevPropsPosition:e}),{x:t.x,y:t.y,prevPropsPosition:{...t}})}constructor(t){super(t),h(this,"onDragStart",(t,e)=>{if((0,n.default)("Draggable: onDragStart: %j",e),!1===this.props.onStart(t,(0,y.createDraggableData)(this,e)))return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(t,e)=>{if(!this.state.dragging)return!1;(0,n.default)("Draggable: onDrag: %j",e);var r=(0,y.createDraggableData)(this,e),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:t,y:e}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;var[s,a]=(0,y.getBoundPosition)(this,i.x,i.y);i.x=s,i.y=a,i.slackX=this.state.slackX+(t-i.x),i.slackY=this.state.slackY+(e-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(t,r))return!1;this.setState(i)}),h(this,"onDragStop",(t,e)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(t,(0,y.createDraggableData)(this,e)))return!1;(0,n.default)("Draggable: onDragStop: %j",e);var r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:t,y:e}=this.props.position;r.x=t,r.y=e}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:(t.position||t.defaultPosition).x,y:(t.position||t.defaultPosition).y,prevPropsPosition:{...t.position},slackX:0,slackY:0,isElementSVG:!1},!t.position||t.onDrag||t.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var t;return null!=(t=null==(t=this.props)||null==(t=t.nodeRef)?void 0:t.current)?t:s.default.findDOMNode(this)}render(){const{axis:t,bounds:e,children:r,defaultPosition:i,defaultClassName:s,defaultClassNameDragging:a,defaultClassNameDragged:n,position:o,positionOffset:l,scale:h,...d}=this.props;let u={},c=null;var f=!Boolean(o)||this.state.dragging,g=o||i,f={x:((0,y.canDragX)(this)&&f?this.state:g).x,y:((0,y.canDragY)(this)&&f?this.state:g).y},g=(this.state.isElementSVG?c=(0,v.createSVGTransform)(f,l):u=(0,v.createCSSTransform)(f,l),(0,p.default)(r.props.className||"",s,{[a]:this.state.dragging,[n]:this.state.dragged}));return m.createElement(T.default,E({},d,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),m.cloneElement(m.Children.only(r),{className:g,style:{...r.props.style,...u},transform:c}))}}h(e.default=d,"displayName","Draggable"),h(d,"propTypes",{...T.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),h(d,"defaultProps",{...T.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},704:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.browserPrefixToKey=a,e.browserPrefixToStyle=function(t,e){return e?"-".concat(e.toLowerCase(),"-").concat(t):t},e.default=void 0,e.getPrefix=s;const i=["Moz","Webkit","O","ms"];function s(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"!=typeof window){var r=null==(t=window.document)||null==(t=t.documentElement)?void 0:t.style;if(r&&!(e in r))for(let t=0;t<i.length;t++)if(a(e,i[t])in r)return i[t]}return""}function a(t,e){return e?"".concat(e).concat(function(e){let r="",i=!0;for(let t=0;t<e.length;t++)i?(r+=e[t].toUpperCase(),i=!1):"-"===e[t]?i=!0:r+=e[t];return r}(t)):t}e.default=s()},705:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=u(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(1)),s=d(r(0)),a=d(r(29)),n=r(583),o=r(607),l=r(571),h=d(r(608));function d(t){return t&&t.__esModule?t:{default:t}}function u(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(u=function(t){return t?r:e})(t))}function c(t,e,r){var i;i=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(e),(e="symbol"==typeof i?i:String(i))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}const f={start:"touchstart",move:"touchmove",stop:"touchend"},g={start:"mousedown",move:"mousemove",stop:"mouseup"};let m=g;class p extends i.Component{constructor(){super(...arguments),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&"number"==typeof t.button&&0!==t.button)return!1;var e=this.findDOMNode();if(!e||!e.ownerDocument||!e.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");var r,i,s=e["ownerDocument"];this.props.disabled||!(t.target instanceof s.defaultView.Node)||this.props.handle&&!(0,n.matchesSelectorAndParentsTo)(t.target,this.props.handle,e)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(t.target,this.props.cancel,e)||("touchstart"===t.type&&t.preventDefault(),e=(0,n.getTouchIdentifier)(t),this.touchIdentifier=e,null!=(e=(0,o.getControlPosition)(t,e,this))&&({x:e,y:r}=e,i=(0,o.createCoreData)(this,e,r),(0,h.default)("DraggableCore: handleDragStart: %j",i),(0,h.default)("calling",this.props.onStart),!1!==this.props.onStart(t,i))&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(s),this.dragging=!0,this.lastX=e,this.lastY=r,(0,n.addEvent)(s,m.move,this.handleDrag),(0,n.addEvent)(s,m.stop,this.handleDragStop)))}),c(this,"handleDrag",r=>{const i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:t,y:e}=i;if(Array.isArray(this.props.grid)){var s=t-this.lastX,a=e-this.lastY;if([s,a]=(0,o.snapToGrid)(this.props.grid,s,a),!s&&!a)return;t=this.lastX+s,e=this.lastY+a}s=(0,o.createCoreData)(this,t,e);if((0,h.default)("DraggableCore: handleDrag: %j",s),!1!==this.props.onDrag(r,s)&&!1!==this.mounted)this.lastX=t,this.lastY=e;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(r){const i=document.createEvent("MouseEvents");i.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(i)}}}),c(this,"handleDragStop",r=>{if(this.dragging){var i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:t,y:e}=i;Array.isArray(this.props.grid)&&(i=t-this.lastX||0,s=e-this.lastY||0,[i,s]=(0,o.snapToGrid)(this.props.grid,i,s),t=this.lastX+i,e=this.lastY+s);i=(0,o.createCoreData)(this,t,e);if(!1===this.props.onStop(r,i)||!1===this.mounted)return!1;var s=this.findDOMNode();s&&this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(s.ownerDocument),(0,h.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,s&&((0,h.default)("DraggableCore: Removing handlers"),(0,n.removeEvent)(s.ownerDocument,m.move,this.handleDrag),(0,n.removeEvent)(s.ownerDocument,m.stop,this.handleDragStop))}}}),c(this,"onMouseDown",t=>(m=g,this.handleDragStart(t))),c(this,"onMouseUp",t=>(m=g,this.handleDragStop(t))),c(this,"onTouchStart",t=>(m=f,this.handleDragStart(t))),c(this,"onTouchEnd",t=>(m=f,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;var t=this.findDOMNode();t&&(0,n.addEvent)(t,f.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;var t,e=this.findDOMNode();e&&(t=e["ownerDocument"],(0,n.removeEvent)(t,g.move,this.handleDrag),(0,n.removeEvent)(t,f.move,this.handleDrag),(0,n.removeEvent)(t,g.stop,this.handleDragStop),(0,n.removeEvent)(t,f.stop,this.handleDragStop),(0,n.removeEvent)(e,f.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack)&&(0,n.removeUserSelectStyles)(t)}findDOMNode(){var t;return null!=(t=this.props)&&t.nodeRef?null==(t=this.props)||null==(t=t.nodeRef)?void 0:t.current:a.default.findDOMNode(this)}render(){return i.cloneElement(i.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}c(e.default=p,"displayName","DraggableCore"),c(p,"propTypes",{allowAnyClick:s.default.bool,children:s.default.node.isRequired,disabled:s.default.bool,enableUserSelectHack:s.default.bool,offsetParent:function(t,e){if(t[e]&&1!==t[e].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:s.default.arrayOf(s.default.number),handle:s.default.string,cancel:s.default.string,nodeRef:s.default.object,onStart:s.default.func,onDrag:s.default.func,onStop:s.default.func,onMouseDown:s.default.func,scale:s.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},743:function(t,e,r){!function(t,f){!function(r){"use strict";var i,e,s,t,a,n,o,l,h,d;function u(t){delete n[t]}function c(t){if(o)setTimeout(c,0,t);else{var e=n[t];if(e){o=!0;try{var r=e.callback,i=e.args;switch(i.length){case 0:r();break;case 1:r(i[0]);break;case 2:r(i[0],i[1]);break;case 3:r(i[0],i[1],i[2]);break;default:r.apply(void 0,i)}}finally{u(t),o=!1}}}}r.setImmediate||(a=1,o=!(n={}),l=r.document,h=(h=Object.getPrototypeOf&&Object.getPrototypeOf(r))&&h.setTimeout?h:r,d="[object process]"==={}.toString.call(r.process)?function(t){f.nextTick(function(){c(t)})}:function(){var t,e;if(r.postMessage&&!r.importScripts)return t=!0,e=r.onmessage,r.onmessage=function(){t=!1},r.postMessage("","*"),r.onmessage=e,t}()?(s="setImmediate$"+Math.random()+"$",t=function(t){t.source===r&&"string"==typeof t.data&&0===t.data.indexOf(s)&&c(+t.data.slice(s.length))},r.addEventListener?r.addEventListener("message",t,!1):r.attachEvent("onmessage",t),function(t){r.postMessage(s+t,"*")}):r.MessageChannel?((e=new MessageChannel).port1.onmessage=function(t){c(t.data)},function(t){e.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,function(t){var e=l.createElement("script");e.onreadystatechange=function(){c(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):function(t){setTimeout(c,0,t)},h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r<e.length;r++)e[r]=arguments[r+1];return n[a]={callback:t,args:e},d(a),a++},h.clearImmediate=u)}("undefined"==typeof self?void 0===t?this:t:self)}.call(this,r(30),r(315))},746:function(t,e,r){"use strict";e.byteLength=function(t){var t=d(t),e=t[0],t=t[1];return 3*(e+t)/4-t},e.toByteArray=function(t){for(var e,r=d(t),i=r[0],r=r[1],s=new h(3*(i+r)/4-r),a=0,n=0<r?i-4:i,o=0;o<n;o+=4)e=l[t.charCodeAt(o)]<<18|l[t.charCodeAt(o+1)]<<12|l[t.charCodeAt(o+2)]<<6|l[t.charCodeAt(o+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===r&&(e=l[t.charCodeAt(o)]<<2|l[t.charCodeAt(o+1)]>>4,s[a++]=255&e),1===r&&(e=l[t.charCodeAt(o)]<<10|l[t.charCodeAt(o+1)]<<4|l[t.charCodeAt(o+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],a=0,n=r-i;a<n;a+=16383)s.push(function(t,e,r){for(var i,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(o[(i=i)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}(t,a,n<a+16383?n:a+16383));return 1==i?(e=t[r-1],s.push(o[e>>2]+o[e<<4&63]+"==")):2==i&&(e=(t[r-2]<<8)+t[r-1],s.push(o[e>>10]+o[e>>4&63]+o[e<<2&63]+"=")),s.join("")};for(var o=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=i.length;s<a;++s)o[s]=i[s],l[i.charCodeAt(s)]=s;function d(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");t=t.indexOf("=");return[t=-1===t?e:t,t===e?0:4-t%4]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},747:function(t,e){e.read=function(t,e,r,i,s){var a,n,o=8*s-i-1,l=(1<<o)-1,h=l>>1,d=-7,u=r?s-1:0,c=r?-1:1,s=t[e+u];for(u+=c,a=s&(1<<-d)-1,s>>=-d,d+=o;0<d;a=256*a+t[e+u],u+=c,d-=8);for(n=a&(1<<-d)-1,a>>=-d,d+=i;0<d;n=256*n+t[e+u],u+=c,d-=8);if(0===a)a=1-h;else{if(a===l)return n?NaN:1/0*(s?-1:1);n+=Math.pow(2,i),a-=h}return(s?-1:1)*n*Math.pow(2,a-i)},e.write=function(t,e,r,i,s,a){var n,o,l=8*a-s-1,h=(1<<l)-1,d=h>>1,u=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,c=i?0:a-1,f=i?1:-1,a=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,n=h):(n=Math.floor(Math.log(e)/Math.LN2),e*(i=Math.pow(2,-n))<1&&(n--,i*=2),2<=(e+=1<=n+d?u/i:u*Math.pow(2,1-d))*i&&(n++,i/=2),h<=n+d?(o=0,n=h):1<=n+d?(o=(e*i-1)*Math.pow(2,s),n+=d):(o=e*Math.pow(2,d-1)*Math.pow(2,s),n=0));8<=s;t[r+c]=255&o,c+=f,o/=256,s-=8);for(n=n<<s|o,l+=s;0<l;t[r+c]=255&n,c+=f,n/=256,l-=8);t[r+c-f]|=128*a}},748:function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}}}]);
|
|
15
|
+
Aborting and switching to level `+t),r.loader&&(this.fragCurrent=this.partCurrent=null,r.abortRequests()),s.trigger(I.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:n}))}}}}}}}onFragLoaded(t,{frag:e,part:r}){var i=(r||e).stats;if(e.type===y&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const t=(r||e).duration,s=this.hls.levels[e.level],a=(s.loaded?s.loaded.bytes:0)+i.loaded,n=(s.loaded?s.loaded.duration:0)+t;s.loaded={bytes:a,duration:n},s.realBitrate=Math.round(8*a/n)}if(e.bitrateTest){const t={stats:i,frag:e,part:r,id:e.type};this.onFragBuffered(I.FRAG_BUFFERED,t),e.bitrateTest=!1}}}onFragBuffered(t,e){var r,{frag:e,part:i}=e,i=(null!=i&&i.stats.loaded?i:e).stats;i.aborted||this.ignoreFragment(e)||(r=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(r,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0)}ignoreFragment(t){return t.type!==y||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let r=this.getNextABRAutoLevel();if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,r)&&e[t].loadError<=e[r].loadError)return t}return r=-1!==t?Math.min(t,r):r}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{maxAutoLevel:i,config:s,minAutoLevel:a,media:n}=r,o=e?e.duration:t?t.duration:0,l=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,u=(d?d.len:0)/l;var c=this.findBestLevel(h,a,i,u,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(0<=c)return c;P.trace(`[abr] ${u?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=o?Math.min(o,s.maxStarvationDelay):s.maxStarvationDelay,g=s.abrBandWidthFactor,m=s.abrBandWidthUpFactor;if(!u){const t=this.bitrateTestDelay;t&&(f=(o?Math.min(o,s.maxLoadingDelay):s.maxLoadingDelay)-t,P.trace(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),g=m=1)}return c=this.findBestLevel(h,a,i,u+f,g,m),Math.max(c,0)}findBestLevel(e,r,i,s,a,n){var t;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:h}=this,d=this.hls["levels"],u=d[h],c=!(null==u||null==(t=u.details)||!t.live),f=null==u?void 0:u.codecSet,g=l?l.duration:o?o.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let p=r,v=-1;for(let t=i;t>=r;t--){const r=d[t];if(!r||f&&r.codecSet!==f)r&&(p=Math.min(t,p),v=Math.max(t,v));else{-1!==v&&P.trace(`[abr] Skipped level(s) ${p}-${v} with CODECS:"${d[v].attrs.CODECS}"; not compatible with "${u.attrs.CODECS}"`);const i=r.details,o=(l?null==i?void 0:i.partTarget:null==i?void 0:i.averagetargetduration)||g;var y=t<=h?a*e:n*e,T=d[t].maxBitrate,E=this.getTimeToLoadFrag(m,y,T*o,void 0===i);if(P.trace(`[abr] level:${t} adjustedbw-bitrate:${Math.round(y-T)} avgDuration:${o.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:`+E.toFixed(1)),T<y&&(0===E||!D(E)||c&&!this.bitrateTestDelay||E<s))return t}}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}},bufferController:class{constructor(t){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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{var{media:t,mediaSource:e}=this;P.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(I.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{P.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{P.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:t,_objectUrl:e}=this;t&&t.src!==e&&P.error(`Media element src was set while attaching MediaSource (${e} > ${t.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.BUFFER_RESET,this.onBufferReset,this),t.on(I.BUFFER_APPENDING,this.onBufferAppending,this),t.on(I.BUFFER_CODECS,this.onBufferCodecs,this),t.on(I.BUFFER_EOS,this.onBufferEos,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(I.FRAG_PARSED,this.onFragParsed,this),t.on(I.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.BUFFER_RESET,this.onBufferReset,this),t.off(I.BUFFER_APPENDING,this.onBufferAppending,this),t.off(I.BUFFER_CODECS,this.onBufferCodecs,this),t.off(I.BUFFER_EOS,this.onBufferEos,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(I.FRAG_PARSED,this.onFragParsed,this),t.off(I.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ii(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let r=2;(!e.audio||e.video)&&e.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,P.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(t,e){e=this.media=e.media;if(e&&Ci){const t=this.mediaSource=new Ci;t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),e.src=self.URL.createObjectURL(t),this._objectUrl=e.src,e.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){var{media:t,mediaSource:e,_objectUrl:r}=this;if(e){if(P.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){P.warn(`[buffer-controller]: onMediaDetaching: ${t.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):P.warn("[buffer-controller]: media.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(I.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{var e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(e){P.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,e)}}),this._initSourceBuffer()}onBufferCodecs(t,l){const h=this.getSourceBufferTypes().length;Object.keys(l).forEach(t=>{if(h){const h=this.tracks[t];if(h&&"function"==typeof h.buffer.changeType){var{id:e,codec:r,levelCodec:i,container:s,metadata:a}=l[t],n=(h.levelCodec||h.codec).replace(Pi,"$1"),o=(i||r).replace(Pi,"$1");if(n!==o){const l=s+";codecs="+(i||r);this.appendChangeType(t,l),P.log(`[buffer-controller]: switching codec ${n} to `+o),this.tracks[t]={buffer:h.buffer,codec:r,container:s,levelCodec:i,metadata:a,id:e}}}}else this.pendingTracks[t]=l[t]}),h||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,r){const i=this["operationQueue"],t={execute:()=>{var t=this.sourceBuffer[e];t&&(P.log(`[buffer-controller]: changing ${e} sourceBuffer type to `+r),t.changeType(r)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{P.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}};i.append(t,e)}onBufferAppending(t,e){const{hls:r,operationQueue:i,tracks:s}=this,{data:a,type:n,frag:o,part:l,chunkMeta:h}=e,d=h.buffering[n],u=self.performance.now(),c=(d.start=u,o.stats.buffering),f=l?l.stats.buffering:null;0===c.start&&(c.start=u),f&&0===f.start&&(f.start=u);e=s.audio;let g=!1;"audio"===n&&"audio/mpeg"===(null==e?void 0:e.container)&&(g=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const m=o.start,p={execute:()=>{var t,e;d.executeStart=self.performance.now(),g&&(t=this.sourceBuffer[n])&&(e=m-t.timestampOffset,.1<=Math.abs(e))&&(P.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${m} (delta: ${e}) sn: ${o.sn})`),t.timestampOffset=m),this.appendExecutor(a,n)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();d.executeEnd=d.end=t,0===c.first&&(c.first=t),f&&0===f.first&&(f.first=t);var e=this["sourceBuffer"],r={};for(const t in e)r[t]=E.getBuffered(e[t]);this.appendError=0,this.hls.trigger(I.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:h,parent:o.type,timeRanges:r})},onError:t=>{P.error(`[buffer-controller]: Error encountered while trying to append to the ${n} SourceBuffer`,t);var e={type:_.MEDIA_ERROR,parent:o.type,details:C.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:h,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=C.BUFFER_FULL_ERROR:(this.appendError++,e.details=C.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(P.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),e.fatal=!0)),r.trigger(I.ERROR,e)}};i.append(p,n)}onBufferFlushing(t,r){const e=this["operationQueue"],i=e=>({execute:this.removeExecutor.bind(this,e,r.startOffset,r.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(I.BUFFER_FLUSHED,{type:e})},onError:t=>{P.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});r.type?e.append(i(r.type),r.type):this.getSourceBufferTypes().forEach(t=>{e.append(i(t),t)})}onFragParsed(t,e){const{frag:r,part:i}=e,s=[],a=(i||r).elementaryStreams;a[Q]?s.push("audiovideo"):(a[S]&&s.push("audio"),a[b]&&s.push("video")),0===s.length&&P.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: `+r.sn),this.blockBuffers(()=>{var t=self.performance.now(),t=(r.stats.buffering.end=t,i&&(i.stats.buffering.end=t),(i||r).stats);this.hls.trigger(I.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},s)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,i){this.getSourceBufferTypes().reduce((t,e)=>{var r=this.sourceBuffer[e];return!r||i.type&&i.type!==e||(r.ending=!0,r.ended)||(r.ended=!0,P.log(`[buffer-controller]: ${e} sourceBuffer now EOS`)),t&&!(r&&!r.ended)},!0)&&(P.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(t=>{t=this.sourceBuffer[t];t&&(t.ending=!1)});var t=this["mediaSource"];t&&"open"===t.readyState?(P.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&P.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:r,details:i,media:t,sourceBuffer:s}=this;if(t&&null!==i){var e=this.getSourceBufferTypes();if(e.length){var a=i.live&&null!==r.config.liveBackBufferLength?r.config.liveBackBufferLength:r.config.backBufferLength;if(D(a)&&!(a<0)){const n=t.currentTime,o=i.levelTargetDuration,l=Math.max(a,o),h=Math.floor(n/o)*o-l;e.forEach(t=>{var e=s[t];if(e){const s=E.getBuffered(e);if(0<s.length&&h>s.start(0)){if(r.trigger(I.BACK_BUFFER_REACHED,{bufferEnd:h}),i.live)r.trigger(I.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(e.ended&&s.end(s.length-1)-n<2*o)return void P.info(`[buffer-controller]: Cannot flush ${t} back buffer while SourceBuffer is in ended state`);r.trigger(I.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:t})}}})}}}}updateMediaElementDuration(){var t,e,r,i,s,a;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:t,hls:e,media:s,mediaSource:r}=this,i=t.fragments[0].start+t.totalduration,s=s.duration,a=D(r.duration)?r.duration:0,t.live&&e.config.liveDurationInfinity?(P.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(a<i&&s<i||!D(s))&&(P.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),r.duration=i))}updateSeekableRange(t){var e=this.mediaSource,r=t.fragments;r.length&&t.live&&null!=e&&e.setLiveSeekableRange&&(r=Math.max(0,r[0].start),t=Math.max(r,r+t.totalduration),e.setLiveSeekableRange(r,t))}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(I.BUFFER_CREATED,{tracks:this.tracks}),t.forEach(t=>{e.executeNext(t)});else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){var{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in t)if(!e[n]){var i=t[n];if(!i)throw Error(`source buffer exists for track ${n}, however track does not`);var s=i.levelCodec||i.codec,a=i.container+";codecs="+s;P.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{const t=e[n]=r.addSourceBuffer(a),o=n;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[n]={buffer:t,codec:s,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(t){P.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:a})}}}_onSBUpdateStart(t){var e=this["operationQueue"];e.current(t).onStart()}_onSBUpdateEnd(t){var e=this["operationQueue"];e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var r=new Error(t+" SourceBuffer error"),r=(P.error("[buffer-controller]: "+r,e),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.BUFFER_APPENDING_ERROR,error:r,fatal:!1}),this.operationQueue.current(t));r&&r.onError(e)}removeExecutor(t,e,r){var{media:i,mediaSource:s,operationQueue:a,sourceBuffer:n}=this,n=n[t];i&&s&&n?(i=D(i.duration)?i.duration:1/0,s=D(s.duration)?s.duration:1/0,(e=Math.max(0,e))<(r=Math.min(r,i,s))&&!n.ending?(n.ended=!1,P.log(`[buffer-controller]: Removing [${e},${r}] from the ${t} SourceBuffer`),n.remove(e,r)):a.shiftAndExecuteNext(t)):(P.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t))}appendExecutor(t,e){var{operationQueue:r,sourceBuffer:i}=this,i=i[e];i?(i.ended=!1,i.appendBuffer(t)):(P.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(e))}blockBuffers(t,e=this.getSourceBufferTypes()){if(e.length){const r=this["operationQueue"],i=e.map(t=>r.appendBlocker(t));Promise.all(i).then(()=>{t(),e.forEach(t=>{var e=this.sourceBuffer[t];null!=e&&e.updating||r.shiftAndExecuteNext(t)})})}else P.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){var i=this.sourceBuffer[t];i&&(r=r.bind(this,t),this.listeners[t].push({event:e,listener:r}),i.addEventListener(e,r))}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(t=>{e.removeEventListener(t.event,t.listener)})}},capLevelController:ys,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=P.log.bind(P,"[info]:"),this.warn=P.warn.bind(P,"[warning]:"),this.error=P.error.bind(P,"[error]:"),this.registerListeners()}registerListeners(){var t=this.hls;t.on(I.ERROR,this.onError,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var t=this.hls;t&&(t.off(I.ERROR,this.onError,this),t.off(I.ERROR,this.onErrorOut,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===y?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){if(!e.fatal){var r,i=this.hls,s=e.context;switch(e.details){case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case C.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:0,flags:0});case C.FRAG_GAP:case C.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case C.LEVEL_EMPTY_ERROR:case C.LEVEL_PARSING_ERROR:{const t=e.parent===y?e.level:i.loadLevel;e.details===C.LEVEL_EMPTY_ERROR&&null!=(r=e.context)&&null!=(r=r.levelDetails)&&r.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.level)));case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.SUBTITLE_LOAD_ERROR:case C.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const t=i.levels[i.loadLevel];if(t&&(s.type===p&&s.groupId===t.audioGroupId||s.type===v&&s.groupId===t.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=i.levels[i.loadLevel],r=null==t?void 0:t.attrs["HDCP-LEVEL"];r&&(e.errorAction={action:2,flags:2,hdcpLevel:r})}return;case C.BUFFER_ADD_CODEC_ERROR:case C.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(r=e.level)?r:i.loadLevel));case C.INTERNAL_EXCEPTION:case C.BUFFER_APPENDING_ERROR:case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:case C.LEVEL_SWITCH_ERROR:case C.BUFFER_STALLED_ERROR:case C.BUFFER_SEEK_OVER_HOLE:case C.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:0,flags:0})}if(e.type===_.KEY_SYSTEM_ERROR){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}}}getPlaylistRetryOrSwitchAction(t,e){var r=Ce(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++,s=null==(s=t.response)?void 0:s.code;return Me(r,i,_e(t),s)?{action:5,flags:0,retryConfig:r,retryCount:i}:(s=this.getLevelSwitchAction(t,e),r&&(s.retryConfig=r,s.retryCount=i),s)}getFragRetryOrSwitchAction(t){const e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],{fragLoadPolicy:s,keyLoadPolicy:a}=e.config,n=Ce(t.details.startsWith("key")?a:s,t),o=e.levels.reduce((t,e)=>t+e.fragmentError,0);if(i){t.details!==C.FRAG_GAP&&i.fragmentError++;const e=null==(l=t.response)?void 0:l.code;if(Me(n,o,_e(t),e))return{action:5,flags:0,retryConfig:n,retryCount:o}}var l=this.getLevelSwitchAction(t,r);return n&&(l.retryConfig=n,l.retryCount=o),l}getLevelSwitchAction(r,i){const s=this.hls;null==i&&(i=s.loadLevel);var a,n=this.hls.levels[i];if(n&&(n.loadError++,s.autoLevelEnabled)){let e=-1;var{levels:o,loadLevel:l,minAutoLevel:h,maxAutoLevel:d}=s,u=null==(a=r.frag)?void 0:a.type,{type:c,groupId:f}=null!=(i=r.context)?i:{};for(let t=o.length;t--;){const a=(t+l)%o.length;if(a!==l&&a>=h&&a<=d&&0===o[a].loadError){const s=o[a];if(r.details===C.FRAG_GAP&&r.frag){const i=o[a].details;if(i){const s=Fe(r.frag,i.fragments,r.frag.start);if(null!=s&&s.gap)continue}}else{if(c===p&&f===s.audioGroupId||c===v&&f===s.textGroupId)continue;if(u===L&&n.audioGroupId===s.audioGroupId||u===ae&&n.textGroupId===s.textGroupId)continue}e=a;break}}if(-1<e&&s.loadLevel!==e)return r.levelRetry=!0,{action:2,flags:this.playlistError=0,nextAutoLevel:e}}return{action:2,flags:1}}onErrorOut(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===C.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){var e=this.hls,r=t.errorAction;if(r){var{flags:i,hdcpLevel:s,nextAutoLevel:a}=r;switch(i){case 0:this.switchLevel(t,a);break;case 1:r.resolved||(r.resolved=this.redundantFailover(t));break;case 2:s&&(e.maxHdcpLevel=Ee[Ee.indexOf(s)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(t,a)}}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after `+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){var{hls:r,penalizedRenditions:i}=this,s=e.parent===y?e.level:r.loadLevel,a=r.levels[s],n=a.url.length,o=(e.frag||a).urlId;a.urlId!==o||e.frag&&!a.details||this.penalizeRendition(a,e);for(let t=1;t<n;t++){const l=(o+t)%n,h=i[l];if(!h||function(t,e,r){if(3e5<performance.now()-t.lastErrorPerfMs)return 1;var i=t.details;if(e.details===C.FRAG_GAP&&i&&e.frag){const t=e.frag.start,r=Fe(null,i.fragments,t);if(r&&!r.gap)return 1}if(r&&t.errors.length<r.errors.length){const r=t.errors[t.errors.length-1];if(i&&r.frag&&e.frag&&Math.abs(r.frag.start-e.frag.start)>3*i.targetduration)return 1}}(h,e,i[o]))return this.warn(`Switching to Redundant Stream ${1+l}/${n}: "${a.url[l]}" after `+e.details),this.playlistError=0,r.levels.forEach(t=>{t.urlId=l}),r.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){var r=this["penalizedRenditions"],i=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(e),i.details=t.details,r[t.urlId]=i}},fpsController:class{constructor(t){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=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;(this.media=t)&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,r){var i,s=performance.now();if(e){if(this.lastTime){const t=s-this.lastTime,a=r-this.lastDroppedFrames,n=e-this.lastDecodedFrames,o=1e3*a/t,l=this.hls;l.trigger(I.FPS_DROP,{currentDropped:a,currentDecoded:n,totalDroppedFrames:r}),0<o&&a>l.config.fpsDroppedMonitoringThreshold*n&&(i=l.currentLevel,P.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),0<i)&&(-1===l.autoLevelCapping||l.autoLevelCapping>=i)&&(--i,l.trigger(I.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:l.currentLevel}),l.autoLevelCapping=i,this.streamController.nextLevelSwitch())}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=e}}checkFPSInterval(){var t,e=this.media;e&&(this.isVideoPlaybackQualityAvailable?(t=e.getVideoPlaybackQuality(),this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)):this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ct,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!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},{cueHandler:_s,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:class extends Er{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",ae),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.ERROR,this.onError,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.ERROR,this.onError,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=d,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,r){var{frag:r,success:i}=r;if(this.fragPrevious=r,this.state=d,i){var s=this.tracksBuffered[this.currentTrackId];if(s){let e;var a=r.start;for(let t=0;t<s.length;t++)if(a>=s[t].start&&a<=s[t].end){e=s[t];break}i=r.start+r.duration;e?e.end=i:(e={start:a,end:i},s.push(e)),this.fragmentTracker.fragBuffered(r)}}}onBufferFlushing(r,t){var{startOffset:e,endOffset:i}=t;if(0===e&&i!==Number.POSITIVE_INFINITY){const r=i-1;r<=0||(t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(e=>{for(let t=0;t<e.length;)if(e[t].end<=r)e.shift();else{if(!(e[t].start<r))break;e[t].start=r,t++}}),this.fragmentTracker.removeFragmentsInRange(e,r,ae))}}onFragBuffered(t,e){this.loadedmetadata||e.frag.type!==y||null!=(e=this.media)&&e.buffered.length&&(this.loadedmetadata=!0)}onError(t,e){e=e.frag;(null==e?void 0:e.type)===ae&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==n)&&(this.state=d)}onSubtitleTracksUpdated(t,{subtitleTracks:e}){Di(this.levels,e)?this.levels=e.map(t=>new Le(t)):(this.tracksBuffered=[],this.levels=e.map(t=>{t=new Le(t);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ae),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId?(null!=(e=this.levels[this.currentTrackId])&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(e,r){var{details:i,id:r}=r,{currentTrackId:t,levels:s}=this;if(s.length){var a=s[t];if(!(r>=s.length||r!==t)&&a){this.mediaBuffer=this.mediaBufferTimeRanges;let t=0;if(i.live||null!=(s=a.details)&&s.live){const e=this.mainDetails;if(i.deltaUpdateFailed||!e)return;const r=e.fragments[0];a.details?0===(t=this.alignPlaylists(i,a.details))&&r&&we(i,t=r.start):i.hasProgramDateTime&&e.hasProgramDateTime?(nr(i,e),t=i.fragments[0].start):r&&we(i,t=r.start)}a.details=i,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(a.details,t),this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==d||Fe(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0)}}}_handleFragmentLoadComplete(r){const{frag:i,payload:t}=r,e=i.decryptdata,s=this.hls;if(!this.fragContextChanged(i)&&t&&0<t.byteLength&&e&&e.key&&e.iv&&"AES-128"===e.method){const r=performance.now();this.decrypter.decrypt(new Uint8Array(t),e.key.buffer,e.iv.buffer).catch(t=>{throw s.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:i}),t}).then(t=>{var e=performance.now();s.trigger(I.FRAG_DECRYPTED,{frag:i,payload:t,stats:{tstart:r,tdecrypt:e}})}).catch(t=>{this.warn(t.name+": "+t.message),this.state=d})}}doTick(){if(this.media){if(this.state===d){var{currentTrackId:e,levels:r}=this,e=r[e];if(r.length&&e&&e.details){var r=this["config"],i=this.getLoadPosition(),{end:i,len:s}=E.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),a=this.getFwdBufferInfo(this.media,y),n=e.details;if(!(s>this.getMaxBufferLength(null==a?void 0:a.len)+n.levelTargetDuration)){var s=n.fragments,a=s.length,o=n.edge;let t=null;var l=this.fragPrevious;i<o?(r=o-(o=r.maxFragLookUpTolerance)<i?0:o,!(t=Fe(l,s,Math.max(s[0].start,i),r))&&l&&l.start<s[0].start&&(t=s[0])):t=s[a-1],t&&("initSegment"!==(t=this.mapToInitFragWhenRequired(t)).sn&&(o=s[t.sn-n.startSN-1])&&o.cc===t.cc&&this.fragmentTracker.getState(o)===He&&(t=o),this.fragmentTracker.getState(t)===He)&&this.loadFragment(t,e,i)}}}}else this.state=d}getMaxBufferLength(t){var e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,r){"initSegment"===(this.fragCurrent=t).sn?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,r))}get mediaBufferTimeRanges(){return new wi(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Ue{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,-1<this.trackId&&this.toggleTrackModes(this.trackId)}registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId),ki(this.media.textTracks).forEach(t=>{ue(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){var r,{id:i,details:s}=e,a=this["trackId"],a=this.tracksInGroup[a];a?(r=a.details,a.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,r)):this.warn("Invalid subtitle track id "+i)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null!=e&&e.textGroupIds){const i=e.textGroupIds[e.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const t=this.tracks.filter(t=>!i||t.groupId===i),e=(this.tracksInGroup=t,this.findTrackId(null==s?void 0:s.name)||this.findTrackId());this.groupId=i||null;var r={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${i}" group-id`),this.hls.trigger(I.SUBTITLE_TRACKS_UPDATED,r),-1!==e&&this.setSubtitleTrack(e,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}}findTrackId(e){var r=this.tracksInGroup;for(let t=0;t<r.length;t++){var i=r[t];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1}onError(t,e){!e.fatal&&e.context&&e.context.type===v&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(e){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,s=r.groupId;let t=r.url;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(I.SUBTITLE_TRACK_LOADING,{url:t,id:i,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(t){var{media:e,trackId:r}=this;if(e){var e=ki(e.textTracks),i=e.filter(t=>t.groupId===this.groupId);if(-1===t)[].slice.call(e).forEach(t=>{t.mode="disabled"});else{const t=i[r];t&&(t.mode="disabled")}e=i[t];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}}setSubtitleTrack(t,e){var r;const i=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!=(r=i[t])&&r.details)||t<-1||t>=i.length)){this.clearTimer();var s=i[t];if(this.log("Switching to subtitle-track "+t+(s?` "${s.name}" lang:${s.lang} group:`+s.groupId:"")),this.trackId=t,s){const{id:t,groupId:r="",name:i,type:a,url:n}=s;this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:t,groupId:r,name:i,type:a,url:n});s=this.switchParams(s.url,null==e?void 0:e.details);this.loadPlaylist(s)}else this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let e=-1;var r=ki(this.media.textTracks);for(let t=0;t<r.length;t++)if("hidden"===r[t].mode)e=t;else if("showing"===r[t].mode){e=t;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}},timelineController:class{constructor(t){if(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.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){const t=new Xi(this,"textTrack1"),e=new Xi(this,"textTrack2"),r=new Xi(this,"textTrack3"),i=new Xi(this,"textTrack4");this.cea608Parser1=new Wi(1,t,e),this.cea608Parser2=new Wi(3,r,i)}t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.FRAG_LOADING,this.onFragLoading,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){var t=this["hls"];t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.FRAG_LOADING,this.onFragLoading,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,r,i,s){let a=!1;for(let t=s.length;t--;){const i=s[t],h=(n=i[0],o=i[1],l=e,Math.min(o,r)-Math.max(n,l));if(0<=h&&(i[0]=Math.min(i[0],e),i[1]=Math.max(i[1],r),a=!0,.5<h/(r-e)))return}var n,o,l;if(a||s.push([e,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[t];this.Cues.newCue(s,e,r,i)}else{const s=this.Cues.newCue(null,e,r,i);this.hls.trigger(I.CUES_PARSED,{type:"captions",cues:s,track:t})}}onInitPtsFound(t,{frag:e,id:r,initPTS:i,timescale:s}){var a=this["unparsedVttFrags"];"main"===r&&(this.initPTS[e.cc]={baseTime:i,timescale:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(t=>{this.onFragLoaded(I.FRAG_LOADED,t)}))}getExistingTrack(e){var r=this["media"];if(r)for(let t=0;t<r.textTracks.length;t++){var i=r.textTracks[t];if(i[e])return i}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(!this.captionsTracks[t]){const{captionsProperties:e,captionsTracks:r,media:i}=this,{label:s,languageCode:a}=e[t],n=this.getExistingTrack(t);if(n)r[t]=n,ue(r[t]),he(r[t],i);else{const e=this.createTextTrack("captions",s,a);e&&(e[t]=!0,r[t]=e)}}}createNonNativeTrack(t){var e;this.nonNativeCaptionsTracks[t]||(e=this.captionsProperties[t])&&(e={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media},this.nonNativeCaptionsTracks[t]=e,this.hls.trigger(I.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[e]}))}createTextTrack(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const e=this["captionsTracks"];Object.keys(e).forEach(t=>{ue(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var t=this["media"];if(t){var e=t.textTracks;if(e)for(let t=0;t<e.length;t++)ue(e[t])}}onSubtitleTracksUpdated(n,t){var t=t.subtitleTracks||[],e=t.some(t=>"stpp.ttml.im1t"===t.textCodec);if(this.config.enableWebVTT||e&&this.config.enableIMSC1)if(Di(this.tracks,t))this.tracks=t;else if(this.textTracks=[],this.tracks=t,this.config.renderTextTracksNatively){const n=this.media?this.media.textTracks:null;this.tracks.forEach((r,t)=>{let i;if(n&&t<n.length){let e=null;for(let t=0;t<n.length;t++)if(s=n[t],a=r,s&&s.label===a.name&&!s.textTrack1&&!s.textTrack2){e=n[t];break}e&&(i=e)}var s,a;if(i)ue(i);else{const n=this._captionsOrSubtitlesFromCharacteristics(r);(i=this.createTextTrack(n,r.name,r.lang))&&(i.mode="disabled")}i&&(i.groupId=r.groupId,this.textTracks.push(i))})}else if(this.tracks.length){const n=this.tracks.map(t=>({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}));this.hls.trigger(I.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){var e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),t=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&t)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(t=>{var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);e&&(e="textTrack"+e[1],e=this.captionsProperties[e])&&(e.label=t.name,t.lang&&(e.languageCode=t.lang),e.media=t)})}closedCaptionsForLevel(t){t=this.hls.levels[t.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){var{cea608Parser1:r,cea608Parser2:i,lastSn:s,lastPartIndex:a}=this;if(this.enabled&&r&&i&&e.frag.type===y){const t=e.frag.sn,n=null!=(e=null==e||null==(e=e.part)?void 0:e.index)?e:-1;t===s+1||t===s&&n===a+1||(r.reset(),i.reset()),this.lastSn=t,this.lastPartIndex=n}}onFragLoaded(t,e){var{frag:r,payload:i}=e;if(r.type===ae)if(i.byteLength){const t=r.decryptdata,s="stats"in e;if(null==t||!t.encrypted||s){const t=this.tracks[r.level],a=this.vttCCs;a[r.cc]||(a[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),t&&"stpp.ttml.im1t"===t.textCodec?this._parseIMSC1(r,i):this._parseVTTs(e)}}else this.hls.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;cs(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{P.log("Failed to parse IMSC1: "+t),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(i){var t;const{frag:o,payload:l}=i,{initPTS:e,unparsedVttFrags:h}=this,d=e.length-1;if(e[o.cc]||-1!=d){const y=this.hls;{var u=null!=(u=o.initSegment)&&u.data?Pt(o.initSegment.data,new Uint8Array(l)):l;var c=this.initPTS[o.cc];var f=this.vttCCs;var g=o.cc;var m=o.start;var p=t=>{this._appendCues(t,o.level),y.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})};var v=t=>{var e="Missing initPTS for VTT MPEGTS"===t.message;e?h.push(i):this._fallbackToIMSC1(o,l),P.log("Failed to parse VTT cue: "+t),e&&d>o.cc||y.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:t})};const T=new ss,E=A(new Uint8Array(u)).trim().replace(os,"\n").split("\n"),S=[],L=c?([u,t=1]=[c.baseTime,c.timescale],zr(u,9e4,1/t)):0;let s,e="00:00.000",a=0,n=0,r=!0;T.oncue=function(t){var e=f[g];let r=f.ccOffset;var i=(a-L)/9e4;if(null!=e&&e.new&&(void 0!==n?r=f.ccOffset=e.start:function(t,e){let r=t[g],i=t[r.prevCC];if(!i||!i.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,r.new=!1;for(;null!=(s=i)&&s.new;){var s;t.ccOffset+=r.start-i.start,r.new=!1,i=t[(r=i).prevCC]}t.presentationOffset=e}(f,i)),i){if(!c)return void(s=new Error("Missing initPTS for VTT MPEGTS"));r=i-f.presentationOffset}e=t.endTime-t.startTime,i=U(9e4*(t.startTime+r-n),9e4*m)/9e4,t.startTime=Math.max(i,0),t.endTime=Math.max(i+e,0),i=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(i)),t.id||(t.id=ls(t.startTime,t.endTime,i)),0<t.endTime&&S.push(t)},T.onparsingerror=function(t){s=t},T.onflush=function(){s?v(s):p(S)},E.forEach(t=>{if(r){if(as(t,"X-TIMESTAMP-MAP=")){r=!1,t.slice(16).split(",").forEach(t=>{as(t,"LOCAL:")?e=t.slice(6):as(t,"MPEGTS:")&&(a=parseInt(t.slice(7)))});try{n=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),s=9<t.length?parseInt(t.substring(0,t.indexOf(":"))):0;if(D(e)&&D(r)&&D(i)&&D(s))return(e+=1e3*r)+6e4*i+36e5*s;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t)}(e)/1e3}catch(t){s=t}return}""===t&&(r=!1)}T.parse(t+"\n")}),T.flush()}}else h.push(i)}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||cs(e,this.initPTS[t.cc],()=>{r.textCodec="stpp.ttml.im1t",this._parseIMSC1(t,e)},()=>{r.textCodec="wvtt"})}_appendCues(t,e){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[e];r&&"disabled"!==r.mode&&t.forEach(t=>de(r,t))}else{var i=this.tracks[e];i&&(i=i.default?"default":"subtitles"+e,r.trigger(I.CUES_PARSED,{type:"subtitles",cues:t,track:i}))}}onFragDecrypted(t,e){var r=e["frag"];r.type===ae&&this.onFragLoaded(I.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){var{cea608Parser1:r,cea608Parser2:i}=this;if(this.enabled&&r&&i){const{frag:s,samples:a}=e;if(s.type!==y||"NONE"!==this.closedCaptionsForLevel(s))for(let t=0;t<a.length;t++){const e=a[t].bytes;if(e){const s=this.extractCea608Data(e);r.addData(a[t].pts,s[0]),i.addData(a[t].pts,s[1])}}}}onBufferFlushing(e,{startOffset:r,endOffset:i,endOffsetSubtitles:s,type:t}){var a=this["media"];if(a&&!(a.currentTime<i)){if(!t||"video"===t){const e=this["captionsTracks"];Object.keys(e).forEach(t=>ce(e[t],r,i))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==s){const e=this["textTracks"];Object.keys(e).forEach(t=>ce(e[t],r,s))}}}extractCea608Data(e){const r=[[],[]],i=31&e[0];let s=2;for(let t=0;t<i;t++){const i=e[s++],a=127&e[s++],n=127&e[s++];if((0!=a||0!=n)&&0!=(4&i)){const e=3&i;0!=e&&1!=e||(r[e].push(a),r[e].push(n))}}return r}},audioStreamController:class extends Er{constructor(t,e,r){super(t,e,r,"[audio-stream-controller]",L),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){var t=this["hls"];t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(I.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(I.ERROR,this.onError,this),t.on(I.BUFFER_RESET,this.onBufferReset,this),t.on(I.BUFFER_CREATED,this.onBufferCreated,this),t.on(I.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var t=this["hls"];t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(I.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(I.ERROR,this.onError,this),t.off(I.BUFFER_RESET,this.onBufferReset,this),t.off(I.BUFFER_CREATED,this.onBufferCreated,this),t.off(I.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:r,initPTS:i,timescale:s}){if("main"===r){const t=e.cc;this.initPTS[e.cc]={baseTime:i,timescale:s},this.log(`InitPTS for cc: ${t} found from main: `+i),this.videoTrackCC=t,this.state===yr&&this.tick()}}startLoad(t){var e;this.levels?(e=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),0<e&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=d):(this.loadedmetadata=!1,this.state=gr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()):(this.startPosition=t,this.state=n)}doTick(){switch(this.state){case d:this.doTickIdle();break;case gr:{var t;const{levels:e,trackId:r}=this,i=null==e||null==(t=e[r])?void 0:t.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=yr}break}case fr:{var e;const t=performance.now(),s=this.retryDate;(!s||t>=s||null!=(e=this.media)&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=d);break}case yr:{const t=this.waitingData;if(t){const{frag:e,part:a,cache:n,complete:o}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=cr;const t={frag:e,part:a,payload:n.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),o&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc `+this.videoTrackCC),this.clearWaitingFragment();else{const t=this.getLoadPosition(),l=E.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);Ne(l.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${l.end} is needed`),this.clearWaitingFragment())}}else this.state=d}}this.onTickEnd()}clearWaitingFragment(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=d)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){var t=this["media"];null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:i,levels:t,media:s,trackId:e}=this,r=i.config;if(null!=t&&t[e]&&(s||!this.startFragRequested&&r.startFragPrefetch)){var a=t[e],n=a.details;if(!n||n.live&&this.levelLastLoaded!==e||this.waitForCdnTuneIn(n))this.state=gr;else{var o=this.mediaBuffer||this.media,o=(this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,S,L)),this.getFwdBufferInfo(o,L));if(null!==o){var{bufferedTrack:l,switchingTrack:h}=this;if(!h&&this._streamEnded(o,n))i.trigger(I.BUFFER_EOS,{type:"audio"}),this.state=pr;else{var d=this.getFwdBufferInfo(this.videoBuffer||this.media,y),u=o.len,c=this.getMaxBufferLength(null==d?void 0:d.len);if(!(c<=u)||h){u=n.fragments[0].start;let t=o.end;if(h&&s){const i=this.getLoadPosition();l&&h.attrs!==l.attrs&&(t=i),n.PTSKnown&&i<u&&(o.end>u||o.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=u+.05)}let e=this.getNextFragment(t,n),r=!1;if(e&&this.isLoopLoading(e,t)&&(r=!!e.gap,e=this.getNextFragmentLoopLoading(e,n,o,y,c)),e){h=d&&e.start>d.end+n.targetduration;if(h||(null==d||!d.len)&&o.len){const i=this.getAppendedFrag(e.start,y);if(null===i)return;if(r=r||!!i.gap||!!h&&0===d.len,h&&!r||r&&o.nextStart&&o.nextStart<i.end)return}this.loadFragment(e,a,t)}else this.bufferFlushed=!0}}}}}}getMaxBufferLength(t){var e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(t=>new Le(t))}onAudioTrackSwitching(t,e){var r=!!e.url,i=(this.trackId=e.id,this)["fragCurrent"];i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=d):(this.switchingTrack=null,this.bufferedTrack=e,this.state=n),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(I.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,r){var i;if(null==this.mainDetails)this.cachedTrackLoadedData=r;else{var s=this["levels"],{details:r,id:a}=r;if(s){this.log(`Track ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:`+r.totalduration);s=s[a];let t=0;if(r.live||null!=(i=s.details)&&i.live){this.checkLiveUpdate(r);const e=this.mainDetails;if(r.deltaUpdateFailed||!e)return;t=!s.details&&r.hasProgramDateTime&&e.hasProgramDateTime?(nr(r,e),r.fragments[0].start):this.alignPlaylists(r,s.details)}s.details=r,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(s.details,t),this.state!==gr||this.waitForCdnTuneIn(r)||(this.state=d),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)}}_handleFragmentLoadProgress(e){var r;const{frag:i,part:s,payload:a}=e,{config:n,trackId:o,levels:t}=this;if(t){e=t[o];if(e){var l=e.details;if(l){var h=n.defaultAudioCodec||e.audioCodec||"mp4a.40.2";let t=this.transmuxer;t=t||(this.transmuxer=new Ei(this.hls,L,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var d=this.initPTS[i.cc],u=null==(r=i.initSegment)?void 0:r.data;if(void 0!==d){const e=!1,r=s?s.index:-1,n=-1!==r,o=new rr(i.level,i.sn,i.stats.chunkCount,a.byteLength,r,n);t.push(a,u,h,"",i,s,l.totalduration,!1,o,d)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track `+o);const e=(this.waitingData=this.waitingData||{frag:i,part:s,cache:new Ri,complete:!1})["cache"];e.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=yr}}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){var{frag:e,part:r}=e;if(e.type===L)if(this.fragContextChanged(e))this.warn(`Fragment ${e.sn}${r?" p: "+r.index:""} of level ${e.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==e.sn){this.fragPrevious=e;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(I.AUDIO_TRACK_SWITCHED,m({},t)))}this.fragBufferedComplete(e,r)}else if(!this.loadedmetadata&&e.type===y){const t=this.videoBuffer||this.media;t&&E.getBuffered(t).length&&(this.loadedmetadata=!0)}}onError(t,e){var r;if(e.fatal)this.state=vr;else switch(e.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(L,e);break;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==gr||(null==(r=e.context)?void 0:r.type)!==p||(this.state=d);break;case C.BUFFER_FULL_ERROR:e.parent&&"audio"===e.parent&&this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,{type:e}){e===S&&(this.bufferFlushed=!0,this.state===pr)&&(this.state=d)}_handleTransmuxComplete(t){var e;const r="audio",i=this["hls"],{remuxResult:s,chunkMeta:a}=t,n=this.getCurrentContext(a);if(n){var{frag:o,part:l,level:t}=n,h=t["details"],{audio:d,text:u,id3:c,initSegment:f}=s;if(!this.fragContextChanged(o)&&h){if(this.state=O,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const t=o.initSegment||o;this._bufferInitSegment(f.tracks,t,a),i.trigger(I.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:r,tracks:f.tracks})}if(d){const{startPTS:t,endPTS:e,startDTS:r,endDTS:i}=d;l&&(l.elementaryStreams[S]={startPTS:t,endPTS:e,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(S,t,e,r,i),this.bufferFragmentData(d,o,l,a)}if(null!=c&&null!=(e=c.samples)&&e.length){const t=k({id:r,frag:o,details:h},c);i.trigger(I.FRAG_PARSING_METADATA,t)}if(u){const t=k({id:r,frag:o,details:h},u);i.trigger(I.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(a)}_bufferInitSegment(t,e,r){if(this.state===O){t.video&&delete t.video;var i=t.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(I.BUFFER_CODECS,t);i=i.initSegment;if(null!=i&&i.byteLength){const t={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:i};this.hls.trigger(I.BUFFER_APPENDING,t)}this.tick()}}}loadFragment(t,e,r){var i=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||i===He||i===Ye?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(i=e.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=yr):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){var{hls:e,media:r,bufferedTrack:i}=this,i=null==i?void 0:i.attrs,s=t.attrs;r&&i&&(i.CHANNELS!==s.CHANNELS||i.NAME!==s.NAME||i.LANGUAGE!==s.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(I.AUDIO_TRACK_SWITCHED,m({},t))}},audioTrackController:class extends Ue{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var t=this["hls"];t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this["hls"];t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(I.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){var r,{id:i,groupId:s,details:a}=e,n=this.tracksInGroup[i];n&&n.groupId===s?(r=n.details,n.details=e.details,this.log(`audio-track ${i} "${n.name}" lang:${n.lang} group:${s} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,r)):this.warn(`Track with id:${i} and group:${s} not found in active group `+n.groupId)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(null!=e&&e.audioGroupIds){const r=e.audioGroupIds[e.urlId];if(this.groupId!==r){this.groupId=r||null;const t=this.tracks.filter(t=>!r||t.groupId===r),e=(this.selectDefaultTrack&&!t.some(t=>t.default)&&(this.selectDefaultTrack=!1),{audioTracks:this.tracksInGroup=t});this.log(`Updating audio tracks, ${t.length} track(s) found in group:`+r),this.hls.trigger(I.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(t,e){!e.fatal&&e.context&&e.context.type===p&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){var e,r,i,s=this.tracksInGroup;t<0||t>=s.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),e=this.currentTrack,s[this.trackId],{groupId:r,name:i}=s=s[t],this.log(`Switching to audio-track ${t} "${i}" lang:${s.lang} group:`+r),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(I.AUDIO_TRACK_SWITCHING,m({},s)),s.details&&!s.details.live||(i=this.switchParams(s.url,null==e?void 0:e.details),this.loadPlaylist(i)))}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{const e=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+t.length);this.warn(e.message),this.hls.trigger(I.ERROR,{type:_.MEDIA_ERROR,details:C.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}findTrackId(e){var r=this.tracksInGroup;for(let t=0;t<r.length;t++){var i=r[t];if(!this.selectDefaultTrack||i.default){if(!e||void 0!==e.attrs["STABLE-RENDITION-ID"]&&e.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(e.name===i.name&&e.lang===i.lang)return i.id}}return-1}loadPlaylist(e){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,s=r.groupId;let t=r.url;if(e)try{t=e.addDirectives(t)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log(`loading audio-track playlist ${i} "${r.name}" lang:${r.lang} group:`+s),this.clearTimer(),this.hls.trigger(I.AUDIO_TRACK_LOADING,{url:t,id:i,groupId:s,deliveryDirectives:e||null})}}},emeController:Ts,cmcdController:Es,contentSteeringController:class{constructor(t){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=t,this.log=P.log.bind(P,"[content-steering]:"),this.registerListeners()}registerListeners(){var t=this.hls;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){var t=this.hls;t&&(t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.ERROR,this.onError,this))}startLoad(){var t;this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri&&(this.updated?(t=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0),this.scheduleRefresh(this.uri,t)):this.loadSteeringManifest(this.uri))}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){e=e.contentSteering;null!==e&&(this.pathwayId=e.pathwayId,this.uri=e.uri,this.started)&&this.startLoad()}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){var r=e["errorAction"];if(2===(null==r?void 0:r.action)&&1===r.flags){let t=this.pathwayPriority;const e=this.pathwayId;this.penalizedPathways[e]||(this.penalizedPathways[e]=performance.now()),(t=!t&&this.levels?this.levels.reduce((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t),[]):t)&&1<t.length&&(this.updatePathwayPriority(t),r.resolved=this.pathwayId!==e)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);var r;return 0===e.length&&(r=t[0].pathwayId,this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),e=this.getLevelsForPathway(r),this.pathwayId=r),e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(t=>{3e5<i-r[t]&&delete r[t]});for(let t=0;t<e.length;t++){var s=e[t];if(!r[s]){if(s===this.pathwayId)return;var a,n=this.hls.nextLoadLevel,o=this.hls.levels[n];if(0<(a=this.getLevelsForPathway(s)).length){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,this.hls.trigger(I.LEVELS_UPDATED,{levels:a});const e=this.hls.levels[n];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to `+e.bitrate),this.hls.nextLoadLevel=n);break}}}}clonePathways(t){const r=this.levels;if(r){const n={},o={};t.forEach(t=>{const{ID:s,"BASE-ID":e,"URI-REPLACEMENT":a}=t;r.some(t=>t.pathwayId===s)||(t=this.getLevelsForPathway(e).map(t=>{var e=k({},t),t=(e.details=void 0,e.url=Ls(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),new w(t.attrs)),r=(t["PATHWAY-ID"]=s,t.AUDIO&&t.AUDIO+"_clone_"+s),i=t.SUBTITLES&&t.SUBTITLES+"_clone_"+s,t=(r&&(n[t.AUDIO]=r,t.AUDIO=r),i&&(o[t.SUBTITLES]=i,t.SUBTITLES=i),e.attrs=t,new Le(e));return $e(t,"audio",r),$e(t,"text",i),t}),r.push(...t),Ss(this.audioTracks,n,a,s),Ss(this.subtitleTracks,o,a,s))})}}loadSteeringManifest(t){var e=this.hls.config,r=e.loader;let o;this.loader&&this.loader.destroy(),this.loader=new r(e);try{o=new self.URL(t)}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if("data:"!==o.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+t)}var r={responseType:"json",url:o.href},t=e.steeringManifestLoadPolicy.default,i=t.errorRetry||t.timeoutRetry||{},t={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},i={onSuccess:(t,e,r,i)=>{this.log(`Loaded steering manifest: "${o}"`);var s=t.data;if(1!==s.VERSION)this.log(`Steering VERSION ${s.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=s.TTL;var{"RELOAD-URI":s,"PATHWAY-CLONES":a,"PATHWAY-PRIORITY":n}=s;if(s)try{this.uri=new self.URL(s,o).href}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+s)}this.scheduleRefresh(this.uri||r.url),a&&this.clonePathways(a),n&&this.updatePathwayPriority(n)}},onError:(t,e,r,i)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)this.enabled=!1,this.log(`Steering manifest ${e.url} no longer available`);else{var s=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,s);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&parseFloat(e)}this.log(`Steering manifest ${e.url} rate limited`)}}},onTimeout:(t,e,r)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(r,t,i)}scheduleRefresh(t,e=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}});function Ps(r){return r&&"object"==typeof r?Array.isArray(r)?r.map(Ps):Object.keys(r).reduce((t,e)=>(t[e]=Ps(r[e]),t),{}):r}class xs{static get version(){return"1.4.12"}static isSupported(){return!!(e=Kt())&&(t=Sr(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove,!!e)&&!!t;var t,e}static get Events(){return I}static get ErrorTypes(){return _}static get ErrorDetails(){return C}static get DefaultConfig(){return xs.defaultConfig||Cs}static set DefaultConfig(t){xs.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new yi,this._autoLevelCapping=void 0,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;var e=t.debug||!1;if(self.console&&!0===e||"object"==typeof e){W(e,"debug","log","info","warn","error");try{Y.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(e){Y=V}}else Y=V;var r=this.config=function(t,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==o.liveMaxLatencyDurationCount&&(void 0===o.liveSyncDurationCount||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==o.liveMaxLatencyDuration&&(void 0===o.liveSyncDuration||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const l=Ps(t),e=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(i=>{const s=("level"===i?"playlist":i)+"LoadPolicy",a=void 0===o[s],n=[];e.forEach(t=>{var e=i+"Loading"+t,r=o[e];if(void 0!==r&&a){n.push(e);const i=l[s].default;switch(o[s]={default:i},t){case"TimeOut":i.maxLoadTimeMs=r,i.maxTimeToFirstByteMs=r;break;case"MaxRetry":i.errorRetry.maxNumRetry=r,i.timeoutRetry.maxNumRetry=r;break;case"RetryDelay":i.errorRetry.retryDelayMs=r,i.timeoutRetry.retryDelayMs=r;break;case"MaxRetryTimeout":i.errorRetry.maxRetryDelayMs=r,i.timeoutRetry.maxRetryDelayMs=r}}}),n.length&&P.warn(`hls.js config: "${n.join('", "')}" setting(s) are deprecated, use "${s}": `+JSON.stringify(o[s]))}),m(m({},l),o)}(xs.DefaultConfig,t),{abrController:i,bufferController:t,capLevelController:s,errorController:a,fpsController:n}=(this.userConfig=t,this._autoLevelCapping=-1,r.progressive&&((i=(t=r).loader)!==Ds&&i!==As?(P.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),1}catch(t){}}()&&(t.loader=Ds,t.progressive=!0,t.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))),r),a=new a(this),o=this.abrController=new i(this),t=this.bufferController=new t(this),s=this.capLevelController=new s(this),n=new n(this),l=new le(this),h=new ye(this),d=r.contentSteeringController,d=d?new d(this):null,u=this.levelController=new Ge(this,d),c=new je(this),f=new tr(this.config),g=this.streamController=new Li(this,c,f),l=(s.setStreamController(g),n.setStreamController(g),[l,u,g]),u=(d&&l.splice(1,0,d),this.networkControllers=l,[o,t,s,n,h,c]),g=(this.audioTrackController=this.createController(r.audioTrackController,l),r.audioStreamController),d=(g&&l.push(new g(this,c,f)),this.subtitleTrackController=this.createController(r.subtitleTrackController,l),r.subtitleStreamController),o=(d&&l.push(new d(this,c,f)),this.createController(r.timelineController,u),f.emeController=this.emeController=this.createController(r.emeController,u),this.cmcdController=this.createController(r.cmcdController,u),this.latencyController=this.createController(Te,u),this.coreComponents=u,l.push(a),a.onErrorOut);"function"==typeof o&&this.on(I.ERROR,o,a)}createController(t,e){return t?(t=new t(this),e&&e.push(t),t):null}on(t,e,r=this){this._emitter.on(t,e,r)}once(t,e,r=this){this._emitter.once(t,e,r)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,r=this,i){this._emitter.off(t,e,r,i)}listeners(t){return this._emitter.listeners(t)}emit(t,e,r){return this._emitter.emit(t,e,r)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){P.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(I.ERROR,{type:_.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){P.log("destroy"),this.trigger(I.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){P.log("attachMedia"),this._media=t,this.trigger(I.MEDIA_ATTACHING,{media:t})}detachMedia(){P.log("detachMedia"),this.trigger(I.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=$.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});P.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(I.MANIFEST_LOADING,{url:t})}startLoad(e=-1){P.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){P.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){P.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){P.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){P.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){P.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){P.log("set loadLevel:"+t),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){P.log("set firstLevel:"+t),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){P.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){t=!!t;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimate():NaN}get ttfbEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(P.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){-1<Ee.indexOf(t)&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){var{levels:e,config:{minAutoBitrate:r}}=this;if(e){var i=e.length;for(let t=0;t<i;t++)if(e[t].maxBitrate>=r)return t}return 0}get maxAutoLevel(){var{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){var t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}xs.defaultConfig=void 0},660:function(t,e,r){"use strict";var i="function"==typeof Symbol&&Symbol.for,s=i?Symbol.for("react.element"):60103,a=i?Symbol.for("react.portal"):60106,n=i?Symbol.for("react.fragment"):60107,o=i?Symbol.for("react.strict_mode"):60108,l=i?Symbol.for("react.profiler"):60114,h=i?Symbol.for("react.provider"):60109,d=i?Symbol.for("react.context"):60110,u=i?Symbol.for("react.async_mode"):60111,c=i?Symbol.for("react.concurrent_mode"):60111,f=i?Symbol.for("react.forward_ref"):60112,g=i?Symbol.for("react.suspense"):60113,m=i?Symbol.for("react.suspense_list"):60120,p=i?Symbol.for("react.memo"):60115,v=i?Symbol.for("react.lazy"):60116,y=i?Symbol.for("react.block"):60121,T=i?Symbol.for("react.fundamental"):60117,E=i?Symbol.for("react.responder"):60118,S=i?Symbol.for("react.scope"):60119;function L(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case s:switch(t=t.type){case u:case c:case n:case l:case o:case g:return t;default:switch(t=t&&t.$$typeof){case d:case f:case v:case p:case h:return t;default:return e}}case a:return e}}}function b(t){return L(t)===c}e.AsyncMode=u,e.ConcurrentMode=c,e.ContextConsumer=d,e.ContextProvider=h,e.Element=s,e.ForwardRef=f,e.Fragment=n,e.Lazy=v,e.Memo=p,e.Portal=a,e.Profiler=l,e.StrictMode=o,e.Suspense=g,e.isAsyncMode=function(t){return b(t)||L(t)===u},e.isConcurrentMode=b,e.isContextConsumer=function(t){return L(t)===d},e.isContextProvider=function(t){return L(t)===h},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===s},e.isForwardRef=function(t){return L(t)===f},e.isFragment=function(t){return L(t)===n},e.isLazy=function(t){return L(t)===v},e.isMemo=function(t){return L(t)===p},e.isPortal=function(t){return L(t)===a},e.isProfiler=function(t){return L(t)===l},e.isStrictMode=function(t){return L(t)===o},e.isSuspense=function(t){return L(t)===g},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===n||t===c||t===l||t===o||t===g||t===m||"object"==typeof t&&null!==t&&(t.$$typeof===v||t.$$typeof===p||t.$$typeof===h||t.$$typeof===d||t.$$typeof===f||t.$$typeof===T||t.$$typeof===E||t.$$typeof===S||t.$$typeof===y)},e.typeOf=L},685:function(t,e,r){var i=r(93),s=r(605),a=r(89),n=r(317),r=i?i.prototype:void 0,o=r?r.toString:void 0;t.exports=function t(e){var r;return"string"==typeof e?e:a(e)?s(e,t)+"":n(e)?o?o.call(e):"":"0"==(r=e+"")&&1/e==-1/0?"-0":r}},707:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return T.default}}),e.default=void 0;var m=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=l(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(1)),i=o(r(0)),s=o(r(29)),p=o(r(43)),v=r(586),y=r(611),a=r(574),T=o(r(709)),n=o(r(612));function o(t){return t&&t.__esModule?t:{default:t}}function l(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(l=function(t){return t?r:e})(t))}function E(){return(E=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r,i=arguments[e];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}function h(t,e,r){var i;i=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(e),(e="symbol"==typeof i?i:String(i))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}class d extends m.Component{static getDerivedStateFromProps(t,e){t=t.position,e=e.prevPropsPosition;return!t||e&&t.x===e.x&&t.y===e.y?null:((0,n.default)("Draggable: getDerivedStateFromProps %j",{position:t,prevPropsPosition:e}),{x:t.x,y:t.y,prevPropsPosition:{...t}})}constructor(t){super(t),h(this,"onDragStart",(t,e)=>{if((0,n.default)("Draggable: onDragStart: %j",e),!1===this.props.onStart(t,(0,y.createDraggableData)(this,e)))return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(t,e)=>{if(!this.state.dragging)return!1;(0,n.default)("Draggable: onDrag: %j",e);var r=(0,y.createDraggableData)(this,e),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:t,y:e}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;var[s,a]=(0,y.getBoundPosition)(this,i.x,i.y);i.x=s,i.y=a,i.slackX=this.state.slackX+(t-i.x),i.slackY=this.state.slackY+(e-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(t,r))return!1;this.setState(i)}),h(this,"onDragStop",(t,e)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(t,(0,y.createDraggableData)(this,e)))return!1;(0,n.default)("Draggable: onDragStop: %j",e);var r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:t,y:e}=this.props.position;r.x=t,r.y=e}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:(t.position||t.defaultPosition).x,y:(t.position||t.defaultPosition).y,prevPropsPosition:{...t.position},slackX:0,slackY:0,isElementSVG:!1},!t.position||t.onDrag||t.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var t;return null!=(t=null==(t=this.props)||null==(t=t.nodeRef)?void 0:t.current)?t:s.default.findDOMNode(this)}render(){const{axis:t,bounds:e,children:r,defaultPosition:i,defaultClassName:s,defaultClassNameDragging:a,defaultClassNameDragged:n,position:o,positionOffset:l,scale:h,...d}=this.props;let u={},c=null;var f=!Boolean(o)||this.state.dragging,g=o||i,f={x:((0,y.canDragX)(this)&&f?this.state:g).x,y:((0,y.canDragY)(this)&&f?this.state:g).y},g=(this.state.isElementSVG?c=(0,v.createSVGTransform)(f,l):u=(0,v.createCSSTransform)(f,l),(0,p.default)(r.props.className||"",s,{[a]:this.state.dragging,[n]:this.state.dragged}));return m.createElement(T.default,E({},d,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),m.cloneElement(m.Children.only(r),{className:g,style:{...r.props.style,...u},transform:c}))}}h(e.default=d,"displayName","Draggable"),h(d,"propTypes",{...T.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),h(d,"defaultProps",{...T.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},708:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.browserPrefixToKey=a,e.browserPrefixToStyle=function(t,e){return e?"-".concat(e.toLowerCase(),"-").concat(t):t},e.default=void 0,e.getPrefix=s;const i=["Moz","Webkit","O","ms"];function s(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"!=typeof window){var r=null==(t=window.document)||null==(t=t.documentElement)?void 0:t.style;if(r&&!(e in r))for(let t=0;t<i.length;t++)if(a(e,i[t])in r)return i[t]}return""}function a(t,e){return e?"".concat(e).concat(function(e){let r="",i=!0;for(let t=0;t<e.length;t++)i?(r+=e[t].toUpperCase(),i=!1):"-"===e[t]?i=!0:r+=e[t];return r}(t)):t}e.default=s()},709:function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var e=u(void 0);if(e&&e.has(t))return e.get(t);var r,i,s={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&((i=a?Object.getOwnPropertyDescriptor(t,r):null)&&(i.get||i.set)?Object.defineProperty(s,r,i):s[r]=t[r]);return s.default=t,e&&e.set(t,s),s}(r(1)),s=d(r(0)),a=d(r(29)),n=r(586),o=r(611),l=r(574),h=d(r(612));function d(t){return t&&t.__esModule?t:{default:t}}function u(t){var e,r;return"function"!=typeof WeakMap?null:(e=new WeakMap,r=new WeakMap,(u=function(t){return t?r:e})(t))}function c(t,e,r){var i;i=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return String(t);e=e.call(t,"string");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(e),(e="symbol"==typeof i?i:String(i))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}const f={start:"touchstart",move:"touchmove",stop:"touchend"},g={start:"mousedown",move:"mousemove",stop:"mouseup"};let m=g;class p extends i.Component{constructor(){super(...arguments),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(this,"handleDragStart",t=>{if(this.props.onMouseDown(t),!this.props.allowAnyClick&&"number"==typeof t.button&&0!==t.button)return!1;var e=this.findDOMNode();if(!e||!e.ownerDocument||!e.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");var r,i,s=e["ownerDocument"];this.props.disabled||!(t.target instanceof s.defaultView.Node)||this.props.handle&&!(0,n.matchesSelectorAndParentsTo)(t.target,this.props.handle,e)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(t.target,this.props.cancel,e)||("touchstart"===t.type&&t.preventDefault(),e=(0,n.getTouchIdentifier)(t),this.touchIdentifier=e,null!=(e=(0,o.getControlPosition)(t,e,this))&&({x:e,y:r}=e,i=(0,o.createCoreData)(this,e,r),(0,h.default)("DraggableCore: handleDragStart: %j",i),(0,h.default)("calling",this.props.onStart),!1!==this.props.onStart(t,i))&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(s),this.dragging=!0,this.lastX=e,this.lastY=r,(0,n.addEvent)(s,m.move,this.handleDrag),(0,n.addEvent)(s,m.stop,this.handleDragStop)))}),c(this,"handleDrag",r=>{const i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:t,y:e}=i;if(Array.isArray(this.props.grid)){var s=t-this.lastX,a=e-this.lastY;if([s,a]=(0,o.snapToGrid)(this.props.grid,s,a),!s&&!a)return;t=this.lastX+s,e=this.lastY+a}s=(0,o.createCoreData)(this,t,e);if((0,h.default)("DraggableCore: handleDrag: %j",s),!1!==this.props.onDrag(r,s)&&!1!==this.mounted)this.lastX=t,this.lastY=e;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(r){const i=document.createEvent("MouseEvents");i.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(i)}}}),c(this,"handleDragStop",r=>{if(this.dragging){var i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:t,y:e}=i;Array.isArray(this.props.grid)&&(i=t-this.lastX||0,s=e-this.lastY||0,[i,s]=(0,o.snapToGrid)(this.props.grid,i,s),t=this.lastX+i,e=this.lastY+s);i=(0,o.createCoreData)(this,t,e);if(!1===this.props.onStop(r,i)||!1===this.mounted)return!1;var s=this.findDOMNode();s&&this.props.enableUserSelectHack&&(0,n.removeUserSelectStyles)(s.ownerDocument),(0,h.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,s&&((0,h.default)("DraggableCore: Removing handlers"),(0,n.removeEvent)(s.ownerDocument,m.move,this.handleDrag),(0,n.removeEvent)(s.ownerDocument,m.stop,this.handleDragStop))}}}),c(this,"onMouseDown",t=>(m=g,this.handleDragStart(t))),c(this,"onMouseUp",t=>(m=g,this.handleDragStop(t))),c(this,"onTouchStart",t=>(m=f,this.handleDragStart(t))),c(this,"onTouchEnd",t=>(m=f,this.handleDragStop(t)))}componentDidMount(){this.mounted=!0;var t=this.findDOMNode();t&&(0,n.addEvent)(t,f.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;var t,e=this.findDOMNode();e&&(t=e["ownerDocument"],(0,n.removeEvent)(t,g.move,this.handleDrag),(0,n.removeEvent)(t,f.move,this.handleDrag),(0,n.removeEvent)(t,g.stop,this.handleDragStop),(0,n.removeEvent)(t,f.stop,this.handleDragStop),(0,n.removeEvent)(e,f.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack)&&(0,n.removeUserSelectStyles)(t)}findDOMNode(){var t;return null!=(t=this.props)&&t.nodeRef?null==(t=this.props)||null==(t=t.nodeRef)?void 0:t.current:a.default.findDOMNode(this)}render(){return i.cloneElement(i.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}c(e.default=p,"displayName","DraggableCore"),c(p,"propTypes",{allowAnyClick:s.default.bool,children:s.default.node.isRequired,disabled:s.default.bool,enableUserSelectHack:s.default.bool,offsetParent:function(t,e){if(t[e]&&1!==t[e].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:s.default.arrayOf(s.default.number),handle:s.default.string,cancel:s.default.string,nodeRef:s.default.object,onStart:s.default.func,onDrag:s.default.func,onStop:s.default.func,onMouseDown:s.default.func,scale:s.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},747:function(t,e,r){!function(t,f){!function(r){"use strict";var i,e,s,t,a,n,o,l,h,d;function u(t){delete n[t]}function c(t){if(o)setTimeout(c,0,t);else{var e=n[t];if(e){o=!0;try{var r=e.callback,i=e.args;switch(i.length){case 0:r();break;case 1:r(i[0]);break;case 2:r(i[0],i[1]);break;case 3:r(i[0],i[1],i[2]);break;default:r.apply(void 0,i)}}finally{u(t),o=!1}}}}r.setImmediate||(a=1,o=!(n={}),l=r.document,h=(h=Object.getPrototypeOf&&Object.getPrototypeOf(r))&&h.setTimeout?h:r,d="[object process]"==={}.toString.call(r.process)?function(t){f.nextTick(function(){c(t)})}:function(){var t,e;if(r.postMessage&&!r.importScripts)return t=!0,e=r.onmessage,r.onmessage=function(){t=!1},r.postMessage("","*"),r.onmessage=e,t}()?(s="setImmediate$"+Math.random()+"$",t=function(t){t.source===r&&"string"==typeof t.data&&0===t.data.indexOf(s)&&c(+t.data.slice(s.length))},r.addEventListener?r.addEventListener("message",t,!1):r.attachEvent("onmessage",t),function(t){r.postMessage(s+t,"*")}):r.MessageChannel?((e=new MessageChannel).port1.onmessage=function(t){c(t.data)},function(t){e.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,function(t){var e=l.createElement("script");e.onreadystatechange=function(){c(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):function(t){setTimeout(c,0,t)},h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r<e.length;r++)e[r]=arguments[r+1];return n[a]={callback:t,args:e},d(a),a++},h.clearImmediate=u)}("undefined"==typeof self?void 0===t?this:t:self)}.call(this,r(30),r(316))},750:function(t,e,r){"use strict";e.byteLength=function(t){var t=d(t),e=t[0],t=t[1];return 3*(e+t)/4-t},e.toByteArray=function(t){for(var e,r=d(t),i=r[0],r=r[1],s=new h(3*(i+r)/4-r),a=0,n=0<r?i-4:i,o=0;o<n;o+=4)e=l[t.charCodeAt(o)]<<18|l[t.charCodeAt(o+1)]<<12|l[t.charCodeAt(o+2)]<<6|l[t.charCodeAt(o+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===r&&(e=l[t.charCodeAt(o)]<<2|l[t.charCodeAt(o+1)]>>4,s[a++]=255&e),1===r&&(e=l[t.charCodeAt(o)]<<10|l[t.charCodeAt(o+1)]<<4|l[t.charCodeAt(o+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],a=0,n=r-i;a<n;a+=16383)s.push(function(t,e,r){for(var i,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(o[(i=i)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}(t,a,n<a+16383?n:a+16383));return 1==i?(e=t[r-1],s.push(o[e>>2]+o[e<<4&63]+"==")):2==i&&(e=(t[r-2]<<8)+t[r-1],s.push(o[e>>10]+o[e>>4&63]+o[e<<2&63]+"=")),s.join("")};for(var o=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=i.length;s<a;++s)o[s]=i[s],l[i.charCodeAt(s)]=s;function d(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");t=t.indexOf("=");return[t=-1===t?e:t,t===e?0:4-t%4]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},751:function(t,e){e.read=function(t,e,r,i,s){var a,n,o=8*s-i-1,l=(1<<o)-1,h=l>>1,d=-7,u=r?s-1:0,c=r?-1:1,s=t[e+u];for(u+=c,a=s&(1<<-d)-1,s>>=-d,d+=o;0<d;a=256*a+t[e+u],u+=c,d-=8);for(n=a&(1<<-d)-1,a>>=-d,d+=i;0<d;n=256*n+t[e+u],u+=c,d-=8);if(0===a)a=1-h;else{if(a===l)return n?NaN:1/0*(s?-1:1);n+=Math.pow(2,i),a-=h}return(s?-1:1)*n*Math.pow(2,a-i)},e.write=function(t,e,r,i,s,a){var n,o,l=8*a-s-1,h=(1<<l)-1,d=h>>1,u=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,c=i?0:a-1,f=i?1:-1,a=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,n=h):(n=Math.floor(Math.log(e)/Math.LN2),e*(i=Math.pow(2,-n))<1&&(n--,i*=2),2<=(e+=1<=n+d?u/i:u*Math.pow(2,1-d))*i&&(n++,i/=2),h<=n+d?(o=0,n=h):1<=n+d?(o=(e*i-1)*Math.pow(2,s),n+=d):(o=e*Math.pow(2,d-1)*Math.pow(2,s),n=0));8<=s;t[r+c]=255&o,c+=f,o/=256,s-=8);for(n=n<<s|o,l+=s;0<l;t[r+c]=255&n,c+=f,n/=256,l-=8);t[r+c-f]|=128*a}},752:function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}}}]);
|