goindex-theme-r/dist/js/chunk-2d1e3ca3.6f34a72d.js
2020-08-29 19:09:42 +08:00

84 lines
244 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d1e3ca3"],{2415:function(e,t,r){"use strict";r.r(t);var i=r("ba56"),a=r.n(i);function n(e){var t=e.src,r=e.autoplay,i=void 0!==r&&r,n=e.media,s=e.callback,o=void 0===s?function(){return{}}:s;if(a.a.isSupported()){var l=new a.a;l.loadSource(t),l.attachMedia(n),l.on(a.a.Events.ERROR,(function(e,t){if(t.fatal)switch(t.type){case a.a.ErrorTypes.NETWORK_ERROR:l.startLoad();break;default:l.destroy();break}})),i&&l.on(a.a.Events.MANIFEST_PARSED,(function(){n.play()})),o(l)}}t["default"]=n},ba56:function(e,t,r){"undefined"!==typeof window&&function(t,r){e.exports=r()}(0,(function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(i,a,function(t){return e[t]}.bind(null,a));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
/*!*********************************************!*\
!*** ./node_modules/eventemitter3/index.js ***!
\*********************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,a="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,i,n){if("function"!==typeof r)throw new TypeError("The listener must be a function");var o=new s(r,i||e,n),l=a?a+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function l(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function u(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(a=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=a?a+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,n=r.length,s=new Array(n);i<n;i++)s[i]=r[i].fn;return s},u.prototype.listenerCount=function(e){var t=a?a+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,i,n,s){var o=a?a+e:e;if(!this._events[o])return!1;var l,u,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,i),!0;case 5:return d.fn.call(d.context,t,r,i,n),!0;case 6:return d.fn.call(d.context,t,r,i,n,s),!0}for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var f,h=d.length;for(u=0;u<h;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),c){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,r);break;case 4:d[u].fn.call(d[u].context,t,r,i);break;default:if(!l)for(f=1,l=new Array(c-1);f<c;f++)l[f-1]=arguments[f];d[u].fn.apply(d[u].context,l)}}return!0},u.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,i){var n=a?a+e:e;if(!this._events[n])return this;if(!t)return l(this,n),this;var s=this._events[n];if(s.fn)s.fn!==t||i&&!s.once||r&&s.context!==r||l(this,n);else{for(var o=0,u=[],d=s.length;o<d;o++)(s[o].fn!==t||i&&!s[o].once||r&&s[o].context!==r)&&u.push(s[o]);u.length?this._events[n]=1===u.length?u[0]:u:l(this,n)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&l(this,t)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=a,u.EventEmitter=u,e.exports=u},"./node_modules/url-toolkit/src/url-toolkit.js":
/*!*****************************************************!*\
!*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
\*****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){(function(t){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),t=t.trim(),!t){if(!r.alwaysNormalize)return e;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=s.normalizePath(n.path),s.buildURLFromParts(n)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var d=o.path,c=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(c)}else u.path=o.path,n.params||(u.params=o.params,n.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path),s.buildURLFromParts(u)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){e=e.split("").reverse().join("").replace(a,"");while(e.length!==(e=e.replace(n,"")).length);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=s})()},"./node_modules/webworkify-webpack/index.js":
/*!**************************************************!*\
!*** ./node_modules/webworkify-webpack/index.js ***!
\**************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(e,t,r){function i(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var i=r(r.s=ENTRY_MODULE);return i.default||i}var a="[\\.|\\-|\\+|\\w|/|@]+",n="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+a+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e){return!isNaN(1*e)}function l(e,t,i){var l={};l[i]=[];var u=t.toString(),d=u.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return l;var c,f=d[1],h=new RegExp("(\\\\n|\\W)"+s(f)+n,"g");while(c=h.exec(u))"dll-reference"!==c[3]&&l[i].push(c[3]);h=new RegExp("\\("+s(f)+'\\("(dll-reference\\s('+a+'))"\\)\\)'+n,"g");while(c=h.exec(u))e[c[2]]||(l[i].push(c[1]),e[c[2]]=r(c[1]).m),l[c[2]]=l[c[2]]||[],l[c[2]].push(c[4]);for(var g=Object.keys(l),p=0;p<g.length;p++)for(var v=0;v<l[g[p]].length;v++)o(l[g[p]][v])&&(l[g[p]][v]=1*l[g[p]][v]);return l}function u(e){var t=Object.keys(e);return t.reduce((function(t,r){return t||e[r].length>0}),!1)}function d(e,t){var r={main:[t]},i={main:[]},a={main:{}};while(u(r))for(var n=Object.keys(r),s=0;s<n.length;s++){var o=n[s],d=r[o],c=d.pop();if(a[o]=a[o]||{},!a[o][c]&&e[o][c]){a[o][c]=!0,i[o]=i[o]||[],i[o].push(c);for(var f=l(e,e[o][c],o),h=Object.keys(f),g=0;g<h.length;g++)r[h[g]]=r[h[g]]||[],r[h[g]]=r[h[g]].concat(f[h[g]])}}return i}e.exports=function(e,t){t=t||{};var a={main:r.m},n=t.all?{main:Object.keys(a.main)}:d(a,e),s="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){var t=0;while(n[e][t])t++;n[e].push(t),a[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+"var "+e+" = ("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n[e].map((function(t){return JSON.stringify(t)+": "+a[e][t].toString()})).join(",")+"});\n"})),s=s+"new (("+i.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+n.main.map((function(e){return JSON.stringify(e)+": "+a.main[e].toString()})).join(",")+"}))(self);";var o=new window.Blob([s],{type:"text/javascript"});if(t.bare)return o;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,u=l.createObjectURL(o),c=new window.Worker(u);return c.objectURL=u,c}},"./src/crypt/decrypter.js":
/*!********************************************!*\
!*** ./src/crypt/decrypter.js + 3 modules ***!
\********************************************/
/*! exports provided: default */
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.ts */function(e,t,r){"use strict";r.r(t);var i=function(){function e(e,t){this.subtle=e,this.aesIV=t}var t=e.prototype;return t.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}(),a=function(){function e(e,t){this.subtle=e,this.key=t}var t=e.prototype;return t.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}(),n=a;function s(e){var t=e.byteLength,r=t&&new DataView(e).getUint8(t-1);return r?e.slice(0,t-r):e}var o=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],c=o[3],f=new Uint32Array(256),h=0,g=0,p=0;for(p=0;p<256;p++)f[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var v=g^g<<1^g<<2^g<<3^g<<4;v=v>>>8^255&v^99,e[h]=v,t[v]=h;var m=f[h],y=f[m],E=f[y],T=257*f[v]^16843008*v;i[h]=T<<24|T>>>8,a[h]=T<<16|T>>>16,n[h]=T<<8|T>>>24,s[h]=T,T=16843009*E^65537*y^257*m^16843008*h,l[v]=T<<24|T>>>8,u[v]=T<<16|T>>>16,d[v]=T<<8|T>>>24,c[v]=T,h?(h=m^f[f[f[E^m]]],g^=f[f[g]]):h=g=1}},t.expandKey=function(e){var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;while(i<t.length&&r)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n,s,o,l,u=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(u),c=this.invKeySchedule=new Uint32Array(u),f=this.sBox,h=this.rcon,g=this.invSubMix,p=g[0],v=g[1],m=g[2],y=g[3];for(n=0;n<u;n++)n<a?o=d[n]=t[n]:(l=o,n%a===0?(l=l<<8|l>>>24,l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=h[n/a|0]<<24):a>6&&n%a===4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),d[n]=o=(d[n-a]^l)>>>0);for(s=0;s<u;s++)n=u-s,l=3&s?d[n]:d[n-4],c[s]=s<4||n<=4?l:p[f[l>>>24]]^v[f[l>>>16&255]]^m[f[l>>>8&255]]^y[f[255&l]],c[s]=c[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r,i){var a,n,o,l,u,d,c,f,h,g,p,v,m,y,E=this.keySize+6,T=this.invKeySchedule,S=this.invSBox,b=this.invSubMix,_=b[0],A=b[1],R=b[2],D=b[3],L=this.uint8ArrayToUint32Array_(r),w=L[0],k=L[1],I=L[2],O=L[3],C=new Int32Array(e),P=new Int32Array(C.length),x=this.networkToHostOrderSwap;while(t<C.length){for(h=x(C[t]),g=x(C[t+1]),p=x(C[t+2]),v=x(C[t+3]),u=h^T[0],d=v^T[1],c=p^T[2],f=g^T[3],m=4,y=1;y<E;y++)a=_[u>>>24]^A[d>>16&255]^R[c>>8&255]^D[255&f]^T[m],n=_[d>>>24]^A[c>>16&255]^R[f>>8&255]^D[255&u]^T[m+1],o=_[c>>>24]^A[f>>16&255]^R[u>>8&255]^D[255&d]^T[m+2],l=_[f>>>24]^A[u>>16&255]^R[d>>8&255]^D[255&c]^T[m+3],u=a,d=n,c=o,f=l,m+=4;a=S[u>>>24]<<24^S[d>>16&255]<<16^S[c>>8&255]<<8^S[255&f]^T[m],n=S[d>>>24]<<24^S[c>>16&255]<<16^S[f>>8&255]<<8^S[255&u]^T[m+1],o=S[c>>>24]<<24^S[f>>16&255]<<16^S[u>>8&255]<<8^S[255&d]^T[m+2],l=S[f>>>24]<<24^S[u>>16&255]<<16^S[d>>8&255]<<8^S[255&c]^T[m+3],m+=3,P[t]=x(a^w),P[t+1]=x(l^k),P[t+2]=x(o^I),P[t+3]=x(n^O),w=h,k=g,I=p,O=v,t+=4}return i?s(P.buffer):P.buffer},t.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},e}(),l=o,u=r("./src/errors.ts"),d=r("./src/utils/logger.js"),c=r("./src/events.js"),f=r("./src/utils/get-self-scope.js"),h=Object(f["getSelfScope"])(),g=function(){function e(e,t,r){var i=void 0===r?{}:r,a=i.removePKCS7Padding,n=void 0===a||a;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=n,n)try{var s=h.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(o){}this.disableWebCrypto=!this.subtle}var t=e.prototype;return t.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.decrypt=function(e,t,r,a){var s=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(d["logger"].log("JS AES decrypt"),this.logEnabled=!1);var o=this.decryptor;o||(this.decryptor=o=new l),o.expandKey(t),a(o.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(d["logger"].log("WebCrypto AES decrypt"),this.logEnabled=!1);var u=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new n(u,t)),this.fastAesKey.expandKey().then((function(n){var o=new i(u,r);o.decrypt(e,n).catch((function(i){s.onWebCryptoError(i,e,t,r,a)})).then((function(e){a(e)}))})).catch((function(i){s.onWebCryptoError(i,e,t,r,a)}))}},t.onWebCryptoError=function(e,t,r,i,a){this.config.enableSoftwareAES?(d["logger"].log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,i,a)):(d["logger"].error("decrypting error : "+e.message),this.observer.trigger(c["default"].ERROR,{type:u["ErrorTypes"].MEDIA_ERROR,details:u["ErrorDetails"].FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))},t.destroy=function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)},e}();t["default"]=g},"./src/demux/demuxer-inline.js":
/*!**************************************************!*\
!*** ./src/demux/demuxer-inline.js + 12 modules ***!
\**************************************************/
/*! exports provided: default */
/*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number-isFinite.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/hls.ts */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/hls.ts */function(e,t,r){"use strict";r.r(t);var i=r("./src/events.js"),a=r("./src/errors.ts"),n=r("./src/crypt/decrypter.js"),s=r("./src/polyfills/number-isFinite.js"),o=r("./src/utils/logger.js"),l=r("./src/utils/get-self-scope.js");function u(e,t,r,n){var s,l,u,d,c,f=navigator.userAgent.toLowerCase(),h=n,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(s=1+((192&t[r+2])>>>6),l=(60&t[r+2])>>>2,!(l>g.length-1))return d=(1&t[r+2])<<2,d|=(192&t[r+3])>>>6,o["logger"].log("manifest codec:"+n+",ADTS data:type:"+s+",sampleingIndex:"+l+"["+g[l]+"Hz],channelConfig:"+d),/firefox/i.test(f)?l>=6?(s=5,c=new Array(4),u=l-3):(s=2,c=new Array(2),u=l):-1!==f.indexOf("android")?(s=2,c=new Array(2),u=l):(s=5,c=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&l>=6?u=l-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(l>=6&&1===d||/vivaldi/i.test(f))||!n&&1===d)&&(s=2,c=new Array(2)),u=l)),c[0]=s<<3,c[0]|=(14&l)>>1,c[1]|=(1&l)<<7,c[1]|=d<<3,5===s&&(c[1]|=(14&u)>>1,c[2]=(1&u)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:g[l],channelCount:d,codec:"mp4a.40."+s,manifestCodec:h};e.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+l})}function d(e,t){return 255===e[t]&&240===(246&e[t+1])}function c(e,t){return 1&e[t+1]?7:9}function f(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function h(e,t){return!!(t+1<e.length&&d(e,t))}function g(e,t){if(h(e,t)){var r=c(e,t),i=r;t+5<e.length&&(i=f(e,t));var a=t+i;if(a===e.length||a+1<e.length&&d(e,a))return!0}return!1}function p(e,t,r,i,a){if(!e.samplerate){var n=u(t,r,i,a);e.config=n.config,e.samplerate=n.samplerate,e.channelCount=n.channelCount,e.codec=n.codec,e.manifestCodec=n.manifestCodec,o["logger"].log("parsed codec:"+e.codec+",rate:"+n.samplerate+",nb channel:"+n.channelCount)}}function v(e){return 9216e4/e}function m(e,t,r,i,a){var n,s,o,l=e.length;if(n=c(e,t),s=f(e,t),s-=n,s>0&&t+n+s<=l)return o=r+i*a,{headerLength:n,frameLength:s,stamp:o}}function y(e,t,r,i,a){var n=v(e.samplerate),s=m(t,r,i,a,n);if(s){var o=s.stamp,l=s.headerLength,u=s.frameLength,d={unit:t.subarray(r+l,r+l+u),pts:o,dts:o};return e.samples.push(d),{sample:d,length:u+l}}}var E=r("./src/demux/id3.js"),T=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=E["default"].getID3Data(e,0)||[],r=t.length,i=e.length;r<i;r++)if(g(e,r))return o["logger"].log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,r,i){var a=this._audioTrack,n=E["default"].getID3Data(e,0)||[],l=E["default"].getTimeStamp(n),u=Object(s["isFiniteNumber"])(l)?90*l:9e4*t,d=0,c=u,f=e.length,g=n.length,v=[{pts:c,dts:c,data:n}];while(g<f-1)if(h(e,g)&&g+5<f){p(a,this.observer,e,g,a.manifestCodec);var m=y(a,e,g,u,d);if(!m){o["logger"].log("Unable to parse AAC frame");break}g+=m.length,c=m.sample.pts,d++}else E["default"].isHeader(e,g)?(n=E["default"].getID3Data(e,g),v.push({pts:c,dts:c,data:n}),g+=n.length):g++;this.remuxer.remux(a,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),S=T,b=r("./src/demux/mp4demuxer.js"),_={BitratesMap:[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],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(e,t,r,i,a){if(!(r+24>t.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var s=9e4*n.samplesPerFrame/n.sampleRate,o=i+a*s,l={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(l),{sample:l,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!==r&&0!==a&&15!==a&&3!==n){var o=3===r?3-i:3===i?3:4,l=1e3*_.BitratesMap[14*o+a-1],u=3===r?0:2===r?1:2,d=_.SamplingRateMap[3*u+n],c=e[t+3]>>6===3?1:2,f=_.SamplesCoefficients[r][i],h=_.BytesInSlot[i],g=8*f*h,p=parseInt(f*l/d+s,10)*h;return{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:g}}},isHeaderPattern:function(e,t){return 255===e[t]&&224===(224&e[t+1])&&0!==(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=4,i=this.parseHeader(e,t),a=r;i&&i.frameLength&&(a=i.frameLength);var n=t+a;if(n===e.length||n+1<e.length&&this.isHeaderPattern(e,n))return!0}return!1}},A=_,R=function(){function e(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&o["logger"].error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){var t,r,i=8,a=8;for(t=0;t<e;t++)0!==a&&(r=this.readEG(),a=(i+r+256)%256),i=0===a?i:a},t.readSPS=function(){var e,t,r,i,a,n,s,o=0,l=0,u=0,d=0,c=this.readUByte.bind(this),f=this.readBits.bind(this),h=this.readUEG.bind(this),g=this.readBoolean.bind(this),p=this.skipBits.bind(this),v=this.skipEG.bind(this),m=this.skipUEG.bind(this),y=this.skipScalingList.bind(this);if(c(),e=c(),f(5),p(3),c(),m(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var E=h();if(3===E&&p(1),m(),m(),p(1),g())for(n=3!==E?8:12,s=0;s<n;s++)g()&&y(s<6?16:64)}m();var T=h();if(0===T)h();else if(1===T)for(p(1),v(),v(),t=h(),s=0;s<t;s++)v();m(),p(1),r=h(),i=h(),a=f(1),0===a&&p(1),p(1),g()&&(o=h(),l=h(),u=h(),d=h());var S=[1,1];if(g()&&g()){var b=c();switch(b){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[c()<<8|c(),c()<<8|c()];break}}return{width:Math.ceil(16*(r+1)-2*o-2*l),height:(2-a)*(i+1)*16-(a?2:4)*(u+d),pixelRatio:S}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),D=R,L=function(){function e(e,t,r,i){this.decryptdata=r,this.discardEPB=i,this.decrypter=new n["default"](e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)},t.decryptAacSample=function(e,t,r,i){var a=e[t].unit,n=a.subarray(16,a.length-a.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),o=this;this.decryptBuffer(s,(function(n){n=new Uint8Array(n),a.set(n,16),i||o.decryptAacSamples(e,t+1,r)}))},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<=e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(e,t,r,i,a,n){var s=this.discardEPB(a.data),o=this.getAvcEncryptedData(s),l=this;this.decryptBuffer(o.buffer,(function(o){a.data=l.getAvcDecryptedUnit(s,o),n||l.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;;r++){if(r>=a.length)break;var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,n,s),!s)return}}}},e}(),w=L,k={video:1,audio:2,id3:3,text:4},I=function(){function e(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new w(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0)&&(r&&o["logger"].warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)},e._syncOffset=function(e){var t=Math.min(1e3,e.length-564),r=0;while(r<t){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:k[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}},t.resetInitSegment=function(t,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",a),this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3",a),this._txtTrack=e.createTrack("text",a),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=r,this.videoCodec=i,this._duration=a},t.resetTimeStamp=function(){},t.append=function(t,r,n,s){var l,u,d,c,f,h,g=t.length,p=!1;this.contiguous=n;var v=this.pmtParsed,m=this._avcTrack,y=this._audioTrack,E=this._id3Track,T=m.pid,S=y.pid,b=E.pid,_=this._pmtId,A=m.pesData,R=y.pesData,D=E.pesData,L=this._parsePAT,w=this._parsePMT,k=this._parsePES,I=this._parseAVCPES.bind(this),O=this._parseAACPES.bind(this),C=this._parseMPEGPES.bind(this),P=this._parseID3PES.bind(this),x=e._syncOffset(t);for(g-=(g+x)%188,l=x;l<g;l+=188)if(71===t[l]){if(u=!!(64&t[l+1]),d=((31&t[l+1])<<8)+t[l+2],c=(48&t[l+3])>>4,c>1){if(f=l+5+t[l+4],f===l+188)continue}else f=l+4;switch(d){case T:u&&(A&&(h=k(A))&&I(h,!1),A={data:[],size:0}),A&&(A.data.push(t.subarray(f,l+188)),A.size+=l+188-f);break;case S:u&&(R&&(h=k(R))&&(y.isAAC?O(h):C(h)),R={data:[],size:0}),R&&(R.data.push(t.subarray(f,l+188)),R.size+=l+188-f);break;case b:u&&(D&&(h=k(D))&&P(h),D={data:[],size:0}),D&&(D.data.push(t.subarray(f,l+188)),D.size+=l+188-f);break;case 0:u&&(f+=t[f]+1),_=this._pmtId=L(t,f);break;case _:u&&(f+=t[f]+1);var F=w(t,f,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);T=F.avc,T>0&&(m.pid=T),S=F.audio,S>0&&(y.pid=S,y.isAAC=F.isAAC),b=F.id3,b>0&&(E.pid=b),p&&!v&&(o["logger"].log("reparse from beginning"),p=!1,l=x-188),v=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=!0;break}}else this.observer.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});A&&(h=k(A))?(I(h,!0),m.pesData=null):m.pesData=A,R&&(h=k(R))?(y.isAAC?O(h):C(h),y.pesData=null):(R&&R.size&&o["logger"].log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=R),D&&(h=k(D))?(P(h),E.pesData=null):E.pesData=D,null==this.sampleAes?this.remuxer.remux(y,m,E,this._txtTrack,r,n,s):this.decryptAndRemux(y,m,E,this._txtTrack,r,n,s)},t.decryptAndRemux=function(e,t,r,i,a,n,s){if(e.samples&&e.isAAC){var o=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){o.decryptAndRemuxAvc(e,t,r,i,a,n,s)}))}else this.decryptAndRemuxAvc(e,t,r,i,a,n,s)},t.decryptAndRemuxAvc=function(e,t,r,i,a,n,s){if(t.samples){var o=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){o.remuxer.remux(e,t,r,i,a,n,s)}))}else this.remuxer.remux(e,t,r,i,a,n,s)},t.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._parsePMT=function(e,t,r,i){var a,n,s,l,u={audio:-1,avc:-1,id3:-1,isAAC:!0};a=(15&e[t+1])<<8|e[t+2],n=t+3+a-4,s=(15&e[t+10])<<8|e[t+11],t+=12+s;while(t<n){switch(l=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!i){o["logger"].log("unknown stream type:"+e[t]);break}case 15:-1===u.audio&&(u.audio=l);break;case 21:-1===u.id3&&(u.id3=l);break;case 219:if(!i){o["logger"].log("unknown stream type:"+e[t]);break}case 27:-1===u.avc&&(u.avc=l);break;case 3:case 4:r?-1===u.audio&&(u.audio=l,u.isAAC=!1):o["logger"].log("MPEG audio found, not supported in this browser for now");break;case 36:o["logger"].warn("HEVC stream type found, not supported for now");break;default:o["logger"].log("unknown stream type:"+e[t]);break}t+=5+((15&e[t+3])<<8|e[t+4])}return u},t._parsePES=function(e){var t,r,i,a,n,s,l,u,d,c=0,f=e.data;if(!e||0===e.size)return null;while(f[0].length<19&&f.length>1){var h=new Uint8Array(f[0].length+f[1].length);h.set(f[0]),h.set(f[1],f[0].length),f[0]=h,f.splice(1,1)}if(t=f[0],i=(t[0]<<16)+(t[1]<<8)+t[2],1===i){if(a=(t[4]<<8)+t[5],a&&a>e.size-6)return null;if(r=t[7],192&r&&(l=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,l>4294967295&&(l-=8589934592),64&r?(u=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,u>4294967295&&(u-=8589934592),l-u>54e5&&(o["logger"].warn(Math.round((l-u)/9e4)+"s delta between PTS and DTS, align them"),l=u)):u=l),n=t[8],d=n+9,e.size<=d)return null;e.size-=d,s=new Uint8Array(e.size);for(var g=0,p=f.length;g<p;g++){t=f[g];var v=t.byteLength;if(d){if(d>v){d-=v;continue}t=t.subarray(d),v-=d,d=0}s.set(t,c),c+=v}return a&&(a-=n+3),{data:s,pts:l,dts:u,len:a}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;if(isNaN(e.pts)){if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&o["logger"].log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var r,i,a,n=this,s=this._avcTrack,o=this._parseAVCNALu(e.data),l=!1,u=this.avcSample,d=!1,c=this.pushAccesUnit.bind(this),f=function(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}};e.data=null,u&&o.length&&!s.audFound&&(c(u,s),u=this.avcSample=f(!1,e.pts,e.dts,"")),o.forEach((function(t){switch(t.type){case 1:i=!0,u||(u=n.avcSample=f(!0,e.pts,e.dts,"")),l&&(u.debug+="NDR "),u.frame=!0;var o=t.data;if(d&&o.length>4){var h=new D(o).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(u.key=!0)}break;case 5:i=!0,u||(u=n.avcSample=f(!0,e.pts,e.dts,"")),l&&(u.debug+="IDR "),u.key=!0,u.frame=!0;break;case 6:i=!0,l&&u&&(u.debug+="SEI "),r=new D(n.discardEPB(t.data)),r.readUByte();var g=0,p=0,v=!1,m=0;while(!v&&r.bytesAvailable>1){g=0;do{m=r.readUByte(),g+=m}while(255===m);p=0;do{m=r.readUByte(),p+=m}while(255===m);if(4===g&&0!==r.bytesAvailable){v=!0;var y=r.readUByte();if(181===y){var T=r.readUShort();if(49===T){var S=r.readUInt();if(1195456820===S){var b=r.readUByte();if(3===b){var _=r.readUByte(),A=r.readUByte(),R=31&_,L=[_,A];for(a=0;a<R;a++)L.push(r.readUByte()),L.push(r.readUByte()),L.push(r.readUByte());n._insertSampleInOrder(n._txtTrack.samples,{type:3,pts:e.pts,bytes:L})}}}}}else if(5===g&&0!==r.bytesAvailable){if(v=!0,p>16){var w=[];for(a=0;a<16;a++)w.push(r.readUByte().toString(16)),3!==a&&5!==a&&7!==a&&9!==a||w.push("-");var k=p-16,I=new Uint8Array(k);for(a=0;a<k;a++)I[a]=r.readUByte();n._insertSampleInOrder(n._txtTrack.samples,{pts:e.pts,payloadType:g,uuid:w.join(""),userDataBytes:I,userData:Object(E["utf8ArrayToStr"])(I.buffer)})}}else if(p<r.bytesAvailable)for(a=0;a<p;a++)r.readUByte()}break;case 7:if(i=!0,d=!0,l&&u&&(u.debug+="SPS "),!s.sps){r=new D(t.data);var O=r.readSPS();s.width=O.width,s.height=O.height,s.pixelRatio=O.pixelRatio,s.sps=[t.data],s.duration=n._duration;var C=t.data.subarray(1,4),P="avc1.";for(a=0;a<3;a++){var x=C[a].toString(16);x.length<2&&(x="0"+x),P+=x}s.codec=P}break;case 8:i=!0,l&&u&&(u.debug+="PPS "),s.pps||(s.pps=[t.data]);break;case 9:i=!1,s.audFound=!0,u&&c(u,s),u=n.avcSample=f(!1,e.pts,e.dts,l?"AUD ":"");break;case 12:i=!1;break;default:i=!1,u&&(u.debug+="unknown NAL "+t.type+" ");break}if(u&&i){var F=u.units;F.push(t)}})),t&&u&&(c(u,s),this.avcSample=null)},t._insertSampleInOrder=function(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts<e[i].pts){e.splice(i,0,t);break}}else e.push(t)},t._getLastNalUnit=function(){var e,t=this.avcSample;if(!t||0===t.units.length){var r=this._avcTrack,i=r.samples;t=i[i.length-1]}if(t){var a=t.units;e=a[a.length-1]}return e},t._parseAVCNALu=function(e){var t,r,i,a,n,s=0,o=e.byteLength,l=this._avcTrack,u=l.naluState||0,d=u,c=[],f=-1;-1===u&&(f=0,n=31&e[0],u=0,s=1);while(s<o)if(t=e[s++],u)if(1!==u)if(t)if(1===t){if(f>=0)i={data:e.subarray(f,s-u-1),type:n},c.push(i);else{var h=this._getLastNalUnit();if(h&&(d&&s<=4-d&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-d)),r=s-u-1,r>0)){var g=new Uint8Array(h.data.byteLength+r);g.set(h.data,0),g.set(e.subarray(0,r),h.data.byteLength),h.data=g}}s<o?(a=31&e[s],f=s,n=a,u=0):u=-1}else u=0;else u=3;else u=t?0:2;else u=t?0:1;if(f>=0&&u>=0&&(i={data:e.subarray(f,o),type:n,state:u},c.push(i)),0===c.length){var p=this._getLastNalUnit();if(p){var v=new Uint8Array(p.data.byteLength+e.byteLength);v.set(p.data,0),v.set(e,p.data.byteLength),p.data=v}}return l.naluState=u,c},t.discardEPB=function(e){var t,r,i=e.byteLength,a=[],n=1;while(n<i-2)0===e[n]&&0===e[n+1]&&3===e[n+2]?(a.push(n+2),n+=2):n++;if(0===a.length)return e;t=i-a.length,r=new Uint8Array(t);var s=0;for(n=0;n<t;s++,n++)s===a[0]&&(s++,a.shift()),r[n]=e[s];return r},t._parseAACPES=function(e){var t,r,n,s,l,u,d,c=this._audioTrack,f=e.data,g=e.pts,m=0,E=this.aacOverFlow,T=this.aacLastPTS;if(E){var S=new Uint8Array(E.byteLength+f.byteLength);S.set(E,0),S.set(f,E.byteLength),f=S}for(n=m,l=f.length;n<l-1;n++)if(h(f,n))break;if(n&&(n<l-1?(u="AAC PES did not start with ADTS header,offset:"+n,d=!1):(u="no ADTS header found in AAC PES",d=!0),o["logger"].warn("parsing error:"+u),this.observer.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].FRAG_PARSING_ERROR,fatal:d,reason:u}),d))return;if(p(c,this.observer,f,n,this.audioCodec),r=0,t=v(c.samplerate),E&&T){var b=T+t;Math.abs(b-g)>1&&(o["logger"].log("AAC: align PTS for overlapping frames by "+Math.round((b-g)/90)),g=b)}while(n<l){if(h(f,n)){if(n+5<l){var _=y(c,f,n,g,r);if(_){n+=_.length,s=_.sample.pts,r++;continue}}break}n++}E=n<l?f.subarray(n,l):null,this.aacOverFlow=E,this.aacLastPTS=s},t._parseMPEGPES=function(e){var t=e.data,r=t.length,i=0,a=0,n=e.pts;while(a<r)if(A.isHeader(t,a)){var s=A.appendFrame(this._audioTrack,t,a,n,i);if(!s)break;a+=s.length,i++}else a++},t._parseID3PES=function(e){this._id3Track.samples.push(e)},e}(),O=I,C=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){var t,r,i=E["default"].getID3Data(e,0);if(i&&void 0!==E["default"].getTimeStamp(i))for(t=i.length,r=Math.min(e.length-1,t+100);t<r;t++)if(A.probe(e,t))return o["logger"].log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,r,i){var a=E["default"].getID3Data(e,0),n=E["default"].getTimeStamp(a),s=n?90*n:9e4*t,o=a.length,l=e.length,u=0,d=0,c=this._audioTrack,f=[{pts:s,dts:s,data:a}];while(o<l)if(A.isHeader(e,o)){var h=A.appendFrame(c,e,o,s,u);if(!h)break;o+=h.length,d=h.sample.pts,u++}else E["default"].isHeader(e,o)?(a=E["default"].getID3Data(e,o),f.push({pts:d,dts:d,data:a}),o+=a.length):o++;this.remuxer.remux(c,{samples:[]},{samples:f,inputTimeScale:9e4},{samples:[]},t,r,i)},t.destroy=function(){},e}(),P=C,x=function(){function e(){}return e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return null},e}(),F=x,M=Math.pow(2,32)-1,N=function(){function e(){}return e.init=function(){var t;for(t in e.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:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))},e.box=function(e){var t,r=Array.prototype.slice.call(arguments,1),i=8,a=r.length,n=a;while(a--)i+=r[a].byteLength;for(t=new Uint8Array(i),t[0]=i>>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),a=0,i=8;a<n;a++)t.set(r[a],i),i+=r[a].byteLength;return t},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(M+1)),a=Math.floor(r%(M+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){var r=t.length,i=[];while(r--)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){var r=t.length,i=[];while(r--)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(M+1)),a=Math.floor(r%(M+1)),n=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,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,n)},e.sdtp=function(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)r=a[i].flags,n[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,n)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,a,n=[],s=[];for(r=0;r<t.sps.length;r++)i=t.sps[r],a=i.byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)i=t.pps[r],a=i.byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],c=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.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,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.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,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,a=t.width,n=t.height,s=Math.floor(i/(M+1)),o=Math.floor(i%(M+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,n=Math.floor(r/(M+1)),s=Math.floor(r%(M+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,a,n,s,o,l,u=t.samples||[],d=u.length,c=12+16*d,f=new Uint8Array(c);for(r+=8+c,f.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=u[i],n=a.duration,s=a.size,o=a.flags,l=a.cts,f.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r,i=e.moov(t);return r=new Uint8Array(e.FTYP.byteLength+i.byteLength),r.set(e.FTYP),r.set(i,e.FTYP.byteLength),r},e}(),U=N,B=9e4;function G(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var a=e*t*r;return i?Math.round(a):a}function K(e,t){return void 0===t&&(t=!1),G(e,1e3,1/B,t)}function j(e,t){return void 0===t&&(t=1),G(e,B,1/t)}var H,V=j(10),W=j(.2),Y=function(){function e(e,t,r,i){this.observer=e,this.config=t,this.typeSupported=r;var a=navigator.userAgent;this.isSafari=i&&i.indexOf("Apple")>-1&&a&&!a.match("CriOS"),this.ISGenerated=!1}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},t.resetInitSegment=function(){this.ISGenerated=!1},t.remux=function(e,t,r,a,n,s,l){if(this.ISGenerated||this.generateIS(e,t,n),this.ISGenerated){var u=e.samples.length,d=t.samples.length,c=n,f=n;if(u&&d){var h=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;c+=Math.max(0,h),f+=Math.max(0,-h)}if(u){e.timescale||(o["logger"].warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,n));var g,p=this.remuxAudio(e,c,s,l);if(d)p&&(g=p.endPTS-p.startPTS),t.timescale||(o["logger"].warn("regenerate InitSegment as video detected"),this.generateIS(e,t,n)),this.remuxVideo(t,f,s,g,l)}else if(d){var v=this.remuxVideo(t,f,s,0,l);v&&e.codec&&this.remuxEmptyAudio(e,c,s,v)}}r.samples.length&&this.remuxID3(r,n),a.samples.length&&this.remuxText(a,n),this.observer.trigger(i["default"].FRAG_PARSED)},t.generateIS=function(e,t,r){var n,s,l=this.observer,u=e.samples,d=t.samples,c=this.typeSupported,f="audio/mp4",h={},g={tracks:h},p=void 0===this._initPTS;if(p&&(n=s=1/0),e.config&&u.length&&(e.timescale=e.samplerate,o["logger"].log("audio sampling rate : "+e.samplerate),e.isAAC||(c.mpeg?(f="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),h.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&c.mpeg?new Uint8Array:U.initSegment([e]),metadata:{channelCount:e.channelCount}},p&&(n=s=u[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&d.length){var v=t.inputTimeScale;t.timescale=v,h.video={container:"video/mp4",codec:t.codec,initSegment:U.initSegment([t]),metadata:{width:t.width,height:t.height}},p&&(n=Math.min(n,d[0].pts-v*r),s=Math.min(s,d[0].dts-v*r),this.observer.trigger(i["default"].INIT_PTS_FOUND,{initPTS:n}))}Object.keys(h).length?(l.trigger(i["default"].FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,p&&(this._initPTS=n,this._initDTS=s)):l.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,n,s){var l,u,d,c,f,h,g,p=8,v=e.timescale,m=e.samples,y=[],E=m.length,T=this._PTSNormalize,S=this._initPTS,b=this.nextAvcDts,_=this.isSafari;if(0!==E){_&&(r|=m.length&&b&&(s&&Math.abs(t-b/v)<.1||Math.abs(m[0].pts-b-S)<v/5)),r||(b=t*v),m.forEach((function(e){e.pts=T(e.pts-S,b),e.dts=T(e.dts-S,b)})),m.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id}));var A=m.reduce((function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-1*W)}),0);if(A<0){o["logger"].warn("PTS < DTS detected in video samples, shifting DTS by "+K(A,!0)+" ms to overcome this issue");for(var R=0;R<m.length;R++)m[R].dts+=A}var D=m[0];f=Math.max(D.dts,0),c=Math.max(D.pts,0);var L=f-b;r&&L&&(L>1?o["logger"].log("AVC: "+K(L,!0)+" ms hole between fragments detected,filling it"):L<-1&&o["logger"].log("AVC: "+K(-L,!0)+" ms overlapping between fragments detected"),f=b,m[0].dts=f,c=Math.max(c-L,b),m[0].pts=c,o["logger"].log("Video: PTS/DTS adjusted: "+K(c,!0)+"/"+K(f,!0)+", delta: "+K(L,!0)+" ms")),D=m[m.length-1],g=Math.max(D.dts,0),h=Math.max(D.pts,0,g),_&&(l=Math.round((g-f)/(m.length-1)));for(var w=0,k=0,I=0;I<E;I++){for(var O=m[I],C=O.units,P=C.length,x=0,F=0;F<P;F++)x+=C[F].data.length;k+=x,w+=P,O.length=x,O.dts=_?f+I*l:Math.max(O.dts,f),O.pts=Math.max(O.pts,O.dts)}var M=k+4*w+8;try{u=new Uint8Array(M)}catch(ne){return void this.observer.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MUX_ERROR,details:a["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:!1,bytes:M,reason:"fail allocating video mdat "+M})}var N=new DataView(u.buffer);N.setUint32(0,M),u.set(U.types.mdat,4);for(var B=0;B<E;B++){for(var G=m[B],j=G.units,H=0,V=void 0,Y=0,q=j.length;Y<q;Y++){var z=j[Y],X=z.data,Q=z.data.byteLength;N.setUint32(p,Q),p+=4,u.set(X,p),p+=Q,H+=4+Q}if(_)V=Math.max(0,l*Math.round((G.pts-G.dts)/l));else{if(B<E-1)l=m[B+1].dts-G.dts;else{var J=this.config,$=G.dts-m[B>0?B-1:B].dts;if(J.stretchShortVideoTrack){var Z=J.maxBufferHole,ee=Math.floor(Z*v),te=(n?c+n*v:this.nextAudioPts)-G.pts;te>ee?(l=te-$,l<0&&(l=$),o["logger"].log("It is approximately "+K(te,!1)+" ms to the next segment; using duration "+K(l,!1)+" ms for the last video frame.")):l=$}else l=$}V=Math.round(G.pts-G.dts)}y.push({size:H,duration:l,cts:V,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=g+l;var re=e.dropped;if(e.nbNalu=0,e.dropped=0,y.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ie=y[0].flags;ie.dependsOn=2,ie.isNonSync=0}e.samples=y,d=U.moof(e.sequenceNumber++,f,e),e.samples=[];var ae={data1:d,data2:u,startPTS:c/v,endPTS:(h+l)/v,startDTS:f/v,endDTS:this.nextAvcDts/v,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:re};return this.observer.trigger(i["default"].FRAG_PARSING_DATA,ae),ae}},t.remuxAudio=function(e,t,r,n){var s,l,u,d,c,f,h=e.inputTimeScale,g=e.timescale,p=h/g,v=e.isAAC?1024:1152,m=v*p,y=this._PTSNormalize,E=this._initPTS,T=!e.isAAC&&this.typeSupported.mpeg,S=T?0:8,b=e.samples,_=[],A=this.nextAudioPts;if(r|=b.length&&A&&(n&&Math.abs(t-A/h)<.1||Math.abs(b[0].pts-A-E)<20*m),b.forEach((function(e){e.pts=e.dts=y(e.pts-E,t*h)})),b=b.filter((function(e){return e.pts>=0})),0!==b.length){if(r||(A=n?t*h:b[0].pts),e.isAAC)for(var R=this.config.maxAudioFramesDrift,D=0,L=A;D<b.length;){var w,k=b[D],I=k.pts;if(w=I-L,w<=-R*m)o["logger"].warn("Dropping 1 audio frame @ "+K(L,!0)+" ms due to "+K(w,!0)+" ms overlap."),b.splice(D,1);else if(w>=R*m&&w<V&&L){var O=Math.round(w/m);o["logger"].warn("Injecting "+O+" audio frames @ "+K(L,!0)+" ms due to "+K(L,!0)+" ms gap.");for(var C=0;C<O;C++){var P=Math.max(L,0);l=F.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),l||(o["logger"].log("Unable to get silent frame for given audio codec; duplicating last frame instead."),l=k.unit.subarray()),b.splice(D,0,{unit:l,pts:P,dts:P}),L+=m,D++}k.pts=k.dts=L,L+=m,D++}else Math.abs(w),k.pts=k.dts=L,L+=m,D++}var x=b.length,M=0;while(x--)M+=b[x].unit.byteLength;for(var N=0,B=b.length;N<B;N++){var G=b[N],j=G.unit,H=G.pts;if(void 0!==f)s.duration=Math.round((H-f)/p);else{var W=H-A,Y=0;if(r&&e.isAAC&&W){if(W>0&&W<V)Y=Math.round((H-A)/m),o["logger"].log(K(W,!0)+" ms hole between AAC samples detected,filling it"),Y>0&&(l=F.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),l||(l=j.subarray()),M+=Y*l.length);else if(W<-12){o["logger"].log("drop overlapping AAC sample, expected/parsed/delta: "+K(A,!0)+" ms / "+K(H,!0)+" ms / "+K(-W,!0)+" ms"),M-=j.byteLength;continue}H=A}if(c=H,!(M>0))return;M+=S;try{u=new Uint8Array(M)}catch(ee){return void this.observer.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MUX_ERROR,details:a["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:!1,bytes:M,reason:"fail allocating audio mdat "+M})}if(!T){var q=new DataView(u.buffer);q.setUint32(0,M),u.set(U.types.mdat,4)}for(var z=0;z<Y;z++)l=F.getSilentFrame(e.manifestCodec||e.codec,e.channelCount),l||(o["logger"].log("Unable to get silent frame for given audio codec; duplicating this frame instead."),l=j.subarray()),u.set(l,S),S+=l.byteLength,s={size:l.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(s)}u.set(j,S);var X=j.byteLength;S+=X,s={size:X,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},_.push(s),f=H}var Q=0;if(x=_.length,x>=2&&(Q=_[x-2].duration,s.duration=Q),x){this.nextAudioPts=A=f+p*Q,e.samples=_,d=T?new Uint8Array:U.moof(e.sequenceNumber++,c/p,e),e.samples=[];var J=c/h,$=A/h,Z={data1:d,data2:u,startPTS:J,endPTS:$,startDTS:J,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:x};return this.observer.trigger(i["default"].FRAG_PARSING_DATA,Z),Z}return null}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,n=e.samplerate?e.samplerate:a,s=a/n,l=this.nextAudioPts,u=(void 0!==l?l:i.startDTS*a)+this._initDTS,d=i.endDTS*a+this._initDTS,c=1024,f=s*c,h=Math.ceil((d-u)/f),g=F.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(o["logger"].warn("remux empty Audio"),g){for(var p=[],v=0;v<h;v++){var m=u+v*f;p.push({unit:g,pts:m,dts:m})}e.samples=p,this.remuxAudio(e,t,r)}else o["logger"].trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")},t.remuxID3=function(e){var t,r=e.samples.length,a=e.inputTimeScale,n=this._initPTS,s=this._initDTS;if(r){for(var o=0;o<r;o++)t=e.samples[o],t.pts=(t.pts-n)/a,t.dts=(t.dts-s)/a;this.observer.trigger(i["default"].FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[]},t.remuxText=function(e){e.samples.sort((function(e,t){return e.pts-t.pts}));var t,r=e.samples.length,a=e.inputTimeScale,n=this._initPTS;if(r){for(var s=0;s<r;s++)t=e.samples[s],t.pts=(t.pts-n)/a;this.observer.trigger(i["default"].FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]},t._PTSNormalize=function(e,t){var r;if(void 0===t)return e;r=t<e?-8589934592:8589934592;while(Math.abs(e-t)>4294967296)e+=r;return e},e}(),q=Y,z=function(){function e(e){this.observer=e}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.remux=function(e,t,r,a,n,s,o,l){var u=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),u.trigger(i["default"].FRAG_PARSING_DATA,{data1:l,startPTS:n,startDTS:n,type:d,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(i["default"].FRAG_PARSED)},e}(),X=z,Q=Object(l["getSelfScope"])();try{H=Q.performance.now.bind(Q.performance)}catch($){o["logger"].debug("Unable to use Performance API on this environment"),H=Q.Date.now}var J=function(){function e(e,t,r,i){this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i}var t=e.prototype;return t.destroy=function(){var e=this.demuxer;e&&e.destroy()},t.push=function(e,t,r,a,s,o,l,u,d,c,f,h){var g=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var p=this.decrypter;null==p&&(p=this.decrypter=new n["default"](this.observer,this.config));var v=H();p.decrypt(e,t.key.buffer,t.iv.buffer,(function(e){var n=H();g.observer.trigger(i["default"].FRAG_DECRYPTED,{stats:{tstart:v,tdecrypt:n}}),g.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,s,o,l,u,d,c,f,h)}))}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,s,o,l,u,d,c,f,h)},t.pushDecrypted=function(e,t,r,n,s,o,l,u,d,c,f,h){var g=this.demuxer;if(!g||(l||u)&&!this.probe(e)){for(var p=this.observer,v=this.typeSupported,m=this.config,y=[{demux:O,remux:q},{demux:b["default"],remux:X},{demux:S,remux:q},{demux:P,remux:q}],E=0,T=y.length;E<T;E++){var _=y[E],A=_.demux.probe;if(A(e)){var R=this.remuxer=new _.remux(p,m,v,this.vendor);g=new _.demux(p,R,m,v),this.probe=A;break}}if(!g)return void p.trigger(i["default"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=g}var D=this.remuxer;(l||u)&&(g.resetInitSegment(r,n,s,c),D.resetInitSegment()),l&&(g.resetTimeStamp(h),D.resetTimeStamp(h)),"function"===typeof g.setDecryptData&&g.setDecryptData(t),g.append(e,o,d,f)},e}();t["default"]=J},"./src/demux/demuxer-worker.js":
/*!*************************************!*\
!*** ./src/demux/demuxer-worker.js ***!
\*************************************/
/*! exports provided: default */
/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./src/demux/demuxer.js (referenced with require.resolve) */function(e,t,r){"use strict";r.r(t);var i=r(/*! ../demux/demuxer-inline */"./src/demux/demuxer-inline.js"),a=r(/*! ../events */"./src/events.js"),n=r(/*! ../utils/logger */"./src/utils/logger.js"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),o=function(e){var t=new s["EventEmitter"];t.trigger=function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];t.emit.apply(t,[e,e].concat(i))},t.off=function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];t.removeListener.apply(t,[e].concat(i))};var r=function(t,r){e.postMessage({event:t,data:r})};e.addEventListener("message",(function(a){var s=a.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.demuxer=new i["default"](t,s.typeSupported,o,s.vendor),Object(n["enableLogs"])(o.debug),r("init",null);break;case"demux":e.demuxer.push(s.data,s.decryptdata,s.initSegment,s.audioCodec,s.videoCodec,s.timeOffset,s.discontinuity,s.trackSwitch,s.contiguous,s.duration,s.accurateTimeOffset,s.defaultInitPTS);break;default:break}})),t.on(a["default"].FRAG_DECRYPTED,r),t.on(a["default"].FRAG_PARSING_INIT_SEGMENT,r),t.on(a["default"].FRAG_PARSED,r),t.on(a["default"].ERROR,r),t.on(a["default"].FRAG_PARSING_METADATA,r),t.on(a["default"].FRAG_PARSING_USERDATA,r),t.on(a["default"].INIT_PTS_FOUND,r),t.on(a["default"].FRAG_PARSING_DATA,(function(t,r){var i=[],a={event:t,data:r};r.data1&&(a.data1=r.data1.buffer,i.push(r.data1.buffer),delete r.data1),r.data2&&(a.data2=r.data2.buffer,i.push(r.data2.buffer),delete r.data2),e.postMessage(a,i)}))};t["default"]=o},"./src/demux/id3.js":
/*!**************************!*\
!*** ./src/demux/id3.js ***!
\**************************/
/*! exports provided: default, utf8ArrayToStr */function(e,t,r){"use strict";r.r(t),r.d(t,"utf8ArrayToStr",(function(){return o}));var i,a=r(/*! ../utils/get-self-scope */"./src/utils/get-self-scope.js"),n=function(){function e(){}return e.isHeader=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},e.isFooter=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},e.getID3Data=function(t,r){var i=r,a=0;while(e.isHeader(t,r)){a+=10;var n=e._readSize(t,r+6);a+=n,e.isFooter(t,r+10)&&(a+=10),r+=a}if(a>0)return t.subarray(i,i+a)},e._readSize=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r},e.getTimeStamp=function(t){for(var r=e.getID3Frames(t),i=0;i<r.length;i++){var a=r[i];if(e.isTimeStampFrame(a))return e._readTimeStamp(a)}},e.isTimeStampFrame=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},e._getFrameData=function(t){var r=String.fromCharCode(t[0],t[1],t[2],t[3]),i=e._readSize(t,4),a=10;return{type:r,size:i,data:t.subarray(a,a+i)}},e.getID3Frames=function(t){var r=0,i=[];while(e.isHeader(t,r)){var a=e._readSize(t,r+6);r+=10;var n=r+a;while(r+8<n){var s=e._getFrameData(t.subarray(r)),o=e._decodeFrame(s);o&&i.push(o),r+=s.size+10}e.isFooter(t,r)&&(r+=10)}return i},e._decodeFrame=function(t){return"PRIV"===t.type?e._decodePrivFrame(t):"T"===t.type[0]?e._decodeTextFrame(t):"W"===t.type[0]?e._decodeURLFrame(t):void 0},e._readTimeStamp=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},e._decodePrivFrame=function(t){if(!(t.size<2)){var r=e._utf8ArrayToStr(t.data,!0),i=new Uint8Array(t.data.subarray(r.length+1));return{key:t.type,info:r,data:i.buffer}}},e._decodeTextFrame=function(t){if(!(t.size<2)){if("TXXX"===t.type){var r=1,i=e._utf8ArrayToStr(t.data.subarray(r),!0);r+=i.length+1;var a=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:i,data:a}}var n=e._utf8ArrayToStr(t.data.subarray(1));return{key:t.type,data:n}}},e._decodeURLFrame=function(t){if("WXXX"===t.type){if(t.size<2)return;var r=1,i=e._utf8ArrayToStr(t.data.subarray(r));r+=i.length+1;var a=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:i,data:a}}var n=e._utf8ArrayToStr(t.data);return{key:t.type,data:n}},e._utf8ArrayToStr=function(e,t){void 0===t&&(t=!1);var r=s();if(r){var i=r.decode(e);if(t){var a=i.indexOf("\0");return-1!==a?i.substring(0,a):i}return i.replace(/\0/g,"")}var n,o,l,u=e.length,d="",c=0;while(c<u){if(n=e[c++],0===n&&t)return d;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=e[c++],d+=String.fromCharCode((31&n)<<6|63&o);break;case 14:o=e[c++],l=e[c++],d+=String.fromCharCode((15&n)<<12|(63&o)<<6|(63&l)<<0);break;default:}}return d},e}();function s(){var e=Object(a["getSelfScope"])();return i||"undefined"===typeof e.TextDecoder||(i=new e.TextDecoder("utf-8")),i}var o=n._utf8ArrayToStr;t["default"]=n},"./src/demux/mp4demuxer.js":
/*!*********************************!*\
!*** ./src/demux/mp4demuxer.js ***!
\*********************************/
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger */"./src/utils/logger.js"),a=r(/*! ../events */"./src/events.js"),n=Math.pow(2,32)-1,s=function(){function e(e,t){this.observer=e,this.remuxer=t}var t=e.prototype;return t.resetTimeStamp=function(e){this.initPTS=e},t.resetInitSegment=function(t,r,i,n){if(t&&t.byteLength){var s=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==i&&(i="avc1.42e01e");var o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:n?t:null}:(s.audio&&(o.audio={container:"audio/mp4",codec:r,initSegment:n?t:null}),s.video&&(o.video={container:"video/mp4",codec:i,initSegment:n?t:null})),this.observer.trigger(a["default"].FRAG_PARSING_INIT_SEGMENT,{tracks:o})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)},e.probe=function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.bin2str=function(e){return String.fromCharCode.apply(null,e)},e.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r},e.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r},e.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},e.findBox=function(t,r){var i,a,n,s,o,l,u,d=[];if(t.data?(l=t.start,s=t.end,t=t.data):(l=0,s=t.byteLength),!r.length)return null;for(i=l;i<s;)a=e.readUint32(t,i),n=e.bin2str(t.subarray(i+4,i+8)),u=a>1?i+a:s,n===r[0]&&(1===r.length?d.push({data:t,start:i+8,end:u}):(o=e.findBox({data:t,start:i+8,end:u},r.slice(1)),o.length&&(d=d.concat(o)))),i=u;return d},e.parseSegmentIndex=function(t){var r,i=e.findBox(t,["moov"])[0],a=i?i.end:null,n=0,s=e.findBox(t,["sidx"]);if(!s||!s[0])return null;r=[],s=s[0];var o=s.data[0];n=0===o?8:16;var l=e.readUint32(s,n);n+=4;var u=0,d=0;n+=0===o?8:16,n+=2;var c=s.end+d,f=e.readUint16(s,n);n+=2;for(var h=0;h<f;h++){var g=n,p=e.readUint32(s,g);g+=4;var v=2147483647&p,m=(2147483648&p)>>>31;if(1===m)return void console.warn("SIDX has hierarchical references (not supported)");var y=e.readUint32(s,g);g+=4,r.push({referenceSize:v,subsegmentDuration:y,info:{duration:y/l,start:c,end:c+v-1}}),c+=v,g+=4,n=g}return{earliestPresentationTime:u,timescale:l,version:o,referencesCount:f,references:r,moovEndOffset:a}},e.parseInitSegment=function(t){var r=[],a=e.findBox(t,["moov","trak"]);return a.forEach((function(t){var a=e.findBox(t,["tkhd"])[0];if(a){var n=a.data[a.start],s=0===n?12:20,o=e.readUint32(a,s),l=e.findBox(t,["mdia","mdhd"])[0];if(l){n=l.data[l.start],s=0===n?12:20;var u=e.readUint32(l,s),d=e.findBox(t,["mdia","hdlr"])[0];if(d){var c=e.bin2str(d.data.subarray(d.start+8,d.start+12)),f={soun:"audio",vide:"video"}[c];if(f){var h=e.findBox(t,["mdia","minf","stbl","stsd"]);if(h.length){h=h[0];var g=e.bin2str(h.data.subarray(h.start+12,h.start+16));i["logger"].log("MP4Demuxer:"+f+":"+g+" found")}r[o]={timescale:u,type:f},r[f]={timescale:u,id:o}}}}}})),r},e.getStartDTS=function(t,r){var i,a,n;return i=e.findBox(r,["moof","traf"]),a=[].concat.apply([],i.map((function(r){return e.findBox(r,["tfhd"]).map((function(i){var a,n,s;return a=e.readUint32(i,4),n=t[a].timescale||9e4,s=e.findBox(r,["tfdt"]).map((function(t){var r,i;return r=t.data[t.start],i=e.readUint32(t,4),1===r&&(i*=Math.pow(2,32),i+=e.readUint32(t,8)),i}))[0],s/n}))}))),n=Math.min.apply(null,a),isFinite(n)?n:0},e.offsetStartDTS=function(t,r,i){e.findBox(r,["moof","traf"]).map((function(r){return e.findBox(r,["tfhd"]).map((function(a){var s=e.readUint32(a,4),o=t[s].timescale||9e4;e.findBox(r,["tfdt"]).map((function(t){var r=t.data[t.start],a=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,a-i*o);else{a*=Math.pow(2,32),a+=e.readUint32(t,8),a-=i*o,a=Math.max(a,0);var s=Math.floor(a/(n+1)),l=Math.floor(a%(n+1));e.writeUint32(t,4,s),e.writeUint32(t,8,l)}}))}))}))},t.append=function(t,r,i,n){var s=this.initData;s||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),s=this.initData);var o,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(s,t);this.initPTS=l=u-r,this.observer.trigger(a["default"].INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(s,t,l),o=e.getStartDTS(s,t),this.remuxer.remux(s.audio,s.video,null,null,o,i,n,t)},t.destroy=function(){},e}();t["default"]=s},"./src/errors.ts":
/*!***********************!*\
!*** ./src/errors.ts ***!
\***********************/
/*! exports provided: ErrorTypes, ErrorDetails */function(e,t,r){"use strict";var i,a;r.r(t),r.d(t,"ErrorTypes",(function(){return i})),r.d(t,"ErrorDetails",(function(){return a})),function(e){e["NETWORK_ERROR"]="networkError",e["MEDIA_ERROR"]="mediaError",e["KEY_SYSTEM_ERROR"]="keySystemError",e["MUX_ERROR"]="muxError",e["OTHER_ERROR"]="otherError"}(i||(i={})),function(e){e["KEY_SYSTEM_NO_KEYS"]="keySystemNoKeys",e["KEY_SYSTEM_NO_ACCESS"]="keySystemNoAccess",e["KEY_SYSTEM_NO_SESSION"]="keySystemNoSession",e["KEY_SYSTEM_LICENSE_REQUEST_FAILED"]="keySystemLicenseRequestFailed",e["KEY_SYSTEM_NO_INIT_DATA"]="keySystemNoInitData",e["MANIFEST_LOAD_ERROR"]="manifestLoadError",e["MANIFEST_LOAD_TIMEOUT"]="manifestLoadTimeOut",e["MANIFEST_PARSING_ERROR"]="manifestParsingError",e["MANIFEST_INCOMPATIBLE_CODECS_ERROR"]="manifestIncompatibleCodecsError",e["LEVEL_LOAD_ERROR"]="levelLoadError",e["LEVEL_LOAD_TIMEOUT"]="levelLoadTimeOut",e["LEVEL_SWITCH_ERROR"]="levelSwitchError",e["AUDIO_TRACK_LOAD_ERROR"]="audioTrackLoadError",e["AUDIO_TRACK_LOAD_TIMEOUT"]="audioTrackLoadTimeOut",e["FRAG_LOAD_ERROR"]="fragLoadError",e["FRAG_LOAD_TIMEOUT"]="fragLoadTimeOut",e["FRAG_DECRYPT_ERROR"]="fragDecryptError",e["FRAG_PARSING_ERROR"]="fragParsingError",e["REMUX_ALLOC_ERROR"]="remuxAllocError",e["KEY_LOAD_ERROR"]="keyLoadError",e["KEY_LOAD_TIMEOUT"]="keyLoadTimeOut",e["BUFFER_ADD_CODEC_ERROR"]="bufferAddCodecError",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"}(a||(a={}))},"./src/events.js":
/*!***********************!*\
!*** ./src/events.js ***!
\***********************/
/*! exports provided: default */function(e,t,r){"use strict";r.r(t);var i={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"};t["default"]=i},"./src/hls.ts":
/*!*********************************!*\
!*** ./src/hls.ts + 50 modules ***!
\*********************************/
/*! exports provided: default */
/*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/demuxer-inline.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number-isFinite.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/demux/demuxer-worker.js */
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/eventemitter3/index.js (<- Module is not an ECMAScript module) */
/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/url-toolkit/src/url-toolkit.js (<- Module is not an ECMAScript module) */function(e,t,r){"use strict";r.r(t);var i={};r.r(i),r.d(i,"newCue",(function(){return gr}));var a,n,s=r("./node_modules/url-toolkit/src/url-toolkit.js"),o=r("./src/errors.ts"),l=r("./src/polyfills/number-isFinite.js"),u=r("./src/events.js"),d=r("./src/utils/logger.js"),c={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},f=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.handledEvents=r,this.useGenericHandler=!0,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){},t.onHandlerDestroyed=function(){},t.isEventHandler=function(){return"object"===typeof this.handledEvents&&this.handledEvents.length&&"function"===typeof this.onEvent},t.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){if(c[e])throw new Error("Forbidden event-name: "+e);this.hls.on(e,this.onEvent)}),this)},t.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){this.hls.off(e,this.onEvent)}),this)},t.onEvent=function(e,t){this.onEventGeneric(e,t)},t.onEventGeneric=function(e,t){var r=function(e,t){var r="on"+e.replace("hls","");if("function"!==typeof this[r])throw new Error("Event "+e+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,t)};try{r.call(this,e,t).call()}catch(i){d["logger"].error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].OTHER_ERROR,details:o["ErrorDetails"].INTERNAL_EXCEPTION,fatal:!1,event:e,err:i})}},e}(),h=f;(function(e){e["MANIFEST"]="manifest",e["LEVEL"]="level",e["AUDIO_TRACK"]="audioTrack",e["SUBTITLE_TRACK"]="subtitleTrack"})(a||(a={})),function(e){e["MAIN"]="main",e["AUDIO"]="audio",e["SUBTITLE"]="subtitle"}(n||(n={}));var g=r("./src/demux/mp4demuxer.js");function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function v(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),e}var m,y=function(){function e(e,t){this._uri=null,this.baseuri=void 0,this.reluri=void 0,this.method=null,this.key=null,this.iv=null,this.baseuri=e,this.reluri=t}return v(e,[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=Object(s["buildAbsoluteURL"])(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),e}();function E(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function T(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}(function(e){e["AUDIO"]="audio",e["VIDEO"]="video"})(m||(m={}));var S=function(){function e(){var e;this._url=null,this._byteRange=null,this._decryptdata=null,this._elementaryStreams=(e={},e[m.AUDIO]=!1,e[m.VIDEO]=!1,e),this.deltaPTS=0,this.rawProgramDateTime=null,this.programDateTime=null,this.title=null,this.tagList=[],this.cc=void 0,this.type=void 0,this.relurl=void 0,this.baseurl=void 0,this.duration=void 0,this.start=void 0,this.sn=0,this.urlId=0,this.level=0,this.levelkey=void 0,this.loader=void 0}var t=e.prototype;return t.setByteRange=function(e,t){var r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},t.addElementaryStream=function(e){this._elementaryStreams[e]=!0},t.hasElementaryStream=function(e){return!0===this._elementaryStreams[e]},t.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},t.setDecryptDataFromLevelKey=function(e,t){var r=e;return e&&e.method&&e.uri&&!e.iv&&(r=new y(e.baseuri,e.reluri),r.method=e.method,r.iv=this.createInitializationVector(t)),r},T(e,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(s["buildAbsoluteURL"])(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!==typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&d["logger"].warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(l["isFiniteNumber"])(this.programDateTime))return null;var e=Object(l["isFiniteNumber"])(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}]),e}();function b(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _(e,t,r){return t&&b(e.prototype,t),r&&b(e,r),e}var A=function(){function e(e){this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=e,this.version=null}return _(e,[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Object(l["isFiniteNumber"])(this.fragments[0].programDateTime))}}]),e}(),R=/^(\d+)x(\d+)$/,D=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,L=function(){function e(t){for(var r in"string"===typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.enumeratedString=function(e){return this[e]},t.decimalResolution=function(e){var t=R.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};D.lastIndex=0;while(null!==(t=D.exec(e))){var i=t[2],a='"';0===i.indexOf(a)&&i.lastIndexOf(a)===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}(),w=L,k={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,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,drac:!0,dvav:!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}};function I(e,t){var r=k[t];return!!r&&!0===r[e.slice(0,4)]}function O(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var C=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,P=/#EXT-X-MEDIA:(.*)/g,x=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),F=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,M=/\.(mp4|m4s|m4v|m4a)$/i,N=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return s["buildAbsoluteURL"](t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,a=[];function n(e,t){["video","audio"].forEach((function(r){var i=e.filter((function(e){return I(e,r)}));if(i.length){var a=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=a.length>0?a[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}C.lastIndex=0;while(null!=(i=C.exec(t))){var s={},o=s.attrs=new w(i[1]);s.url=e.resolve(i[2],r);var l=o.decimalResolution("RESOLUTION");l&&(s.width=l.width,s.height=l.height),s.bitrate=o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),s.name=o.NAME,n([].concat((o.CODECS||"").split(/[ ,]+/)),s),s.videoCodec&&-1!==s.videoCodec.indexOf("avc1")&&(s.videoCodec=e.convertAVC1ToAVCOTI(s.videoCodec)),a.push(s)}return a},e.parseMasterPlaylistMedia=function(t,r,i,a){var n;void 0===a&&(a=[]);var s=[],o=0;P.lastIndex=0;while(null!==(n=P.exec(t))){var l=new w(n[1]);if(l.TYPE===i){var u={id:o++,groupId:l["GROUP-ID"],name:l.NAME||l.LANGUAGE,type:i,default:"YES"===l.DEFAULT,autoselect:"YES"===l.AUTOSELECT,forced:"YES"===l.FORCED,lang:l.LANGUAGE};if(l.URI&&(u.url=e.resolve(l.URI,r)),a.length){var d=e.findGroup(a,u.groupId);u.audioCodec=d?d.codec:a[0].codec}s.push(u)}}return s},e.parseLevelPlaylist=function(e,t,r,i,a){var n,s,o,u=0,c=0,f=new A(t),h=0,g=null,p=new S,v=null;x.lastIndex=0;while(null!==(n=x.exec(e))){var m=n[1];if(m){p.duration=parseFloat(m);var E=(" "+n[2]).slice(1);p.title=E||null,p.tagList.push(E?["INF",m,E]:["INF",m])}else if(n[3]){if(Object(l["isFiniteNumber"])(p.duration)){var T=u++;p.type=i,p.start=c,o&&(p.levelkey=o),p.sn=T,p.level=r,p.cc=h,p.urlId=a,p.baseurl=t,p.relurl=(" "+n[3]).slice(1),B(p,g),f.fragments.push(p),g=p,c+=p.duration,p=new S}}else if(n[4]){var b=(" "+n[4]).slice(1);g?p.setByteRange(b,g):p.setByteRange(b)}else if(n[5])p.rawProgramDateTime=(" "+n[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),null===v&&(v=f.fragments.length);else{if(n=n[0].match(F),!n){d["logger"].warn("No matches on slow regex match for level playlist!");continue}for(s=1;s<n.length;s++)if("undefined"!==typeof n[s])break;var _=(" "+n[s+1]).slice(1),R=(" "+n[s+2]).slice(1);switch(n[s]){case"#":p.tagList.push(R?[_,R]:[_]);break;case"PLAYLIST-TYPE":f.type=_.toUpperCase();break;case"MEDIA-SEQUENCE":u=f.startSN=parseInt(_);break;case"TARGETDURATION":f.targetduration=parseFloat(_);break;case"VERSION":f.version=parseInt(_);break;case"EXTM3U":break;case"ENDLIST":f.live=!1;break;case"DIS":h++,p.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":h=parseInt(_);break;case"KEY":var D=_,L=new w(D),k=L.enumeratedString("METHOD"),I=L.URI,O=L.hexadecimalInteger("IV");k&&(o=new y(t,I),I&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(k)>=0&&(o.method=k,o.key=null,o.iv=O));break;case"START":var C=new w(_),P=C.decimalFloatingPoint("TIME-OFFSET");Object(l["isFiniteNumber"])(P)&&(f.startTimeOffset=P);break;case"MAP":var N=new w(_);p.relurl=N.URI,N.BYTERANGE&&p.setByteRange(N.BYTERANGE),p.baseurl=t,p.level=r,p.type=i,p.sn="initSegment",f.initSegment=p,p=new S,p.rawProgramDateTime=f.initSegment.rawProgramDateTime;break;default:d["logger"].warn("line parsed but not handled: "+n);break}}}return p=g,p&&!p.relurl&&(f.fragments.pop(),c-=p.duration),f.totalduration=c,f.averagetargetduration=c/f.fragments.length,f.endSN=u-1,f.startCC=f.fragments[0]?f.fragments[0].cc:0,f.endCC=h,!f.initSegment&&f.fragments.length&&f.fragments.every((function(e){return M.test(e.relurl)}))&&(d["logger"].warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),p=new S,p.relurl=f.fragments[0].relurl,p.baseurl=t,p.level=r,p.type=i,p.sn="initSegment",f.initSegment=p,f.needSidxRanges=!0),v&&U(f.fragments,v),f},e}();function U(e,t){for(var r=e[t],i=t-1;i>=0;i--){var a=e[i];a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}function B(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(l["isFiniteNumber"])(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function G(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var K=window,j=K.performance,H=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MANIFEST_LOADING,u["default"].LEVEL_LOADING,u["default"].AUDIO_TRACK_LOADING,u["default"].SUBTITLE_TRACK_LOADING)||this,r.loaders={},r}G(t,e),t.canHaveQualityLevels=function(e){return e!==a.AUDIO_TRACK&&e!==a.SUBTITLE_TRACK},t.mapContextToLevelType=function(e){var t=e.type;switch(t){case a.AUDIO_TRACK:return n.AUDIO;case a.SUBTITLE_TRACK:return n.SUBTITLE;default:return n.MAIN}},t.getResponseUrl=function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r};var r=t.prototype;return r.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=r||i,n=new a(t);return e.loader=n,this.loaders[e.type]=n,n},r.getInternalLoader=function(e){return this.loaders[e.type]},r.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},r.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},r.destroy=function(){this.destroyInternalLoaders(),e.prototype.destroy.call(this)},r.onManifestLoading=function(e){this.load({url:e.url,type:a.MANIFEST,level:0,id:null,responseType:"text"})},r.onLevelLoading=function(e){this.load({url:e.url,type:a.LEVEL,level:e.level,id:e.id,responseType:"text"})},r.onAudioTrackLoading=function(e){this.load({url:e.url,type:a.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},r.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:a.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},r.load=function(e){var t=this.hls.config;d["logger"].debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id);var r,i,n,s,o=this.getInternalLoader(e);if(o){var l=o.context;if(l&&l.url===e.url)return d["logger"].trace("playlist request ongoing"),!1;d["logger"].warn("aborting previous loader for type: "+e.type),o.abort()}switch(e.type){case a.MANIFEST:r=t.manifestLoadingMaxRetry,i=t.manifestLoadingTimeOut,n=t.manifestLoadingRetryDelay,s=t.manifestLoadingMaxRetryTimeout;break;case a.LEVEL:r=0,s=0,n=0,i=t.levelLoadingTimeOut;break;default:r=t.levelLoadingMaxRetry,i=t.levelLoadingTimeOut,n=t.levelLoadingRetryDelay,s=t.levelLoadingMaxRetryTimeout;break}o=this.createInternalLoader(e);var u={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:s},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return d["logger"].debug("Calling internal loader delegate for URL: "+e.url),o.load(e,u,c),!0},r.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);if(this.resetInternalLoader(r.type),"string"!==typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var a=e.data;t.tload=j.now(),0===a.indexOf("#EXTM3U")?a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},r.loaderror=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!1,e)},r.loadtimeout=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!0)},r._handleMasterPlaylist=function(e,r,i,a){var n=this.hls,s=e.data,o=t.getResponseUrl(e,i),l=N.parseMasterPlaylist(s,o);if(l.length){var c=l.map((function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}})),f=N.parseMasterPlaylistMedia(s,o,"AUDIO",c),h=N.parseMasterPlaylistMedia(s,o,"SUBTITLES");if(f.length){var g=!1;f.forEach((function(e){e.url||(g=!0)})),!1===g&&l[0].audioCodec&&!l[0].attrs.AUDIO&&(d["logger"].log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1}))}n.trigger(u["default"].MANIFEST_LOADED,{levels:l,audioTracks:f,subtitles:h,url:o,stats:r,networkDetails:a})}else this._handleManifestParsingError(e,i,"no level found in manifest",a)},r._handleTrackOrLevelPlaylist=function(e,r,i,n){var s=this.hls,o=i.id,d=i.level,c=i.type,f=t.getResponseUrl(e,i),h=Object(l["isFiniteNumber"])(o)?o:0,g=Object(l["isFiniteNumber"])(d)?d:h,p=t.mapContextToLevelType(i),v=N.parseLevelPlaylist(e.data,f,g,p,h);if(v.tload=r.tload,c===a.MANIFEST){var m={url:f,details:v};s.trigger(u["default"].MANIFEST_LOADED,{levels:[m],audioTracks:[],url:f,stats:r,networkDetails:n})}if(r.tparsed=j.now(),v.needSidxRanges){var y=v.initSegment.url;this.load({url:y,isSidxRequest:!0,type:c,level:d,levelDetails:v,id:o,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else i.levelDetails=v,this._handlePlaylistLoaded(e,r,i,n)},r._handleSidxRequest=function(e,t){if("string"===typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r=g["default"].parseSegmentIndex(new Uint8Array(e.data));if(r){var i=r.references,a=t.levelDetails;i.forEach((function(e,t){var r=e.info;if(a){var i=a.fragments[t];0===i.byteRange.length&&i.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}})),a&&a.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},r._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].NETWORK_ERROR,details:o["ErrorDetails"].MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})},r._handleNetworkError=function(e,t,r,i){var n,s;void 0===r&&(r=!1),void 0===i&&(i=null),d["logger"].info("A network error occured while loading a "+e.type+"-type playlist");var l=this.getInternalLoader(e);switch(e.type){case a.MANIFEST:n=r?o["ErrorDetails"].MANIFEST_LOAD_TIMEOUT:o["ErrorDetails"].MANIFEST_LOAD_ERROR,s=!0;break;case a.LEVEL:n=r?o["ErrorDetails"].LEVEL_LOAD_TIMEOUT:o["ErrorDetails"].LEVEL_LOAD_ERROR,s=!1;break;case a.AUDIO_TRACK:n=r?o["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:o["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR,s=!1;break;default:s=!1}l&&(l.abort(),this.resetInternalLoader(e.type));var c={type:o["ErrorTypes"].NETWORK_ERROR,details:n,fatal:s,url:e.url,loader:l,context:e,networkDetails:t};i&&(c.response=i),this.hls.trigger(u["default"].ERROR,c)},r._handlePlaylistLoaded=function(e,r,i,n){var s=i.type,o=i.level,l=i.id,d=i.levelDetails;if(d&&d.targetduration){var c=t.canHaveQualityLevels(i.type);if(c)this.hls.trigger(u["default"].LEVEL_LOADED,{details:d,level:o||0,id:l||0,stats:r,networkDetails:n});else switch(s){case a.AUDIO_TRACK:this.hls.trigger(u["default"].AUDIO_TRACK_LOADED,{details:d,id:l,stats:r,networkDetails:n});break;case a.SUBTITLE_TRACK:this.hls.trigger(u["default"].SUBTITLE_TRACK_LOADED,{details:d,id:l,stats:r,networkDetails:n});break}}else this._handleManifestParsingError(e,i,"invalid target duration",n)},t}(h),V=H;function W(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Y=function(e){function t(t){var r;return r=e.call(this,t,u["default"].FRAG_LOADING)||this,r.loaders={},r}W(t,e);var r=t.prototype;return r.destroy=function(){var t=this.loaders;for(var r in t){var i=t[r];i&&i.destroy()}this.loaders={},e.prototype.destroy.call(this)},r.onFragLoading=function(e){var t=e.frag,r=t.type,i=this.loaders,a=this.hls.config,n=a.fLoader,s=a.loader;t.loaded=0;var o,u,c,f=i[r];f&&(d["logger"].warn("abort previous fragment loader for type: "+r),f.abort()),f=i[r]=t.loader=a.fLoader?new n(a):new s(a),o={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var h=t.byteRangeStartOffset,g=t.byteRangeEndOffset;Object(l["isFiniteNumber"])(h)&&Object(l["isFiniteNumber"])(g)&&(o.rangeStart=h,o.rangeEnd=g),u={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},f.load(o,u,c)},r.loadsuccess=function(e,t,r,i){void 0===i&&(i=null);var a=e.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(u["default"].FRAG_LOADED,{payload:a,frag:n,stats:t,networkDetails:i})},r.loaderror=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].NETWORK_ERROR,details:o["ErrorDetails"].FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},r.loadtimeout=function(e,t,r){void 0===r&&(r=null);var i=t.frag,a=i.loader;a&&a.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].NETWORK_ERROR,details:o["ErrorDetails"].FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},r.loadprogress=function(e,t,r,i){void 0===i&&(i=null);var a=t.frag;a.loaded=e.loaded,this.hls.trigger(u["default"].FRAG_LOAD_PROGRESS,{frag:a,stats:e,networkDetails:i})},t}(h),q=Y;function z(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var X=function(e){function t(t){var r;return r=e.call(this,t,u["default"].KEY_LOADING)||this,r.loaders={},r.decryptkey=null,r.decrypturl=null,r}z(t,e);var r=t.prototype;return r.destroy=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy()}this.loaders={},e.prototype.destroy.call(this)},r.onKeyLoading=function(e){var t=e.frag,r=t.type,i=this.loaders[r];if(t.decryptdata){var a=t.decryptdata.uri;if(a!==this.decrypturl||null===this.decryptkey){var n=this.hls.config;if(i&&(d["logger"].warn("abort previous key loader for type:"+r),i.abort()),!a)return void d["logger"].warn("key uri is falsy");t.loader=this.loaders[r]=new n.loader(n),this.decrypturl=a,this.decryptkey=null;var s={url:a,frag:t,responseType:"arraybuffer"},o={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};t.loader.load(s,o,l)}else this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(u["default"].KEY_LOADED,{frag:t}))}else d["logger"].warn("Missing decryption data on fragment in onKeyLoading")},r.loadsuccess=function(e,t,r){var i=r.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,delete this.loaders[i.type],this.hls.trigger(u["default"].KEY_LOADED,{frag:i})):d["logger"].error("after key load, decryptdata unset")},r.loaderror=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].NETWORK_ERROR,details:o["ErrorDetails"].KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},r.loadtimeout=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].NETWORK_ERROR,details:o["ErrorDetails"].KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},t}(h),Q=X;function J(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var $={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Z=function(e){function t(t){var r;return r=e.call(this,t,u["default"].BUFFER_APPENDED,u["default"].FRAG_BUFFERED,u["default"].FRAG_LOADED)||this,r.bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=t.config,r}J(t,e);var r=t.prototype;return r.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,h.prototype.destroy.call(this),e.prototype.destroy.call(this)},r.getBufferedFrag=function(e,t){var r=this.fragments,i=Object.keys(r).filter((function(i){var a=r[i];if(a.body.type!==t)return!1;if(!a.buffered)return!1;var n=a.body;return n.startPTS<=e&&e<=n.endPTS}));if(0===i.length)return null;var a=i.pop();return r[a].body},r.detectEvictedFragments=function(e,t){var r,i,a=this;Object.keys(this.fragments).forEach((function(n){var s=a.fragments[n];if(!0===s.buffered){var o=s.range[e];if(o){r=o.time;for(var l=0;l<r.length;l++)if(i=r[l],!1===a.isTimeBuffered(i.startPTS,i.endPTS,t)){a.removeFragment(s.body);break}}}}))},r.detectPartialFragments=function(e){var t=this,r=this.getFragmentKey(e),i=this.fragments[r];i&&(i.buffered=!0,Object.keys(this.timeRanges).forEach((function(r){if(e.hasElementaryStream(r)){var a=t.timeRanges[r];i.range[r]=t.getBufferedTimes(e.startPTS,e.endPTS,a)}})))},r.getBufferedTimes=function(e,t,r){for(var i,a,n=[],s=!1,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a){n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))});break}if(e<a&&t>i)n.push({startPTS:Math.max(e,r.start(o)),endPTS:Math.min(t,r.end(o))}),s=!0;else if(t<=i)break}return{time:n,partial:s}},r.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},r.getPartialFragment=function(e){var t,r,i,a=this,n=null,s=0;return Object.keys(this.fragments).forEach((function(o){var l=a.fragments[o];a.isPartial(l)&&(r=l.body.startPTS-a.bufferPadding,i=l.body.endPTS+a.bufferPadding,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=l.body,s=t)))})),n},r.getState=function(e){var t=this.getFragmentKey(e),r=this.fragments[t],i=$.NOT_LOADED;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?$.PARTIAL:$.OK:$.APPENDING),i},r.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},r.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},r.onFragLoaded=function(e){var t=e.frag;Object(l["isFiniteNumber"])(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},r.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach((function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)}))},r.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},r.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},r.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},r.removeAllFragments=function(){this.fragments=Object.create(null)},t}(h),ee={search:function(e,t){var r=0,i=e.length-1,a=null,n=null;while(r<=i){a=(r+i)/2|0,n=e[a];var s=t(n);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null}},te=ee,re=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,i=0;i<r.length;i++)if(t>=r.start(i)&&t<=r.end(i))return!0}catch(a){}return!1},e.bufferInfo=function(e,t,r){try{if(e){var i,a=e.buffered,n=[];for(i=0;i<a.length;i++)n.push({start:a.start(i),end:a.end(i)});return this.bufferedInfo(n,t,r)}}catch(s){}return{len:0,start:t,end:t,nextStart:void 0}},e.bufferedInfo=function(e,t,r){e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var i=[];if(r)for(var a=0;a<e.length;a++){var n=i.length;if(n){var s=i[n-1].end;e[a].start-s<r?e[a].end>s&&(i[n-1].end=e[a].end):i.push(e[a])}else i.push(e[a])}else i=e;for(var o,l=0,u=t,d=t,c=0;c<i.length;c++){var f=i[c].start,h=i[c].end;if(t+r>=f&&t<h)u=f,d=h,l=d-t;else if(t+r<f){o=f;break}}return{len:l,start:u,end:d,nextStart:o}},e}(),ie=r("./node_modules/eventemitter3/index.js"),ae=r("./node_modules/webworkify-webpack/index.js"),ne=r("./src/demux/demuxer-inline.js");function se(){return window.MediaSource||window.WebKitMediaSource}var oe=r("./src/utils/get-self-scope.js");function le(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var ue=function(e){function t(){return e.apply(this,arguments)||this}le(t,e);var r=t.prototype;return r.trigger=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];this.emit.apply(this,[e,e].concat(r))},t}(ie["EventEmitter"]),de=Object(oe["getSelfScope"])(),ce=se()||{isTypeSupported:function(){return!1}},fe=function(){function e(e,t){var r=this;this.hls=e,this.id=t;var i=this.observer=new ue,a=e.config,n=function(t,i){i=i||{},i.frag=r.frag,i.id=r.id,e.trigger(t,i)};i.on(u["default"].FRAG_DECRYPTED,n),i.on(u["default"].FRAG_PARSING_INIT_SEGMENT,n),i.on(u["default"].FRAG_PARSING_DATA,n),i.on(u["default"].FRAG_PARSED,n),i.on(u["default"].ERROR,n),i.on(u["default"].FRAG_PARSING_METADATA,n),i.on(u["default"].FRAG_PARSING_USERDATA,n),i.on(u["default"].INIT_PTS_FOUND,n);var s={mp4:ce.isTypeSupported("video/mp4"),mpeg:ce.isTypeSupported("audio/mpeg"),mp3:ce.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(a.enableWorker&&"undefined"!==typeof Worker){var c;d["logger"].log("demuxing in webworker");try{c=this.w=ae(/*! ../demux/demuxer-worker.js */"./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(t){e.trigger(u["default"].ERROR,{type:o["ErrorTypes"].OTHER_ERROR,details:o["ErrorDetails"].INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:t.message+" ("+t.filename+":"+t.lineno+")"}})},c.postMessage({cmd:"init",typeSupported:s,vendor:l,id:t,config:JSON.stringify(a)})}catch(f){d["logger"].warn("Error in worker:",f),d["logger"].error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),c&&de.URL.revokeObjectURL(c.objectURL),this.demuxer=new ne["default"](i,s,a,l),this.w=void 0}}else this.demuxer=new ne["default"](i,s,a,l)}var t=e.prototype;return t.destroy=function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var t=this.demuxer;t&&(t.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)},t.push=function(e,t,r,i,a,n,s,o){var u=this.w,c=Object(l["isFiniteNumber"])(a.startPTS)?a.startPTS:a.start,f=a.decryptdata,h=this.frag,g=!(h&&a.cc===h.cc),p=!(h&&a.level===h.level),v=h&&a.sn===h.sn+1,m=!p&&v;if(g&&d["logger"].log(this.id+":discontinuity detected"),p&&d["logger"].log(this.id+":switch detected"),this.frag=a,u)u.postMessage({cmd:"demux",data:e,decryptdata:f,initSegment:t,audioCodec:r,videoCodec:i,timeOffset:c,discontinuity:g,trackSwitch:p,contiguous:m,duration:n,accurateTimeOffset:s,defaultInitPTS:o},e instanceof ArrayBuffer?[e]:[]);else{var y=this.demuxer;y&&y.push(e,f,t,r,i,c,g,p,m,n,s,o)}},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":de.URL.revokeObjectURL(this.w.objectURL);break;case u["default"].FRAG_PARSING_DATA:t.data.data1=new Uint8Array(t.data1),t.data2&&(t.data.data2=new Uint8Array(t.data2));default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}},e}(),he=fe;function ge(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r);break}}function pe(e,t,r){var i=e[t],a=e[r],n=a.startPTS;Object(l["isFiniteNumber"])(n)?r>t?(i.duration=n-i.start,i.duration<0&&d["logger"].warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(a.duration=i.start-n,a.duration<0&&d["logger"].warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):a.start=r>t?i.start+i.duration:Math.max(i.start-a.duration,0)}function ve(e,t,r,i,a,n){var s=r;if(Object(l["isFiniteNumber"])(t.startPTS)){var o=Math.abs(t.startPTS-r);Object(l["isFiniteNumber"])(t.deltaPTS)?t.deltaPTS=Math.max(o,t.deltaPTS):t.deltaPTS=o,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),i=Math.max(i,t.endPTS),a=Math.min(a,t.startDTS),n=Math.max(n,t.endDTS)}var u=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=i,t.startDTS=a,t.endDTS=n,t.duration=i-r;var d,c,f,h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;for(d=h-e.startSN,c=e.fragments,c[d]=t,f=d;f>0;f--)pe(c,f,f-1);for(f=d;f<c.length-1;f++)pe(c,f,f+1);return e.PTSKnown=!0,u}function me(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment);var r,i=0;if(Ee(e,t,(function(e,a){i=e.cc-a.cc,Object(l["isFiniteNumber"])(e.startPTS)&&(a.start=a.startPTS=e.startPTS,a.endPTS=e.endPTS,a.duration=e.duration,a.backtracked=e.backtracked,a.dropped=e.dropped,r=a),t.PTSKnown=!0})),t.PTSKnown){if(i){d["logger"].log("discontinuity sliding from playlist, take drift into account");for(var a=t.fragments,n=0;n<a.length;n++)a[n].cc+=i}r?ve(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Te(e,t),t.PTSKnown=e.PTSKnown}}function ye(e,t,r){void 0===r&&(r=0);var i=-1;Ee(e,t,(function(e,t,r){t.start=e.start,i=r}));var a=t.fragments;if(i<0)a.forEach((function(e){e.start+=r}));else for(var n=i+1;n<a.length;n++)a[n].start=a[n-1].start+a[n-1].duration}function Ee(e,t,r){if(e&&t)for(var i=Math.max(e.startSN,t.startSN)-t.startSN,a=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,s=i;s<=a;s++){var o=e.fragments[n+s],l=t.fragments[s];if(!o||!l)break;r(o,l,s)}}function Te(e,t){var r=t.startSN-e.startSN,i=e.fragments,a=t.fragments;if(!(r<0||r>i.length))for(var n=0;n<a.length;n++)a[n].start+=i[r].start}function Se(e,t,r){var i=1e3*(t.averagetargetduration?t.averagetargetduration:t.targetduration),a=i/2;return e&&t.endSN===e.endSN&&(i=a),r&&(i=Math.max(a,i-(window.performance.now()-r))),Math.round(i)}var be={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}},_e=be;function Ae(e,t){for(var r=null,i=0;i<e.length;i+=1){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}function Re(e,t){return te.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function De(e,t,r){var i=!1;return t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)&&(i=!0),i}function Le(e,t){var r=e.fragments,i=t.fragments;if(i.length&&r.length){var a=Ae(r,i[0].cc);if(a&&(!a||a.startPTS))return a;d["logger"].log("No frag in previous level to align on")}else d["logger"].log("No fragments to align")}function we(e,t){t.fragments.forEach((function(t){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}})),t.PTSKnown=!0}function ke(e,t,r){Ie(e,r,t),!r.PTSKnown&&t&&Oe(r,t.details)}function Ie(e,t,r){if(De(e,r,t)){var i=Le(r.details,t);i&&(d["logger"].log("Adjusting PTS using last level due to CC increase within current level"),we(i.start,t))}}function Oe(e,t){if(t&&t.fragments.length){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;var r=t.fragments[0].programDateTime,i=e.fragments[0].programDateTime,a=(i-r)/1e3+t.fragments[0].start;Object(l["isFiniteNumber"])(a)&&(d["logger"].log("adjusting PTS using programDateTime delta, sliding:"+a.toFixed(3)),we(a,e))}}function Ce(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Object(l["isFiniteNumber"])(t))return null;var i=e[0].programDateTime;if(t<(i||0))return null;var a=e[e.length-1].endProgramDateTime;if(t>=(a||0))return null;r=r||0;for(var n=0;n<e.length;++n){var s=e[n];if(Fe(t,r,s))return s}return null}function Pe(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=e?t[e.sn-t[0].sn+1]:null;return a&&!xe(r,i,a)?a:te.search(t,xe.bind(null,r,i))}function xe(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Fe(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0)),a=r.endProgramDateTime||0;return a-i>e}var Me=250,Ne=2,Ue=.1,Be=.05,Ge=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,a=r.currentTime,n=r.seeking,s=this.seeking&&!n,o=!this.seeking&&n;if(this.seeking=n,a===e){if((o||s)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){var l=re.bufferInfo(r,a,0),u=l.len>0,c=l.nextStart||0;if(u||c){if(n){var f=l.len>Ne,h=!c||c-a>Ne;if(f||h)return;this.moved=!1}if(!this.moved&&this.stalled){var g=Math.max(c,l.start||0)-a;if(g>0&&g<=Ne)return void this._trySkipBufferHole(null)}var p=self.performance.now();if(null!==i){var v=p-i;!n&&v>=Me&&this._reportStall(l.len);var m=re.bufferInfo(r,a,t.maxBufferHole);this._tryFixBufferStall(m,v)}else this.stalled=p}}}else if(this.moved=!0,null!==i){if(this.stallReported){var y=self.performance.now()-i;d["logger"].warn("playback not stuck anymore @"+a+", after "+Math.round(y)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media,n=a.currentTime,s=i.getPartialFragment(n);if(s){var o=this._trySkipBufferHole(s);if(o)return}e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(d["logger"].warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media,i=this.stallReported;i||(this.stallReported=!0,d["logger"].warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,a=i.currentTime,n=0,s=0;s<i.buffered.length;s++){var l=i.buffered.start(s);if(a+t.maxBufferHole>=n&&a<l){var c=Math.max(l+Be,i.currentTime+Ue);return d["logger"].warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,i.currentTime=c,e&&r.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+c,frag:e}),c}n=i.buffered.end(s)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=r.currentTime,a=(this.nudgeRetry||0)+1;if(this.nudgeRetry=a,a<e.nudgeMaxRetry){var n=i+a*e.nudgeOffset;d["logger"].warn("Nudging 'currentTime' from "+i+" to "+n),r.currentTime=n,t.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_NUDGE_ON_STALL,fatal:!1})}else d["logger"].error("Playhead still not moving while enough data buffered @"+i+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:!0})},e}();function Ke(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function je(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var He=function(e){function t(t){for(var r,i=arguments.length,a=new Array(i>1?i-1:0),n=1;n<i;n++)a[n-1]=arguments[n];return r=e.call.apply(e,[this,t].concat(a))||this,r._boundTick=void 0,r._tickTimer=null,r._tickInterval=null,r._tickCallCount=0,r._boundTick=r.tick.bind(Ke(r)),r}je(t,e);var r=t.prototype;return r.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},r.hasInterval=function(){return!!this._tickInterval},r.hasNextTick=function(){return!!this._tickTimer},r.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},r.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},r.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},r.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},r.doTick=function(){},t}(h);function Ve(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var We={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},Ye=function(e){function t(){return e.apply(this,arguments)||this}Ve(t,e);var r=t.prototype;return r.doTick=function(){},r.startLoad=function(){},r.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=We.STOPPED},r._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var a=i.getState(r);return a===$.PARTIAL||a===$.OK}return!1},r.onMediaSeeking=function(){var e=this.config,t=this.media,r=this.mediaBuffer,i=this.state,a=t?t.currentTime:null,n=re.bufferInfo(r||t,a,this.config.maxBufferHole);if(Object(l["isFiniteNumber"])(a)&&d["logger"].log("media seeking to "+a.toFixed(3)),i===We.FRAG_LOADING){var s=this.fragCurrent;if(0===n.len&&s){var o=e.maxFragLookUpTolerance,u=s.start-o,c=s.start+s.duration+o;a<u||a>c?(s.loader&&(d["logger"].log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=We.IDLE):d["logger"].log("seeking outside of buffer but within currently loaded fragment range")}}else i===We.ENDED&&(0===n.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=We.IDLE);t&&(this.lastCurrentTime=a),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=a),this.tick()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},r.onHandlerDestroyed=function(){this.state=We.STOPPED,this.fragmentTracker=null},r.computeLivePosition=function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)},t}(He);function qe(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ze(e,t,r){return t&&qe(e.prototype,t),r&&qe(e,r),e}function Xe(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Qe=100,Je=function(e){function t(t,r){var i;return i=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHING,u["default"].MANIFEST_LOADING,u["default"].MANIFEST_PARSED,u["default"].LEVEL_LOADED,u["default"].KEY_LOADED,u["default"].FRAG_LOADED,u["default"].FRAG_LOAD_EMERGENCY_ABORTED,u["default"].FRAG_PARSING_INIT_SEGMENT,u["default"].FRAG_PARSING_DATA,u["default"].FRAG_PARSED,u["default"].ERROR,u["default"].AUDIO_TRACK_SWITCHING,u["default"].AUDIO_TRACK_SWITCHED,u["default"].BUFFER_CREATED,u["default"].BUFFER_APPENDED,u["default"].BUFFER_FLUSHED)||this,i.fragmentTracker=r,i.config=t.config,i.audioCodecSwap=!1,i._state=We.STOPPED,i.stallReported=!1,i.gapController=null,i.altAudio=!1,i}Xe(t,e);var r=t.prototype;return r.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(Qe),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(i=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(d["logger"].log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=We.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=We.STOPPED},r.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case We.BUFFER_FLUSHING:this.fragLoadError=0;break;case We.IDLE:this._doTickIdle();break;case We.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=We.IDLE);break;case We.FRAG_LOADING_WAITING_RETRY:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(d["logger"].log("mediaController: retryDate reached, switch back to IDLE state"),this.state=We.IDLE);break;case We.ERROR:case We.STOPPED:case We.FRAG_LOADING:case We.PARSING:case We.PARSED:case We.ENDED:break;default:break}this._checkBuffer(),this._checkFragmentChanged()},r._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch)){var i;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=e.nextLoadLevel,n=this.levels[a];if(n){var s,o=n.bitrate;s=o?Math.max(8*t.maxBufferSize/o,t.maxBufferLength):t.maxBufferLength,s=Math.min(s,t.maxMaxBufferLength);var l=re.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,t.maxBufferHole),c=l.len;if(!(c>=s)){d["logger"].trace("buffer length of "+c.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=a;var f=n.details;if(!f||f.live&&this.levelLastLoaded!==a)this.state=We.WAITING_LEVEL;else{if(this._streamEnded(l,f)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(u["default"].BUFFER_EOS,h),void(this.state=We.ENDED)}this._fetchPayloadOrEos(i,l,f)}}}}},r._fetchPayloadOrEos=function(e,t,r){var i=this.fragPrevious,a=this.level,n=r.fragments,s=n.length;if(0!==s){var o,l=n[0].start,u=n[s-1].start+n[s-1].duration,c=t.end;if(r.initSegment&&!r.initSegment.data)o=r.initSegment;else if(r.live){var f=this.config.initialLiveManifestSize;if(s<f)return void d["logger"].warn("Can not start playback of a level, reason: not enough fragments "+s+" < "+f);if(o=this._ensureFragmentAtLivePoint(r,c,l,u,i,n,s),null===o)return}else c<l&&(o=n[0]);o||(o=this._findFragment(l,i,s,n,c,u,r)),o&&(o.encrypted?(d["logger"].log("Loading key for "+o.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+a),this._loadKey(o)):(d["logger"].log("Loading "+o.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+a+", currentTime:"+e.toFixed(3)+",bufferEnd:"+c.toFixed(3)),this._loadFragment(o)))}},r._ensureFragmentAtLivePoint=function(e,t,r,i,a,n,s){var o,l=this.hls.config,u=this.media,c=void 0!==l.liveMaxLatencyDuration?l.liveMaxLatencyDuration:l.liveMaxLatencyDurationCount*e.targetduration;if(t<Math.max(r-l.maxFragLookUpTolerance,i-c)){var f=this.liveSyncPosition=this.computeLivePosition(r,e);t=f,u&&!u.paused&&u.readyState&&u.duration>f&&f>u.currentTime&&(d["logger"].log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+f.toFixed(3)),u.currentTime=f),this.nextLoadPosition=f}if(e.PTSKnown&&t>i&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(a)if(e.hasProgramDateTime)d["logger"].log("live playlist, switching playlist, load frag with same PDT: "+a.programDateTime),o=Ce(n,a.endProgramDateTime,l.maxFragLookUpTolerance);else{var h=a.sn+1;if(h>=e.startSN&&h<=e.endSN){var g=n[h-e.startSN];a.cc===g.cc&&(o=g,d["logger"].log("live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=te.search(n,(function(e){return a.cc-e.cc})),o&&d["logger"].log("live playlist, switching playlist, load frag with same CC: "+o.sn))}o||(o=n[Math.min(s-1,Math.round(s/2))],d["logger"].log("live playlist, switching playlist, unknown, load middle frag : "+o.sn))}return o},r._findFragment=function(e,t,r,i,a,n,s){var o,l=this.hls.config;if(a<n){var u=a>n-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance;o=Pe(t,i,a,u)}else o=i[r-1];if(o){var c=o.sn-s.startSN,f=t&&o.level===t.level,h=i[c-1],g=i[c+1];if(t&&o.sn===t.sn)if(f&&!o.backtracked)if(o.sn<s.endSN){var p=t.deltaPTS;p&&p>l.maxBufferHole&&t.dropped&&c?(o=h,d["logger"].warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):(o=g,d["logger"].log("Re-loading fragment with SN: "+o.sn))}else o=null;else o.backtracked&&(g&&g.backtracked?(d["logger"].warn("Already backtracked from fragment "+g.sn+", will not backtrack to fragment "+o.sn+". Loading fragment "+g.sn),o=g):(d["logger"].warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),o.dropped=0,h?(o=h,o.backtracked=!0):c&&(o=null)))}return o},r._loadKey=function(e){this.state=We.KEY_LOADING,this.hls.trigger(u["default"].KEY_LOADING,{frag:e})},r._loadFragment=function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,"initSegment"!==e.sn&&(this.startFragRequested=!0),Object(l["isFiniteNumber"])(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===$.NOT_LOADED||t===$.PARTIAL?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(u["default"].FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new he(this.hls,"main")),this.state=We.FRAG_LOADING):t===$.APPENDING&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,n.MAIN)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},r._checkFragmentChanged=function(){var e,t,r=this.media;if(r&&r.readyState&&!1===r.seeking&&(t=r.currentTime,t>this.lastCurrentTime&&(this.lastCurrentTime=t),re.isBuffered(r,t)?e=this.getBufferedFrag(t):re.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(u["default"].FRAG_CHANGED,{frag:i});var a=i.level;this.fragPlaying&&this.fragPlaying.level===a||this.hls.trigger(u["default"].LEVEL_SWITCHED,{level:a}),this.fragPlaying=i}}},r.immediateLevelSwitch=function(){if(d["logger"].log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e,t=this.media;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,re.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},r.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,r,i;if(r=this.getBufferedFrag(e.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}if(i=this.getBufferedFrag(e.currentTime+t),i&&(i=this.followingBufferedFrag(i),i)){var o=this.fragCurrent;o&&o.loader&&o.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},r.flushMainBuffer=function(e,t){this.state=We.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(u["default"].BUFFER_FLUSHING,r)},r.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new Ge(r,t,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(d["logger"].log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach((function(e){e.details&&e.details.fragments.forEach((function(e){e.backtracked=void 0}))})),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.fragmentTracker.removeAllFragments(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(l["isFiniteNumber"])(t)&&d["logger"].log("media seeked to "+t.toFixed(3)),this.tick()},r.onManifestLoading=function(){d["logger"].log("trigger BUFFER_RESET"),this.hls.trigger(u["default"].BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},r.onManifestParsed=function(e){var t,r=!1,i=!1;e.levels.forEach((function(e){t=e.audioCodec,t&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&d["logger"].log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.altAudio=e.altAudio,this.levels=e.levels,this.startFragRequested=!1;var a=this.config;(a.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(a.startPosition)},r.onLevelLoaded=function(e){var t=e.details,r=e.level,i=this.levels[this.levelLastLoaded],a=this.levels[r],n=t.totalduration,s=0;if(d["logger"].log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+n),t.live){var o=a.details;o&&t.fragments.length>0?(me(o,t),s=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(s,o),t.PTSKnown&&Object(l["isFiniteNumber"])(s)?d["logger"].log("live playlist sliding:"+s.toFixed(3)):(d["logger"].log("live playlist - outdated PTS, unknown sliding"),ke(this.fragPrevious,i,t))):(d["logger"].log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,ke(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(a.details=t,this.levelLastLoaded=r,this.hls.trigger(u["default"].LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var c=t.startTimeOffset;Object(l["isFiniteNumber"])(c)?(c<0&&(d["logger"].log("negative start time offset "+c+", count from end of last fragment"),c=s+n+c),d["logger"].log("start time offset found in playlist, adjust startPosition to "+c),this.startPosition=c):t.live?(this.startPosition=this.computeLivePosition(s,t),d["logger"].log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===We.WAITING_LEVEL&&(this.state=We.IDLE),this.tick()},r.onKeyLoaded=function(){this.state===We.KEY_LOADING&&(this.state=We.IDLE,this.tick())},r.onFragLoaded=function(e){var t=this.fragCurrent,r=this.hls,i=this.levels,a=this.media,n=e.frag;if(this.state===We.FRAG_LOADING&&t&&"main"===n.type&&n.level===t.level&&n.sn===t.sn){var s=e.stats,o=i[t.level],l=o.details;if(this.bitrateTest=!1,this.stats=s,d["logger"].log("Loaded "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level),n.bitrateTest&&r.nextLoadLevel)this.state=We.IDLE,this.startFragRequested=!1,s.tparsed=s.tbuffered=window.performance.now(),r.trigger(u["default"].FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else if("initSegment"===n.sn)this.state=We.IDLE,s.tparsed=s.tbuffered=window.performance.now(),l.initSegment.data=e.payload,r.trigger(u["default"].FRAG_BUFFERED,{stats:s,frag:t,id:"main"}),this.tick();else{d["logger"].log("Parsing "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level+", cc "+t.cc),this.state=We.PARSING,this.pendingBuffering=!0,this.appended=!1,n.bitrateTest&&(n.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:n}));var c=!(a&&a.seeking)&&(l.PTSKnown||!l.live),f=l.initSegment?l.initSegment.data:[],h=this._getAudioCodec(o),g=this.demuxer=this.demuxer||new he(this.hls,"main");g.push(e.payload,f,h,o.videoCodec,t,l.totalduration,c)}}this.fragLoadError=0},r.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===We.PARSING){var i,a,n=e.tracks;if(n.audio&&this.altAudio&&delete n.audio,a=n.audio,a){var s=this.levels[this.level].audioCodec,o=navigator.userAgent.toLowerCase();s&&this.audioCodecSwap&&(d["logger"].log("swapping playlist audio codec"),s=-1!==s.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===o.indexOf("firefox")&&(s="mp4a.40.5"),-1!==o.indexOf("android")&&"audio/mpeg"!==a.container&&(s="mp4a.40.2",d["logger"].log("Android: force audio codec to "+s)),a.levelCodec=s,a.id=e.id}for(i in a=n.video,a&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=e.id),this.hls.trigger(u["default"].BUFFER_CODECS,n),n){a=n[i],d["logger"].log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var l=a.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u["default"].BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},r.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"main"===e.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===We.PARSING){var a=this.levels[this.level],n=r;if(Object(l["isFiniteNumber"])(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&n.addElementaryStream(m.AUDIO),!0===e.hasVideo&&n.addElementaryStream(m.VIDEO),d["logger"].log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(n.dropped=e.dropped,n.dropped)if(n.backtracked)d["logger"].warn("Already backtracked on this fragment, appending with the gap",n.sn);else{var s=a.details;if(!s||n.sn!==s.startSN)return d["logger"].warn("missing video frame(s), backtracking fragment",n.sn),this.fragmentTracker.removeFragment(n),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=We.IDLE,this.fragPrevious=n,void this.tick();d["logger"].warn("missing video frame(s) on first frag, appending with gap",n.sn)}else n.backtracked=!1;var o=ve(a.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),c=this.hls;c.trigger(u["default"].LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:o,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach((function(r){r&&r.length&&t.state===We.PARSING&&(t.appended=!0,t.pendingBuffering=!0,c.trigger(u["default"].BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))})),this.tick()}},r.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===We.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=We.PARSED,this._checkAppendedParsed())},r.onAudioTrackSwitching=function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){d["logger"].log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(d["logger"].log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=We.IDLE}var a=this.hls;a.trigger(u["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(u["default"].AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},r.onAudioTrackSwitched=function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(d["logger"].log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},r.onBufferCreated=function(e){var t,r,i=e.tracks,a=!1;for(var n in i){var s=i[n];"main"===s.id?(r=n,t=s,"video"===n&&(this.videoBuffer=i[n].buffer)):a=!0}a&&t?(d["logger"].log("alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},r.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==We.PARSING&&t!==We.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},r._checkAppendedParsed=function(){if(this.state===We.PARSED&&(!this.appended||!this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;d["logger"].log("main buffered : "+_e.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(u["default"].FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=We.IDLE}this.tick()}},r.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&re.isBuffered(this.media,this.media.currentTime)&&re.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case o["ErrorDetails"].FRAG_LOAD_ERROR:case o["ErrorDetails"].FRAG_LOAD_TIMEOUT:case o["ErrorDetails"].KEY_LOAD_ERROR:case o["ErrorDetails"].KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);d["logger"].warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=We.FRAG_LOADING_WAITING_RETRY}else d["logger"].error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=We.ERROR;break;case o["ErrorDetails"].LEVEL_LOAD_ERROR:case o["ErrorDetails"].LEVEL_LOAD_TIMEOUT:this.state!==We.ERROR&&(e.fatal?(this.state=We.ERROR,d["logger"].warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==We.WAITING_LEVEL||(this.state=We.IDLE));break;case o["ErrorDetails"].BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==We.PARSING&&this.state!==We.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=We.IDLE):(d["logger"].warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)));break;default:break}}},r._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,d["logger"].warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},r._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=this.mediaBuffer?this.mediaBuffer:e,r=t.buffered;!this.loadedmetadata&&r.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,r)}},r.onFragLoadEmergencyAborted=function(){this.state=We.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},r.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(m.VIDEO,e.buffered),this.state=We.IDLE,this.fragPrevious=null},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&r>=0&&(d["logger"].log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)},r._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(d["logger"].log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},ze(t,[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,d["logger"].log("main stream-controller: "+t+"->"+e),this.hls.trigger(u["default"].STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}]),t}(Ye),$e=Je;function Ze(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function et(e,t,r){return t&&Ze(e.prototype,t),r&&Ze(e,r),e}function tt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var rt,it=window,at=(it.performance,function(e){function t(t){var r;return r=e.call(this,t,u["default"].MANIFEST_LOADED,u["default"].LEVEL_LOADED,u["default"].AUDIO_TRACK_SWITCHED,u["default"].FRAG_LOADED,u["default"].ERROR)||this,r.canload=!1,r.currentLevelIndex=null,r.manualLevelIndex=-1,r.timer=null,rt=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r}tt(t,e);var r=t.prototype;return r.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},r.clearTimer=function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)},r.startLoad=function(){var e=this._levels;this.canload=!0,this.levelRetryCount=0,e&&e.forEach((function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)})),null!==this.timer&&this.loadLevel()},r.stopLoad=function(){this.canload=!1},r.onManifestLoaded=function(e){var t,r=[],i=[],a={},n=null,s=!1,l=!1;if(e.levels.forEach((function(e){var t=e.attrs;e.loadError=0,e.fragmentError=!1,s=s||!!e.videoCodec,l=l||!!e.audioCodec,rt&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),n=a[e.bitrate],n?n.url.push(e.url):(e.url=[e.url],e.urlId=0,a[e.bitrate]=e,r.push(e)),t&&(t.AUDIO&&(l=!0,ge(n||e,"audio",t.AUDIO)),t.SUBTITLES&&ge(n||e,"text",t.SUBTITLES))})),s&&l&&(r=r.filter((function(e){var t=e.videoCodec;return!!t}))),r=r.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||O(t,"audio"))&&(!r||O(r,"video"))})),e.audioTracks&&(i=e.audioTracks.filter((function(e){return!e.audioCodec||O(e.audioCodec,"audio")})),i.forEach((function(e,t){e.id=t}))),r.length>0){t=r[0].bitrate,r.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=r;for(var c=0;c<r.length;c++)if(r[c].bitrate===t){this._firstLevel=c,d["logger"].log("manifest loaded,"+r.length+" level(s) found, first bitrate:"+t);break}this.hls.trigger(u["default"].MANIFEST_PARSED,{levels:r,audioTracks:i,firstLevel:this._firstLevel,stats:e.stats,audio:l,video:s,altAudio:i.some((function(e){return!!e.url}))})}else this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},r.setLevelInternal=function(e){var t=this._levels,r=this.hls;if(e>=0&&e<t.length){if(this.clearTimer(),this.currentLevelIndex!==e){d["logger"].log("switching to level "+e),this.currentLevelIndex=e;var i=t[e];i.level=e,r.trigger(u["default"].LEVEL_SWITCHING,i)}var a=t[e],n=a.details;if(!n||n.live){var s=a.urlId;r.trigger(u["default"].LEVEL_LOADING,{url:a.url[s],level:e,id:s})}}else r.trigger(u["default"].ERROR,{type:o["ErrorTypes"].OTHER_ERROR,details:o["ErrorDetails"].LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})},r.onError=function(e){if(e.fatal)e.type===o["ErrorTypes"].NETWORK_ERROR&&this.clearTimer();else{var t,r=!1,i=!1;switch(e.details){case o["ErrorDetails"].FRAG_LOAD_ERROR:case o["ErrorDetails"].FRAG_LOAD_TIMEOUT:case o["ErrorDetails"].KEY_LOAD_ERROR:case o["ErrorDetails"].KEY_LOAD_TIMEOUT:t=e.frag.level,i=!0;break;case o["ErrorDetails"].LEVEL_LOAD_ERROR:case o["ErrorDetails"].LEVEL_LOAD_TIMEOUT:t=e.context.level,r=!0;break;case o["ErrorDetails"].REMUX_ALLOC_ERROR:t=e.level,r=!0;break}void 0!==t&&this.recoverLevel(e,t,r,i)}},r.recoverLevel=function(e,t,r,i){var a,n,s,o=this,l=this.hls.config,u=e.details,c=this._levels[t];if(c.loadError++,c.fragmentError=i,r){if(!(this.levelRetryCount+1<=l.levelLoadingMaxRetry))return d["logger"].error("level controller, cannot recover from "+u+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);n=Math.min(Math.pow(2,this.levelRetryCount)*l.levelLoadingRetryDelay,l.levelLoadingMaxRetryTimeout),this.timer=setTimeout((function(){return o.loadLevel()}),n),e.levelRetry=!0,this.levelRetryCount++,d["logger"].warn("level controller, "+u+", retry in "+n+" ms, current retry count is "+this.levelRetryCount)}(r||i)&&(a=c.url.length,a>1&&c.loadError<a?(c.urlId=(c.urlId+1)%a,c.details=void 0,d["logger"].warn("level controller, "+u+" for level "+t+": switching to redundant URL-id "+c.urlId)):-1===this.manualLevelIndex?(s=0===t?this._levels.length-1:t-1,d["logger"].warn("level controller, "+u+": switch to "+s),this.hls.nextAutoLevel=this.currentLevelIndex=s):i&&(d["logger"].warn("level controller, "+u+": reload a fragment"),this.currentLevelIndex=null))},r.onFragLoaded=function(e){var t=e.frag;if(void 0!==t&&"main"===t.type){var r=this._levels[t.level];void 0!==r&&(r.fragmentError=!1,r.loadError=0,this.levelRetryCount=0)}},r.onLevelLoaded=function(e){var t=this,r=e.level,i=e.details;if(r===this.currentLevelIndex){var a=this._levels[r];if(a.fragmentError||(a.loadError=0,this.levelRetryCount=0),i.live){var n=Se(a.details,i,e.stats.trequest);d["logger"].log("live playlist, reload in "+Math.round(n)+" ms"),this.timer=setTimeout((function(){return t.loadLevel()}),n)}else this.clearTimer()}},r.onAudioTrackSwitched=function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===t){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},r.loadLevel=function(){if(d["logger"].debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload){var e=this._levels[this.currentLevelIndex];if("object"===typeof e&&e.url.length>0){var t=this.currentLevelIndex,r=e.urlId,i=e.url[r];d["logger"].log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(u["default"].LEVEL_LOADING,{url:i,level:t,id:r})}}},et(t,[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(h)),nt=r("./src/demux/id3.js");function st(e,t){var r;try{r=new Event("addtrack")}catch(i){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ot(e){if(e&&e.cues)while(e.cues.length>0)e.removeCue(e.cues[0])}function lt(e,t){if(t<e[0].endTime)return e[0];if(t>e[e.length-1].endTime)return e[e.length-1];var r=0,i=e.length-1;while(r<=i){var a=Math.floor((i+r)/2);if(t<e[a].endTime)i=a-1;else{if(!(t>e[a].endTime))return e[a];r=a+1}}return e[r].endTime-t<t-e[i].endTime?e[r]:e[i]}function ut(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var dt=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHING,u["default"].FRAG_PARSING_METADATA,u["default"].LIVE_BACK_BUFFER_REACHED)||this,r.id3Track=void 0,r.media=void 0,r}ut(t,e);var r=t.prototype;return r.destroy=function(){h.prototype.destroy.call(this)},r.onMediaAttached=function(e){this.media=e.media,this.media},r.onMediaDetaching=function(){ot(this.id3Track),this.id3Track=void 0,this.media=void 0},r.getID3Track=function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return st(r,this.media),r}return this.media.addTextTrack("metadata","id3")},r.onFragParsingMetadata=function(e){var t=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,a=0;a<r.length;a++){var n=nt["default"].getID3Frames(r[a].data);if(n){var s=r[a].pts,o=a<r.length-1?r[a+1].pts:t.endPTS;s===o?o+=1e-4:s>o&&(d["logger"].warn("detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)"),o=s+.25);for(var l=0;l<n.length;l++){var u=n[l];if(!nt["default"].isTimeStampFrame(u)){var c=new i(s,o,"");c.value=u,this.id3Track.addCue(c)}}}}},r.onLiveBackBufferReached=function(e){var t=e.bufferEnd,r=this.id3Track;if(r&&r.cues&&r.cues.length){var i=lt(r.cues,t);if(i)while(r.cues[0]!==i)r.removeCue(r.cues[0])}},t}(h),ct=dt;function ft(){var e=se();if(!e)return!1;var t=self.SourceBuffer||self.WebKitSourceBuffer,r=e&&"function"===typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"===typeof t.prototype.appendBuffer&&"function"===typeof t.prototype.remove;return!!r&&!!i}var ht=function(){function e(e){this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=0,this.totalWeight_=0}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/e}return this.estimate_},e}(),gt=ht,pt=function(){function e(e,t,r,i){this.hls=void 0,this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.hls=e,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new gt(t),this.fast_=new gt(r)}var t=e.prototype;return t.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t,i=e/1e3,a=r/i;this.fast_.sample(i,a),this.slow_.sample(i,a)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}(),vt=pt;function mt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function yt(e,t,r){return t&&mt(e.prototype,t),r&&mt(e,r),e}function Et(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Tt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var St=window,bt=St.performance,_t=function(e){function t(t){var r;return r=e.call(this,t,u["default"].FRAG_LOADING,u["default"].FRAG_LOADED,u["default"].FRAG_BUFFERED,u["default"].ERROR)||this,r.lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=t,r.timer=null,r._bwEstimator=null,r.onCheck=r._abandonRulesCheck.bind(Et(r)),r}Tt(t,e);var r=t.prototype;return r.destroy=function(){this.clearTimer(),h.prototype.destroy.call(this)},r.onFragLoading=function(e){var t=e.frag;if("main"===t.type&&(this.timer||(this.fragCurrent=t,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var r,i,a=this.hls,n=a.config,s=t.level,o=a.levels[s].details.live;o?(r=n.abrEwmaFastLive,i=n.abrEwmaSlowLive):(r=n.abrEwmaFastVoD,i=n.abrEwmaSlowVoD),this._bwEstimator=new vt(a,i,r,n.abrEwmaDefaultEstimate)}},r._abandonRulesCheck=function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var i=r.loader,a=e.minAutoLevel;if(!i||i.stats&&i.stats.aborted)return d["logger"].warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var n=i.stats;if(t&&n&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var s=bt.now()-n.trequest,o=Math.abs(t.playbackRate);if(s>500*r.duration/o){var l=e.levels,c=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/s),f=l[r.level],h=f.realBitrate?Math.max(f.realBitrate,f.bitrate):f.bitrate,g=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*h/8)),p=t.currentTime,v=(g-n.loaded)/c,m=(re.bufferInfo(t,p,e.config.maxBufferHole).end-p)/o;if(m<2*r.duration/o&&v>m){var y,E;for(E=r.level-1;E>a;E--){var T=l[E].realBitrate?Math.max(l[E].realBitrate,l[E].bitrate):l[E].bitrate,S=r.duration*T/(6.4*c);if(S<m)break}y<v&&(d["logger"].warn("loading too slow, abort fragment loading and switch to level "+E+":fragLoadedDelay["+E+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+y.toFixed(1)+"<"+v.toFixed(1)+":"+m.toFixed(1)),e.nextLoadLevel=E,this._bwEstimator.sample(s,n.loaded),i.abort(),this.clearTimer(),e.trigger(u["default"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:n}))}}}}},r.onFragLoaded=function(e){var t=e.frag;if("main"===t.type&&Object(l["isFiniteNumber"])(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],i=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,a=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:i,duration:a},r.realBitrate=Math.round(8*i/a)}if(e.frag.bitrateTest){var n=e.stats;n.tparsed=n.tbuffered=n.tload,this.onFragBuffered(e)}}},r.onFragBuffered=function(e){var t=e.stats,r=e.frag;if(!0!==t.aborted&&"main"===r.type&&Object(l["isFiniteNumber"])(r.sn)&&(!r.bitrateTest||t.tload===t.tbuffered)){var i=t.tparsed-t.trequest;d["logger"].log("latency/loading/parsing/append/kbps:"+Math.round(t.tfirst-t.trequest)+"/"+Math.round(t.tload-t.tfirst)+"/"+Math.round(t.tparsed-t.tload)+"/"+Math.round(t.tbuffered-t.tparsed)+"/"+Math.round(8*t.loaded/(t.tbuffered-t.trequest))),this._bwEstimator.sample(i,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},r.onError=function(e){switch(e.details){case o["ErrorDetails"].FRAG_LOAD_ERROR:case o["ErrorDetails"].FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},r.clearTimer=function(){clearInterval(this.timer),this.timer=null},r._findBestLevel=function(e,t,r,i,a,n,s,o,l){for(var u=a;u>=i;u--){var c=l[u];if(c){var f=c.details,h=f?f.totalduration/f.fragments.length:t,g=!!f&&f.live,p=void 0;p=u<=e?s*r:o*r;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,m=v*h/p;if(d["logger"].trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+v+"/"+h+"/"+n+"/"+m),p>v&&(!m||g&&!this.bitrateTestDelay||m<n))return u}}return-1},yt(t,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(-1!==e&&(!t||!t.canEstimate()))return e;var r=this._nextABRAutoLevel;return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}},{key:"_nextABRAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.levels,i=e.config,a=e.minAutoLevel,n=e.media,s=this.lastLoadedFragLevel,o=this.fragCurrent?this.fragCurrent.duration:0,l=n?n.currentTime:0,u=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,c=this._bwEstimator?this._bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,f=(re.bufferInfo(n,l,i.maxBufferHole).end-l)/u,h=this._findBestLevel(s,o,c,a,t,f,i.abrBandWidthFactor,i.abrBandWidthUpFactor,r);if(h>=0)return h;d["logger"].trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var g=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,v=i.abrBandWidthUpFactor;if(0===f){var m=this.bitrateTestDelay;if(m){var y=o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay;g=y-m,d["logger"].trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),p=v=1}}return h=this._findBestLevel(s,o,c,a,t,f+g,p,v,r),Math.max(h,0)}}]),t}(h),At=_t;function Rt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Dt=se(),Lt=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MEDIA_ATTACHING,u["default"].MEDIA_DETACHING,u["default"].MANIFEST_PARSED,u["default"].BUFFER_RESET,u["default"].BUFFER_APPENDING,u["default"].BUFFER_CODECS,u["default"].BUFFER_EOS,u["default"].BUFFER_FLUSHING,u["default"].LEVEL_PTS_UPDATED,u["default"].LEVEL_UPDATED)||this,r._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r._needsFlush=!1,r._needsEos=!1,r.config=void 0,r.audioTimestampOffset=void 0,r.bufferCodecEventsExpected=0,r._bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.segments=[],r.parent=void 0,r.appending=!1,r.appended=0,r.appendError=0,r.flushBufferCounter=0,r.tracks={},r.pendingTracks={},r.sourceBuffer={},r.flushRange=[],r._onMediaSourceOpen=function(){d["logger"].log("media source opened"),r.hls.trigger(u["default"].MEDIA_ATTACHED,{media:r.media});var e=r.mediaSource;e&&e.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},r._onMediaSourceClose=function(){d["logger"].log("media source closed")},r._onMediaSourceEnded=function(){d["logger"].log("media source ended")},r._onSBUpdateEnd=function(){if(r.audioTimestampOffset&&r.sourceBuffer.audio){var e=r.sourceBuffer.audio;d["logger"].warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+r.audioTimestampOffset),e.timestampOffset=r.audioTimestampOffset,delete r.audioTimestampOffset}r._needsFlush&&r.doFlush(),r._needsEos&&r.checkEos(),r.appending=!1;var t=r.parent,i=r.segments.reduce((function(e,r){return r.parent===t?e+1:e}),0),a={},n=r.sourceBuffer;for(var s in n){var o=n[s];if(!o)throw Error("handling source buffer update end error: source buffer for "+s+" uninitilized and unable to update buffered TimeRanges.");a[s]=o.buffered}r.hls.trigger(u["default"].BUFFER_APPENDED,{parent:t,pending:i,timeRanges:a}),r._needsFlush||r.doAppending(),r.updateMediaElementDuration(),0===i&&r.flushLiveBackBuffer()},r._onSBUpdateError=function(e){d["logger"].error("sourceBuffer error:",e),r.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_APPENDING_ERROR,fatal:!1})},r.config=t.config,r}Rt(t,e);var r=t.prototype;return r.destroy=function(){h.prototype.destroy.call(this)},r.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(!i)throw Error("Level PTS Updated and source buffer for audio uninitalized");var a=Math.abs(i.timestampOffset-e.start);if(a>.1){var n=i.updating;try{i.abort()}catch(s){d["logger"].warn("can not abort audio buffer: "+s)}n?this.audioTimestampOffset=e.start:(d["logger"].warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}},r.onManifestParsed=function(e){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e.altAudio?2:1,d["logger"].log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},r.onMediaAttaching=function(e){var t=this.media=e.media;if(t&&Dt){var r=this.mediaSource=new Dt;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}},r.onMediaDetaching=function(){d["logger"].log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(t){d["logger"].warn("onMediaDetaching:"+t.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.media&&(this._objectUrl&&window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):d["logger"].warn("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.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.hls.trigger(u["default"].MEDIA_DETACHED)},r.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},r.onBufferReset=function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];try{r&&(this.mediaSource&&this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this._onSBUpdateEnd),r.removeEventListener("error",this._onSBUpdateError))}catch(i){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},r.onBufferCodecs=function(e){var t=this;Object.keys(this.sourceBuffer).length||(Object.keys(e).forEach((function(r){t.pendingTracks[r]=e[r]})),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},r.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var a=e[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var n=a.levelCodec||a.codec,s=a.container+";codecs="+n;d["logger"].log("creating sourceBuffer("+s+")");try{var l=t[i]=r.addSourceBuffer(s);l.addEventListener("updateend",this._onSBUpdateEnd),l.addEventListener("error",this._onSBUpdateError),this.tracks[i]={buffer:l,codec:n,id:a.id,container:a.container,levelCodec:a.levelCodec}}catch(c){d["logger"].error("error while trying to add sourceBuffer:"+c.message),this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].BUFFER_ADD_CODEC_ERROR,fatal:!1,err:c,mimeType:s})}}this.hls.trigger(u["default"].BUFFER_CREATED,{tracks:this.tracks})},r.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},r.onBufferEos=function(e){for(var t in this.sourceBuffer)if(!e.type||e.type===t){var r=this.sourceBuffer[t];r&&!r.ended&&(r.ended=!0,d["logger"].log(t+" sourceBuffer now EOS"))}this.checkEos()},r.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var i=e[r];if(i){if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}}d["logger"].log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(a){d["logger"].warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},r.onBufferFlushing=function(e){e.type?this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}):(this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"video"}),this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"audio"})),this.flushBufferCounter=0,this.doFlush()},r.flushLiveBackBuffer=function(){if(this._live){var e=this.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))if(this.media)for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),a=t-Math.max(e,this._levelTargetDuration),n=i.length-1;n>=0;n--){var s=i[n],o=r[s];if(o){var l=o.buffered;l.length>0&&a>l.start(0)&&this.removeBufferRange(s,o,0,a)&&this.hls.trigger(u["default"].LIVE_BACK_BUFFER_REACHED,{bufferEnd:a})}}else d["logger"].error("flushLiveBackBuffer called without attaching media")}},r.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},r.updateMediaElementDuration=function(){var e,t=this.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer){var i=this.sourceBuffer[r];if(i&&!0===i.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(d["logger"].log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(l["isFiniteNumber"])(e))&&(d["logger"].log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},r.doFlush=function(){while(this.flushRange.length){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var a=r[i];a&&(t+=a.buffered.length)}}catch(n){d["logger"].error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(u["default"].BUFFER_FLUSHED)}},r.doAppending=function(){var e=this.config,t=this.hls,r=this.segments,i=this.sourceBuffer;if(Object.keys(i).length){if(!this.media||this.media.error)return this.segments=[],void d["logger"].error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var a=r.shift();if(a)try{var n=i[a.type];if(!n)return void this._onSBUpdateEnd();if(n.updating)return void r.unshift(a);n.ended=!1,this.parent=a.parent,n.appendBuffer(a.data),this.appendError=0,this.appended++,this.appending=!0}catch(l){d["logger"].error("error while trying to append buffer:"+l.message),r.unshift(a);var s={type:o["ErrorTypes"].MEDIA_ERROR,parent:a.parent,details:"",fatal:!1};22===l.code?(this.segments=[],s.details=o["ErrorDetails"].BUFFER_FULL_ERROR):(this.appendError++,s.details=o["ErrorDetails"].BUFFER_APPEND_ERROR,this.appendError>e.appendErrorMaxRetry&&(d["logger"].log("fail "+e.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],s.fatal=!0)),t.trigger(u["default"].ERROR,s)}}}},r.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var a="null";if(this.media&&(a=this.media.currentTime.toFixed(3)),d["logger"].log("flushBuffer,pos/start/end: "+a+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return d["logger"].warn("abort flushing too many retries"),!0;var n=i[r];if(n){if(n.ended=!1,n.updating)return d["logger"].warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,n,e,t))return this.flushBufferCounter++,!1}return d["logger"].log("buffer flushed"),!0},r.removeBufferRange=function(e,t,r,i){try{for(var a=0;a<t.buffered.length;a++){var n=t.buffered.start(a),s=t.buffered.end(a),o=Math.max(n,r),l=Math.min(s,i);if(Math.min(l,s)-o>.5){var u="null";return this.media&&(u=this.media.currentTime.toString()),d["logger"].log("sb remove "+e+" ["+o+","+l+"], of ["+n+","+s+"], pos:"+u),t.remove(o,l),!0}}}catch(c){d["logger"].warn("removeBufferRange failed",c)}return!1},t}(h),wt=Lt;function kt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function It(e,t,r){return t&&kt(e.prototype,t),r&&kt(e,r),e}function Ot(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Ct=function(e){function t(t){var r;return r=e.call(this,t,u["default"].FPS_DROP_LEVEL_CAPPING,u["default"].MEDIA_ATTACHING,u["default"].MANIFEST_PARSED,u["default"].BUFFER_CODECS,u["default"].MEDIA_DETACHING)||this,r.autoLevelCapping=Number.POSITIVE_INFINITY,r.firstLevel=null,r.levels=[],r.media=null,r.restrictedLevels=[],r.timer=null,r}Ot(t,e);var r=t.prototype;return r.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this.stopCapping())},r.onFpsDropLevelCapping=function(e){t.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)},r.onMediaAttaching=function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null},r.onManifestParsed=function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},r.onBufferCodecs=function(e){var t=this.hls;t.config.capLevelToPlayerSize&&e.video&&this.startCapping()},r.onLevelsUpdated=function(e){this.levels=e.levels},r.onMediaDetaching=function(){this.stopCapping()},r.detectPlayerSize=function(){if(this.media){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},r.getMaxLevel=function(e){var r=this;if(!this.levels)return-1;var i=this.levels.filter((function(i,a){return t.isLevelAllowed(a,r.restrictedLevels)&&a<=e}));return t.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},r.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},r.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},t.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},t.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var i=function(e,t){return!t||(e.width!==t.width||e.height!==t.height)},a=e.length-1,n=0;n<e.length;n+=1){var s=e[n];if((s.width>=t||s.height>=r)&&i(s,e[n+1])){a=n;break}}return a},It(t,[{key:"mediaWidth",get:function(){var e,r=this.media;return r&&(e=r.width||r.clientWidth||r.offsetWidth,e*=t.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,r=this.media;return r&&(e=r.height||r.clientHeight||r.offsetHeight,e*=t.contentScaleFactor),e}}],[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(t){}return e}}]),t}(h),Pt=Ct;function xt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Ft=window,Mt=Ft.performance,Nt=function(e){function t(t){return e.call(this,t,u["default"].MEDIA_ATTACHING)||this}xt(t,e);var r=t.prototype;return r.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},r.onMediaAttaching=function(e){var t=this.hls.config;if(t.capLevelOnFPSDrop){var r=this.video=e.media instanceof window.HTMLVideoElement?e.media:null;"function"===typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod)}},r.checkFPS=function(e,t,r){var i=Mt.now();if(t){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(u["default"].FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var c=l.currentLevel;d["logger"].warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=c)&&(c-=1,l.trigger(u["default"].FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},r.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},t}(h),Ut=Nt,Bt=window,Gt=Bt.performance,Kt=Bt.XMLHttpRequest,jt=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:Gt.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e,t=this.context;e=this.loader=new Kt;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(a){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(a){return void this.callbacks.onError({code:e.status,text:a.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},t.readystatechange=function(e){var t=e.currentTarget,r=t.readyState,i=this.stats,a=this.context,n=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(Gt.now(),i.trequest)),4===r){var s=t.status;if(s>=200&&s<300){var o,l;i.tload=Math.max(i.tfirst,Gt.now()),"arraybuffer"===a.responseType?(o=t.response,l=o.byteLength):(o=t.responseText,l=o.length),i.loaded=i.total=l;var u={url:t.responseURL,data:o};this.callbacks.onSuccess(u,i,a,t)}else i.retry>=n.maxRetry||s>=400&&s<499?(d["logger"].error(s+" while loading "+a.url),this.callbacks.onError({code:s,text:t.statusText},a,t)):(d["logger"].warn(s+" while loading "+a.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,n.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),n.timeout)},t.loadtimeout=function(){d["logger"].warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)},e}(),Ht=jt;function Vt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Wt(e,t,r){return t&&Vt(e.prototype,t),r&&Vt(e,r),e}function Yt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var qt=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MANIFEST_LOADING,u["default"].MANIFEST_PARSED,u["default"].AUDIO_TRACK_LOADED,u["default"].AUDIO_TRACK_SWITCHED,u["default"].LEVEL_LOADED,u["default"].ERROR)||this,r._trackId=-1,r._selectDefaultTrack=!0,r.tracks=[],r.trackIdBlacklist=Object.create(null),r.audioGroupId=null,r}Yt(t,e);var r=t.prototype;return r.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},r.onManifestParsed=function(e){var t=this.tracks=e.audioTracks||[];this.hls.trigger(u["default"].AUDIO_TRACKS_UPDATED,{audioTracks:t}),this._selectAudioGroup(this.hls.nextLoadLevel)},r.onAudioTrackLoaded=function(e){if(e.id>=this.tracks.length)d["logger"].warn("Invalid audio track id:",e.id);else{if(d["logger"].log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}},r.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},r.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},r.onError=function(e){e.type===o["ErrorTypes"].NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===o["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR&&(d["logger"].warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},r._setAudioTrack=function(e){if(this._trackId===e&&this.tracks[this._trackId].details)d["logger"].debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)d["logger"].warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];d["logger"].log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,i=t.type,a=t.id;this.hls.trigger(u["default"].AUDIO_TRACK_SWITCHING,{id:a,type:i,url:r}),this._loadTrackDetailsIfNeeded(t)}},r.doTick=function(){this._updateTrack(this._trackId)},r._selectAudioGroup=function(e){var t=this.hls.levels[e];if(t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}},r._selectInitialAudioTrack=function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var a=t.filter((function(e){return e.default}));a.length?t=a:d["logger"].warn("No default audio tracks defined")}var n=!1,s=function(){t.forEach((function(t){n||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),n=!0)}))};s(),n||(i=null,s()),n||(d["logger"].error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:o["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},r._needsTrackLoading=function(e){var t=e.details,r=e.url;return!(t&&!t.live)&&!!r},r._loadTrackDetailsIfNeeded=function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;d["logger"].log("loading audio-track playlist for id: "+r),this.hls.trigger(u["default"].AUDIO_TRACK_LOADING,{url:t,id:r})}},r._updateTrack=function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,d["logger"].log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}},r._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,a=t.groupId;d["logger"].warn("Loading failed on audio track id: "+e+", group-id: "+a+', name/language: "'+r+'" / "'+i+'"');for(var n=e,s=0;s<this.tracks.length;s++)if(!this.trackIdBlacklist[s]){var o=this.tracks[s];if(o.name===r){n=s;break}}n!==e?(d["logger"].log("Attempting audio-track fallback id:",n,"group-id:",this.tracks[n].groupId),this._setAudioTrack(n)):d["logger"].warn('No fallback audio-track found for name/language: "'+r+'" / "'+i+'"')},Wt(t,[{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}]),t}(He),zt=qt;function Xt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Qt(e,t,r){return t&&Xt(e.prototype,t),r&&Xt(e,r),e}function Jt(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var $t=window,Zt=$t.performance,er=100,tr=function(e){function t(t,r){var i;return i=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHING,u["default"].AUDIO_TRACKS_UPDATED,u["default"].AUDIO_TRACK_SWITCHING,u["default"].AUDIO_TRACK_LOADED,u["default"].KEY_LOADED,u["default"].FRAG_LOADED,u["default"].FRAG_PARSING_INIT_SEGMENT,u["default"].FRAG_PARSING_DATA,u["default"].FRAG_PARSED,u["default"].ERROR,u["default"].BUFFER_RESET,u["default"].BUFFER_CREATED,u["default"].BUFFER_APPENDED,u["default"].BUFFER_FLUSHED,u["default"].INIT_PTS_FOUND)||this,i.fragmentTracker=r,i.config=t.config,i.audioCodecSwap=!1,i._state=We.STOPPED,i.initPTS=[],i.waitingFragment=null,i.videoTrackCC=null,i}Jt(t,e);var r=t.prototype;return r.onInitPtsFound=function(e){var t=e.id,r=e.frag.cc,i=e.initPTS;"main"===t&&(this.initPTS[r]=i,this.videoTrackCC=r,d["logger"].log("InitPTS for cc: "+r+" found from video track: "+i),this.state===We.WAITING_INIT_PTS&&this.tick())},r.startLoad=function(e){if(this.tracks){var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(er),this.fragLoadError=0,t>0&&-1===e?(d["logger"].log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=We.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=We.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=We.STOPPED},r.doTick=function(){var e,t,r,i=this.hls,a=i.config;switch(this.state){case We.ERROR:case We.PAUSED:case We.BUFFER_FLUSHING:break;case We.STARTING:this.state=We.WAITING_TRACK,this.loadedmetadata=!1;break;case We.IDLE:var n=this.tracks;if(!n)break;if(!this.media&&(this.startFragRequested||!a.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(e=this.nextLoadPosition,void 0===e)break;var s=this.mediaBuffer?this.mediaBuffer:this.media,o=this.videoBuffer?this.videoBuffer:this.media,c=re.bufferInfo(s,e,a.maxBufferHole),f=re.bufferInfo(o,e,a.maxBufferHole),h=c.len,g=c.end,p=this.fragPrevious,v=Math.min(a.maxBufferLength,a.maxMaxBufferLength),m=Math.max(v,f.len),y=this.audioSwitch,E=this.trackId;if((h<m||y)&&E<n.length){if(r=n[E].details,"undefined"===typeof r){this.state=We.WAITING_TRACK;break}if(!y&&this._streamEnded(c,r))return this.hls.trigger(u["default"].BUFFER_EOS,{type:"audio"}),void(this.state=We.ENDED);var T,S=r.fragments,b=S.length,_=S[0].start,A=S[b-1].start+S[b-1].duration;if(y)if(r.live&&!r.PTSKnown)d["logger"].log("switching audiotrack, live stream, unknown PTS,load first fragment"),g=0;else if(g=e,r.PTSKnown&&e<_){if(!(c.end>_||c.nextStart))return;d["logger"].log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=_+.05}if(r.initSegment&&!r.initSegment.data)T=r.initSegment;else if(g<=_){if(T=S[0],null!==this.videoTrackCC&&T.cc!==this.videoTrackCC&&(T=Re(S,this.videoTrackCC)),r.live&&T.loadIdx&&T.loadIdx===this.fragLoadIdx){var R=c.nextStart?c.nextStart:_;return d["logger"].log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(R+.05)),void(this.media.currentTime=R+.05)}}else{var D,L=a.maxFragLookUpTolerance,w=p?S[p.sn-S[0].sn+1]:void 0,k=function(e){var t=Math.min(L,e.duration);return e.start+e.duration-t<=g?1:e.start-t>g&&e.start?-1:0};g<A?(g>A-L&&(L=0),D=w&&!k(w)?w:te.search(S,k)):D=S[b-1],D&&(T=D,_=D.start,p&&T.level===p.level&&T.sn===p.sn&&(T.sn<r.endSN?(T=S[T.sn+1-r.startSN],d["logger"].log("SN just loaded, load next one: "+T.sn)):T=null))}T&&(T.encrypted?(d["logger"].log("Loading key for "+T.sn+" of ["+r.startSN+" ,"+r.endSN+"],track "+E),this.state=We.KEY_LOADING,i.trigger(u["default"].KEY_LOADING,{frag:T})):(d["logger"].log("Loading "+T.sn+", cc: "+T.cc+" of ["+r.startSN+" ,"+r.endSN+"],track "+E+", currentTime:"+e+",bufferEnd:"+g.toFixed(3)),this.fragCurrent=T,(y||this.fragmentTracker.getState(T)===$.NOT_LOADED)&&("initSegment"!==T.sn&&(this.startFragRequested=!0),Object(l["isFiniteNumber"])(T.sn)&&(this.nextLoadPosition=T.start+T.duration),i.trigger(u["default"].FRAG_LOADING,{frag:T}),this.state=We.FRAG_LOADING)))}break;case We.WAITING_TRACK:t=this.tracks[this.trackId],t&&t.details&&(this.state=We.IDLE);break;case We.FRAG_LOADING_WAITING_RETRY:var I=Zt.now(),O=this.retryDate;s=this.media;var C=s&&s.seeking;(!O||I>=O||C)&&(d["logger"].log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=We.IDLE);break;case We.WAITING_INIT_PTS:var P=this.videoTrackCC;if(void 0===this.initPTS[P])break;var x=this.waitingFragment;if(x){var F=x.frag.cc;P!==F?(t=this.tracks[this.trackId],t.details&&t.details.live&&(d["logger"].warn("Waiting fragment CC ("+F+") does not match video track CC ("+P+")"),this.waitingFragment=null,this.state=We.IDLE)):(this.state=We.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=We.IDLE;break;case We.STOPPED:case We.FRAG_LOADING:case We.PARSING:case We.PARSED:case We.ENDED:break;default:break}},r.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},r.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(d["logger"].log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},r.onAudioTracksUpdated=function(e){d["logger"].log("audio tracks updated"),this.tracks=e.audioTracks},r.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=We.PAUSED,this.waitingFragment=null,t?this.setInterval(er):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=We.IDLE),this.tick()},r.onAudioTrackLoaded=function(e){var t=e.details,r=e.id,i=this.tracks[r],a=t.totalduration,n=0;if(d["logger"].log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.live){var s=i.details;s&&t.fragments.length>0?(me(s,t),n=t.fragments[0].start,t.PTSKnown?d["logger"].log("live audio playlist sliding:"+n.toFixed(3)):d["logger"].log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,d["logger"].log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(i.details=t,!this.startFragRequested){if(-1===this.startPosition){var o=t.startTimeOffset;Object(l["isFiniteNumber"])(o)?(d["logger"].log("start time offset found in playlist, adjust startPosition to "+o),this.startPosition=o):t.live?(this.startPosition=this.computeLivePosition(n,t),d["logger"].log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===We.WAITING_TRACK&&(this.state=We.IDLE),this.tick()},r.onKeyLoaded=function(){this.state===We.KEY_LOADING&&(this.state=We.IDLE,this.tick())},r.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag;if(this.state===We.FRAG_LOADING&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var i=this.tracks[this.trackId],a=i.details,n=a.totalduration,s=t.level,o=t.sn,l=t.cc,c=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",f=this.stats=e.stats;if("initSegment"===o)this.state=We.IDLE,f.tparsed=f.tbuffered=Zt.now(),a.initSegment.data=e.payload,this.hls.trigger(u["default"].FRAG_BUFFERED,{stats:f,frag:t,id:"audio"}),this.tick();else{this.state=We.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new he(this.hls,"audio"));var h=this.initPTS[l],g=a.initSegment?a.initSegment.data:[];if(a.initSegment||void 0!==h){this.pendingBuffering=!0,d["logger"].log("Demuxing "+o+" of ["+a.startSN+" ,"+a.endSN+"],track "+s);var p=!1;this.demuxer.push(e.payload,g,c,null,t,n,p,h)}else d["logger"].log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+o+" of ["+a.startSN+" ,"+a.endSN+"],track "+s),this.waitingFragment=e,this.state=We.WAITING_INIT_PTS}}this.fragLoadError=0},r.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===We.PARSING){var i,a=e.tracks;if(a.video&&delete a.video,i=a.audio,i){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(u["default"].BUFFER_CODECS,a),d["logger"].log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var n=i.initSegment;if(n){var s={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[s]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u["default"].BUFFER_APPENDING,s))}this.tick()}}},r.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&i.sn===r.sn&&i.level===r.level&&this.state===We.PARSING){var a=this.trackId,n=this.tracks[a],s=this.hls;Object(l["isFiniteNumber"])(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),r.addElementaryStream(m.AUDIO),d["logger"].log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),ve(n.details,r,e.startPTS,e.endPTS);var c=this.audioSwitch,f=this.media,h=!1;if(c)if(f&&f.readyState){var g=f.currentTime;d["logger"].log("switching audio track : currentTime:"+g),g>=e.startPTS&&(d["logger"].log("switching audio track : flushing all audio"),this.state=We.BUFFER_FLUSHING,s.trigger(u["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),h=!0,this.audioSwitch=!1,s.trigger(u["default"].AUDIO_TRACK_SWITCHED,{id:a}))}else this.audioSwitch=!1,s.trigger(u["default"].AUDIO_TRACK_SWITCHED,{id:a});var p=this.pendingData;if(!p)return d["logger"].warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void s.trigger(u["default"].ERROR,{type:o["ErrorTypes"].MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach((function(t){t&&t.length&&p.push({type:e.type,data:t,parent:"audio",content:"data"})})),!h&&p.length&&(p.forEach((function(e){t.state===We.PARSING&&(t.pendingBuffering=!0,t.hls.trigger(u["default"].BUFFER_APPENDING,e))})),this.pendingData=[],this.appended=!0)),this.tick()}},r.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===We.PARSING&&(this.stats.tparsed=Zt.now(),this.state=We.PARSED,this._checkAppendedParsed())},r.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},r.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},r.onBufferAppended=function(e){if("audio"===e.parent){var t=this.state;t!==We.PARSING&&t!==We.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},r._checkAppendedParsed=function(){if(this.state===We.PARSED&&(!this.appended||!this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=Zt.now(),r.trigger(u["default"].FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;i&&d["logger"].log("audio buffered : "+_e.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(u["default"].AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=We.IDLE}this.tick()}},r.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case o["ErrorDetails"].FRAG_LOAD_ERROR:case o["ErrorDetails"].FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var a=this.config;if(i<=a.fragLoadingMaxRetry){this.fragLoadError=i;var n=Math.min(Math.pow(2,i-1)*a.fragLoadingRetryDelay,a.fragLoadingMaxRetryTimeout);d["logger"].warn("AudioStreamController: frag loading failed, retry in "+n+" ms"),this.retryDate=Zt.now()+n,this.state=We.FRAG_LOADING_WAITING_RETRY}else d["logger"].error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=We.ERROR}break;case o["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR:case o["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:case o["ErrorDetails"].KEY_LOAD_ERROR:case o["ErrorDetails"].KEY_LOAD_TIMEOUT:this.state!==We.ERROR&&(this.state=e.fatal?We.ERROR:We.IDLE,d["logger"].warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case o["ErrorDetails"].BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===We.PARSING||this.state===We.PARSED)){var s=this.mediaBuffer,l=this.media.currentTime,c=s&&re.isBuffered(s,l)&&re.isBuffered(s,l+.5);if(c){var f=this.config;f.maxMaxBufferLength>=f.maxBufferLength&&(f.maxMaxBufferLength/=2,d["logger"].warn("AudioStreamController: reduce max buffer length to "+f.maxMaxBufferLength+"s")),this.state=We.IDLE}else d["logger"].warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=We.BUFFER_FLUSHING,this.hls.trigger(u["default"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}break;default:break}},r.onBufferFlushed=function(){var e=this,t=this.pendingData;t&&t.length?(d["logger"].log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach((function(t){e.hls.trigger(u["default"].BUFFER_APPENDING,t)})),this.appended=!0,this.pendingData=[],this.state=We.PARSED):(this.state=We.IDLE,this.fragPrevious=null,this.tick())},Qt(t,[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,d["logger"].log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}]),t}(Ye),rr=tr,ir=function(){if("undefined"!==typeof window&&window.VTTCue)return window.VTTCue;var e="auto",t={"":!0,lr:!0,rl:!0},r={start:!0,middle:!0,end:!0,left:!0,right:!0};function i(e){if("string"!==typeof e)return!1;var r=t[e.toLowerCase()];return!!r&&e.toLowerCase()}function a(e){if("string"!==typeof e)return!1;var t=r[e.toLowerCase()];return!!t&&e.toLowerCase()}function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]=r[i]}return e}function s(t,r,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",d=!1,c=t,f=r,h=s,g=null,p="",v=!0,m="auto",y="start",E=50,T="middle",S=50,b="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return c},set:function(e){if("number"!==typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return f},set:function(e){if("number"!==typeof e)throw new TypeError("End time must be set to a number.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return g},set:function(e){g=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return p},set:function(e){var t=i(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");p=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return v},set:function(e){v=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return m},set:function(t){if("number"!==typeof t&&t!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return E},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return T},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return b},set:function(e){var t=a(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){var e=window.WebVTT;return e.convertCueToDOMTree(window,this.text)},s}(),ar=function(){return{decode:function(e){if(!e)return"";if("string"!==typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function nr(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new ar,this.regionList=[]}function sr(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}function or(){this.values=Object.create(null)}function lr(e,t,r,i){var a=i?e.split(i):[e];for(var n in a)if("string"===typeof a[n]){var s=a[n].split(r);if(2===s.length){var o=s[0],l=s[1];t(o,l)}}}or.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},integer:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},percent:function(e,t){return!!(t.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(t=parseFloat(t),t>=0&&t<=100))&&(this.set(e,t),!0)}};var ur=new ir(0,0,0),dr="middle"===ur.align?"middle":"center";function cr(e,t,r){var i=e;function a(){var t=sr(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(e,t){var i=new or;lr(e,(function(e,t){switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),s=n[0];i.integer(e,s),i.percent(e,s)&&i.set("snapToLines",!1),i.alt(e,s,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",dr,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",dr,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",dr,"end","left","right"]);break}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===ur.line&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",dr);var n=i.get("position","auto");"auto"===n&&50===ur.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=a(),s(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),s(),t.endTime=a(),s(),n(e,t)}function fr(e){return e.replace(/<br(?: \/)?>/gi,"\n")}nr.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;e=fr(e);while(r<e.length&&"\r"!==e[r]&&"\n"!==e[r])++r;var i=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),i}function i(e){lr(e,(function(e,t){switch(e){case"Region":break}}),/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;a=r();var n=a.match(/^()?WEBVTT([ \t].*)?$/);if(!n||!n[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}var s=!1;while(t.buffer){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:a=r(),t.state){case"HEADER":/:/.test(a)?i(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new ir(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":try{cr(a,t.cue,t.regionList)}catch(l){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var o=-1!==a.indexOf("--\x3e");if(!a||o&&(s=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID");continue}}}catch(l){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var e=this;try{if(e.buffer+=e.decoder.decode(),(e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){throw t}return e.onflush&&e.onflush(),this}};var hr=nr;function gr(e,t,r,i){for(var a,n,s,o,l,u=window.VTTCue||TextTrackCue,d=0;d<i.rows.length;d++)if(a=i.rows[d],s=!0,o=0,l="",!a.isEmpty()){for(var c=0;c<a.chars.length;c++)a.chars[c].uchar.match(/\s/)&&s?o++:(l+=a.chars[c].uchar,s=!1);a.cueStartTime=t,t===r&&(r+=1e-4),n=new u(t,r,fr(l.trim())),o>=16?o--:o++,navigator.userAgent.match(/Firefox\//)?n.line=d+1:n.line=d>7?d-2:d+1,n.align="left",n.position=Math.max(0,Math.min(100,o/32*100)),e.addCue(n)}}var pr,vr={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},mr=function(e){var t=e;return vr.hasOwnProperty(e)&&(t=vr[e]),String.fromCharCode(t)},yr=15,Er=100,Tr={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Sr={17:2,18:4,21:6,22:8,23:10,19:13,20:15},br={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_r={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ar=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(function(e){e[e["ERROR"]=0]="ERROR",e[e["TEXT"]=1]="TEXT",e[e["WARNING"]=2]="WARNING",e[e["INFO"]=2]="INFO",e[e["DEBUG"]=3]="DEBUG",e[e["DATA"]=3]="DATA"})(pr||(pr={}));var Rr={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e];this.verboseLevel}},Dr=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},Lr=function(){function e(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),wr=function(){function e(e,t,r,i,a,n){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Lr(t,r,i,a,n)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),kr=function(){function e(){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.chars=[];for(var e=0;e<Er;e++)this.chars.push(new wr);this.pos=0,this.currPenState=new Lr}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<Er;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<Er;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<Er;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(Rr.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>Er&&(Rr.log("ERROR","Too large cursor position "+this.pos),this.pos=Er)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=mr(e);this.pos>=Er?Rr.log("ERROR","Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<Er;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<Er;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e);var t=this.chars[this.pos];t.setPenState(this.currPenState)},e}(),Ir=function(){function e(){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.rows=[];for(var e=0;e<yr;e++)this.rows.push(new kr);this.currRow=yr-1,this.nrRollUpRows=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<yr;e++)this.rows[e].clear();this.currRow=yr-1},t.equals=function(e){for(var t=!0,r=0;r<yr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<yr;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<yr;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){var e=this.rows[this.currRow];e.backSpace()},t.clearToEndOfRow=function(){var e=this.rows[this.currRow];e.clearToEndOfRow()},t.insertChar=function(e){var t=this.rows[this.currRow];t.insertChar(e)},t.setPen=function(e){var t=this.rows[this.currRow];t.setPenStyles(e)},t.moveCursor=function(e){var t=this.rows[this.currRow];t.moveCursor(e)},t.setCursor=function(e){Rr.log("INFO","setCursor: "+e);var t=this.rows[this.currRow];t.setCursor(e)},t.setPAC=function(e){Rr.log("INFO","pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<yr;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime;if(n&&Rr.time&&n<Rr.time)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[i+s])}}this.currRow=t;var o=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,u=Math.max(l-1,0);o.setCursor(e.indent),e.color=o.chars[u].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)},t.setBkgData=function(e){Rr.log("INFO","bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){Rr.log("TEXT",this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),Rr.log("INFO","Rolling up")}else Rr.log("DEBUG","roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<yr;a++){var n=this.rows[a].getTextString();n&&(i=a+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),Or=function(){function e(e,t){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.lastCueEndTime=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ir,this.nonDisplayedMemory=new Ir,this.lastOutputScreen=new Ir,this.currRollUpRow=this.displayedMemory.rows[yr-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[yr-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,Rr.log("INFO","MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";Rr.log("INFO",r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(Rr.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){Rr.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){Rr.log("INFO","BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){Rr.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){Rr.log("INFO","RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){Rr.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){Rr.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){Rr.log("INFO","TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){Rr.log("INFO","RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){Rr.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){Rr.log("INFO","CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){Rr.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(Rr.log("INFO","EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,Rr.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){Rr.log("INFO","TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}Rr.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=Rr.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),Cr=function(){function e(e,t,r){this.field=void 0,this.outputs=void 0,this.channels=void 0,this.currChNr=void 0,this.lastCmdA=void 0,this.lastCmdB=void 0,this.lastTime=void 0,this.dataCounters=void 0,this.field=e||1,this.outputs=[t,r],this.channels=[new Or(1,t),new Or(2,r)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i,a,n=!1;this.lastTime=e,Rr.setTime(e);for(var s=0;s<t.length;s+=2)if(i=127&t[s],a=127&t[s+1],0!==i||0!==a){if(Rr.log("DATA","["+Dr([t[s],t[s+1]])+"] -> ("+Dr([i,a])+")"),r=this.parseCmd(i,a),r||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(n=this.parseChars(i,a),n))if(this.currChNr&&this.currChNr>=0){var o=this.channels[this.currChNr-1];o.insertChars(n)}else Rr.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,Rr.log("WARNING","Couldn't parse cleaned data "+Dr([i,a])+" orig: "+Dr([t[s],t[s+1]])))}else this.dataCounters.padding+=2},t.parseCmd=function(e,t){var r=null,i=(20===e||28===e)&&t>=32&&t<=47,a=(23===e||31===e)&&t>=33&&t<=35;if(!i&&!a)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,Rr.log("DEBUG","Repeated command ("+Dr([e,t])+") is dropped"),!0;r=20===e||23===e?1:2;var n=this.channels[r-1];return 20===e||28===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.parseMidrow=function(e,t){var r=null;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currChNr)return Rr.log("ERROR","Mismatch channel in midrow parsing"),!1;var i=this.channels[r-1];return i.ccMIDROW(t),Rr.log("DEBUG","MIDROW ("+Dr([e,t])+")"),!0}return!1},t.parsePAC=function(e,t){var r=null,i=null,a=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(16===e||24===e)&&t>=64&&t<=95;if(!a&&!n)return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=e<=23?1:2,i=t>=64&&t<=95?1===r?Tr[e]:br[e]:1===r?Sr[e]:_r[e];var s=this.interpretPAC(i,t),o=this.channels[r-1];return o.setPAC(s),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0},t.interpretPAC=function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1===(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.parseChars=function(e,t){var r=null,i=null,a=null;if(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19){var n=t;n=17===a?t+80:18===a?t+112:t+144,Rr.log("INFO","Special char '"+mr(n)+"' in channel "+r),i=[n]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var s=Dr(i);Rr.log("DEBUG","Char codes = "+s.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.parseBackgroundAttributes=function(e,t){var r,i,a,n,s=(16===e||24===e)&&t>=32&&t<=47,o=(23===e||31===e)&&t>=45&&t<=47;return!(!s&&!o)&&(r={},16===e||24===e?(i=Math.floor((t-32)/2),r.background=Ar[i],t%2===1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0)),a=e<24?1:2,n=this.channels[a-1],n.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)},t.reset=function(){for(var e=0;e<this.channels.length;e++)this.channels[e]&&this.channels[e].reset();this.lastCmdA=null,this.lastCmdB=null},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++)this.channels[t]&&this.channels[t].cueSplitAtTime(e)},e}(),Pr=Cr,xr=function(){function e(e,t){this.timelineController=void 0,this.trackName=void 0,this.startTime=void 0,this.endTime=void 0,this.screen=void 0,this.timelineController=e,this.trackName=t,this.startTime=null,this.endTime=null,this.screen=null}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e}(),Fr=function(e,t,r){return e.substr(r||0,t.length)===t},Mr=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),a=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!Object(l["isFiniteNumber"])(t)||!Object(l["isFiniteNumber"])(r)||!Object(l["isFiniteNumber"])(i)||!Object(l["isFiniteNumber"])(a))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*i,t+=36e5*a,t},Nr=function(e){var t=5381,r=e.length;while(r)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},Ur=function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);while(a&&a.new)e.ccOffset+=i.start-a.start,i.new=!1,i=a,a=e[i.prevCC];e.presentationOffset=r},Br={parse:function(e,t,r,i,a,n){var s,o=/\r\n|\n\r|\n|\r/g,l=Object(nt["utf8ArrayToStr"])(new Uint8Array(e)).trim().replace(o,"\n").split("\n"),u="00:00.000",d=0,c=0,f=0,h=[],g=!0,p=!1,v=new hr;v.oncue=function(e){var t=r[i],a=r.ccOffset;t&&t.new&&(void 0!==c?a=r.ccOffset=t.start:Ur(r,i,f)),f&&(a=f-r.presentationOffset),p&&(e.startTime+=a-c,e.endTime+=a-c),e.id=Nr(e.startTime.toString())+Nr(e.endTime.toString())+Nr(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&h.push(e)},v.onparsingerror=function(e){s=e},v.onflush=function(){s&&n?n(s):a(h)},l.forEach((function(e){if(g){if(Fr(e,"X-TIMESTAMP-MAP=")){g=!1,p=!0,e.substr(16).split(",").forEach((function(e){Fr(e,"LOCAL:")?u=e.substr(6):Fr(e,"MPEGTS:")&&(d=parseInt(e.substr(7)))}));try{t+(9e4*r[i].start||0)<0&&(t+=8589934592),d-=t,c=Mr(u)/1e3,f=d/9e4}catch(a){p=!1,s=a}return}""===e&&(g=!1)}v.parse(e+"\n")})),v.flush()}},Gr=Br;function Kr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function jr(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Hr=function(e){function t(t){var r;if(r=e.call(this,t,u["default"].MEDIA_ATTACHING,u["default"].MEDIA_DETACHING,u["default"].FRAG_PARSING_USERDATA,u["default"].FRAG_DECRYPTED,u["default"].MANIFEST_LOADING,u["default"].MANIFEST_LOADED,u["default"].FRAG_LOADED,u["default"].INIT_PTS_FOUND)||this,r.media=null,r.config=void 0,r.enabled=!0,r.Cues=void 0,r.textTracks=[],r.tracks=[],r.initPTS=[],r.unparsedVttFrags=[],r.cueRanges=[],r.captionsTracks={},r.captionsProperties=void 0,r.cea608Parser=void 0,r.lastSn=-1,r.prevCC=-1,r.vttCCs=null,r.hls=t,r.config=t.config,r.Cues=t.config.cueHandler,r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode}},r.config.enableCEA708Captions){var i=new xr(Kr(r),"textTrack1"),a=new xr(Kr(r),"textTrack2");r.cea608Parser=new Pr(0,i,a)}return r}jr(t,e);var r=t.prototype;return r.addCues=function(e,t,r,i){for(var a=this.cueRanges,n=!1,s=a.length;s--;){var o=a[s],l=Wr(o[0],o[1],t,r);if(l>=0&&(o[0]=Math.min(o[0],t),o[1]=Math.max(o[1],r),n=!0,l/(r-t)>.5))return}n||a.push([t,r]),this.Cues.newCue(this.captionsTracks[e],t,r,i)},r.onInitPtsFound=function(e){var t=this,r=e.frag,i=e.id,a=e.initPTS,n=this.unparsedVttFrags;"main"===i&&(this.initPTS[r.cc]=a),n.length&&(this.unparsedVttFrags=[],n.forEach((function(e){t.onFragLoaded(e)})))},r.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},r.createCaptionsTrack=function(e){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],n=a.label,s=a.languageCode;if(!r[e]){var o=this.getExistingTrack(e);if(o)r[e]=o,ot(r[e]),st(r[e],i);else{var l=this.createTextTrack("captions",n,s);l&&(l[e]=!0,r[e]=l)}}},r.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},r.destroy=function(){e.prototype.destroy.call(this)},r.onMediaAttaching=function(e){this.media=e.media,this._cleanTracks()},r.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){ot(e[t]),delete e[t]}))},r.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()},r._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)ot(t[r])}},r.onManifestLoaded=function(e){var t=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=e.subtitles||[];var r=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,i){var a;if(i<r.length){for(var n=null,s=0;s<r.length;s++)if(Vr(r[s],e)){n=r[s];break}n&&(a=n)}a||(a=t.createTextTrack("subtitles",e.name,e.lang)),e.default?a.mode=t.hls.subtitleDisplay?"showing":"hidden":a.mode="disabled",t.textTracks.push(a)}))}},r.onFragLoaded=function(e){var t=e.frag,r=e.payload,i=this.cea608Parser,a=this.initPTS,n=this.lastSn,s=this.unparsedVttFrags;if("main"===t.type){var o=t.sn;t.sn!==n+1&&i&&i.reset(),this.lastSn=o}else if("subtitle"===t.type)if(r.byteLength){if(!Object(l["isFiniteNumber"])(a[t.cc]))return s.push(e),void(a.length&&this.hls.trigger(u["default"].SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t}));var d=t.decryptdata;null!=d&&null!=d.key&&"AES-128"===d.method||this._parseVTTs(t,r)}else this.hls.trigger(u["default"].SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})},r._parseVTTs=function(e,t){var r=this.hls,i=this.prevCC,a=this.textTracks,n=this.vttCCs;n[e.cc]||(n[e.cc]={start:e.start,prevCC:i,new:!0},this.prevCC=e.cc),Gr.parse(t,this.initPTS[e.cc],n,e.cc,(function(t){var i=a[e.level];"disabled"!==i.mode?(t.forEach((function(e){if(!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){d["logger"].debug("Failed occurred on adding cues: "+r);var t=new window.TextTrackCue(e.startTime,e.endTime,e.text);t.id=e.id,i.addCue(t)}})),r.trigger(u["default"].SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})):r.trigger(u["default"].SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})}),(function(t){d["logger"].log("Failed to parse VTT cue: "+t),r.trigger(u["default"].SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})}))},r.onFragDecrypted=function(e){var t=e.frag,r=e.payload;if("subtitle"===t.type){if(!Object(l["isFiniteNumber"])(this.initPTS[t.cc]))return void this.unparsedVttFrags.push(e);this._parseVTTs(t,r)}},r.onFragParsingUserdata=function(e){if(this.enabled&&this.cea608Parser)for(var t=0;t<e.samples.length;t++){var r=e.samples[t].bytes;if(r){var i=this.extractCea608Data(r);this.cea608Parser.addData(e.samples[t].pts,i)}}},r.extractCea608Data=function(e){for(var t,r,i,a,n,s=31&e[0],o=2,l=[],u=0;u<s;u++)t=e[o++],r=127&e[o++],i=127&e[o++],a=0!==(4&t),n=3&t,0===r&&0===i||a&&0===n&&(l.push(r),l.push(i));return l},t}(h);function Vr(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function Wr(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}var Yr=Hr;function qr(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function zr(e,t,r){return t&&qr(e.prototype,t),r&&qr(e,r),e}function Xr(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Qr=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHING,u["default"].MANIFEST_LOADED,u["default"].SUBTITLE_TRACK_LOADED)||this,r.tracks=[],r.trackId=-1,r.media=null,r.stopped=!0,r.subtitleDisplay=!0,r.queuedDefaultTrack=null,r}Xr(t,e);var r=t.prototype;return r.destroy=function(){h.prototype.destroy.call(this)},r.onMediaAttached=function(e){var t=this;this.media=e.media,this.media&&(Object(l["isFiniteNumber"])(this.queuedDefaultTrack)&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=null),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval((function(){t.trackChangeListener()}),500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},r.onMediaDetaching=function(){if(this.media){this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),Object(l["isFiniteNumber"])(this.subtitleTrack)&&(this.queuedDefaultTrack=this.subtitleTrack);var e=Jr(this.media.textTracks);e.forEach((function(e){ot(e)})),this.subtitleTrack=-1,this.media=null}},r.onManifestLoaded=function(e){var t=this,r=e.subtitles||[];this.tracks=r,this.hls.trigger(u["default"].SUBTITLE_TRACKS_UPDATED,{subtitleTracks:r}),r.forEach((function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)}))},r.onSubtitleTrackLoaded=function(e){var t=this,r=e.id,i=e.details,a=this.trackId,n=this.tracks,s=n[a];if(r>=n.length||r!==a||!s||this.stopped)this._clearReloadTimer();else if(d["logger"].log("subtitle track "+r+" loaded"),i.live){var o=Se(s.details,i,e.stats.trequest);d["logger"].log("Reloading live subtitle playlist in "+o+"ms"),this.timer=setTimeout((function(){t._loadCurrentTrack()}),o)}else this._clearReloadTimer()},r.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},r.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},r._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},r._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(d["logger"].log("Loading subtitle track "+e),r.trigger(u["default"].SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},r._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;if(t){var a=Jr(t.textTracks);if(-1===e)[].slice.call(a).forEach((function(e){e.mode="disabled"}));else{var n=a[i];n&&(n.mode="disabled")}var s=a[e];s&&(s.mode=r?"showing":"hidden")}},r._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(l["isFiniteNumber"])(e)||e<-1||e>=r.length||(this.trackId=e,d["logger"].log("Switching to subtitle track "+e),t.trigger(u["default"].SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},r._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Jr(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}},zr(t,[{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.trackId!==e&&(this._toggleTrackModes(e),this._setSubtitleTrackInternal(e))}}]),t}(h);function Jr(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}var $r=Qr,Zr=r("./src/crypt/decrypter.js");function ei(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ti(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var ri,ii=window,ai=ii.performance,ni=500,si=function(e){function t(t,r){var i;return i=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHING,u["default"].ERROR,u["default"].KEY_LOADED,u["default"].FRAG_LOADED,u["default"].SUBTITLE_TRACKS_UPDATED,u["default"].SUBTITLE_TRACK_SWITCH,u["default"].SUBTITLE_TRACK_LOADED,u["default"].SUBTITLE_FRAG_PROCESSED,u["default"].LEVEL_UPDATED)||this,i.fragmentTracker=r,i.config=t.config,i.state=We.STOPPED,i.tracks=[],i.tracksBuffered=[],i.currentTrackId=-1,i.decrypter=new Zr["default"](t,t.config),i.lastAVStart=0,i._onMediaSeeking=i.onMediaSeeking.bind(ei(i)),i}ti(t,e);var r=t.prototype;return r.onSubtitleFragProcessed=function(e){var t=e.frag,r=e.success;if(this.fragPrevious=t,this.state=We.IDLE,r){var i=this.tracksBuffered[this.currentTrackId];if(i){for(var a,n=t.start,s=0;s<i.length;s++)if(n>=i[s].start&&n<=i[s].end){a=i[s];break}var o=t.start+t.duration;a?a.end=o:(a={start:n,end:o},i.push(a))}}},r.onMediaAttached=function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=We.IDLE},r.onMediaDetaching=function(){var e=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach((function(t){e.tracksBuffered[t.id]=[]})),this.media=null,this.state=We.STOPPED)},r.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=We.IDLE)},r.onSubtitleTracksUpdated=function(e){var t=this;d["logger"].log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach((function(e){t.tracksBuffered[e.id]=[]}))},r.onSubtitleTrackSwitch=function(e){if(this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(ni)}else this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,r=e.details,i=this.currentTrackId,a=this.tracks,n=a[i];t>=a.length||t!==i||!n||(r.live&&ye(n.details,r,this.lastAVStart),n.details=r,this.setInterval(ni))},r.onKeyLoaded=function(){this.state===We.KEY_LOADING&&(this.state=We.IDLE)},r.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag.decryptdata,i=e.frag,a=this.hls;if(this.state===We.FRAG_LOADING&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&e.payload.byteLength>0&&r&&r.key&&"AES-128"===r.method){var n=ai.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,(function(e){var t=ai.now();a.trigger(u["default"].FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:n,tdecrypt:t}})}))}},r.onLevelUpdated=function(e){var t=e.details,r=t.fragments;this.lastAVStart=r.length?r[0].start:0},r.doTick=function(){if(this.media)switch(this.state){case We.IDLE:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,a=this.tracks;if(!a||!a[t]||!a[t].details)break;var n,s=e.maxBufferHole,o=e.maxFragLookUpTolerance,l=Math.min(e.maxBufferLength,e.maxMaxBufferLength),c=re.bufferedInfo(this._getBuffered(),i.currentTime,s),f=c.end,h=c.len,g=a[t].details,p=g.fragments,v=p.length,m=p[v-1].start+p[v-1].duration;if(h>l)return;var y=this.fragPrevious;f<m?(y&&g.hasProgramDateTime&&(n=Ce(p,y.endProgramDateTime,o)),n||(n=Pe(y,p,f,o))):n=p[v-1],n&&n.encrypted?(d["logger"].log("Loading key for "+n.sn),this.state=We.KEY_LOADING,this.hls.trigger(u["default"].KEY_LOADING,{frag:n})):n&&r.getState(n)===$.NOT_LOADED&&(this.fragCurrent=n,this.state=We.FRAG_LOADING,this.hls.trigger(u["default"].FRAG_LOADING,{frag:n}))}else this.state=We.IDLE},r.stopLoad=function(){this.lastAVStart=0,e.prototype.stopLoad.call(this)},r._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},r.onMediaSeeking=function(){this.fragPrevious=null},t}(Ye);(function(e){e["WIDEVINE"]="com.widevine.alpha",e["PLAYREADY"]="com.microsoft.playready"})(ri||(ri={}));var oi=function(){return"undefined"!==typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null}();function li(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ui(e,t,r){return t&&li(e.prototype,t),r&&li(e,r),e}function di(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var ci=3,fi=function(e,t){var r={videoCapabilities:[]};return t.forEach((function(e){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"'})})),[r]},hi=function(e,t,r){switch(e){case ri.WIDEVINE:return fi(t,r);default:throw new Error("Unknown key-system: "+e)}},gi=function(e){function t(t){var r;return r=e.call(this,t,u["default"].MEDIA_ATTACHED,u["default"].MEDIA_DETACHED,u["default"].MANIFEST_PARSED)||this,r._widevineLicenseUrl=void 0,r._licenseXhrSetup=void 0,r._emeEnabled=void 0,r._requestMediaKeySystemAccess=void 0,r._config=void 0,r._mediaKeysList=[],r._media=null,r._hasSetMediaKeys=!1,r._requestLicenseFailureCount=0,r._onMediaEncrypted=function(e){d["logger"].log('Media is encrypted using "'+e.initDataType+'" init data type'),r._attemptSetMediaKeys(),r._generateRequestWithPreferredKeySession(e.initDataType,e.initData)},r._config=t.config,r._widevineLicenseUrl=r._config.widevineLicenseUrl,r._licenseXhrSetup=r._config.licenseXhrSetup,r._emeEnabled=r._config.emeEnabled,r._requestMediaKeySystemAccess=r._config.requestMediaKeySystemAccessFunc,r}di(t,e);var r=t.prototype;return r.getLicenseServerUrl=function(e){switch(e){case ri.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},r._attemptKeySystemAccess=function(e,t,r){var i=this,a=hi(e,t,r);d["logger"].log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(e,a).then((function(t){i._onMediaKeySystemAccessObtained(e,t)})).catch((function(t){d["logger"].error('Failed to obtain key-system "'+e+'" access:',t)}))},r._onMediaKeySystemAccessObtained=function(e,t){var r=this;d["logger"].log('Access for key-system "'+e+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(i),t.createMediaKeys().then((function(t){i.mediaKeys=t,d["logger"].log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated()})).catch((function(e){d["logger"].error("Failed to create media-keys:",e)}))},r._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},r._onNewMediaKeySession=function(e){var t=this;d["logger"].log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},r._onKeySessionMessage=function(e,t){d["logger"].log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){d["logger"].log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t)}))},r._attemptSetMediaKeys=function(){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return d["logger"].error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_KEYS,fatal:!0});d["logger"].log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},r._generateRequestWithPreferredKeySession=function(e,t){var r=this,i=this._mediaKeysList[0];if(!i)return d["logger"].error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:!0});if(i.mediaKeysSessionInitialized)d["logger"].warn("Key-Session already initialized but requested again");else{var a=i.mediaKeysSession;if(!a)return d["logger"].error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return d["logger"].warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_INIT_DATA,fatal:!0});d["logger"].log('Generating key-session request for "'+e+'" init data type'),i.mediaKeysSessionInitialized=!0,a.generateRequest(e,t).then((function(){d["logger"].debug("Key-session generation succeeded")})).catch((function(e){d["logger"].error("Error generating key-session request:",e),r.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},r._createLicenseXhr=function(e,t,r){var i=new XMLHttpRequest,a=this._licenseXhrSetup;try{if(a)try{a(i,e)}catch(n){i.open("POST",e,!0),a(i,e)}i.readyState||i.open("POST",e,!0)}catch(n){throw new Error("issue setting up KeySystem license XHR "+n)}return i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,e,t,r),i},r._onLicenseRequestReadyStageChange=function(e,t,r,i){switch(e.readyState){case 4:if(200===e.status)this._requestLicenseFailureCount=0,d["logger"].log("License request succeeded"),"arraybuffer"!==e.responseType&&d["logger"].warn("xhr response type was not set to the expected arraybuffer for license request"),i(e.response);else{if(d["logger"].error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>ci)return void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var a=ci-this._requestLicenseFailureCount+1;d["logger"].warn("Retrying license request, "+a+" attempts left"),this._requestLicense(r,i)}break}},r._generateLicenseRequestChallenge=function(e,t){switch(e.mediaKeySystemDomain){case ri.WIDEVINE:return t}throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},r._requestLicense=function(e,t){d["logger"].log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return d["logger"].error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),a=this._createLicenseXhr(i,e,t);d["logger"].log("Sending license request to URL: "+i);var n=this._generateLicenseRequestChallenge(r,e);a.send(n)}catch(s){d["logger"].error("Failure requesting DRM license: "+s),this.hls.trigger(u["default"].ERROR,{type:o["ErrorTypes"].KEY_SYSTEM_ERROR,details:o["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},r.onMediaAttached=function(e){if(this._emeEnabled){var t=e.media;this._media=t,t.addEventListener("encrypted",this._onMediaEncrypted)}},r.onMediaDetached=function(){this._media&&(this._media.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null)},r.onManifestParsed=function(e){if(this._emeEnabled){var t=e.levels.map((function(e){return e.audioCodec})),r=e.levels.map((function(e){return e.videoCodec}));this._attemptKeySystemAccess(ri.WIDEVINE,t,r)}},ui(t,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),t}(h),pi=gi;function vi(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},i=Object.keys(r);"function"===typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),i.forEach((function(t){mi(e,t,r[t])}))}return e}function mi(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var yi=vi({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ht,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:At,bufferController:wt,capLevelController:Pt,fpsController:Ut,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,requestMediaKeySystemAccessFunc:oi},Ei(),{subtitleStreamController:si,subtitleTrackController:$r,timelineController:Yr,audioStreamController:rr,audioTrackController:zt,emeController:pi});function Ei(){return{cueHandler:i,enableCEA708Captions:!0,enableWebVTT:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es"}}function Ti(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},i=Object.keys(r);"function"===typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),i.forEach((function(t){Si(e,t,r[t])}))}return e}function Si(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bi(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function Ai(e,t,r){return t&&_i(e.prototype,t),r&&_i(e,r),e}function Ri(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}r.d(t,"default",(function(){return Di}));var Di=function(e){function t(r){var i;void 0===r&&(r={}),i=e.call(this)||this,i.config=void 0,i._autoLevelCapping=void 0,i.abrController=void 0,i.capLevelController=void 0,i.levelController=void 0,i.streamController=void 0,i.networkControllers=void 0,i.audioTrackController=void 0,i.subtitleTrackController=void 0,i.emeController=void 0,i.coreComponents=void 0,i.media=null,i.url=null;var a=t.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");i.config=Ti({},a,r);var n=bi(i),s=n.config;if(void 0!==s.liveMaxLatencyDurationCount&&s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==s.liveMaxLatencyDuration&&(void 0===s.liveSyncDuration||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');Object(d["enableLogs"])(s.debug),i._autoLevelCapping=-1;var o=i.abrController=new s.abrController(bi(i)),l=new s.bufferController(bi(i)),u=i.capLevelController=new s.capLevelController(bi(i)),c=new s.fpsController(bi(i)),f=new V(bi(i)),h=new q(bi(i)),g=new Q(bi(i)),p=new ct(bi(i)),v=i.levelController=new at(bi(i)),m=new Z(bi(i)),y=i.streamController=new $e(bi(i),m),E=[v,y],T=s.audioStreamController;T&&E.push(new T(bi(i),m)),i.networkControllers=E;var S=[f,h,g,o,l,u,c,p,m];if(T=s.audioTrackController,T){var b=new T(bi(i));i.audioTrackController=b,S.push(b)}if(T=s.subtitleTrackController,T){var _=new T(bi(i));i.subtitleTrackController=_,E.push(_)}if(T=s.emeController,T){var A=new T(bi(i));i.emeController=A,S.push(A)}return T=s.subtitleStreamController,T&&E.push(new T(bi(i),m)),T=s.timelineController,T&&S.push(new T(bi(i))),i.coreComponents=S,i}Ri(t,e),t.isSupported=function(){return ft()},Ai(t,null,[{key:"version",get:function(){return"0.13.2"}},{key:"Events",get:function(){return u["default"]}},{key:"ErrorTypes",get:function(){return o["ErrorTypes"]}},{key:"ErrorDetails",get:function(){return o["ErrorDetails"]}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:yi},set:function(e){t.defaultConfig=e}}]);var r=t.prototype;return r.destroy=function(){d["logger"].log("destroy"),this.trigger(u["default"].DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach((function(e){e.destroy()})),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},r.attachMedia=function(e){d["logger"].log("attachMedia"),this.media=e,this.trigger(u["default"].MEDIA_ATTACHING,{media:e})},r.detachMedia=function(){d["logger"].log("detachMedia"),this.trigger(u["default"].MEDIA_DETACHING),this.media=null},r.loadSource=function(e){e=s["buildAbsoluteURL"](window.location.href,e,{alwaysNormalize:!0}),d["logger"].log("loadSource:"+e),this.url=e,this.trigger(u["default"].MANIFEST_LOADING,{url:e})},r.startLoad=function(e){void 0===e&&(e=-1),d["logger"].log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},r.stopLoad=function(){d["logger"].log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},r.swapAudioCodec=function(){d["logger"].log("swapAudioCodec"),this.streamController.swapAudioCodec()},r.recoverMediaError=function(){d["logger"].log("recoverMediaError");var e=this.media;this.detachMedia(),e&&this.attachMedia(e)},Ai(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){d["logger"].log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){d["logger"].log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){d["logger"].log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){d["logger"].log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){d["logger"].log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){d["logger"].log("set autoLevelCapping:"+e),this._autoLevelCapping=e}},{key:"bandwidthEstimate",get:function(){var e=this.abrController._bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var e=this.levels,t=this.config.minAutoBitrate,r=e?e.length:0,i=0;i<r;i++){var a=e[i].realBitrate?Math.max(e[i].realBitrate,e[i].bitrate):e[i].bitrate;if(a>t)return i}return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping;return e=-1===r&&t&&t.length?t.length-1:r,e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),t}(ue);Di.defaultConfig=void 0},"./src/polyfills/number-isFinite.js":
/*!******************************************!*\
!*** ./src/polyfills/number-isFinite.js ***!
\******************************************/
/*! exports provided: isFiniteNumber */function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",(function(){return i}));var i=Number.isFinite||function(e){return"number"===typeof e&&isFinite(e)}},"./src/utils/get-self-scope.js":
/*!*************************************!*\
!*** ./src/utils/get-self-scope.js ***!
\*************************************/
/*! exports provided: getSelfScope */function(e,t,r){"use strict";function i(){return"undefined"===typeof window?self:window}r.r(t),r.d(t,"getSelfScope",(function(){return i}))},"./src/utils/logger.js":
/*!*****************************!*\
!*** ./src/utils/logger.js ***!
\*****************************/
/*! exports provided: enableLogs, logger */function(e,t,r){"use strict";r.r(t),r.d(t,"enableLogs",(function(){return c})),r.d(t,"logger",(function(){return f}));var i=r(/*! ./get-self-scope */"./src/utils/get-self-scope.js");function a(){}var n={trace:a,debug:a,log:a,warn:a,info:a,error:a},s=n;function o(e,t){return t="["+e+"] > "+t,t}var l=Object(i["getSelfScope"])();function u(e){var t=l.console[e];return t?function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];i[0]&&(i[0]=o(e,i[0])),t.apply(l.console,i)}:a}function d(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){s[t]=e[t]?e[t].bind(e):u(t)}))}var c=function(e){if(l.console&&!0===e||"object"===typeof e){d(e,"debug","log","info","warn","error");try{s.log()}catch(t){s=n}}else s=n},f=s}})["default"]}))}}]);