9 lines
129 KiB
JavaScript
9 lines
129 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-40ad1794"],{1368:function(e,t,i){(function(t,i){
|
|
/*!
|
|
* @overview es6-promise - a tiny implementation of Promises/A+.
|
|
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
|
* @license Licensed under MIT license
|
|
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
|
* @version v4.2.8+1e68dce6
|
|
*/
|
|
(function(t,i){e.exports=i()})(0,(function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function s(e){return"function"===typeof e}var r=void 0;r=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var n=r,a=0,o=void 0,h=void 0,l=function(e,t){b[a]=e,b[a+1]=t,a+=2,2===a&&(h?h(A):L())};function d(e){h=e}function u(e){l=e}var _="undefined"!==typeof window?window:void 0,c=_||{},m=c.MutationObserver||c.WebKitMutationObserver,f="undefined"===typeof self&&"undefined"!==typeof t&&"[object process]"==={}.toString.call(t),p="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel;function g(){return function(){return t.nextTick(A)}}function E(){return"undefined"!==typeof o?function(){o(A)}:y()}function v(){var e=0,t=new m(A),i=document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=e=++e%2}}function S(){var e=new MessageChannel;return e.port1.onmessage=A,function(){return e.port2.postMessage(0)}}function y(){var e=setTimeout;return function(){return e(A,1)}}var b=new Array(1e3);function A(){for(var e=0;e<a;e+=2){var t=b[e],i=b[e+1];t(i),b[e]=void 0,b[e+1]=void 0}a=0}function R(){try{var e=Function("return this")().require("vertx");return o=e.runOnLoop||e.runOnContext,E()}catch(t){return y()}}var L=void 0;function w(e,t){var i=this,s=new this.constructor(C);void 0===s[k]&&X(s);var r=i._state;if(r){var n=arguments[r-1];l((function(){return H(r,s,n,i._result)}))}else j(i,s,e,t);return s}function T(e){var t=this;if(e&&"object"===typeof e&&e.constructor===t)return e;var i=new t(C);return F(i,e),i}L=f?g():m?v():p?S():void 0===_?R():y();var k=Math.random().toString(36).substring(2);function C(){}var I=void 0,D=1,O=2;function M(){return new TypeError("You cannot resolve a promise with itself")}function B(){return new TypeError("A promises callback cannot return that same promise.")}function x(e,t,i,s){try{e.call(t,i,s)}catch(r){return r}}function U(e,t,i){l((function(e){var s=!1,r=x(i,t,(function(i){s||(s=!0,t!==i?F(e,i):V(e,i))}),(function(t){s||(s=!0,z(e,t))}),"Settle: "+(e._label||" unknown promise"));!s&&r&&(s=!0,z(e,r))}),e)}function N(e,t){t._state===D?V(e,t._result):t._state===O?z(e,t._result):j(t,void 0,(function(t){return F(e,t)}),(function(t){return z(e,t)}))}function P(e,t,i){t.constructor===e.constructor&&i===w&&t.constructor.resolve===T?N(e,t):void 0===i?V(e,t):s(i)?U(e,t,i):V(e,t)}function F(t,i){if(t===i)z(t,M());else if(e(i)){var s=void 0;try{s=i.then}catch(r){return void z(t,r)}P(t,i,s)}else V(t,i)}function G(e){e._onerror&&e._onerror(e._result),K(e)}function V(e,t){e._state===I&&(e._result=t,e._state=D,0!==e._subscribers.length&&l(K,e))}function z(e,t){e._state===I&&(e._state=O,e._result=t,l(G,e))}function j(e,t,i,s){var r=e._subscribers,n=r.length;e._onerror=null,r[n]=t,r[n+D]=i,r[n+O]=s,0===n&&e._state&&l(K,e)}function K(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var s=void 0,r=void 0,n=e._result,a=0;a<t.length;a+=3)s=t[a],r=t[a+i],s?H(i,s,r,n):r(n);e._subscribers.length=0}}function H(e,t,i,r){var n=s(i),a=void 0,o=void 0,h=!0;if(n){try{a=i(r)}catch(l){h=!1,o=l}if(t===a)return void z(t,B())}else a=r;t._state!==I||(n&&h?F(t,a):!1===h?z(t,o):e===D?V(t,a):e===O&&z(t,a))}function q(e,t){try{t((function(t){F(e,t)}),(function(t){z(e,t)}))}catch(i){z(e,i)}}var W=0;function $(){return W++}function X(e){e[k]=W++,e._state=void 0,e._result=void 0,e._subscribers=[]}function Y(){return new Error("Array Methods must be provided an Array")}var Z=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(C),this.promise[k]||X(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?V(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&V(this.promise,this._result))):z(this.promise,Y())}return e.prototype._enumerate=function(e){for(var t=0;this._state===I&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,s=i.resolve;if(s===T){var r=void 0,n=void 0,a=!1;try{r=e.then}catch(h){a=!0,n=h}if(r===w&&e._state!==I)this._settledAt(e._state,t,e._result);else if("function"!==typeof r)this._remaining--,this._result[t]=e;else if(i===se){var o=new i(C);a?z(o,n):P(o,e,r),this._willSettleAt(o,t)}else this._willSettleAt(new i((function(t){return t(e)})),t)}else this._willSettleAt(s(e),t)},e.prototype._settledAt=function(e,t,i){var s=this.promise;s._state===I&&(this._remaining--,e===O?z(s,i):this._result[t]=i),0===this._remaining&&V(s,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;j(e,void 0,(function(e){return i._settledAt(D,t,e)}),(function(e){return i._settledAt(O,t,e)}))},e}();function Q(e){return new Z(this,e).promise}function J(e){var t=this;return n(e)?new t((function(i,s){for(var r=e.length,n=0;n<r;n++)t.resolve(e[n]).then(i,s)})):new t((function(e,t){return t(new TypeError("You must pass an array to race."))}))}function ee(e){var t=this,i=new t(C);return z(i,e),i}function te(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function ie(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var se=function(){function e(t){this[k]=$(),this._result=this._state=void 0,this._subscribers=[],C!==t&&("function"!==typeof t&&te(),this instanceof e?q(this,t):ie())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this,i=t.constructor;return s(e)?t.then((function(t){return i.resolve(e()).then((function(){return t}))}),(function(t){return i.resolve(e()).then((function(){throw t}))})):t.then(e,e)},e}();function re(){var e=void 0;if("undefined"!==typeof i)e=i;else if("undefined"!==typeof self)e=self;else try{e=Function("return this")()}catch(r){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var s=null;try{s=Object.prototype.toString.call(t.resolve())}catch(r){}if("[object Promise]"===s&&!t.cast)return}e.Promise=se}return se.prototype.then=w,se.all=Q,se.race=J,se.resolve=T,se.reject=ee,se._setScheduler=d,se._setAsap=u,se._asap=l,se.polyfill=re,se.Promise=se,se}))}).call(this,i("4362"),i("c8ba"))},3683:function(e,t,i){"use strict";i.r(t);class s{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Object.assign=Object.assign||function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");let t=Object(e);for(let i=1;i<arguments.length;i++){let e=arguments[i];if(void 0!==e&&null!==e)for(let i in e)e.hasOwnProperty(i)&&(t[i]=e[i])}return t},"function"!==typeof self.Promise&&i("1368").polyfill()}}s.install();var r=s,n=i("faa1"),a=i.n(n);class o{static e(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","error",i),o.ENABLE_ERROR&&(console.error?console.error(i):console.warn?console.warn(i):console.log(i))}static i(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","info",i),o.ENABLE_INFO&&(console.info?console.info(i):console.log(i))}static w(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","warn",i),o.ENABLE_WARN&&(console.warn?console.warn(i):console.log(i))}static d(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","debug",i),o.ENABLE_DEBUG&&(console.debug?console.debug(i):console.log(i))}static v(e,t){e&&!o.FORCE_GLOBAL_TAG||(e=o.GLOBAL_TAG);let i=`[${e}] > ${t}`;o.ENABLE_CALLBACK&&o.emitter.emit("log","verbose",i),o.ENABLE_VERBOSE&&console.log(i)}}o.GLOBAL_TAG="flv.js",o.FORCE_GLOBAL_TAG=!1,o.ENABLE_ERROR=!0,o.ENABLE_INFO=!0,o.ENABLE_WARN=!0,o.ENABLE_DEBUG=!0,o.ENABLE_VERBOSE=!0,o.ENABLE_CALLBACK=!1,o.emitter=new a.a;var h=o;class l{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(e){0===this._firstCheckpoint?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=e,this._totalBytes+=e):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=e,this._totalBytes+=e):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=e,this._totalBytes+=e,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let e=(this._now()-this._lastCheckpoint)/1e3;return 0==e&&(e=1),this._intervalBytes/e/1024}get lastSecondKBps(){return this.addBytes(0),0!==this._lastSecondBytes?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024}}var d=l;class u{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class _ extends u{constructor(e){super(e)}get name(){return"IllegalStateException"}}class c extends u{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends u{constructor(e){super(e)}get name(){return"NotImplementedException"}}const f={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},p={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class g{constructor(e){this._type=e||"undefined",this._status=f.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=f.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===f.kConnecting||this._status===f.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(e){this._onContentLengthKnown=e}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(e){this._onURLRedirect=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}open(e,t){throw new m("Unimplemented abstract function!")}abort(){throw new m("Unimplemented abstract function!")}}let E={};function v(){let e=self.navigator.userAgent.toLowerCase(),t=/(edge)\/([\w.]+)/.exec(e)||/(opr)[\/]([\w.]+)/.exec(e)||/(chrome)[ \/]([\w.]+)/.exec(e)||/(iemobile)[\/]([\w.]+)/.exec(e)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(e)||[],i=/(ipad)/.exec(e)||/(ipod)/.exec(e)||/(windows phone)/.exec(e)||/(iphone)/.exec(e)||/(kindle)/.exec(e)||/(android)/.exec(e)||/(windows)/.exec(e)||/(mac)/.exec(e)||/(linux)/.exec(e)||/(cros)/.exec(e)||[],s={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:i[0]||""},r={};if(s.browser){r[s.browser]=!0;let e=s.majorVersion.split(".");r.version={major:parseInt(s.majorVersion,10),string:s.version},e.length>1&&(r.version.minor=parseInt(e[1],10)),e.length>2&&(r.version.build=parseInt(e[2],10))}if(s.platform&&(r[s.platform]=!0),(r.chrome||r.opr||r.safari)&&(r.webkit=!0),r.rv||r.iemobile){r.rv&&delete r.rv;let e="msie";s.browser=e,r[e]=!0}if(r.edge){delete r.edge;let e="msedge";s.browser=e,r[e]=!0}if(r.opr){let e="opera";s.browser=e,r[e]=!0}if(r.safari&&r.android){let e="android";s.browser=e,r[e]=!0}r.name=s.browser,r.platform=s.platform;for(let n in E)E.hasOwnProperty(n)&&delete E[n];Object.assign(E,r)}v();var S=E;class y extends g{static isSupported(){try{let e=S.msedge&&S.version.minor>=15048,t=!S.msedge||e;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}}constructor(e,t){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);let s=this._seekHandler.getConfig(i,t),r=new self.Headers;if("object"===typeof s.headers){let e=s.headers;for(let t in e)e.hasOwnProperty(t)&&r.append(t,e[t])}let n={method:"GET",headers:r,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"===typeof this._config.headers)for(let a in this._config.headers)r.append(a,this._config.headers[a]);!1===e.cors&&(n.mode="same-origin"),e.withCredentials&&(n.credentials="include"),e.referrerPolicy&&(n.referrerPolicy=e.referrerPolicy),this._status=f.kConnecting,self.fetch(s.url,n).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=f.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==s.url&&this._onURLRedirect){let t=this._seekHandler.removeURLParameters(e.url);this._onURLRedirect(t)}let t=e.headers.get("Content-Length");return null!=t&&(this._contentLength=parseInt(t),0!==this._contentLength&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,e.body.getReader())}if(this._status=f.kError,!this._onError)throw new u("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=f.kError,!this._onError)throw e;this._onError(p.EXCEPTION,{code:-1,msg:e.message})})}abort(){this._requestAbort=!0}_pump(e){return e.read().then(t=>{if(t.done)if(null!==this._contentLength&&this._receivedLength<this._contentLength){this._status=f.kError;let e=p.EARLY_EOF,t={code:-1,msg:"Fetch stream meet Early-EOF"};if(!this._onError)throw new u(t.msg);this._onError(e,t)}else this._status=f.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1);else{if(!0===this._requestAbort)return this._requestAbort=!1,this._status=f.kComplete,e.cancel();this._status=f.kBuffering;let i=t.value.buffer,s=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength,this._onDataArrival&&this._onDataArrival(i,s,this._receivedLength),this._pump(e)}}).catch(e=>{if(11===e.code&&S.msedge)return;this._status=f.kError;let t=0,i=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength<this._contentLength)?(t=p.EXCEPTION,i={code:e.code,msg:e.message}):(t=p.EARLY_EOF,i={code:e.code,msg:"Fetch stream meet Early-EOF"}),!this._onError)throw new u(i.msg);this._onError(t,i)})}}var b=y;class A extends g{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="moz-chunked-arraybuffer","moz-chunked-arraybuffer"===e.responseType}catch(e){return h.w("MozChunkedLoader",e.message),!1}}constructor(e,t){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=e,this._config=t,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(e,t){this._dataSource=e,this._range=t;let i=e.url;this._config.reuseRedirectedURL&&void 0!=e.redirectedURL&&(i=e.redirectedURL);let s=this._seekHandler.getConfig(i,t);this._requestURL=s.url;let r=this._xhr=new XMLHttpRequest;if(r.open("GET",s.url,!0),r.responseType="moz-chunked-arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onloadend=this._onLoadEnd.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"===typeof s.headers){let e=s.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}if("object"===typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}this._status=f.kConnecting,r.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=f.kComplete}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(void 0!=t.responseURL&&t.responseURL!==this._requestURL&&this._onURLRedirect){let e=this._seekHandler.removeURLParameters(t.responseURL);this._onURLRedirect(e)}if(0!==t.status&&(t.status<200||t.status>299)){if(this._status=f.kError,!this._onError)throw new u("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=f.kBuffering}}_onProgress(e){if(this._status===f.kError)return;null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let t=e.target.response,i=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==f.kError&&(this._status=f.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=f.kError;let t=0,i=null;if(this._contentLength&&e.loaded<this._contentLength?(t=p.EARLY_EOF,i={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(t=p.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new u(i.msg);this._onError(t,i)}}var R=A;class L extends g{static isSupported(){try{let e=new XMLHttpRequest;return e.open("GET","https://example.com",!0),e.responseType="arraybuffer","arraybuffer"===e.responseType}catch(e){return h.w("RangeLoader",e.message),!1}}constructor(e,t){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=e,this._config=t,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new d,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(e,t){this._dataSource=e,this._range=t,this._status=f.kConnecting;let i=!1;void 0!=this._dataSource.filesize&&0!==this._dataSource.filesize&&(i=!0,this._totalLength=this._dataSource.filesize),this._totalLengthReceived||i?this._openSubRange():(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1}))}_openSubRange(){let e=1024*this._currentChunkSizeKB,t=this._range.from+this._receivedLength,i=t+e;null!=this._contentLength&&i-this._range.from>=this._contentLength&&(i=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:i},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let i=e.url;this._config.reuseRedirectedURL&&(void 0!=this._currentRedirectedURL?i=this._currentRedirectedURL:void 0!=e.redirectedURL&&(i=e.redirectedURL));let s=this._seekHandler.getConfig(i,t);this._currentRequestURL=s.url;let r=this._xhr=new XMLHttpRequest;if(r.open("GET",s.url,!0),r.responseType="arraybuffer",r.onreadystatechange=this._onReadyStateChange.bind(this),r.onprogress=this._onProgress.bind(this),r.onload=this._onLoad.bind(this),r.onerror=this._onXhrError.bind(this),e.withCredentials&&(r.withCredentials=!0),"object"===typeof s.headers){let e=s.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}if("object"===typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&r.setRequestHeader(t,e[t])}r.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=f.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(e){let t=e.target;if(2===t.readyState){if(void 0!=t.responseURL){let e=this._seekHandler.removeURLParameters(t.responseURL);t.responseURL!==this._currentRequestURL&&e!==this._currentRedirectedURL&&(this._currentRedirectedURL=e,this._onURLRedirect&&this._onURLRedirect(e))}if(t.status>=200&&t.status<=299){if(this._waitForTotalLength)return;this._status=f.kBuffering}else{if(this._status=f.kError,!this._onError)throw new u("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(p.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===f.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let i=e.total;this._internalAbort(),null!=i&0!==i&&(this._totalLength=i)}if(-1===this._range.to?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,t)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let t=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(t)}_normalizeSpeed(e){let t=this._chunkSizeKBList,i=t.length-1,s=0,r=0,n=i;if(e<t[0])return t[0];while(r<=n){if(s=r+Math.floor((n-r)/2),s===i||e>=t[s]&&e<t[s+1])return t[s];t[s]<e?r=s+1:n=s-1}}_onLoad(e){if(this._status===f.kError)return;if(this._waitForTotalLength)return void(this._waitForTotalLength=!1);this._lastTimeLoaded=0;let t=this._speedSampler.lastSecondKBps;if(0===t&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let i=e.target.response,s=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;let r=!1;null!=this._contentLength&&this._receivedLength<this._contentLength?this._openSubRange():r=!0,this._onDataArrival&&this._onDataArrival(i,s,this._receivedLength),r&&(this._status=f.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(e){this._status=f.kError;let t=0,i=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(t=p.EARLY_EOF,i={code:-1,msg:"RangeLoader meet Early-Eof"}):(t=p.EXCEPTION,i={code:-1,msg:e.constructor.name+" "+e.type}),!this._onError)throw new u(i.msg);this._onError(t,i)}}var w=L;class T extends g{static isSupported(){try{return"undefined"!==typeof self.WebSocket}catch(e){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(e){try{let t=this._ws=new self.WebSocket(e.url);t.binaryType="arraybuffer",t.onopen=this._onWebSocketOpen.bind(this),t.onclose=this._onWebSocketClose.bind(this),t.onmessage=this._onWebSocketMessage.bind(this),t.onerror=this._onWebSocketError.bind(this),this._status=f.kConnecting}catch(t){this._status=f.kError;let e={code:t.code,msg:t.message};if(!this._onError)throw new u(e.msg);this._onError(p.EXCEPTION,e)}}abort(){let e=this._ws;!e||0!==e.readyState&&1!==e.readyState||(this._requestAbort=!0,e.close()),this._ws=null,this._status=f.kComplete}_onWebSocketOpen(e){this._status=f.kBuffering}_onWebSocketClose(e){!0!==this._requestAbort?(this._status=f.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)):this._requestAbort=!1}_onWebSocketMessage(e){if(e.data instanceof ArrayBuffer)this._dispatchArrayBuffer(e.data);else if(e.data instanceof Blob){let t=new FileReader;t.onload=()=>{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=f.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new u(t.msg);this._onError(p.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,i=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}_onWebSocketError(e){this._status=f.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new u(t.msg);this._onError(p.EXCEPTION,t)}}var k=T;class C{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let i={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,i["Range"]=e}else this._zeroStart&&(i["Range"]="bytes=0-");return{url:e,headers:i}}removeURLParameters(e){return e}}var I=C;class D{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let i=e;if(0!==t.from||-1!==t.to){let e=!0;-1===i.indexOf("?")&&(i+="?",e=!1),e&&(i+="&"),i+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(i+=`&${this._endName}=${t.to.toString()}`)}return{url:i,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],i=void 0,s=e.indexOf("?");-1!==s&&(i=e.substring(s+1));let r="";if(void 0!=i&&i.length>0){let e=i.split("&");for(let t=0;t<e.length;t++){let i=e[t].split("="),s=t>0;i[0]!==this._startName&&i[0]!==this._endName&&(s&&(r+="&"),r+=e[t])}}return 0===r.length?t:t+"?"+r}}var O=D;class M{constructor(e,t,i){this.TAG="IOController",this._config=t,this._extraData=i,this._stashInitialSize=393216,void 0!=t.stashInitialSize&&t.stashInitialSize>0&&(this._stashInitialSize=t.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,!1===t.enableStashBuffer&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new d,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(e){this._extraData=e}get onDataArrival(){return this._onDataArrival}set onDataArrival(e){this._onDataArrival=e}get onSeeked(){return this._onSeeked}set onSeeked(e){this._onSeeked=e}get onError(){return this._onError}set onError(e){this._onError=e}get onComplete(){return this._onComplete}set onComplete(e){this._onComplete=e}get onRedirect(){return this._onRedirect}set onRedirect(e){this._onRedirect=e}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(e){this._onRecoveredEarlyEof=e}get currentURL(){return this._dataSource.url}get hasRedirect(){return null!=this._redirectedURL||void 0!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===w?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new I(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",i=e.seekParamEnd||"bend";this._seekHandler=new O(t,i)}else{if("custom"!==e.seekType)throw new c("Invalid seekType in config: "+e.seekType);if("function"!==typeof e.customSeekHandler)throw new c("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}}_selectLoader(){if(null!=this._config.customLoader)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=k;else if(b.isSupported())this._loaderClass=b;else if(R.isSupported())this._loaderClass=R;else{if(!w.isSupported())throw new u("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=w}}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),!1===this._loader.needStashBuffer&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(e){this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),this._speedSampler.reset(),e||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}}seek(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)}_internalSeek(e,t){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(t),this._loader.destroy(),this._loader=null;let i={from:e,to:-1};this._currentRange={from:i.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,i),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!==typeof e||0===e.length)throw new c("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;while(t+1048576<e)t*=2;if(t+=1048576,t===this._bufferSize)return;let i=new ArrayBuffer(t);if(this._stashUsed>0){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed),s=new Uint8Array(i,0,t);s.set(e,0)}this._stashBuffer=i,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,i=t.length-1,s=0,r=0,n=i;if(e<t[0])return t[0];while(r<=n){if(s=r+Math.floor((n-r)/2),s===i||e>=t[s]&&e<t[s+1])return t[s];t[s]<e?r=s+1:n=s-1}}_adjustStashSize(e){let t=0;t=this._config.isLive||e<512?e:e>=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let i=1024*t+1048576;this._bufferSize<i&&this._expandBuffer(i),this._stashSize=1024*t}_dispatchChunks(e,t){return this._currentRange.to=t+e.byteLength-1,this._onDataArrival(e,t)}_onURLRedirect(e){this._redirectedURL=e,this._onRedirect&&this._onRedirect(e)}_onContentLengthKnown(e){e&&this._fullRequestFlag&&(this._totalLength=e,this._fullRequestFlag=!1)}_onLoaderChunkArrival(e,t,i){if(!this._onDataArrival)throw new _("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(e.byteLength);let s=this._speedSampler.lastSecondKBps;if(0!==s){let e=this._normalizeSpeed(s);this._speedNormalized!==e&&(this._speedNormalized=e,this._adjustStashSize(e))}if(this._enableStash)if(0===this._stashUsed&&0===this._stashByteStart&&(this._stashByteStart=t),this._stashUsed+e.byteLength<=this._stashSize){let t=new Uint8Array(this._stashBuffer,0,this._stashSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let i=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),s=this._dispatchChunks(t,this._stashByteStart);if(s<t.byteLength){if(s>0){let e=new Uint8Array(t,s);i.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=s}}else this._stashUsed=0,this._stashByteStart+=s;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let s=this._dispatchChunks(e,t);if(s<e.byteLength){let r=e.byteLength-s;r>this._bufferSize&&(this._expandBuffer(r),i=new Uint8Array(this._stashBuffer,0,this._bufferSize)),i.set(new Uint8Array(e,s),0),this._stashUsed+=r,this._stashByteStart=t+s}}}else if(0===this._stashUsed){let i=this._dispatchChunks(e,t);if(i<e.byteLength){let s=e.byteLength-i;s>this._bufferSize&&this._expandBuffer(s);let r=new Uint8Array(this._stashBuffer,0,this._bufferSize);r.set(new Uint8Array(e,i),0),this._stashUsed+=s,this._stashByteStart=t+i}}else{this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength);let t=new Uint8Array(this._stashBuffer,0,this._bufferSize);t.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength;let i=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(i<this._stashUsed&&i>0){let e=new Uint8Array(this._stashBuffer,i);t.set(e,0)}this._stashUsed-=i,this._stashByteStart+=i}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),i=this._dispatchChunks(t,this._stashByteStart),s=t.byteLength-i;if(i<t.byteLength){if(!e){if(i>0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),s=new Uint8Array(t,i);e.set(s,0),this._stashUsed=s.byteLength,this._stashByteStart+=i}return 0}h.w(this.TAG,s+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,s}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(h.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=p.UNRECOVERABLE_EARLY_EOF),e){case p.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e<this._totalLength&&(h.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(e,!1)))}e=p.UNRECOVERABLE_EARLY_EOF;break;case p.UNRECOVERABLE_EARLY_EOF:case p.CONNECTING_TIMEOUT:case p.HTTP_STATUS_CODE_INVALID:case p.EXCEPTION:break}if(!this._onError)throw new u("IOException: "+t.msg);this._onError(e,t)}}var B=M;const x={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function U(){return Object.assign({},x)}class N{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let e=new B({},U()),t=e.loaderType;return e.destroy(),"fetch-stream-loader"==t||"xhr-moz-chunked-loader"==t}static getNetworkLoaderTypeName(){let e=new B({},U()),t=e.loaderType;return e.destroy(),t}static supportNativeMediaPlayback(e){void 0==N.videoElement&&(N.videoElement=window.document.createElement("video"));let t=N.videoElement.canPlayType(e);return"probably"===t||"maybe"==t}static getFeatureList(){let e={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return e.mseFlvPlayback=N.supportMSEH264Playback(),e.networkStreamIO=N.supportNetworkStreamIO(),e.networkLoaderName=N.getNetworkLoaderTypeName(),e.mseLiveFlvPlayback=e.mseFlvPlayback&&e.networkStreamIO,e.nativeMP4H264Playback=N.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),e.nativeWebmVP8Playback=N.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),e.nativeWebmVP9Playback=N.supportNativeMediaPlayback('video/webm; codecs="vp9"'),e}}var P=N;const F={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};var G=F;class V{static get forceGlobalTag(){return h.FORCE_GLOBAL_TAG}static set forceGlobalTag(e){h.FORCE_GLOBAL_TAG=e,V._notifyChange()}static get globalTag(){return h.GLOBAL_TAG}static set globalTag(e){h.GLOBAL_TAG=e,V._notifyChange()}static get enableAll(){return h.ENABLE_VERBOSE&&h.ENABLE_DEBUG&&h.ENABLE_INFO&&h.ENABLE_WARN&&h.ENABLE_ERROR}static set enableAll(e){h.ENABLE_VERBOSE=e,h.ENABLE_DEBUG=e,h.ENABLE_INFO=e,h.ENABLE_WARN=e,h.ENABLE_ERROR=e,V._notifyChange()}static get enableDebug(){return h.ENABLE_DEBUG}static set enableDebug(e){h.ENABLE_DEBUG=e,V._notifyChange()}static get enableVerbose(){return h.ENABLE_VERBOSE}static set enableVerbose(e){h.ENABLE_VERBOSE=e,V._notifyChange()}static get enableInfo(){return h.ENABLE_INFO}static set enableInfo(e){h.ENABLE_INFO=e,V._notifyChange()}static get enableWarn(){return h.ENABLE_WARN}static set enableWarn(e){h.ENABLE_WARN=e,V._notifyChange()}static get enableError(){return h.ENABLE_ERROR}static set enableError(e){h.ENABLE_ERROR=e,V._notifyChange()}static getConfig(){return{globalTag:h.GLOBAL_TAG,forceGlobalTag:h.FORCE_GLOBAL_TAG,enableVerbose:h.ENABLE_VERBOSE,enableDebug:h.ENABLE_DEBUG,enableInfo:h.ENABLE_INFO,enableWarn:h.ENABLE_WARN,enableError:h.ENABLE_ERROR,enableCallback:h.ENABLE_CALLBACK}}static applyConfig(e){h.GLOBAL_TAG=e.globalTag,h.FORCE_GLOBAL_TAG=e.forceGlobalTag,h.ENABLE_VERBOSE=e.enableVerbose,h.ENABLE_DEBUG=e.enableDebug,h.ENABLE_INFO=e.enableInfo,h.ENABLE_WARN=e.enableWarn,h.ENABLE_ERROR=e.enableError,h.ENABLE_CALLBACK=e.enableCallback}static _notifyChange(){let e=V.emitter;if(e.listenerCount("change")>0){let t=V.getConfig();e.emit("change",t)}}static registerListener(e){V.emitter.addListener("change",e)}static removeListener(e){V.emitter.removeListener("change",e)}static addLogListener(e){h.emitter.addListener("log",e),h.emitter.listenerCount("log")>0&&(h.ENABLE_CALLBACK=!0,V._notifyChange())}static removeLogListener(e){h.emitter.removeListener("log",e),0===h.emitter.listenerCount("log")&&(h.ENABLE_CALLBACK=!1,V._notifyChange())}}V.emitter=new a.a;var z=V;class j{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let e=!1===this.hasAudio||!0===this.hasAudio&&null!=this.audioCodec&&null!=this.audioSampleRate&&null!=this.audioChannelCount,t=!1===this.hasVideo||!0===this.hasVideo&&null!=this.videoCodec&&null!=this.width&&null!=this.height&&null!=this.fps&&null!=this.profile&&null!=this.level&&null!=this.refFrames&&null!=this.chromaFormat&&null!=this.sarNum&&null!=this.sarDen;return null!=this.mimeType&&null!=this.duration&&null!=this.metadata&&null!=this.hasKeyframesIndex&&e&&t}isSeekable(){return!0===this.hasKeyframesIndex}getNearestKeyframe(e){if(null==this.keyframesIndex)return null;let t=this.keyframesIndex,i=this._search(t.times,e);return{index:i,milliseconds:t.times[i],fileposition:t.filepositions[i]}}_search(e,t){let i=0,s=e.length-1,r=0,n=0,a=s;t<e[0]&&(i=0,n=a+1);while(n<=a){if(r=n+Math.floor((a-n)/2),r===s||t>=e[r]&&t<e[r+1]){i=r;break}e[r]<t?n=r+1:a=r-1}return i}}var K=j;function H(e,t,i){let s=e;if(t+i<s.length){while(i--)if(128!==(192&s[++t]))return!1;return!0}return!1}function q(e){let t=[],i=e,s=0,r=e.length;while(s<r)if(i[s]<128)t.push(String.fromCharCode(i[s])),++s;else{if(i[s]<192);else if(i[s]<224){if(H(i,s,1)){let e=(31&i[s])<<6|63&i[s+1];if(e>=128){t.push(String.fromCharCode(65535&e)),s+=2;continue}}}else if(i[s]<240){if(H(i,s,2)){let e=(15&i[s])<<12|(63&i[s+1])<<6|63&i[s+2];if(e>=2048&&55296!==(63488&e)){t.push(String.fromCharCode(65535&e)),s+=3;continue}}}else if(i[s]<248&&H(i,s,3)){let e=(7&i[s])<<18|(63&i[s+1])<<12|(63&i[s+2])<<6|63&i[s+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),s+=4;continue}}t.push(String.fromCharCode(65533)),++s}return t.join("")}var W=q;let $=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class X{static parseScriptData(e,t,i){let s={};try{let r=X.parseValue(e,t,i),n=X.parseValue(e,t+r.size,i-r.size);s[r.data]=n.data}catch(r){h.e("AMF",r.toString())}return s}static parseObject(e,t,i){if(i<3)throw new _("Data not enough when parse ScriptDataObject");let s=X.parseString(e,t,i),r=X.parseValue(e,t+s.size,i-s.size),n=r.objectEnd;return{data:{name:s.data,value:r.data},size:s.size+r.size,objectEnd:n}}static parseVariable(e,t,i){return X.parseObject(e,t,i)}static parseString(e,t,i){if(i<2)throw new _("Data not enough when parse String");let s,r=new DataView(e,t,i),n=r.getUint16(0,!$);return s=n>0?W(new Uint8Array(e,t+2,n)):"",{data:s,size:2+n}}static parseLongString(e,t,i){if(i<4)throw new _("Data not enough when parse LongString");let s,r=new DataView(e,t,i),n=r.getUint32(0,!$);return s=n>0?W(new Uint8Array(e,t+4,n)):"",{data:s,size:4+n}}static parseDate(e,t,i){if(i<10)throw new _("Data size invalid when parse Date");let s=new DataView(e,t,i),r=s.getFloat64(0,!$),n=s.getInt16(8,!$);return r+=60*n*1e3,{data:new Date(r),size:10}}static parseValue(e,t,i){if(i<1)throw new _("Data not enough when parse Value");let s,r=new DataView(e,t,i),n=1,a=r.getUint8(0),o=!1;try{switch(a){case 0:s=r.getFloat64(1,!$),n+=8;break;case 1:{let e=r.getUint8(1);s=!!e,n+=1;break}case 2:{let r=X.parseString(e,t+1,i-1);s=r.data,n+=r.size;break}case 3:{s={};let a=0;9===(16777215&r.getUint32(i-4,!$))&&(a=3);while(n<i-4){let r=X.parseObject(e,t+n,i-n-a);if(r.objectEnd)break;s[r.data.name]=r.data.value,n+=r.size}if(n<=i-3){let e=16777215&r.getUint32(n-1,!$);9===e&&(n+=3)}break}case 8:{s={},n+=4;let a=0;9===(16777215&r.getUint32(i-4,!$))&&(a=3);while(n<i-8){let r=X.parseVariable(e,t+n,i-n-a);if(r.objectEnd)break;s[r.data.name]=r.data.value,n+=r.size}if(n<=i-3){let e=16777215&r.getUint32(n-1,!$);9===e&&(n+=3)}break}case 9:s=void 0,n=1,o=!0;break;case 10:{s=[];let a=r.getUint32(1,!$);n+=4;for(let r=0;r<a;r++){let r=X.parseValue(e,t+n,i-n);s.push(r.data),n+=r.size}break}case 11:{let r=X.parseDate(e,t+1,i-1);s=r.data,n+=r.size;break}case 12:{let r=X.parseString(e,t+1,i-1);s=r.data,n+=r.size;break}default:n=i,h.w("AMF","Unsupported AMF value type "+a)}}catch(l){h.e("AMF",l.toString())}return{data:s,size:n,objectEnd:o}}}var Y=X;class Z{constructor(e){this.TAG="ExpGolomb",this._buffer=e,this._buffer_index=0,this._total_bytes=e.byteLength,this._total_bits=8*e.byteLength,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let e=this._total_bytes-this._buffer_index;if(e<=0)throw new _("ExpGolomb: _fillCurrentWord() but no bytes available");let t=Math.min(4,e),i=new Uint8Array(4);i.set(this._buffer.subarray(this._buffer_index,this._buffer_index+t)),this._current_word=new DataView(i.buffer).getUint32(0,!1),this._buffer_index+=t,this._current_word_bits_left=8*t}readBits(e){if(e>32)throw new c("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){let t=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,t}let t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;let i=e-this._current_word_bits_left;this._fillCurrentWord();let s=Math.min(i,this._current_word_bits_left),r=this._current_word>>>32-s;return this._current_word<<=s,this._current_word_bits_left-=s,t=t<<s|r,t}readBool(){return 1===this.readBits(1)}readByte(){return this.readBits(8)}_skipLeadingZero(){let e;for(e=0;e<this._current_word_bits_left;e++)if(0!==(this._current_word&2147483648>>>e))return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()}readUEG(){let e=this._skipLeadingZero();return this.readBits(e+1)-1}readSEG(){let e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)}}var Q=Z;class J{static _ebsp2rbsp(e){let t=e,i=t.byteLength,s=new Uint8Array(i),r=0;for(let n=0;n<i;n++)n>=2&&3===t[n]&&0===t[n-1]&&0===t[n-2]||(s[r]=t[n],r++);return new Uint8Array(s.buffer,0,r)}static parseSPS(e){let t=J._ebsp2rbsp(e),i=new Q(t);i.readByte();let s=i.readByte();i.readByte();let r=i.readByte();i.readUEG();let n=J.getProfileString(s),a=J.getLevelString(r),o=1,h=420,l=[0,420,422,444],d=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(o=i.readUEG(),3===o&&i.readBits(1),o<=3&&(h=l[o]),d=i.readUEG()+8,i.readUEG(),i.readBits(1),i.readBool())){let e=3!==o?8:12;for(let t=0;t<e;t++)i.readBool()&&(t<6?J._skipScalingList(i,16):J._skipScalingList(i,64))}i.readUEG();let u=i.readUEG();if(0===u)i.readUEG();else if(1===u){i.readBits(1),i.readSEG(),i.readSEG();let e=i.readUEG();for(let t=0;t<e;t++)i.readSEG()}let _=i.readUEG();i.readBits(1);let c=i.readUEG(),m=i.readUEG(),f=i.readBits(1);0===f&&i.readBits(1),i.readBits(1);let p=0,g=0,E=0,v=0,S=i.readBool();S&&(p=i.readUEG(),g=i.readUEG(),E=i.readUEG(),v=i.readUEG());let y=1,b=1,A=0,R=!0,L=0,w=0,T=i.readBool();if(T){if(i.readBool()){let e=i.readByte(),t=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],s=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];e>0&&e<16?(y=t[e-1],b=s[e-1]):255===e&&(y=i.readByte()<<8|i.readByte(),b=i.readByte()<<8|i.readByte())}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(4),i.readBool()&&i.readBits(24)),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool()){let e=i.readBits(32),t=i.readBits(32);R=i.readBool(),L=t,w=2*e,A=L/w}}let k=1;1===y&&1===b||(k=y/b);let C=0,I=0;if(0===o)C=1,I=2-f;else{let e=3===o?1:2,t=1===o?2:1;C=e,I=t*(2-f)}let D=16*(c+1),O=16*(m+1)*(2-f);D-=(p+g)*C,O-=(E+v)*I;let M=Math.ceil(D*k);return i.destroy(),i=null,{profile_string:n,level_string:a,bit_depth:d,ref_frames:_,chroma_format:h,chroma_format_string:J.getChromaFormatString(h),frame_rate:{fixed:R,fps:A,fps_den:w,fps_num:L},sar_ratio:{width:y,height:b},codec_size:{width:D,height:O},present_size:{width:M,height:O}}}static _skipScalingList(e,t){let i=8,s=8,r=0;for(let n=0;n<t;n++)0!==s&&(r=e.readSEG(),s=(i+r+256)%256),i=0===s?i:s}static getProfileString(e){switch(e){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(e){return(e/10).toFixed(1)}static getChromaFormatString(e){switch(e){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var ee=J;const te={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};var ie=te;function se(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}class re{constructor(e,t){this.TAG="FLVDemuxer",this._config=t,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new K,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(e){let t=new Uint8Array(e),i={match:!1};if(70!==t[0]||76!==t[1]||86!==t[2]||1!==t[3])return i;let s=(4&t[4])>>>2!==0,r=0!==(1&t[4]),n=se(t,5);return n<9?i:{match:!0,consumed:n,dataOffset:n,hasAudioTrack:s,hasVideoTrack:r}}bindDataSource(e){return e.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(e){this._onTrackMetadata=e}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(e){this._onMediaInfo=e}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(e){this._onMetaDataArrived=e}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(e){this._onScriptDataArrived=e}get onError(){return this._onError}set onError(e){this._onError=e}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(e){this._onDataAvailable=e}get timestampBase(){return this._timestampBase}set timestampBase(e){this._timestampBase=e}get overridedDuration(){return this._duration}set overridedDuration(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo.duration=e}set overridedHasAudio(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo.hasAudio=e}set overridedHasVideo(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo.hasVideo=e}resetMediaInfo(){this._mediaInfo=new K}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched}parseChunks(e,t){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new _("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let i=0,s=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;{let t=re.probe(e);i=t.dataOffset}}if(this._firstParse){this._firstParse=!1,t+i!==this._dataOffset&&h.w(this.TAG,"First time parsing but chunk byteStart invalid!");let r=new DataView(e,i),n=r.getUint32(0,!s);0!==n&&h.w(this.TAG,"PrevTagSize0 !== 0 !!!"),i+=4}while(i<e.byteLength){this._dispatch=!0;let r=new DataView(e,i);if(i+11+4>e.byteLength)break;let n=r.getUint8(0),a=16777215&r.getUint32(0,!s);if(i+11+a+4>e.byteLength)break;if(8!==n&&9!==n&&18!==n){h.w(this.TAG,`Unsupported tag type ${n}, skipped`),i+=11+a+4;continue}let o=r.getUint8(4),l=r.getUint8(5),d=r.getUint8(6),u=r.getUint8(7),_=d|l<<8|o<<16|u<<24,c=16777215&r.getUint32(7,!s);0!==c&&h.w(this.TAG,"Meet tag which has StreamID != 0!");let m=i+11;switch(n){case 8:this._parseAudioData(e,m,a,_);break;case 9:this._parseVideoData(e,m,a,_,t+i);break;case 18:this._parseScriptData(e,m,a);break}let f=r.getUint32(11+a,!s);f!==11+a&&h.w(this.TAG,"Invalid PrevTagSize "+f),i+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),i}_parseScriptData(e,t,i){let s=Y.parseScriptData(e,t,i);if(s.hasOwnProperty("onMetaData")){if(null==s.onMetaData||"object"!==typeof s.onMetaData)return void h.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&h.w(this.TAG,"Found another onMetaData tag!"),this._metadata=s;let e=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},e)),"boolean"===typeof e.hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=e.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),"boolean"===typeof e.hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=e.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),"number"===typeof e.audiodatarate&&(this._mediaInfo.audioDataRate=e.audiodatarate),"number"===typeof e.videodatarate&&(this._mediaInfo.videoDataRate=e.videodatarate),"number"===typeof e.width&&(this._mediaInfo.width=e.width),"number"===typeof e.height&&(this._mediaInfo.height=e.height),"number"===typeof e.duration){if(!this._durationOverrided){let t=Math.floor(e.duration*this._timescale);this._duration=t,this._mediaInfo.duration=t}}else this._mediaInfo.duration=0;if("number"===typeof e.framerate){let t=Math.floor(1e3*e.framerate);if(t>0){let e=t/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=e,this._referenceFrameRate.fps_num=t,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=e}}if("object"===typeof e.keyframes){this._mediaInfo.hasKeyframesIndex=!0;let t=e.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(t),e.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=e,h.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(s).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},s))}_parseKeyframesIndex(e){let t=[],i=[];for(let s=1;s<e.times.length;s++){let r=this._timestampBase+Math.floor(1e3*e.times[s]);t.push(r),i.push(e.filepositions[s])}return{times:t,filepositions:i}}_parseAudioData(e,t,i,s){if(i<=1)return void h.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");if(!0===this._hasAudioFlagOverrided&&!1===this._hasAudio)return;this._littleEndian;let r=new DataView(e,t,i),n=r.getUint8(0),a=n>>>4;if(2!==a&&10!==a)return void this._onError(ie.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+a);let o=0,l=(12&n)>>>2;if(!(l>=0&&l<=4))return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+l);o=this._flvSoundRateTable[l];let d=1&n,u=this._audioMetadata,_=this._audioTrack;if(u||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),u=this._audioMetadata={},u.type="audio",u.id=_.id,u.timescale=this._timescale,u.duration=this._duration,u.audioSampleRate=o,u.channelCount=0===d?1:2),10===a){let r=this._parseAACAudioData(e,t+1,i-1);if(void 0==r)return;if(0===r.packetType){u.config&&h.w(this.TAG,"Found another AudioSpecificConfig!");let e=r.data;u.audioSampleRate=e.samplingRate,u.channelCount=e.channelCount,u.codec=e.codec,u.originalCodec=e.originalCodec,u.config=e.config,u.refSampleDuration=1024/u.audioSampleRate*u.timescale,h.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",u);let t=this._mediaInfo;t.audioCodec=u.originalCodec,t.audioSampleRate=u.audioSampleRate,t.audioChannelCount=u.channelCount,t.hasVideo?null!=t.videoCodec&&(t.mimeType='video/x-flv; codecs="'+t.videoCodec+","+t.audioCodec+'"'):t.mimeType='video/x-flv; codecs="'+t.audioCodec+'"',t.isComplete()&&this._onMediaInfo(t)}else if(1===r.packetType){let e=this._timestampBase+s,t={unit:r.data,length:r.data.byteLength,dts:e,pts:e};_.samples.push(t),_.length+=r.data.length}else h.e(this.TAG,"Flv: Unsupported AAC data type "+r.packetType)}else if(2===a){if(!u.codec){let s=this._parseMP3AudioData(e,t+1,i-1,!0);if(void 0==s)return;u.audioSampleRate=s.samplingRate,u.channelCount=s.channelCount,u.codec=s.codec,u.originalCodec=s.originalCodec,u.refSampleDuration=1152/u.audioSampleRate*u.timescale,h.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",u);let r=this._mediaInfo;r.audioCodec=u.codec,r.audioSampleRate=u.audioSampleRate,r.audioChannelCount=u.channelCount,r.audioDataRate=s.bitRate,r.hasVideo?null!=r.videoCodec&&(r.mimeType='video/x-flv; codecs="'+r.videoCodec+","+r.audioCodec+'"'):r.mimeType='video/x-flv; codecs="'+r.audioCodec+'"',r.isComplete()&&this._onMediaInfo(r)}let r=this._parseMP3AudioData(e,t+1,i-1,!1);if(void 0==r)return;let n=this._timestampBase+s,a={unit:r,length:r.byteLength,dts:n,pts:n};_.samples.push(a),_.length+=r.length}}_parseAACAudioData(e,t,i){if(i<=1)return void h.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let s={},r=new Uint8Array(e,t,i);return s.packetType=r[0],0===r[0]?s.data=this._parseAACAudioSpecificConfig(e,t+1,i-1):s.data=r.subarray(1),s}_parseAACAudioSpecificConfig(e,t,i){let s=new Uint8Array(e,t,i),r=null,n=0,a=0,o=null,h=0,l=null;if(n=a=s[0]>>>3,h=(7&s[0])<<1|s[1]>>>7,h<0||h>=this._mpegSamplingRates.length)return void this._onError(ie.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let d=this._mpegSamplingRates[h],u=(120&s[1])>>>3;if(u<0||u>=8)return void this._onError(ie.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===n&&(l=(7&s[1])<<1|s[2]>>>7,o=(124&s[2])>>>2);let _=self.navigator.userAgent.toLowerCase();return-1!==_.indexOf("firefox")?h>=6?(n=5,r=new Array(4),l=h-3):(n=2,r=new Array(2),l=h):-1!==_.indexOf("android")?(n=2,r=new Array(2),l=h):(n=5,l=h,r=new Array(4),h>=6?l=h-3:1===u&&(n=2,r=new Array(2),l=h)),r[0]=n<<3,r[0]|=(15&h)>>>1,r[1]=(15&h)<<7,r[1]|=(15&u)<<3,5===n&&(r[1]|=(15&l)>>>1,r[2]=(1&l)<<7,r[2]|=8,r[3]=0),{config:r,samplingRate:d,channelCount:u,codec:"mp4a.40."+n,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,i,s){if(i<4)return void h.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let r=new Uint8Array(e,t,i),n=null;if(s){if(255!==r[0])return;let e=r[1]>>>3&3,t=(6&r[1])>>1,i=(240&r[2])>>>4,s=(12&r[2])>>>2,a=r[3]>>>6&3,o=3!==a?2:1,h=0,l=0,d=34,u="mp3";switch(e){case 0:h=this._mpegAudioV25SampleRateTable[s];break;case 2:h=this._mpegAudioV20SampleRateTable[s];break;case 3:h=this._mpegAudioV10SampleRateTable[s];break}switch(t){case 1:d=34,i<this._mpegAudioL3BitRateTable.length&&(l=this._mpegAudioL3BitRateTable[i]);break;case 2:d=33,i<this._mpegAudioL2BitRateTable.length&&(l=this._mpegAudioL2BitRateTable[i]);break;case 3:d=32,i<this._mpegAudioL1BitRateTable.length&&(l=this._mpegAudioL1BitRateTable[i]);break}n={bitRate:l,samplingRate:h,channelCount:o,codec:u,originalCodec:u}}else n=r;return n}_parseVideoData(e,t,i,s,r){if(i<=1)return void h.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");if(!0===this._hasVideoFlagOverrided&&!1===this._hasVideo)return;let n=new Uint8Array(e,t,i)[0],a=(240&n)>>>4,o=15&n;7===o?this._parseAVCVideoPacket(e,t+1,i-1,s,r,a):this._onError(ie.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+o)}_parseAVCVideoPacket(e,t,i,s,r,n){if(i<4)return void h.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,o=new DataView(e,t,i),l=o.getUint8(0),d=16777215&o.getUint32(0,!a),u=d<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,i-4);else if(1===l)this._parseAVCVideoData(e,t+4,i-4,s,r,n,u);else if(2!==l)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,i){if(i<7)return void h.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let s=this._videoMetadata,r=this._videoTrack,n=this._littleEndian,a=new DataView(e,t,i);s?"undefined"!==typeof s.avcc&&h.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),s=this._videoMetadata={},s.type="video",s.id=r.id,s.timescale=this._timescale,s.duration=this._duration);let o=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==o||0===l)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(ie.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let d=31&a.getUint8(5);if(0===d)return void this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");d>1&&h.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+d);let u=6;for(let h=0;h<d;h++){let i=a.getUint16(u,!n);if(u+=2,0===i)continue;let r=new Uint8Array(e,t+u,i);u+=i;let o=ee.parseSPS(r);if(0!==h)continue;s.codecWidth=o.codec_size.width,s.codecHeight=o.codec_size.height,s.presentWidth=o.present_size.width,s.presentHeight=o.present_size.height,s.profile=o.profile_string,s.level=o.level_string,s.bitDepth=o.bit_depth,s.chromaFormat=o.chroma_format,s.sarRatio=o.sar_ratio,s.frameRate=o.frame_rate,!1!==o.frame_rate.fixed&&0!==o.frame_rate.fps_num&&0!==o.frame_rate.fps_den||(s.frameRate=this._referenceFrameRate);let l=s.frameRate.fps_den,d=s.frameRate.fps_num;s.refSampleDuration=s.timescale*(l/d);let _=r.subarray(1,4),c="avc1.";for(let e=0;e<3;e++){let t=_[e].toString(16);t.length<2&&(t="0"+t),c+=t}s.codec=c;let m=this._mediaInfo;m.width=s.codecWidth,m.height=s.codecHeight,m.fps=s.frameRate.fps,m.profile=s.profile,m.level=s.level,m.refFrames=o.ref_frames,m.chromaFormat=o.chroma_format_string,m.sarNum=s.sarRatio.width,m.sarDen=s.sarRatio.height,m.videoCodec=c,m.hasAudio?null!=m.audioCodec&&(m.mimeType='video/x-flv; codecs="'+m.videoCodec+","+m.audioCodec+'"'):m.mimeType='video/x-flv; codecs="'+m.videoCodec+'"',m.isComplete()&&this._onMediaInfo(m)}let _=a.getUint8(u);if(0!==_){_>1&&h.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+_),u++;for(let e=0;e<_;e++){let e=a.getUint16(u,!n);u+=2,0!==e&&(u+=e)}s.avcc=new Uint8Array(i),s.avcc.set(new Uint8Array(e,t,i),0),h.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",s)}else this._onError(ie.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS")}_parseAVCVideoData(e,t,i,s,r,n,a){let o=this._littleEndian,l=new DataView(e,t,i),d=[],u=0,_=0;const c=this._naluLengthSize;let m=this._timestampBase+s,f=1===n;while(_<i){if(_+4>=i){h.w(this.TAG,`Malformed Nalu near timestamp ${m}, offset = ${_}, dataSize = ${i}`);break}let s=l.getUint32(_,!o);if(3===c&&(s>>>=8),s>i-c)return void h.w(this.TAG,`Malformed Nalus near timestamp ${m}, NaluSize > DataSize!`);let r=31&l.getUint8(_+c);5===r&&(f=!0);let n=new Uint8Array(e,t+_,c+s),a={type:r,data:n};d.push(a),u+=n.byteLength,_+=c+s}if(d.length){let e=this._videoTrack,t={units:d,length:u,isKeyframe:f,dts:m,cts:a,pts:m+a};f&&(t.fileposition=r),e.samples.push(t),e.length+=u}}}var ne=re;class ae{static init(){ae.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let t in ae.types)ae.types.hasOwnProperty(t)&&(ae.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);let e=ae.constants={};e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=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]),e.HDLR_AUDIO=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.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(e){let t=8,i=null,s=Array.prototype.slice.call(arguments,1),r=s.length;for(let a=0;a<r;a++)t+=s[a].byteLength;i=new Uint8Array(t),i[0]=t>>>24&255,i[1]=t>>>16&255,i[2]=t>>>8&255,i[3]=255&t,i.set(e,4);let n=8;for(let a=0;a<r;a++)i.set(s[a],n),n+=s[a].byteLength;return i}static generateInitSegment(e){let t=ae.box(ae.types.ftyp,ae.constants.FTYP),i=ae.moov(e),s=new Uint8Array(t.byteLength+i.byteLength);return s.set(t,0),s.set(i,t.byteLength),s}static moov(e){let t=ae.mvhd(e.timescale,e.duration),i=ae.trak(e),s=ae.mvex(e);return ae.box(ae.types.moov,t,i,s)}static mvhd(e,t){return ae.box(ae.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,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]))}static trak(e){return ae.box(ae.types.trak,ae.tkhd(e),ae.mdia(e))}static tkhd(e){let t=e.id,i=e.duration,s=e.presentWidth,r=e.presentHeight;return ae.box(ae.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,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,s>>>8&255,255&s,0,0,r>>>8&255,255&r,0,0]))}static mdia(e){return ae.box(ae.types.mdia,ae.mdhd(e),ae.hdlr(e),ae.minf(e))}static mdhd(e){let t=e.timescale,i=e.duration;return ae.box(ae.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?ae.constants.HDLR_AUDIO:ae.constants.HDLR_VIDEO,ae.box(ae.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?ae.box(ae.types.smhd,ae.constants.SMHD):ae.box(ae.types.vmhd,ae.constants.VMHD),ae.box(ae.types.minf,t,ae.dinf(),ae.stbl(e))}static dinf(){let e=ae.box(ae.types.dinf,ae.box(ae.types.dref,ae.constants.DREF));return e}static stbl(e){let t=ae.box(ae.types.stbl,ae.stsd(e),ae.box(ae.types.stts,ae.constants.STTS),ae.box(ae.types.stsc,ae.constants.STSC),ae.box(ae.types.stsz,ae.constants.STSZ),ae.box(ae.types.stco,ae.constants.STCO));return t}static stsd(e){return"audio"===e.type?"mp3"===e.codec?ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.mp3(e)):ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.mp4a(e)):ae.box(ae.types.stsd,ae.constants.STSD_PREFIX,ae.avc1(e))}static mp3(e){let t=e.channelCount,i=e.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return ae.box(ae.types[".mp3"],s)}static mp4a(e){let t=e.channelCount,i=e.audioSampleRate,s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return ae.box(ae.types.mp4a,s,ae.esds(e))}static esds(e){let t=e.config||[],i=t.length,s=new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t).concat([6,1,2]));return ae.box(ae.types.esds,s)}static avc1(e){let t=e.avcc,i=e.codecWidth,s=e.codecHeight,r=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,i>>>8&255,255&i,s>>>8&255,255&s,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return ae.box(ae.types.avc1,r,ae.box(ae.types.avcC,t))}static mvex(e){return ae.box(ae.types.mvex,ae.trex(e))}static trex(e){let t=e.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return ae.box(ae.types.trex,i)}static moof(e,t){return ae.box(ae.types.moof,ae.mfhd(e.sequenceNumber),ae.traf(e,t))}static mfhd(e){let t=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return ae.box(ae.types.mfhd,t)}static traf(e,t){let i=e.id,s=ae.box(ae.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),r=ae.box(ae.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),n=ae.sdtp(e),a=ae.trun(e,n.byteLength+16+16+8+16+8+8);return ae.box(ae.types.traf,s,r,a,n)}static sdtp(e){let t=e.samples||[],i=t.length,s=new Uint8Array(4+i);for(let r=0;r<i;r++){let e=t[r].flags;s[r+4]=e.isLeading<<6|e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy}return ae.box(ae.types.sdtp,s)}static trun(e,t){let i=e.samples||[],s=i.length,r=12+16*s,n=new Uint8Array(r);t+=8+r,n.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let a=0;a<s;a++){let e=i[a].duration,t=i[a].size,s=i[a].flags,r=i[a].cts;n.set([e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.isNonSync,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r],12+16*a)}return ae.box(ae.types.trun,n)}static mdat(e){return ae.box(ae.types.mdat,e)}}ae.init();var oe=ae;class he{static getSilentFrame(e,t){if("mp4a.40.2"===e){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])}else{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}}var le=he;class de{constructor(e,t,i,s,r){this.dts=e,this.pts=t,this.duration=i,this.originalDts=s,this.isSyncPoint=r,this.fileposition=null}}class ue{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(e){e.isSyncPoint=!0,this.syncPoints.push(e)}}class _e{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts<t[t.length-1].originalDts&&this.clear(),Array.prototype.push.apply(t,e))}getLastSyncPointBeforeDts(e){if(0==this._list.length)return null;let t=this._list,i=0,s=t.length-1,r=0,n=0,a=s;e<t[0].dts&&(i=0,n=a+1);while(n<=a){if(r=n+Math.floor((a-n)/2),r===s||e>=t[r].dts&&e<t[r+1].dts){i=r;break}t[r].dts<e?n=r+1:a=r-1}return this._list[i]}}class ce{constructor(e){this._type=e,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return 0===this._list.length}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(e){let t=this._list;if(0===t.length)return-2;let i=t.length-1,s=0,r=0,n=i,a=0;if(e<t[0].originalBeginDts)return a=-1,a;while(r<=n){if(s=r+Math.floor((n-r)/2),s===i||e>t[s].lastSample.originalDts&&e<t[s+1].originalBeginDts){a=s;break}t[s].originalBeginDts<e?r=s+1:n=s-1}return a}_searchNearestSegmentAfter(e){return this._searchNearestSegmentBefore(e)+1}append(e){let t=this._list,i=e,s=this._lastAppendLocation,r=0;-1!==s&&s<t.length&&i.originalBeginDts>=t[s].lastSample.originalDts&&(s===t.length-1||s<t.length-1&&i.originalBeginDts<t[s+1].originalBeginDts)?r=s+1:t.length>0&&(r=this._searchNearestSegmentBefore(i.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,i)}getLastSegmentBefore(e){let t=this._searchNearestSegmentBefore(e);return t>=0?this._list[t]:null}getLastSampleBefore(e){let t=this.getLastSegmentBefore(e);return null!=t?t.lastSample:null}getLastSyncPointBefore(e){let t=this._searchNearestSegmentBefore(e),i=this._list[t].syncPoints;while(0===i.length&&t>0)t--,i=this._list[t].syncPoints;return i.length>0?i[i.length-1]:null}}class me{constructor(e){this.TAG="MP4Remuxer",this._config=e,this._isLive=!0===e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new ce("audio"),this._videoSegmentInfoList=new ce("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!S.chrome||!(S.version.major<50||50===S.version.major&&S.version.build<2661)),this._fillSilentAfterSeek=S.msedge||S.msie,this._mp3UseMpegAudio=!S.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(e){return e.onDataAvailable=this.remux.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(e){this._onInitSegment=e}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(e){this._onMediaSegment=e}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(e,t){if(!this._onMediaSegment)throw new _("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let i=null,s="mp4",r=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(s="mpeg",r="",i=new Uint8Array):i=oe.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,i=oe.generateInitSegment(t)}if(!this._onInitSegment)throw new _("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:i.buffer,codec:r,container:`${e}/${s}`,mediaDuration:t.duration})}_calculateDtsBase(e,t){this._dtsBaseInited||(e.samples&&e.samples.length&&(this._audioDtsBase=e.samples[0].dts),t.samples&&t.samples.length&&(this._videoDtsBase=t.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let e=this._videoStashedLastSample,t=this._audioStashedLastSample,i={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(i.samples.push(e),i.length=e.length);let s={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(s.samples.push(t),s.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(i,!0),this._remuxAudio(s,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let i=e,s=i.samples,r=void 0,n=-1,a=-1,o=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,d=this._dtsBaseInited&&void 0===this._audioNextDts,u=!1;if(!s||0===s.length)return;if(1===s.length&&!t)return;let _=0,c=null,m=0;l?(_=0,m=i.length):(_=8,m=8+i.length);let f=null;if(s.length>1&&(f=s.pop(),m-=f.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,s.unshift(e),m+=e.length}null!=f&&(this._audioStashedLastSample=f);let p=s[0].dts-this._dtsBase;if(this._audioNextDts)r=p-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())r=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(u=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0);let i=e.dts+e.duration+t;r=p-i}else r=0}if(u){let e=p-r,t=this._videoSegmentInfoList.getLastSegmentBefore(p);if(null!=t&&t.beginDts<e){let i=le.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(i){let r=t.beginDts,n=e-t.beginDts;h.v(this.TAG,`InsertPrefixSilentAudio: dts: ${r}, duration: ${n}`),s.unshift({unit:i,dts:r,pts:r}),m+=i.byteLength}}else u=!1}let g=[];for(let A=0;A<s.length;A++){let e=s[A],t=e.unit,i=e.dts-this._dtsBase,a=i-r;-1===n&&(n=a);let l=0;if(A!==s.length-1){let e=s[A+1].dts-this._dtsBase-r;l=e-a}else if(null!=f){let e=f.dts-this._dtsBase-r;l=e-a}else l=g.length>=1?g[g.length-1].duration:Math.floor(o);let d=!1,u=null;if(l>1.5*o&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!S.safari){d=!0;let e=Math.abs(l-o),s=Math.ceil(e/o),r=a+o;h.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${a+l} ms, expected: ${a+Math.round(o)} ms, delta: ${Math.round(e)} ms, generate: ${s} frames`);let n=le.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==n&&(h.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),n=t),u=[];for(let t=0;t<s;t++){let e=Math.round(r);if(u.length>0){let t=u[u.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:n,size:n.byteLength,duration:0,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};u.push(t),m+=t.size,r+=o}let _=u[u.length-1];_.duration=a+l-_.dts,l=Math.round(o)}g.push({dts:a,pts:a,cts:0,unit:e.unit,size:e.unit.byteLength,duration:l,originalDts:i,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,u)}l?c=new Uint8Array(m):(c=new Uint8Array(m),c[0]=m>>>24&255,c[1]=m>>>16&255,c[2]=m>>>8&255,c[3]=255&m,c.set(oe.types.mdat,4));for(let h=0;h<g.length;h++){let e=g[h].unit;c.set(e,_),_+=e.byteLength}let E=g[g.length-1];a=E.dts+E.duration,this._audioNextDts=a;let v=new ue;v.beginDts=n,v.endDts=a,v.beginPts=n,v.endPts=a,v.originalBeginDts=g[0].originalDts,v.originalEndDts=E.originalDts+E.duration,v.firstSample=new de(g[0].dts,g[0].pts,g[0].duration,g[0].originalDts,!1),v.lastSample=new de(E.dts,E.pts,E.duration,E.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(v),i.samples=g,i.sequenceNumber++;let y=null;y=l?new Uint8Array:oe.moof(i,n),i.samples=[],i.length=0;let b={type:"audio",data:this._mergeBoxes(y,c).buffer,sampleCount:g.length,info:v};l&&d&&(b.timestampOffset=n),this._onMediaSegment("audio",b)}_remuxVideo(e,t){if(null==this._videoMeta)return;let i=e,s=i.samples,r=void 0,n=-1,a=-1,o=-1,h=-1;if(!s||0===s.length)return;if(1===s.length&&!t)return;let l=8,d=null,u=8+e.length,_=null;if(s.length>1&&(_=s.pop(),u-=_.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(e),u+=e.length}null!=_&&(this._videoStashedLastSample=_);let c=s[0].dts-this._dtsBase;if(this._videoNextDts)r=c-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())r=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(c);if(null!=e){let t=c-(e.originalDts+e.duration);t<=3&&(t=0);let i=e.dts+e.duration+t;r=c-i}else r=0}let m=new ue,f=[];for(let E=0;E<s.length;E++){let e=s[E],t=e.dts-this._dtsBase,i=e.isKeyframe,a=t-r,h=e.cts,l=a+h;-1===n&&(n=a,o=l);let d=0;if(E!==s.length-1){let e=s[E+1].dts-this._dtsBase-r;d=e-a}else if(null!=_){let e=_.dts-this._dtsBase-r;d=e-a}else d=f.length>=1?f[f.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(i){let t=new de(a,l,d,e.dts,!0);t.fileposition=e.fileposition,m.appendSyncPoint(t)}f.push({dts:a,pts:l,cts:h,units:e.units,size:e.length,isKeyframe:i,duration:d,originalDts:t,flags:{isLeading:0,dependsOn:i?2:1,isDependedOn:i?1:0,hasRedundancy:0,isNonSync:i?0:1}})}d=new Uint8Array(u),d[0]=u>>>24&255,d[1]=u>>>16&255,d[2]=u>>>8&255,d[3]=255&u,d.set(oe.types.mdat,4);for(let E=0;E<f.length;E++){let e=f[E].units;while(e.length){let t=e.shift(),i=t.data;d.set(i,l),l+=i.byteLength}}let p=f[f.length-1];if(a=p.dts+p.duration,h=p.pts+p.duration,this._videoNextDts=a,m.beginDts=n,m.endDts=a,m.beginPts=o,m.endPts=h,m.originalBeginDts=f[0].originalDts,m.originalEndDts=p.originalDts+p.duration,m.firstSample=new de(f[0].dts,f[0].pts,f[0].duration,f[0].originalDts,f[0].isKeyframe),m.lastSample=new de(p.dts,p.pts,p.duration,p.originalDts,p.isKeyframe),this._isLive||this._videoSegmentInfoList.append(m),i.samples=f,i.sequenceNumber++,this._forceFirstIDR){let e=f[0].flags;e.dependsOn=2,e.isNonSync=0}let g=oe.moof(i,n);i.samples=[],i.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(g,d).buffer,sampleCount:f.length,info:m})}_mergeBoxes(e,t){let i=new Uint8Array(e.byteLength+t.byteLength);return i.set(e,0),i.set(t,e.byteLength),i}}var fe=me;const pe={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};var ge=pe;class Ee{constructor(e,t){this.TAG="TransmuxingController",this._emitter=new a.a,this._config=t,e.segments||(e.segments=[{duration:e.duration,filesize:e.filesize,url:e.url}]),"boolean"!==typeof e.cors&&(e.cors=!0),"boolean"!==typeof e.withCredentials&&(e.withCredentials=!1),this._mediaDataSource=e,this._currentSegmentIndex=0;let i=0;this._mediaDataSource.segments.forEach(s=>{s.timestampBase=i,i+=s.duration,s.cors=e.cors,s.withCredentials=e.withCredentials,t.referrerPolicy&&(s.referrerPolicy=t.referrerPolicy)}),isNaN(i)||this._mediaDataSource.duration===i||(this._mediaDataSource.duration=i),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(e,t){this._currentSegmentIndex=e;let i=this._mediaDataSource.segments[e],s=this._ioctl=new B(i,this._config,e);s.onError=this._onIOException.bind(this),s.onSeeked=this._onIOSeeked.bind(this),s.onComplete=this._onIOComplete.bind(this),s.onRedirect=this._onIORedirect.bind(this),s.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):s.onDataArrival=this._onInitChunkArrival.bind(this),s.open(t)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(e){if(null==this._mediaInfo||!this._mediaInfo.isSeekable())return;let t=this._searchSegmentIndexContains(e);if(t===this._currentSegmentIndex){let i=this._mediaInfo.segments[t];if(void 0==i)this._pendingSeekTime=e;else{let t=i.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let i=this._mediaInfo.segments[t];if(void 0==i)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let s=i.getNearestKeyframe(e);this._internalAbort(),this._remuxer.seek(e),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[t].timestampBase,this._loadSegment(t,s.fileposition),this._pendingResolveSeekPoint=s.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,i=t.length-1;for(let s=0;s<t.length;s++)if(e<t[s].timestampBase){i=s-1;break}return i}_onInitChunkArrival(e,t){let i=null,s=0;if(t>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,s=this._demuxer.parseChunks(e,t);else if((i=ne.probe(e)).match){this._demuxer=new ne(i,this._config),this._remuxer||(this._remuxer=new fe(this._config));let r=this._mediaDataSource;void 0==r.duration||isNaN(r.duration)||(this._demuxer.overridedDuration=r.duration),"boolean"===typeof r.hasAudio&&(this._demuxer.overridedHasAudio=r.hasAudio),"boolean"===typeof r.hasVideo&&(this._demuxer.overridedHasVideo=r.hasVideo),this._demuxer.timestampBase=r.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),s=this._demuxer.parseChunks(e,t)}else i=null,h.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(ge.DEMUX_ERROR,ie.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),s=0;return s}_onMediaInfo(e){null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,K.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,K.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=t,this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then(()=>{let e=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(e)})}_onMetaDataArrived(e){this._emitter.emit(ge.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(ge.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e,i=t+1;i<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(i)):(this._remuxer.flushStashedSamples(),this._emitter.emit(ge.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(e){let t=this._ioctl.extraData;this._mediaDataSource.segments[t].redirectedURL=e}_onIORecoveredEarlyEof(){this._emitter.emit(ge.RECOVERED_EARLY_EOF)}_onIOException(e,t){h.e(this.TAG,`IOException: type = ${e}, code = ${t.code}, msg = ${t.msg}`),this._emitter.emit(ge.IO_ERROR,e,t),this._disableStatisticsReporter()}_onDemuxException(e,t){h.e(this.TAG,`DemuxException: type = ${e}, info = ${t}`),this._emitter.emit(ge.DEMUX_ERROR,e,t)}_onRemuxerInitSegmentArrival(e,t){this._emitter.emit(ge.INIT_SEGMENT,e,t)}_onRemuxerMediaSegmentArrival(e,t){if(null==this._pendingSeekTime&&(this._emitter.emit(ge.MEDIA_SEGMENT,e,t),null!=this._pendingResolveSeekPoint&&"video"===e)){let e=t.info.syncPoints,i=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,S.safari&&e.length>0&&e[0].originalDts===i&&(i=e[0].pts),this._emitter.emit(ge.RECOMMEND_SEEKPOINT,i)}}_enableStatisticsReporter(){null==this._statisticsReporter&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(e){let t=this._mediaInfo.segments[e],i=Object.assign({},t);i.duration=this._mediaInfo.duration,i.segmentCount=this._mediaInfo.segmentCount,delete i.segments,delete i.keyframesIndex,this._emitter.emit(ge.MEDIA_INFO,i)}_reportStatisticsInfo(){let e={};e.url=this._ioctl.currentURL,e.hasRedirect=this._ioctl.hasRedirect,e.hasRedirect&&(e.redirectedURL=this._ioctl.currentRedirectedURL),e.speed=this._ioctl.currentSpeed,e.loaderType=this._ioctl.loaderType,e.currentSegmentIndex=this._currentSegmentIndex,e.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(ge.STATISTICS_INFO,e)}}var ve=Ee;let Se=function(e){let t=null,i=f.bind(this);function s(t,i){let s={msg:ge.INIT_SEGMENT,data:{type:t,data:i}};e.postMessage(s,[i.data])}function n(t,i){let s={msg:ge.MEDIA_SEGMENT,data:{type:t,data:i}};e.postMessage(s,[i.data])}function a(){let t={msg:ge.LOADING_COMPLETE};e.postMessage(t)}function o(){let t={msg:ge.RECOVERED_EARLY_EOF};e.postMessage(t)}function h(t){let i={msg:ge.MEDIA_INFO,data:t};e.postMessage(i)}function l(t){let i={msg:ge.METADATA_ARRIVED,data:t};e.postMessage(i)}function d(t){let i={msg:ge.SCRIPTDATA_ARRIVED,data:t};e.postMessage(i)}function u(t){let i={msg:ge.STATISTICS_INFO,data:t};e.postMessage(i)}function _(t,i){e.postMessage({msg:ge.IO_ERROR,data:{type:t,info:i}})}function c(t,i){e.postMessage({msg:ge.DEMUX_ERROR,data:{type:t,info:i}})}function m(t){e.postMessage({msg:ge.RECOMMEND_SEEKPOINT,data:t})}function f(t,i){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:i}})}r.install(),e.addEventListener("message",(function(r){switch(r.data.cmd){case"init":t=new ve(r.data.param[0],r.data.param[1]),t.on(ge.IO_ERROR,_.bind(this)),t.on(ge.DEMUX_ERROR,c.bind(this)),t.on(ge.INIT_SEGMENT,s.bind(this)),t.on(ge.MEDIA_SEGMENT,n.bind(this)),t.on(ge.LOADING_COMPLETE,a.bind(this)),t.on(ge.RECOVERED_EARLY_EOF,o.bind(this)),t.on(ge.MEDIA_INFO,h.bind(this)),t.on(ge.METADATA_ARRIVED,l.bind(this)),t.on(ge.SCRIPTDATA_ARRIVED,d.bind(this)),t.on(ge.STATISTICS_INFO,u.bind(this)),t.on(ge.RECOMMEND_SEEKPOINT,m.bind(this));break;case"destroy":t&&(t.destroy(),t=null),e.postMessage({msg:"destroyed"});break;case"start":t.start();break;case"stop":t.stop();break;case"seek":t.seek(r.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=r.data.param;z.applyConfig(e),!0===e.enableCallback?z.addLogListener(i):z.removeLogListener(i);break}}}))};var ye=Se;class be{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new a.a,t.enableWorker&&"undefined"!==typeof Worker)try{let s=i("d2be");this._worker=s(ye),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[e,t]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},z.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:z.getConfig()})}catch(s){h.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ve(e,t)}else this._controller=new ve(e,t);if(this._controller){let e=this._controller;e.on(ge.IO_ERROR,this._onIOError.bind(this)),e.on(ge.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(ge.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(ge.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(ge.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(ge.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(ge.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(ge.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(ge.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(ge.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(ge.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),z.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}hasWorker(){return null!=this._worker}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(e){this._worker?this._worker.postMessage({cmd:"seek",param:e}):this._controller.seek(e)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(ge.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(ge.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(ge.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(ge.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(ge.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,i=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case ge.INIT_SEGMENT:case ge.MEDIA_SEGMENT:this._emitter.emit(t.msg,i.type,i.data);break;case ge.LOADING_COMPLETE:case ge.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case ge.MEDIA_INFO:Object.setPrototypeOf(i,K.prototype),this._emitter.emit(t.msg,i);break;case ge.METADATA_ARRIVED:case ge.SCRIPTDATA_ARRIVED:case ge.STATISTICS_INFO:this._emitter.emit(t.msg,i);break;case ge.IO_ERROR:case ge.DEMUX_ERROR:this._emitter.emit(t.msg,i.type,i.info);break;case ge.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,i);break;case"logcat_callback":h.emitter.emit("log",i.type,i.logcat);break;default:break}}}var Ae=be;const Re={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var Le=Re;class we{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new a.a,this._config.isLive&&void 0==this._config.autoCleanupSourceBuffer&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new _e}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaSource)throw new _("MediaSource has been attached to an HTMLMediaElement!");let t=this._mediaSource=new window.MediaSource;t.addEventListener("sourceopen",this.e.onSourceOpen),t.addEventListener("sourceended",this.e.onSourceEnded),t.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=e,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),e.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let t=this._mediaSource;for(let i in this._sourceBuffers){let s=this._pendingSegments[i];s.splice(0,s.length),this._pendingSegments[i]=null,this._pendingRemoveRanges[i]=null,this._lastInitSegments[i]=null;let r=this._sourceBuffers[i];if(r){if("closed"!==t.readyState){try{t.removeSourceBuffer(r)}catch(e){h.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[i]=null,this._sourceBuffers[i]=null}}if("open"===t.readyState)try{t.endOfStream()}catch(e){h.e(this.TAG,e.message)}t.removeEventListener("sourceopen",this.e.onSourceOpen),t.removeEventListener("sourceended",this.e.onSourceEnded),t.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(e,t){if(!this._mediaSource||"open"!==this._mediaSource.readyState)return this._pendingSourceBufferInit.push(e),void this._pendingSegments[e.type].push(e);let i=e,s=""+i.container;i.codec&&i.codec.length>0&&(s+=";codecs="+i.codec);let r=!1;if(h.v(this.TAG,"Received Initialization Segment, mimeType: "+s),this._lastInitSegments[i.type]=i,s!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])h.v(this.TAG,`Notice: ${i.type} mimeType changed, origin: ${this._mimeTypes[i.type]}, target: ${s}`);else{r=!0;try{let e=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(s);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(n){return h.e(this.TAG,n.message),void this._emitter.emit(Le.ERROR,{code:n.code,msg:n.message})}}this._mimeTypes[i.type]=s}t||this._pendingSegments[i.type].push(i),r||this._sourceBuffers[i.type]&&!this._sourceBuffers[i.type].updating&&this._doAppendSegments(),S.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let i=this._sourceBuffers[t.type];!i||i.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let i in this._sourceBuffers){if(!this._sourceBuffers[i])continue;let e=this._sourceBuffers[i];if("open"===this._mediaSource.readyState)try{e.abort()}catch(t){h.e(this.TAG,t.message)}this._idrList.clear();let s=this._pendingSegments[i];if(s.splice(0,s.length),"closed"!==this._mediaSource.readyState){for(let t=0;t<e.buffered.length;t++){let s=e.buffered.start(t),r=e.buffered.end(t);this._pendingRemoveRanges[i].push({start:s,end:r})}if(e.updating||this._doRemoveRanges(),S.safari){let t=this._lastInitSegments[i];t&&(this._pendingSegments[i].push(t),e.updating||this._doAppendSegments())}}}}endOfStream(){let e=this._mediaSource,t=this._sourceBuffers;e&&"open"===e.readyState?t.video&&t.video.updating||t.audio&&t.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,e.endOfStream()):e&&"closed"===e.readyState&&this._hasPendingSegments()&&(this._hasPendingEos=!0)}getNearestKeyframe(e){return this._idrList.getLastSyncPointBeforeDts(e)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let i=this._sourceBuffers[t];if(i){let t=i.buffered;if(t.length>=1&&e-t.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let e=this._mediaElement.currentTime;for(let t in this._sourceBuffers){let i=this._sourceBuffers[t];if(i){let s=i.buffered,r=!1;for(let i=0;i<s.length;i++){let n=s.start(i),a=s.end(i);if(n<=e&&e<a+3){if(e-n>=this._config.autoCleanupMaxBackwardDuration){r=!0;let i=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:n,end:i})}}else a<e&&(r=!0,this._pendingRemoveRanges[t].push({start:n,end:a}))}r&&!i.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let e=this._sourceBuffers;if(0===this._mediaElement.readyState||"open"!==this._mediaSource.readyState)return;if(e.video&&e.video.updating||e.audio&&e.audio.updating)return;let t=this._mediaSource.duration,i=this._pendingMediaDuration;i>0&&(isNaN(t)||i>t)&&(h.v(this.TAG,`Update MediaSource duration from ${t} to ${i}`),this._mediaSource.duration=i),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let e in this._pendingRemoveRanges){if(!this._sourceBuffers[e]||this._sourceBuffers[e].updating)continue;let t=this._sourceBuffers[e],i=this._pendingRemoveRanges[e];while(i.length&&!t.updating){let e=i.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let i in e)if(this._sourceBuffers[i]&&!this._sourceBuffers[i].updating&&e[i].length>0){let s=e[i].shift();if(s.timestampOffset){let e=this._sourceBuffers[i].timestampOffset,t=s.timestampOffset/1e3,r=Math.abs(e-t);r>.1&&(h.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${t}`),this._sourceBuffers[i].timestampOffset=t),delete s.timestampOffset}if(!s.data||0===s.data.byteLength)continue;try{this._sourceBuffers[i].appendBuffer(s.data),this._isBufferFull=!1,"video"===i&&s.hasOwnProperty("info")&&this._idrList.appendArray(s.info.syncPoints)}catch(t){this._pendingSegments[i].unshift(s),22===t.code?(this._isBufferFull||this._emitter.emit(Le.BUFFER_FULL),this._isBufferFull=!0):(h.e(this.TAG,t.message),this._emitter.emit(Le.ERROR,{code:t.code,msg:t.message}))}}}_onSourceOpen(){if(h.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;while(e.length){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(Le.SOURCE_OPEN)}_onSourceEnded(){h.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){h.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let e=this._pendingSegments;return e.video.length>0||e.audio.length>0}_hasPendingRemoveRanges(){let e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(Le.UPDATE_END)}_onSourceBufferError(e){h.e(this.TAG,"SourceBuffer Error: "+e)}}var Te=we;const ke={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},Ce={NETWORK_EXCEPTION:p.EXCEPTION,NETWORK_STATUS_CODE_INVALID:p.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:p.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:p.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:ie.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:ie.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:ie.CODEC_UNSUPPORTED};class Ie{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new a.a,this._config=U(),"object"===typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new c("FlvPlayer requires an flv MediaDataSource input!");!0===e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let i=S.chrome&&(S.version.major<50||50===S.version.major&&S.version.build<2661);this._alwaysSeekKeyframe=!!(i||S.msedge||S.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===G.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}):e===G.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new Te(this._config),this._msectl.on(Le.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(Le.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(Le.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(Le.ERROR,e=>{this._emitter.emit(G.ERROR,ke.MEDIA_ERROR,Ce.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new _("FlvPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(this._config.deferLoadAfterSourceOpen&&!1===this._mseSourceOpened?this._hasPendingLoad=!0:(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new Ae(this._mediaDataSource,this._config),this._transmuxer.on(ge.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(ge.MEDIA_SEGMENT,(e,t)=>{if(this._msectl.appendMediaSegment(t),this._config.lazyLoad&&!this._config.isLive){let e=this._mediaElement.currentTime;t.info.endDts>=1e3*(e+this._config.lazyLoadMaxDuration)&&null==this._progressChecker&&(h.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(ge.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(G.LOADING_COMPLETE)}),this._transmuxer.on(ge.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(G.RECOVERED_EARLY_EOF)}),this._transmuxer.on(ge.IO_ERROR,(e,t)=>{this._emitter.emit(G.ERROR,ke.NETWORK_ERROR,e,t)}),this._transmuxer.on(ge.DEMUX_ERROR,(e,t)=>{this._emitter.emit(G.ERROR,ke.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(ge.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(G.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(ge.METADATA_ARRIVED,e=>{this._emitter.emit(G.METADATA_ARRIVED,e)}),this._transmuxer.on(ge.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(G.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(ge.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(G.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(ge.RECOMMEND_SEEKPOINT,e=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e/1e3)}),this._transmuxer.open()))}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._internalSeek(e):this._pendingSeekTime=e}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return null==this._statisticsInfo&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(e){if(e.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,s=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,s=e.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,s=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=s),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,i=0,s=0;for(let r=0;r<e.length;r++){let n=e.start(r),a=e.end(r);if(n<=t&&t<a){i=n,s=a;break}}s>=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(h.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){h.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let e=this._mediaElement.currentTime,t=this._mediaElement.buffered,i=!1;for(let s=0;s<t.length;s++){let r=t.start(s),n=t.end(s);if(e>=r&&e<n){e>=n-this._config.lazyLoadRecoverDuration&&(i=!0);break}}i&&(window.clearInterval(this._progressChecker),this._progressChecker=null,i&&(h.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let i=0;i<t.length;i++){let s=t.start(i),r=t.end(i);if(e>=s&&e<r)return!0}return!1}_internalSeek(e){let t=this._isTimepointBuffered(e),i=!1,s=0;if(e<1&&this._mediaElement.buffered.length>0){let t=this._mediaElement.buffered.start(0);(t<1&&e<t||S.safari)&&(i=!0,s=S.safari?.1:t)}if(i)this._requestSetTime=!0,this._mediaElement.currentTime=s;else if(t){if(this._alwaysSeekKeyframe){let t=this._msectl.getNearestKeyframe(Math.floor(1e3*e));this._requestSetTime=!0,this._mediaElement.currentTime=null!=t?t.dts/1e3:e}else this._requestSetTime=!0,this._mediaElement.currentTime=e;null!=this._progressChecker&&this._checkProgressAndResume()}else null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let e=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(e)||(null!=this._progressChecker&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(e),this._transmuxer.seek(Math.floor(1e3*e)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=e))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(e){let t=this._mediaElement;if(e||!this._receivedCanPlay||t.readyState<2){let e=t.buffered;e.length>0&&t.currentTime<e.start(0)&&(h.w(this.TAG,`Playback seems stuck at ${t.currentTime}, seek to ${e.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=e.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(e){let t=this._mediaElement.currentTime,i=this._mediaElement.buffered;if(this._requestSetTime)this._requestSetTime=!1;else{if(t<1&&i.length>0){let e=i.start(0);if(e<1&&t<e||S.safari)return this._requestSetTime=!0,void(this._mediaElement.currentTime=S.safari?.1:e)}if(this._isTimepointBuffered(t)){if(this._alwaysSeekKeyframe){let e=this._msectl.getNearestKeyframe(Math.floor(1e3*t));null!=e&&(this._requestSetTime=!0,this._mediaElement.currentTime=e.dts/1e3)}null!=this._progressChecker&&this._checkProgressAndResume()}else this._seekpointRecord={seekPoint:t,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}}_onvCanPlay(e){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(e){this._checkAndResumeStuckPlayback(!0)}_onvProgress(e){this._checkAndResumeStuckPlayback()}}var De=Ie;class Oe{constructor(e,t){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new a.a,this._config=U(),"object"===typeof t&&Object.assign(this._config,t),"flv"===e.type.toLowerCase())throw new c("NativePlayer does't support flv MediaDataSource input!");if(e.hasOwnProperty("segments"))throw new c(`NativePlayer(${e.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=e,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(e,t){e===G.MEDIA_INFO?null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}):e===G.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(e,t)}off(e,t){this._emitter.removeListener(e,t)}attachMediaElement(e){if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(t){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new _("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(e){this._mediaElement.volume=e}get muted(){return this._mediaElement.muted}set muted(e){this._mediaElement.muted=e}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(e){this._mediaElement?this._mediaElement.currentTime=e:this._pendingSeekTime=e}get mediaInfo(){let e=this._mediaElement instanceof HTMLAudioElement?"audio/":"video/",t={mimeType:e+this._mediaDataSource.type};return this._mediaElement&&(t.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(t.width=this._mediaElement.videoWidth,t.height=this._mediaElement.videoHeight)),t}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,i=0,s=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();i=e.totalVideoFrames,s=e.droppedVideoFrames}else void 0!=this._mediaElement.webkitDecodedFrameCount?(i=this._mediaElement.webkitDecodedFrameCount,s=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=i,e.droppedFrames=s),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(G.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(G.STATISTICS_INFO,this.statisticsInfo)}}var Me=Oe;function Be(e,t){let i=e;if(null==i||"object"!==typeof i)throw new c("MediaDataSource must be an javascript object!");if(!i.hasOwnProperty("type"))throw new c("MediaDataSource must has type field to indicate video file type!");switch(i.type){case"flv":return new De(i,t);default:return new Me(i,t)}}function xe(){return P.supportMSEH264Playback()}function Ue(){return P.getFeatureList()}r.install();let Ne={};Ne.createPlayer=Be,Ne.isSupported=xe,Ne.getFeatureList=Ue,Ne.BaseLoader=g,Ne.LoaderStatus=f,Ne.LoaderErrors=p,Ne.Events=G,Ne.ErrorTypes=ke,Ne.ErrorDetails=Ce,Ne.FlvPlayer=De,Ne.NativePlayer=Me,Ne.LoggingControl=z,Object.defineProperty(Ne,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var Pe=Ne;function Fe(e){var t=e.src,i=e.autoplay,s=void 0!==i&&i,r=e.media,n=e.options,a=void 0===n?{type:"flv",url:t}:n,o=e.callback,h=void 0===o?function(){return{}}:o;if(Pe.isSupported()){var l=Pe.createPlayer(a);l.attachMediaElement(r),l.load(),l.on(Pe.Events.ERROR,(function(e){switch(e){case Pe.ErrorTypes.NETWORK_ERROR:l.load();break;default:l.destroy();break}})),s&&l.play(),h(l)}}t["default"]=Fe},4362:function(e,t,i){t.nextTick=function(e){var t=Array.prototype.slice.call(arguments);t.shift(),setTimeout((function(){e.apply(null,t)}),0)},t.platform=t.arch=t.execPath=t.title="browser",t.pid=1,t.browser=!0,t.env={},t.argv=[],t.binding=function(e){throw new Error("No such module. (Possibly not yet loaded)")},function(){var e,s="/";t.cwd=function(){return s},t.chdir=function(t){e||(e=i("df7c")),s=e.resolve(t,s)}}(),t.exit=t.kill=t.umask=t.dlopen=t.uptime=t.memoryUsage=t.uvCounters=function(){},t.features={}},d2be:function(e,t){var i=arguments[3],s=arguments[4],r=arguments[5],n=JSON.stringify;e.exports=function(e,t){for(var a,o=Object.keys(r),h=0,l=o.length;h<l;h++){var d=o[h],u=r[d].exports;if(u===e||u&&u.default===e){a=d;break}}if(!a){a=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var _={};for(h=0,l=o.length;h<l;h++){d=o[h];_[d]=d}s[a]=["function(require,module,exports){"+e+"(self); }",_]}var c=Math.floor(Math.pow(16,8)*Math.random()).toString(16),m={};m[a]=a,s[c]=["function(require,module,exports){var f = require("+n(a)+");(f.default ? f.default : f)(self);}",m];var f={};function p(e){for(var t in f[e]=!0,s[e][1]){var i=s[e][1][t];f[i]||p(i)}}p(c);var g="("+i+")({"+Object.keys(f).map((function(e){return n(e)+":["+s[e][0]+","+n(s[e][1])+"]"})).join(",")+"},{},["+n(c)+"])",E=window.URL||window.webkitURL||window.mozURL||window.msURL,v=new Blob([g],{type:"text/javascript"});if(t&&t.bare)return v;var S=E.createObjectURL(v),y=new Worker(S);return y.objectURL=S,y}},df7c:function(e,t,i){(function(e){function i(e,t){for(var i=0,s=e.length-1;s>=0;s--){var r=e[s];"."===r?e.splice(s,1):".."===r?(e.splice(s,1),i++):i&&(e.splice(s,1),i--)}if(t)for(;i--;i)e.unshift("..");return e}function s(e){"string"!==typeof e&&(e+="");var t,i=0,s=-1,r=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!r){i=t+1;break}}else-1===s&&(r=!1,s=t+1);return-1===s?"":e.slice(i,s)}function r(e,t){if(e.filter)return e.filter(t);for(var i=[],s=0;s<e.length;s++)t(e[s],s,e)&&i.push(e[s]);return i}t.resolve=function(){for(var t="",s=!1,n=arguments.length-1;n>=-1&&!s;n--){var a=n>=0?arguments[n]:e.cwd();if("string"!==typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,s="/"===a.charAt(0))}return t=i(r(t.split("/"),(function(e){return!!e})),!s).join("/"),(s?"/":"")+t||"."},t.normalize=function(e){var s=t.isAbsolute(e),a="/"===n(e,-1);return e=i(r(e.split("/"),(function(e){return!!e})),!s).join("/"),e||s||(e="."),e&&a&&(e+="/"),(s?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(r(e,(function(e,t){if("string"!==typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,i){function s(e){for(var t=0;t<e.length;t++)if(""!==e[t])break;for(var i=e.length-1;i>=0;i--)if(""!==e[i])break;return t>i?[]:e.slice(t,i-t+1)}e=t.resolve(e).substr(1),i=t.resolve(i).substr(1);for(var r=s(e.split("/")),n=s(i.split("/")),a=Math.min(r.length,n.length),o=a,h=0;h<a;h++)if(r[h]!==n[h]){o=h;break}var l=[];for(h=o;h<r.length;h++)l.push("..");return l=l.concat(n.slice(o)),l.join("/")},t.sep="/",t.delimiter=":",t.dirname=function(e){if("string"!==typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),i=47===t,s=-1,r=!0,n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),47===t){if(!r){s=n;break}}else r=!1;return-1===s?i?"/":".":i&&1===s?"/":e.slice(0,s)},t.basename=function(e,t){var i=s(e);return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i},t.extname=function(e){"string"!==typeof e&&(e+="");for(var t=-1,i=0,s=-1,r=!0,n=0,a=e.length-1;a>=0;--a){var o=e.charCodeAt(a);if(47!==o)-1===s&&(r=!1,s=a+1),46===o?-1===t?t=a:1!==n&&(n=1):-1!==t&&(n=-1);else if(!r){i=a+1;break}}return-1===t||-1===s||0===n||1===n&&t===s-1&&t===i+1?"":e.slice(t,s)};var n="b"==="ab".substr(-1)?function(e,t,i){return e.substr(t,i)}:function(e,t,i){return t<0&&(t=e.length+t),e.substr(t,i)}}).call(this,i("4362"))},faa1:function(e,t,i){"use strict";var s,r="object"===typeof Reflect?Reflect:null,n=r&&"function"===typeof r.apply?r.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};function a(e){console&&console.warn&&console.warn(e)}s=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!==e};function h(){h.init.call(this)}e.exports=h,h.EventEmitter=h,h.prototype._events=void 0,h.prototype._eventsCount=0,h.prototype._maxListeners=void 0;var l=10;function d(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?h.defaultMaxListeners:e._maxListeners}function _(e,t,i,s){var r,n,o;if(d(i),n=e._events,void 0===n?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),n=e._events),o=n[t]),void 0===o)o=n[t]=i,++e._eventsCount;else if("function"===typeof o?o=n[t]=s?[i,o]:[o,i]:s?o.unshift(i):o.push(i),r=u(e),r>0&&o.length>r&&!o.warned){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,a(h)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function m(e,t,i){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=c.bind(s);return r.listener=i,s.wrapFn=r,r}function f(e,t,i){var s=e._events;if(void 0===s)return[];var r=s[t];return void 0===r?[]:"function"===typeof r?i?[r.listener||r]:[r]:i?v(r):g(r,r.length)}function p(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"===typeof i)return 1;if(void 0!==i)return i.length}return 0}function g(e,t){for(var i=new Array(t),s=0;s<t;++s)i[s]=e[s];return i}function E(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}Object.defineProperty(h,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!==typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),h.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},h.prototype.setMaxListeners=function(e){if("number"!==typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},h.prototype.getMaxListeners=function(){return u(this)},h.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var s="error"===e,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var h=r[e];if(void 0===h)return!1;if("function"===typeof h)n(h,this,t);else{var l=h.length,d=g(h,l);for(i=0;i<l;++i)n(d[i],this,t)}return!0},h.prototype.addListener=function(e,t){return _(this,e,t,!1)},h.prototype.on=h.prototype.addListener,h.prototype.prependListener=function(e,t){return _(this,e,t,!0)},h.prototype.once=function(e,t){return d(t),this.on(e,m(this,e,t)),this},h.prototype.prependOnceListener=function(e,t){return d(t),this.prependListener(e,m(this,e,t)),this},h.prototype.removeListener=function(e,t){var i,s,r,n,a;if(d(t),s=this._events,void 0===s)return this;if(i=s[e],void 0===i)return this;if(i===t||i.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!==typeof i){for(r=-1,n=i.length-1;n>=0;n--)if(i[n]===t||i[n].listener===t){a=i[n].listener,r=n;break}if(r<0)return this;0===r?i.shift():E(i,r),1===i.length&&(s[e]=i[0]),void 0!==s.removeListener&&this.emit("removeListener",e,a||t)}return this},h.prototype.off=h.prototype.removeListener,h.prototype.removeAllListeners=function(e){var t,i,s;if(i=this._events,void 0===i)return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,n=Object.keys(i);for(s=0;s<n.length;++s)r=n[s],"removeListener"!==r&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],"function"===typeof t)this.removeListener(e,t);else if(void 0!==t)for(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},h.prototype.listeners=function(e){return f(this,e,!0)},h.prototype.rawListeners=function(e){return f(this,e,!1)},h.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},h.prototype.listenerCount=p,h.prototype.eventNames=function(){return this._eventsCount>0?s(this._events):[]}}}]); |