cbplayer
Version:
CDNBye official web player
1 lines • 514 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("CBPlayer",[],t):"object"==typeof exports?exports.CBPlayer=t():e.CBPlayer=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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 n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},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(r.s=60)}([function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var a=r(8),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function s(e){return void 0===e}function l(e){return null!==e&&"object"===n(e)}function d(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!==n(e)&&(e=[e]),o(e))for(var r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:l,isUndefined:s,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:d,isStream:function(e){return l(e)&&d(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:u,merge:function e(){var t={};function r(r,a){"object"===n(t[a])&&"object"===n(r)?t[a]=e(t[a],r):t[a]=r}for(var a=0,i=arguments.length;a<i;a++)u(arguments[a],r);return t},deepMerge:function e(){var t={};function r(r,a){"object"===n(t[a])&&"object"===n(r)?t[a]=e(t[a],r):"object"===n(r)?t[a]=e({},r):t[a]=r}for(var a=0,i=arguments.length;a<i;a++)u(arguments[a],r);return t},extend:function(e,t,r){return u(t,(function(t,n){e[n]=r&&"function"==typeof t?a(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,r){(function(e){var r,n,a,i;function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}"undefined"!=typeof window&&(i=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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"===o(e)&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},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":function(e,t,r){"use strict";var n=Object.prototype.hasOwnProperty,a="~";function i(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,n,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,n||e,i),l=a?a+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function d(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(a=!1)),d.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)n.call(e,t)&&r.push(a?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},d.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 n=0,i=r.length,o=new Array(i);n<i;n++)o[n]=r[n].fn;return o},d.prototype.listenerCount=function(e){var t=a?a+e:e,r=this._events[t];return r?r.fn?1:r.length:0},d.prototype.emit=function(e,t,r,n,i,o){var s=a?a+e:e;if(!this._events[s])return!1;var l,d,u=this._events[s],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,n),!0;case 5:return u.fn.call(u.context,t,r,n,i),!0;case 6:return u.fn.call(u.context,t,r,n,i,o),!0}for(d=1,l=new Array(c-1);d<c;d++)l[d-1]=arguments[d];u.fn.apply(u.context,l)}else{var f,p=u.length;for(d=0;d<p;d++)switch(u[d].once&&this.removeListener(e,u[d].fn,void 0,!0),c){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,t);break;case 3:u[d].fn.call(u[d].context,t,r);break;case 4:u[d].fn.call(u[d].context,t,r,n);break;default:if(!l)for(f=1,l=new Array(c-1);f<c;f++)l[f-1]=arguments[f];u[d].fn.apply(u[d].context,l)}}return!0},d.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},d.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},d.prototype.removeListener=function(e,t,r,n){var i=a?a+e:e;if(!this._events[i])return this;if(!t)return l(this,i),this;var o=this._events[i];if(o.fn)o.fn!==t||n&&!o.once||r&&o.context!==r||l(this,i);else{for(var s=0,d=[],u=o.length;s<u;s++)(o[s].fn!==t||n&&!o[s].once||r&&o[s].context!==r)&&d.push(o[s]);d.length?this._events[i]=1===d.length?d[0]:d:l(this,i)}return this},d.prototype.removeAllListeners=function(e){var t;return e?(t=a?a+e:e,this._events[t]&&l(this,t)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=a,d.EventEmitter=d,e.exports=d},"./node_modules/url-toolkit/src/url-toolkit.js":function(e,t,r){var n,a,i,o,s;n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,a=/^([^\/?#]*)(.*)$/,i=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var n=s.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):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=a.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var d={scheme:o.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(d.netLoc=o.netLoc,"/"!==i.path[0]))if(i.path){var u=o.path,c=u.substring(0,u.lastIndexOf("/")+1)+i.path;d.path=s.normalizePath(c)}else d.path=o.path,i.params||(d.params=o.params,i.query||(d.query=o.query));return null===d.path&&(d.path=r.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(d)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(o,"")).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":function(e,t,r){function n(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].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,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},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 n=r(r.s=ENTRY_MODULE);return n.default||n}var a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function i(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,n){var o={};o[n]=[];var s=t.toString(),l=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!l)return o;for(var d,u=l[1],c=new RegExp("(\\\\n|\\W)"+i(u)+a,"g");d=c.exec(s);)"dll-reference"!==d[3]&&o[n].push(d[3]);for(c=new RegExp("\\("+i(u)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+a,"g");d=c.exec(s);)e[d[2]]||(o[n].push(d[1]),e[d[2]]=r(d[1]).m),o[d[2]]=o[d[2]]||[],o[d[2]].push(d[4]);for(var f,p=Object.keys(o),h=0;h<p.length;h++)for(var g=0;g<o[p[h]].length;g++)f=o[p[h]][g],isNaN(1*f)||(o[p[h]][g]=1*o[p[h]][g]);return o}function s(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}e.exports=function(e,t){t=t||{};var a={main:r.m},i=t.all?{main:Object.keys(a.main)}:function(e,t){for(var r={main:[t]},n={main:[]},a={main:{}};s(r);)for(var i=Object.keys(r),l=0;l<i.length;l++){var d=i[l],u=r[d].pop();if(a[d]=a[d]||{},!a[d][u]&&e[d][u]){a[d][u]=!0,n[d]=n[d]||[],n[d].push(u);for(var c=o(e,e[d][u],d),f=Object.keys(c),p=0;p<f.length;p++)r[f[p]]=r[f[p]]||[],r[f[p]]=r[f[p]].concat(c[f[p]])}}return n}(a,e),l="";Object.keys(i).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;i[e][t];)t++;i[e].push(t),a[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+e+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+i[e].map((function(t){return JSON.stringify(t)+": "+a[e][t].toString()})).join(",")+"});\n"})),l=l+"new (("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i.main.map((function(e){return JSON.stringify(e)+": "+a.main[e].toString()})).join(",")+"}))(self);";var d=new window.Blob([l],{type:"text/javascript"});if(t.bare)return d;var u=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(d),c=new window.Worker(u);return c.objectURL=u,c}},"./src/crypt/decrypter.js":function(e,t,r){"use strict";r.r(t);var n=function(){function e(e,t){this.subtle=e,this.aesIV=t}return e.prototype.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}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}(),i=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),n=0;n<4;n++)r[n]=t.getUint32(4*n);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,n=r[0],a=r[1],i=r[2],o=r[3],s=this.invSubMix,l=s[0],d=s[1],u=s[2],c=s[3],f=new Uint32Array(256),p=0,h=0,g=0;for(g=0;g<256;g++)f[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var m=h^h<<1^h<<2^h<<3^h<<4;m=m>>>8^255&m^99,e[p]=m,t[m]=p;var y=f[p],v=f[y],b=f[v],w=257*f[m]^16843008*m;n[p]=w<<24|w>>>8,a[p]=w<<16|w>>>16,i[p]=w<<8|w>>>24,o[p]=w,w=16843009*b^65537*v^257*y^16843008*p,l[m]=w<<24|w>>>8,d[m]=w<<16|w>>>16,u[m]=w<<8|w>>>24,c[m]=w,p?(p=y^f[f[f[b^y]]],h^=f[f[h]]):p=h=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;n<t.length&&r;)r=t[n]===this.key[n],n++;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 i,o,s,l,d=this.ksRows=4*(a+6+1),u=this.keySchedule=new Uint32Array(d),c=this.invKeySchedule=new Uint32Array(d),f=this.sBox,p=this.rcon,h=this.invSubMix,g=h[0],m=h[1],y=h[2],v=h[3];for(i=0;i<d;i++)i<a?s=u[i]=t[i]:(l=s,i%a==0?(l=f[(l=l<<8|l>>>24)>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l],l^=p[i/a|0]<<24):a>6&&i%a==4&&(l=f[l>>>24]<<24|f[l>>>16&255]<<16|f[l>>>8&255]<<8|f[255&l]),u[i]=s=(u[i-a]^l)>>>0);for(o=0;o<d;o++)i=d-o,l=3&o?u[i]:u[i-4],c[o]=o<4||i<=4?l:g[f[l>>>24]]^m[f[l>>>16&255]]^y[f[l>>>8&255]]^v[f[255&l]],c[o]=c[o]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r,n){for(var a,i,o,s,l,d,u,c,f,p,h,g,m,y,v,b,w,k=this.keySize+6,E=this.invKeySchedule,_=this.invSBox,T=this.invSubMix,S=T[0],x=T[1],A=T[2],R=T[3],L=this.uint8ArrayToUint32Array_(r),C=L[0],D=L[1],P=L[2],O=L[3],I=new Int32Array(e),M=new Int32Array(I.length),F=this.networkToHostOrderSwap;t<I.length;){for(f=F(I[t]),p=F(I[t+1]),h=F(I[t+2]),g=F(I[t+3]),l=f^E[0],d=g^E[1],u=h^E[2],c=p^E[3],m=4,y=1;y<k;y++)a=S[l>>>24]^x[d>>16&255]^A[u>>8&255]^R[255&c]^E[m],i=S[d>>>24]^x[u>>16&255]^A[c>>8&255]^R[255&l]^E[m+1],o=S[u>>>24]^x[c>>16&255]^A[l>>8&255]^R[255&d]^E[m+2],s=S[c>>>24]^x[l>>16&255]^A[d>>8&255]^R[255&u]^E[m+3],l=a,d=i,u=o,c=s,m+=4;a=_[l>>>24]<<24^_[d>>16&255]<<16^_[u>>8&255]<<8^_[255&c]^E[m],i=_[d>>>24]<<24^_[u>>16&255]<<16^_[c>>8&255]<<8^_[255&l]^E[m+1],o=_[u>>>24]<<24^_[c>>16&255]<<16^_[l>>8&255]<<8^_[255&d]^E[m+2],s=_[c>>>24]<<24^_[l>>16&255]<<16^_[d>>8&255]<<8^_[255&u]^E[m+3],m+=3,M[t]=F(a^C),M[t+1]=F(s^D),M[t+2]=F(o^P),M[t+3]=F(i^O),C=f,D=p,P=h,O=g,t+=4}return n?(v=M.buffer,b=v.byteLength,(w=b&&new DataView(v).getUint8(b-1))?v.slice(0,b-w):v):M.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}(),o=r("./src/errors.ts"),s=r("./src/utils/logger.js"),l=r("./src/events.js"),d=r("./src/utils/get-self-scope.js"),u=Object(d.getSelfScope)(),c=function(){function e(e,t,r){var n=(void 0===r?{}:r).removePKCS7Padding,a=void 0===n||n;if(this.logEnabled=!0,this.observer=e,this.config=t,this.removePKCS7Padding=a,a)try{var i=u.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}var t=e.prototype;return t.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.decrypt=function(e,t,r,o){var l=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(s.logger.log("JS AES decrypt"),this.logEnabled=!1);var d=this.decryptor;d||(this.decryptor=d=new i),d.expandKey(t),o(d.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(s.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var u=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new a(u,t)),this.fastAesKey.expandKey().then((function(a){new n(u,r).decrypt(e,a).catch((function(n){l.onWebCryptoError(n,e,t,r,o)})).then((function(e){o(e)}))})).catch((function(n){l.onWebCryptoError(n,e,t,r,o)}))}},t.onWebCryptoError=function(e,t,r,n,a){this.config.enableSoftwareAES?(s.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,n,a)):(s.logger.error("decrypting error : "+e.message),this.observer.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.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=c},"./src/demux/demuxer-inline.js":function(e,t,r){"use strict";r.r(t);var n=r("./src/events.js"),a=r("./src/errors.ts"),i=r("./src/crypt/decrypter.js"),o=r("./src/polyfills/number-isFinite.js"),s=r("./src/utils/logger.js"),l=r("./src/utils/get-self-scope.js");function d(e,t){return 255===e[t]&&240==(246&e[t+1])}function u(e,t){return 1&e[t+1]?7:9}function c(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function f(e,t){return!!(t+1<e.length&&d(e,t))}function p(e,t){if(f(e,t)){var r=u(e,t);if(t+r>=e.length)return!1;var n=c(e,t);if(n<=r)return!1;var a=t+n;if(a===e.length||a+1<e.length&&d(e,a))return!0}return!1}function h(e,t,r,i,o){if(!e.samplerate){var l=function(e,t,r,i){var o,l,d,u,c,f=navigator.userAgent.toLowerCase(),p=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(o=1+((192&t[r+2])>>>6),!((l=(60&t[r+2])>>>2)>h.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,s.logger.log("manifest codec:"+i+",ADTS data:type:"+o+",sampleingIndex:"+l+"["+h[l]+"Hz],channelConfig:"+u),/firefox/i.test(f)?l>=6?(o=5,c=new Array(4),d=l-3):(o=2,c=new Array(2),d=l):-1!==f.indexOf("android")?(o=2,c=new Array(2),d=l):(o=5,c=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&l>=6?d=l-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(l>=6&&1===u||/vivaldi/i.test(f))||!i&&1===u)&&(o=2,c=new Array(2)),d=l)),c[0]=o<<3,c[0]|=(14&l)>>1,c[1]|=(1&l)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&d)>>1,c[2]=(1&d)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:h[l],channelCount:u,codec:"mp4a.40."+o,manifestCodec:p};e.trigger(n.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+l})}(t,r,i,o);e.config=l.config,e.samplerate=l.samplerate,e.channelCount=l.channelCount,e.codec=l.codec,e.manifestCodec=l.manifestCodec,s.logger.log("parsed codec:"+e.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)}}function g(e){return 9216e4/e}function m(e,t,r,n,a){var i=function(e,t,r,n,a){var i,o,s=e.length;if(i=u(e,t),o=c(e,t),(o-=i)>0&&t+i+o<=s)return{headerLength:i,frameLength:o,stamp:r+n*a}}(t,r,n,a,g(e.samplerate));if(i){var o=i.stamp,s=i.headerLength,l=i.frameLength,d={unit:t.subarray(r+s,r+s+l),pts:o,dts:o};return e.samples.push(d),{sample:d,length:l+s}}}var y=r("./src/demux/id3.js"),v=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,n){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:n,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(y.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(p(e,t))return s.logger.log("ADTS sync word found !"),!0;return!1},t.append=function(e,t,r,n){for(var a=this._audioTrack,i=y.default.getID3Data(e,0)||[],l=y.default.getTimeStamp(i),d=Object(o.isFiniteNumber)(l)?90*l:9e4*t,u=0,c=d,p=e.length,g=i.length,v=[{pts:c,dts:c,data:i}];g<p-1;)if(f(e,g)&&g+5<p){h(a,this.observer,e,g,a.manifestCodec);var b=m(a,e,g,d,u);if(!b){s.logger.log("Unable to parse AAC frame");break}g+=b.length,c=b.sample.pts,u++}else y.default.isHeader(e,g)?(i=y.default.getID3Data(e,g),v.push({pts:c,dts:c,data:i}),g+=i.length):g++;this.remuxer.remux(a,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,n)},t.destroy=function(){},e}(),b=r("./src/demux/mp4demuxer.js"),w={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,n,a){if(!(r+24>t.length)){var i=this.parseHeader(t,r);if(i&&r+i.frameLength<=t.length){var o=n+a*(9e4*i.samplesPerFrame/i.sampleRate),s={unit:t.subarray(r,r+i.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=i.channelCount,e.samplerate=i.sampleRate,e.samples.push(s),{sample:s,length:i.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,i=e[t+2]>>2&3,o=e[t+2]>>1&1;if(1!==r&&0!==a&&15!==a&&3!==i){var s=3===r?3-n:3===n?3:4,l=1e3*w.BitratesMap[14*s+a-1],d=3===r?0:2===r?1:2,u=w.SamplingRateMap[3*d+i],c=e[t+3]>>6==3?1:2,f=w.SamplesCoefficients[r][n],p=w.BytesInSlot[n],h=8*f*p;return{sampleRate:u,channelCount:c,frameLength:parseInt(f*l/u+o,10)*p,samplesPerFrame:h}}},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=this.parseHeader(e,t),n=4;r&&r.frameLength&&(n=r.frameLength);var a=t+n;if(a===e.length||a+1<e.length&&this.isHeaderPattern(e,a))return!0}return!1}},k=w,E=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,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(r,r+a)),this.word=new DataView(n.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,e-=(t=e>>3)>>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&&s.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)>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=8,n=8;for(t=0;t<e;t++)0!==n&&(n=(r+this.readEG()+256)%256),r=0===n?r:n},t.readSPS=function(){var e,t,r,n,a,i,o,s=0,l=0,d=0,u=0,c=this.readUByte.bind(this),f=this.readBits.bind(this),p=this.readUEG.bind(this),h=this.readBoolean.bind(this),g=this.skipBits.bind(this),m=this.skipEG.bind(this),y=this.skipUEG.bind(this),v=this.skipScalingList.bind(this);if(c(),e=c(),f(5),g(3),c(),y(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var b=p();if(3===b&&g(1),y(),y(),g(1),h())for(i=3!==b?8:12,o=0;o<i;o++)h()&&v(o<6?16:64)}y();var w=p();if(0===w)p();else if(1===w)for(g(1),m(),m(),t=p(),o=0;o<t;o++)m();y(),g(1),r=p(),n=p(),0===(a=f(1))&&g(1),g(1),h()&&(s=p(),l=p(),d=p(),u=p());var k=[1,1];if(h()&&h())switch(c()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:k=[c()<<8|c(),c()<<8|c()]}return{width:Math.ceil(16*(r+1)-2*s-2*l),height:(2-a)*(n+1)*16-(a?2:4)*(d+u),pixelRatio:k}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}(),_=function(){function e(e,t,r,n){this.decryptdata=r,this.discardEPB=n,this.decrypter=new i.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,n){var a=e[t].unit,i=a.subarray(16,a.length-a.length%16),o=i.buffer.slice(i.byteOffset,i.byteOffset+i.length),s=this;this.decryptBuffer(o,(function(i){i=new Uint8Array(i),a.set(i,16),n||s.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 n=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,n),!n)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,a=32;a<=e.length-16;a+=160,n+=16)r.set(e.subarray(a,a+16),n);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,n=32;n<=e.length-16;n+=160,r+=16)e.set(t.subarray(r,r+16),n);return e},t.decryptAvcSample=function(e,t,r,n,a,i){var o=this.discardEPB(a.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,(function(s){a.data=l.getAvcDecryptedUnit(o,s),i||l.decryptAvcSamples(e,t,r+1,n)}))},t.decryptAvcSamples=function(e,t,r,n){for(;;t++,r=0){if(t>=e.length)return void n();for(var a=e[t].units;!(r>=a.length);r++){var i=a[r];if(!(i.length<=48||1!==i.type&&5!==i.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,n,i,o),!o)return}}}},e}(),T={video:1,audio:2,id3:3,text:4},S=function(){function e(e,t,r,n){this.observer=e,this.config=r,this.typeSupported=n,this.remuxer=t,this.sampleAes=null,this.pmtUnknownTypes={}}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new _(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0||(r&&s.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},e._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;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:T[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,n,a){this.pmtParsed=!1,this._pmtId=-1,this.pmtUnknownTypes={},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=n,this._duration=a},t.resetTimeStamp=function(){},t.append=function(t,r,i,o){var l,d,u,c,f,p=t.length,h=!1;this.pmtUnknownTypes={},this.contiguous=i;var g=this.pmtParsed,m=this._avcTrack,y=this._audioTrack,v=this._id3Track,b=m.pid,w=y.pid,k=v.pid,E=this._pmtId,_=m.pesData,T=y.pesData,S=v.pesData,x=this._parsePAT,A=this._parsePMT.bind(this),R=this._parsePES,L=this._parseAVCPES.bind(this),C=this._parseAACPES.bind(this),D=this._parseMPEGPES.bind(this),P=this._parseID3PES.bind(this),O=e._syncOffset(t);for(p-=(p+O)%188,l=O;l<p;l+=188)if(71===t[l]){if(d=!!(64&t[l+1]),u=((31&t[l+1])<<8)+t[l+2],(48&t[l+3])>>4>1){if((c=l+5+t[l+4])===l+188)continue}else c=l+4;switch(u){case b:d&&(_&&(f=R(_))&&L(f,!1),_={data:[],size:0}),_&&(_.data.push(t.subarray(c,l+188)),_.size+=l+188-c);break;case w:d&&(T&&(f=R(T))&&(y.isAAC?C(f):D(f)),T={data:[],size:0}),T&&(T.data.push(t.subarray(c,l+188)),T.size+=l+188-c);break;case k:d&&(S&&(f=R(S))&&P(f),S={data:[],size:0}),S&&(S.data.push(t.subarray(c,l+188)),S.size+=l+188-c);break;case 0:d&&(c+=t[c]+1),E=this._pmtId=x(t,c);break;case E:d&&(c+=t[c]+1);var I=A(t,c,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(b=I.avc)>0&&(m.pid=b),(w=I.audio)>0&&(y.pid=w,y.isAAC=I.isAAC),(k=I.id3)>0&&(v.pid=k),h&&!g&&(s.logger.log("reparse from beginning"),h=!1,l=O-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:h=!0}}else this.observer.trigger(n.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});_&&(f=R(_))?(L(f,!0),m.pesData=null):m.pesData=_,T&&(f=R(T))?(y.isAAC?C(f):D(f),y.pesData=null):(T&&T.size&&s.logger.log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=T),S&&(f=R(S))?(P(f),v.pesData=null):v.pesData=S,null==this.sampleAes?this.remuxer.remux(y,m,v,this._txtTrack,r,i,o):this.decryptAndRemux(y,m,v,this._txtTrack,r,i,o)},t.decryptAndRemux=function(e,t,r,n,a,i,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){s.decryptAndRemuxAvc(e,t,r,n,a,i,o)}))}else this.decryptAndRemuxAvc(e,t,r,n,a,i,o)},t.decryptAndRemuxAvc=function(e,t,r,n,a,i,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){s.remuxer.remux(e,t,r,n,a,i,o)}))}else this.remuxer.remux(e,t,r,n,a,i,o)},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._trackUnknownPmt=function(e,t,r){var n=this.pmtUnknownTypes[e]||0;return 0===n&&(this.pmtUnknownTypes[e]=0,t.call(s.logger,r)),this.pmtUnknownTypes[e]++,n},t._parsePMT=function(e,t,r,n){var a,i,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(a=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){switch(i=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!n){this._trackUnknownPmt(e[t],s.logger.warn,"ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===o.audio&&(o.audio=i);break;case 21:-1===o.id3&&(o.id3=i);break;case 219:if(!n){this._trackUnknownPmt(e[t],s.logger.warn,"H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===o.avc&&(o.avc=i);break;case 3:case 4:r?-1===o.audio&&(o.audio=i,o.isAAC=!1):this._trackUnknownPmt(e[t],s.logger.warn,"MPEG audio found, not supported in this browser");break;case 36:this._trackUnknownPmt(e[t],s.logger.warn,"Unsupported HEVC stream type found");break;default:this._trackUnknownPmt(e[t],s.logger.log,"Unknown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return o},t._parsePES=function(e){var t,r,n,a,i,o,l,d,u=0,c=e.data;if(!e||0===e.size)return null;for(;c[0].length<19&&c.length>1;){var f=new Uint8Array(c[0].length+c[1].length);f.set(c[0]),f.set(c[1],c[0].length),c[0]=f,c.splice(1,1)}if(1===((t=c[0])[0]<<16)+(t[1]<<8)+t[2]){if((n=(t[4]<<8)+t[5])&&n>e.size-6)return null;if(192&(r=t[7])&&((o=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)>4294967295&&(o-=8589934592),64&r?((l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>4294967295&&(l-=8589934592),o-l>54e5&&(s.logger.warn(Math.round((o-l)/9e4)+"s delta between PTS and DTS, align them"),o=l)):l=o),d=(a=t[8])+9,e.size<=d)return null;e.size-=d,i=new Uint8Array(e.size);for(var p=0,h=c.length;p<h;p++){var g=(t=c[p]).byteLength;if(d){if(d>g){d-=g;continue}t=t.subarray(d),g-=d,d=0}i.set(t,u),u+=g}return n&&(n-=a+3),{data:i,pts:o,dts:l,len:n}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,n=r.length;if(isNaN(e.pts)){if(!n)return void t.dropped++;var a=r[n-1];e.pts=a.pts,e.dts=a.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(n||this.contiguous)?(e.id=n,r.push(e)):t.dropped++}e.debug.length&&s.logger.log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var r,n,a,i=this,o=this._avcTrack,s=this._parseAVCNALu(e.data),l=this.avcSample,d=!1,u=this.pushAccesUnit.bind(this),c=function(e,t,r,n){return{key:e,pts:t,dts:r,units:[],debug:n}};e.data=null,l&&s.length&&!o.audFound&&(u(l,o),l=this.avcSample=c(!1,e.pts,e.dts,"")),s.forEach((function(t){switch(t.type){case 1:n=!0,l||(l=i.avcSample=c(!0,e.pts,e.dts,"")),l.frame=!0;var s=t.data;if(d&&s.length>4){var f=new E(s).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(l.key=!0)}break;case 5:n=!0,l||(l=i.avcSample=c(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:n=!0,(r=new E(i.discardEPB(t.data))).readUByte();for(var p=0,h=0,g=!1,m=0;!g&&r.bytesAvailable>1;){p=0;do{p+=m=r.readUByte()}while(255===m);h=0;do{h+=m=r.readUByte()}while(255===m);if(4===p&&0!==r.bytesAvailable){if(g=!0,181===r.readUByte()&&49===r.readUShort()&&1195456820===r.readUInt()&&3===r.readUByte()){var v=r.readUByte(),b=31&v,w=[v,r.readUByte()];for(a=0;a<b;a++)w.push(r.readUByte()),w.push(r.readUByte()),w.push(r.readUByte());i._insertSampleInOrder(i._txtTrack.samples,{type:3,pts:e.pts,bytes:w})}}else if(5===p&&0!==r.bytesAvailable){if(g=!0,h>16){var k=[];for(a=0;a<16;a++)k.push(r.readUByte().toString(16)),3!==a&&5!==a&&7!==a&&9!==a||k.push("-");var _=h-16,T=new Uint8Array(_);for(a=0;a<_;a++)T[a]=r.readUByte();i._insertSampleInOrder(i._txtTrack.samples,{pts:e.pts,payloadType:p,uuid:k.join(""),userDataBytes:T,userData:Object(y.utf8ArrayToStr)(T.buffer)})}}else if(h<r.bytesAvailable)for(a=0;a<h;a++)r.readUByte()}break;case 7:if(n=!0,d=!0,!o.sps){var S=(r=new E(t.data)).readSPS();o.width=S.width,o.height=S.height,o.pixelRatio=S.pixelRatio,o.sps=[t.data],o.duration=i._duration;var x=t.data.subarray(1,4),A="avc1.";for(a=0;a<3;a++){var R=x[a].toString(16);R.length<2&&(R="0"+R),A+=R}o.codec=A}break;case 8:n=!0,o.pps||(o.pps=[t.data]);break;case 9:n=!1,o.audFound=!0,l&&u(l,o),l=i.avcSample=c(!1,e.pts,e.dts,"");break;case 12:n=!1;break;default:n=!1,l&&(l.debug+="unknown NAL "+t.type+" ")}l&&n&&l.units.push(t)})),t&&l&&(u(l,o),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 n=r-1;n>=0;n--)if(t.pts<e[n].pts){e.splice(n,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.samples;t=r[r.length-1]}if(t){var n=t.units;e=n[n.length-1]}return e},t._parseAVCNALu=function(e){var t,r,n,a,i=0,o=e.byteLength,s=this._avcTrack,l=s.naluState||0,d=l,u=[],c=-1;for(-1===l&&(c=0,a=31&e[0],l=0,i=1);i<o;)if(t=e[i++],l)if(1!==l)if(t)if(1===t){if(c>=0)n={data:e.subarray(c,i-l-1),type:a},u.push(n);else{var f=this._getLastNalUnit();if(f&&(d&&i<=4-d&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-d)),(r=i-l-1)>0)){var p=new Uint8Array(f.data.byteLength+r);p.set(f.data,0),p.set(e.subarray(0,r),f.data.byteLength),f.data=p}}i<o?(c=i,a=31&e[i],l=0):l=-1}else l=0;else l=3;else l=t?0:2;else l=t?0:1;if(c>=0&&l>=0&&(n={data:e.subarray(c,o),type:a,state:l},u.push(n)),0===u.length){var h=this._getLastNalUnit();if(h){var g=new Uint8Array(h.data.byteLength+e.byteLength);g.set(h.data,0),g.set(e,h.data.byteLength),h.data=g}}return s.naluState=l,u},t.discardEPB=function(e){for(var t,r,n=e.byteLength,a=[],i=1;i<n-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(a.push(i+2),i+=2):i++;if(0===a.length)return e;t=n-a.length,r=new Uint8Array(t);var o=0;for(i=0;i<t;o++,i++)o===a[0]&&(o++,a.shift()),r[i]=e[o];return r},t._parseAACPES=function(e){var t,r,i,o,l,d,u,c=this._audioTrack,p=e.data,y=e.pts,v=this.aacOverFlow,b=this.aacLastPTS;if(v){var w=new Uint8Array(v.byteLength+p.byteLength);w.set(v,0),w.set(p,v.byteLength),p=w}for(i=0,l=p.length;i<l-1&&!f(p,i);i++);if(!i||(i<l-1?(d="AAC PES did not start with ADTS header,offset:"+i,u=!1):(d="no ADTS header found in AAC PES",u=!0),s.logger.warn("parsing error:"+d),this.observer.trigger(n.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:u,reason:d}),!u)){if(h(c,this.observer,p,i,this.audioCodec),r=0,t=g(c.samplerate),v&&b){var k=b+t;Math.abs(k-y)>1&&(s.logger.log("AAC: align PTS for overlapping frames by "+Math.round((k-y)/90)),y=k)}for(;i<l;){if(f(p,i)){if(i+5<l){var E=m(c,p,i,y,r);if(E){i+=E.length,o=E.sample.pts,r++;continue}}break}i++}v=i<l?p.subarray(i,l):null,this.aacOverFlow=v,this.aacLastPTS=o}},t._parseMPEGPES=function(e){for(var t=e.data,r=t.length,n=0,a=0,i=e.pts;a<r;)if(k.isHeader(t,a)){var o=k.appendFrame(this._audioTrack,t,a,i,n);if(!o)break;a+=o.length,n++}else a++},t._parseID3PES=function(e){this._id3Track.samples.push(e)},e}(),x=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,n){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:n,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){var t,r,n=y.default.getID3Data(e,0);if(n&&void 0!==y.default.getTimeStamp(n))for(t=n.length,r=Math.min(e.length-1,t+100);t<r;t++)if(k.probe(e,t))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},t.append=function(e,t,r,n){for(var a=y.default.getID3Data(e,0),i=y.default.getTimeStamp(a),o=void 0!==i?90*i:9e4*t,s=a.length,l=e.length,d=0,u=0,c=this._audioTrack,f=[{pts:o,dts:o,data:a}];s<l;)if(k.isHeader(e,s)){var p=k.appendFrame(c,e,s,o,d);if(!p)break;s+=p.length,u=p.sample.pts,d++}else y.default.isHeader(e,s)?(a=y.default.getID3Data(e,s),f.push({pts:u,dts:u,data:a}),s+=a.length):s++;this.remuxer.remux(c,{samples:[]},{samples:f,inputTimeScale:9e4},{samples:[]},t,r,n)},t.destroy=function(){},e}(),A=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])}return null},e}(),R=Math.pow(2,32)-1,L=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]),n=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:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=i,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,l,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))},e.box=function(e){for(var t,r=Array.prototype.slice.call(arguments,1),n=8,a=r.length,i=a;a--;)n+=r[a].byteLength;for((t=new Uint8Array(n))[0]=n>>24&255,t[1]=n>>16&255,t[2]=n>>8&255,t[3]=255&n,t.set(e,4),a=0,n=8;a<i;a++)t.set(r[a],n),n+=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 n=Math.floor(r/(R+1)),a=Math.floor(r%(R+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,n>>24,n>>16&255,n>>8&255,255&n,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,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))},e.moov=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(n))},e.mvhd=function(t,r){r*=t;var n=Math.floor(r/(R+1)),a=Math.floor(r%(R+1)),i=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,n>>24,n>>16&255,n>>8&255,255&n,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,i)},e.sdtp=function(t){var r,n,a=t.samples||[],i=new Uint8Array(4+a.length);for(n=0;n<a.length;n++)r=a[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,i)},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,n,a,i=[],o=[];for(r=0;r<t.sps.length;r++)a=(n=t.sps[r]).byteLength,i.push(a>>>8&255),i.push(255&a),i=i.concat(Array.prototype.slice.call(n));for(r=0;r<t.pps.length;r++)a=(n=t.pps[r]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(o))),l=t.width,d=t.height,u=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,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,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,n=t.duration*t.timescale,a=t.width,i=t.height,o=Math.floor(n/(R+1)),s=Math.floor(n%(R+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,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,i>>8&255,255&i,0,0]))},e.traf=function(t,r){var n=e.sdtp(t),a=t.id,i=Math.floor(r/(R+1)),o=Math.floor(r%(R+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,i>>24,i>>16&255,i>>8&255,255&i,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)},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 n,a,i,o,s,l,d=t.samples||[],u=d.length,c=12+16*u,f=new Uint8Array(c);for(r+=8+c,f.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n<u;n++)i=(a=d[n]).duration,o=a.size,s=a.flags,l=a.cts,f.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*n);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r,n=e.moov(t);return(r=new Uint8Array(e.FTYP.byteLength+n.byteLength)).set(e.FTYP),r.set(n,e.FTYP.byteLength),r},e}();function C(e,t,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var a=e*t*r;return n?Math.round(a):a}function D(e,t){return void 0===t&&(t=!1),C(e,1e3,1/9e4,t)}function P(e,t){return void 0===t&&(t=1),C(e,9e4,1/t)}var O,I=P(10),M=P(.2),F=function(){function e(e,t,r,n){this.observer=e,this.config=t,this.typeSupported=r;var a=navigator.userAgent;this.isSafari=n&&n.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,i,o,l){if(this.ISGenerated||this.generateIS(e,t,i),this.ISGenerated){var d=e.samples.length,u=t.samples.length,c=i,f=i;if(d&&u){var p=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;c+=Math.max(0,p),f+=Math.max(0,-p)}if(d){e.timescale||(s.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,i));var h,g=this.remuxAudio(e,c,o,l);u&&(g&&(h=g.endPTS-g.startPTS),t.timescale||(s.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,i)),this.remuxVideo(t,f,o,h,l))}else if(u){var m=this.remuxVideo(t,f,o,0,l);m&&e.codec&&this.remuxEmptyAudio(e,c,o,m)}}r.samples.length&&this.remuxID3(r,i),a.samples.length&&this.remuxText(a,i),this.observer.trigger(n.default.FRAG_PARSED)},t.generateIS=function(e,t,r){var i,o,l=this.observer,d=e.samples,u=t.samples,c=this.typeSupported,f="audio/mp4",p={},h={tracks:p},g=void 0===this._initPTS;if(g&&(i=o=1/0),e.config&&d.length&&(e.timescale=e.samplerate,s.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(c.mpeg?(f="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),p.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&c.mpeg?new Uint8Array:L.initSegment([e]),metadata:{channelCount:e.channelCount}},g&&(i=o=d[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&u.length){var m=t.inputTimeScale;t.timescale=m,p.video={container:"video/mp4",codec:t.codec,initSegment:L.initSegment([t]),metadata:{width:t.width,height:t.height}},g&&(i=Math.min(i,u[0].pts-m*r),o=Math.min(o,u[0].dts-m*r),this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:i}))}else g&&p.audio&&this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:i});Object.keys(p).length?(l.trigger(n.default.FRAG_PARSING_INIT_SEGMENT,h),this.ISGenerated=!0,g&&(this._initPTS=i,this._initDTS=o)):l.trigger(n.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,i,o){var l,d,u,c,f,p,h,g=8,m=e.timescale,y=e.samples,v=[],b=y.length,w=this._PTSNormalize,k=this._initPTS,E=this.nextAvcDts,_=this.isSafari;if(0!==b){_&&(r|=y.length&&E&&(o&&Math.abs(t-E/m)<.1||Math.abs(y[0].pts-E-k)<m/5)),r||(E=t*m),y.forEach((function(e){e.pts=w(e.pts-k,E),e.dts=w(e.dts-k,E)})),y.sort((function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n||e.id-t.id}));var T=y.reduce((function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-1*M)}),0);if(T<0){s.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+D(T,!0)+" ms to overcome this issue");for(var S=0;S<y.length;S++)y[S].dts+=T}var x=y[0];f=Math.max(x.dts,0),c=Math.max(x.pts,0);var A=f-E;r&&A&&(A>1?s.logger.log("AVC: "+D(A,!0)+" ms hole between fragments detected,filling it"):A<-1&&s.logger.log("AVC: "+D(-A,!0)+" ms overlapping between fragments detected"),f=E,y[0].dts=f,c=Math.max(c-A,E),y[0].pts=c,s.logger.log("Video: PTS/DTS adjusted: "+D(c,!0)+"/"+D(f,!0)+", delta: "+D(A,!0)+" ms")),x=y[y.length-1],h=Math.max(x.dts,0),p=Math.max(x.pts,0,h),_&&(l=Math.round((h-f)/(y.leng