From 3ad6b541255e0479e025ee3b2bb79ff1a354b950 Mon Sep 17 00:00:00 2001 From: “zhangzhuo <1365436742@qq.com> Date: Fri, 26 Mar 2021 19:32:55 +0800 Subject: [PATCH] 更新视频静音配置 --- README.md | 1 + dist/index.js | 2 +- package.json | 2 +- src/components/allVideoCom/allVideoCom.js | 7 ++++--- src/index.js | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 26a7109..54a9417 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ export default class App extends Component { config={{}}//里面和flv的配置是一样的 maxCount="5" //设置重连次数,默认5次 testingTimer={30} //检测时间 + volume={0}//音量大小静音设置成0 > ``` diff --git a/dist/index.js b/dist/index.js index 038814b..3022ac8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -42,4 +42,4 @@ object-assign /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ t.read=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,u=-7,d=n?i-1:0,h=n?-1:1,p=e[t+d];for(d+=h,o=p&(1<<-u)-1,p>>=-u,u+=s;u>0;o=256*o+e[t+d],d+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+d],d+=h,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var a,s,l,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+d>=1?h/l:h*Math.pow(2,1-d))*l>=2&&(a++,l/=2),a+d>=u?(s=0,a=u):a+d>=1?(s=(t*l-1)*Math.pow(2,i),a+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),a=0));i>=8;e[n+p]=255&s,p+=f,s/=256,i-=8);for(a=a<0;e[n+p]=255&a,p+=f,a/=256,c-=8);e[n+p-f]|=128*m}},function(e,t){},function(e,t,n){"use strict";function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){for(var n=0;n0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return a.alloc(0);for(var t,n,r,i=a.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,n=i,r=s,a.prototype.copy.call(t,n,r),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var n;return ei.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=a.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:l,value:function(e,t){return s(this,function(e){for(var t=1;t */ -var r=n(3),i=r.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function a(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},a.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},a.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},a.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";(function(t){var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var o=n(20),a=Symbol("lastResolve"),s=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),d=Symbol("handlePromise"),h=Symbol("stream");function p(e,t){return{value:e,done:t}}function f(e){var t=e[a];if(null!==t){var n=e[h].read();null!==n&&(e[u]=null,e[a]=null,e[s]=null,t(p(n,!1)))}}function m(e){t.nextTick(f,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(r={get stream(){return this[h]},next:function(){var e=this,n=this[l];if(null!==n)return Promise.reject(n);if(this[c])return Promise.resolve(p(void 0,!0));if(this[h].destroyed)return new Promise((function(n,r){t.nextTick((function(){e[l]?r(e[l]):n(p(void 0,!0))}))}));var r,i=this[u];if(i)r=new Promise(function(e,t){return function(n,r){e.then((function(){t[c]?n(p(void 0,!0)):t[d](n,r)}),r)}}(i,this));else{var o=this[h].read();if(null!==o)return Promise.resolve(p(o,!1));r=new Promise(this[d])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),i(r,"return",(function(){var e=this;return new Promise((function(t,n){e[h].destroy(null,(function(e){e?n(e):t(p(void 0,!0))}))}))})),r),y);e.exports=function(e){var t,n=Object.create(g,(i(t={},h,{value:e,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,d,{value:function(e,t){var r=n[h].read();r?(n[u]=null,n[a]=null,n[s]=null,e(p(r,!1))):(n[a]=e,n[s]=t)},writable:!0}),t));return n[u]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[s];return null!==t&&(n[u]=null,n[a]=null,n[s]=null,t(e)),void(n[l]=e)}var r=n[a];null!==r&&(n[u]=null,n[a]=null,n[s]=null,r(p(void 0,!0))),n[c]=!0})),e.on("readable",m.bind(null,n)),n}}).call(this,n(2))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,n){"use strict";e.exports=i;var r=n(39);function i(e){if(!(this instanceof i))return new i(e);r.call(this,e)}n(7)(i,r),i.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";var r;var i=n(10).codes,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function l(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var s=!1;e.on("close",(function(){s=!0})),void 0===r&&(r=n(20)),r(e,{readable:t,writable:i},(function(e){if(e)return o(e);s=!0,o()}));var l=!1;return function(t){if(!s&&!l)return l=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new a("pipe"))}}function c(e){e()}function u(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?s:e.pop():s}e.exports=function(){for(var e=arguments.length,t=new Array(e),n=0;n0,(function(e){r||(r=e),e&&a.forEach(c),o||(a.forEach(c),i(r))}))}));return t.reduce(u)}},function(e,t,n){t.parser=n(74).parser,t.generate=n(80),t.writeToStream=n(41)},function(e,t,n){const r=n(75),i=n(1),o=n(77),a=n(40),s=n(8)("mqtt-packet:parser");class l extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new l).parser(e)}_resetState(){s("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),s("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,s("parse: state complete. _stateCounter is now: %d",this._stateCounter),s("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return s("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),s("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),s("_parseLength %d",e.value),!!e}_parsePayload(){s("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return s("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;s("_parseConnect");const i={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(o.clientId=c,s("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,s("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,s("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));o.username=r,s("_parseConnect: packet.username: %s",o.username)}if(i.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));o.password=n}return this.settings=o,s("_parseConnect: complete"),o}_parseConnack(){s("_parseConnack");const e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}s("_parseConnack: complete")}_parsePublish(){s("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),s("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){s("_parseSubscribe");const e=this.packet;let t,n,r,i,o,l,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&a.SUBSCRIBE_OPTIONS_QOS_MASK,l=0!=(n>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(n>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),i=n>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:r},5===this.settings.protocolVersion&&(c.nl=l,c.rap=o,c.rh=i),s("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){s("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos2&&(e.reasonCode=this._parseByte(),s("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(s("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return s("_parseDisconnect result: true"),!0}_parseAuth(){s("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),s("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(s("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,s("_parseString: result: %s",r),r}_parseStringPair(){return s("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,s("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,s("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,s("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){s("_parseVarByteNum");let t,n=0,r=1,i=0,o=!1;const l=this._pos?this._pos:0;for(;n<4;){if(t=this._list.readUInt8(l+n++),i+=r*(t&a.VARBYTEINT_MASK),r*=128,0==(t&a.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=n)break}return!o&&4===n&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),o=!!o&&(e?{bytes:n,value:i}:i),s("_parseVarByteNum: result: %o",o),o}_parseByte(){const e=this._list.readUInt8(this._pos);return this._pos++,s("_parseByte: result: %o",e),e}_parseByType(e){switch(s("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){s("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._posthis.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,n,i){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof i||i>this.length)&&(i=this.length),n>=this.length)return e||r.alloc(0);if(i<=0)return e||r.alloc(0);const o=!!e,a=this._offset(n),s=i-n;let l=s,c=o&&t||0,u=a[1];if(0===n&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;tn)){this._bufs[t].copy(e,c,u,u+l),c+=n;break}this._bufs[t].copy(e,c,u),c+=n,l-=n,u&&(u=0)}return e.length>c?e.slice(0,c):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!==n[1]&&(i[0]=i[0].slice(n[1])),this._new(i)},o.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;tthis.length?this.length:t;const i=this._offset(t);let o=i[0],a=i[1];for(;o=e.length){const n=t.indexOf(e,a);if(-1!==n)return this._reverseOffset([o,n]);a=t.length-e.length+1}else{const t=this._reverseOffset([o,a]);if(this._match(t,e))return t;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===s&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=i)return a(e,t,i,"hour");if(t>=r)return a(e,t,r,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){const r=n(41),i=n(1);class o extends i{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const n=new Array(this._array.length),r=this._array;let i,o=0;for(i=0;i>8,0),n.writeUInt8(255&e,1),n}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=i(e)},generateNumber:i,genBufVariableByteInt:function(e){let n=0,i=0;const o=t.allocUnsafe(4);do{n=e%128|0,(e=e/128|0)>0&&(n|=128),o.writeUInt8(n,i++)}while(e>0&&i<4);return e>0&&(i=0),r?o.subarray(0,i):o.slice(0,i)},generate4ByteBuffer:function(e){const n=t.allocUnsafe(4);return n.writeUInt32BE(e,0),n}}}).call(this,n(3).Buffer)},function(e,t,n){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,n)}));case 3:return t.nextTick((function(){e.call(null,n,r)}));case 4:return t.nextTick((function(){e.call(null,n,r,i)}));default:for(o=new Array(s-1),a=0;a0){e=new Array(arguments.length-2);for(var t=0;t",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(89);function b(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?I+="x":I+=O[D];if(!I.match(p)){var B=M.slice(0,T),U=M.slice(T+1),N=O.match(f);N&&(B.push(N[1]),U.unshift(N[2])),U.length&&(b="/"+U.join(".")+b),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[S])for(T=0,L=u.length;T0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift());return n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=k.slice(-1)[0],x=(n.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,T=0,R=k.length;R>=0;R--)"."===(A=k[R])?k.splice(R,1):".."===A?(k.splice(R,1),T++):T&&(k.splice(R,1),T--);if(!w&&!S)for(;T--;T)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var C,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=M?"":k.length?k.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift()));return(w=w||n.host&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){(function(e,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof r&&r;a.global!==a&&a.window!==a&&a.self;var s,l=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,f=String.fromCharCode;function m(e){throw new RangeError(h[e])}function y(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+y((e=e.replace(d,".")).split("."),t).join(".")}function v(e){for(var t,n,r=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=f((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=f(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function S(e){var t,n,r,i,o,a,s,c,u,d,h,f=[],y=e.length,g=0,v=128,_=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i=y&&m("invalid-input"),((c=(h=e.charCodeAt(i++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((l-g)/a))&&m("overflow"),g+=c*a,!(c<(u=s<=_?1:s>=_+26?26:s-_));s+=36)a>p(l/(d=36-u))&&m("overflow"),a*=d;_=w(g-o,t=f.length+1,0==o),p(g/t)>l-v&&m("overflow"),v+=p(g/t),g%=t,f.splice(g++,0,v)}return b(f)}function k(e){var t,n,r,i,o,a,s,c,u,d,h,y,g,b,S,k=[];for(y=(e=v(e)).length,t=128,n=0,o=72,a=0;a=t&&hp((l-n)/(g=r+1))&&m("overflow"),n+=(s-t)*g,t=s,a=0;al&&m("overflow"),h==t){for(c=n,u=36;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=36)S=c-d,b=36-d,k.push(f(_(d+S%b,0))),c=p(S/b);k.push(f(_(c,0))),o=w(n,g,r==i),n=0,++r}++n,++t}return k.join("")}s={version:"1.4.1",ucs2:{decode:v,encode:b},decode:S,encode:k,toASCII:function(e){return g(e,(function(e){return u.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,n,t,e))||(e.exports=i)}()}).call(this,n(87)(e),n(6))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(90),t.encode=t.stringify=n(91)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u=0?(d=m.substr(0,y),h=m.substr(y+1)):(d=m,h=""),p=decodeURIComponent(d),f=decodeURIComponent(h),r(a,p)?i(a[p])?a[p].push(f):a[p]=[a[p],f]:a[p]=f}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,s){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(r(a))+n;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(r(e))})).join(t):s+encodeURIComponent(r(e[a]))})).join(t):s?encodeURIComponent(r(s))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){"use strict";e.exports=o;var r=n(48),i=Object.create(n(14));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(12),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){var r=n(101),i=function(){},o=function(e,n,a){if("function"==typeof n)return o(e,null,n);n||(n={}),a=r(a||i);var s=e._writableState,l=e._readableState,c=n.readable||!1!==n.readable&&e.readable,u=n.writable||!1!==n.writable&&e.writable,d=!1,h=function(){e.writable||p()},p=function(){u=!1,c||a.call(e)},f=function(){c=!1,u||a.call(e)},m=function(t){a.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){a.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!d)return(!c||l&&l.ended&&!l.destroyed)&&(!u||s&&s.ended&&!s.destroyed)?void 0:a.call(e,new Error("premature close"))},b=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?u&&!s&&(e.on("end",h),e.on("close",h)):(e.on("complete",p),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",f),e.on("finish",p),!1!==n.error&&e.on("error",y),e.on("close",g),function(){d=!0,e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",p),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",f),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=o}).call(this,n(2))},function(e,t,n){var r=n(102);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}e.exports=r(i),e.exports.strict=r(o),i.proto=i((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","error",n),c.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))}static i(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","info",n),c.ENABLE_INFO&&(console.info?console.info(n):console.log(n))}static w(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","warn",n),c.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))}static d(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","debug",n),c.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))}static v(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","verbose",n),c.ENABLE_VERBOSE&&console.log(n)}}c.GLOBAL_TAG="flv.js",c.FORCE_GLOBAL_TAG=!1,c.ENABLE_ERROR=!0,c.ENABLE_INFO=!0,c.ENABLE_WARN=!0,c.ENABLE_DEBUG=!0,c.ENABLE_VERBOSE=!0,c.ENABLE_CALLBACK=!1,c.emitter=new l.a;var u=c;var d=class{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}};class h{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class p extends h{constructor(e){super(e)}get name(){return"IllegalStateException"}}class f extends h{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends h{constructor(e){super(e)}get name(){return"NotImplementedException"}}const y={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},g={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class v{constructor(e){this._type=e||"undefined",this._status=y.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=y.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===y.kConnecting||this._status===y.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 b={};!function(){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)||[],n=/(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)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},i={};if(r.browser){i[r.browser]=!0;let e=r.majorVersion.split(".");i.version={major:parseInt(r.majorVersion,10),string:r.version},e.length>1&&(i.version.minor=parseInt(e[1],10)),e.length>2&&(i.version.build=parseInt(e[2],10))}if(r.platform&&(i[r.platform]=!0),(i.chrome||i.opr||i.safari)&&(i.webkit=!0),i.rv||i.iemobile){i.rv&&delete i.rv;let e="msie";r.browser=e,i[e]=!0}if(i.edge){delete i.edge;let e="msedge";r.browser=e,i[e]=!0}if(i.opr){let e="opera";r.browser=e,i[e]=!0}if(i.safari&&i.android){let e="android";r.browser=e,i[e]=!0}i.name=r.browser,i.platform=r.platform;for(let e in b)b.hasOwnProperty(e)&&delete b[e];Object.assign(b,i)}();var _=b;var w=class extends v{static isSupported(){try{let e=_.msedge&&_.version.minor>=15048,t=!_.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 n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t),i=new self.Headers;if("object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.append(t,e[t])}let o={method:"GET",headers:i,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(let e in this._config.headers)i.append(e,this._config.headers[e]);!1===e.cors&&(o.mode="same-origin"),e.withCredentials&&(o.credentials="include"),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),this._status=y.kConnecting,self.fetch(r.url,o).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=y.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.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=y.kError,!this._onError)throw new h("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=y.kError,!this._onError)throw e;this._onError(g.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{if(11===e.code&&_.msedge)return;this._status=y.kError;let t=0,n=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength299)){if(this._status=y.kError,!this._onError)throw new h("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=y.kBuffering}}_onProgress(e){if(this._status===y.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,n=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==y.kError&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&e.loaded=this._contentLength&&(n=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let n=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?n=this._currentRedirectedURL:null!=e.redirectedURL&&(n=e.redirectedURL));let r=this._seekHandler.getConfig(n,t);this._currentRequestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onload=this._onLoad.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}i.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=y.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(null!=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=y.kBuffering}else{if(this._status=y.kError,!this._onError)throw new h("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===y.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let n=e.total;this._internalAbort(),null!=n&0!==n&&(this._totalLength=n)}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,n=t.length-1,r=0,i=0,o=n;if(e=t[r]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;let i=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=y.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,n=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onWebSocketError(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}};var A=class{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let n={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,n.Range=e}else this._zeroStart&&(n.Range="bytes=0-");return{url:e,headers:n}}removeURLParameters(e){return e}};var x=class{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let n=e;if(0!==t.from||-1!==t.to){let e=!0;-1===n.indexOf("?")&&(n+="?",e=!1),e&&(n+="&"),n+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(n+=`&${this._endName}=${t.to.toString()}`)}return{url:n,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],n=void 0,r=e.indexOf("?");-1!==r&&(n=e.substring(r+1));let i="";if(null!=n&&n.length>0){let e=n.split("&");for(let t=0;t0;n[0]!==this._startName&&n[0]!==this._endName&&(r&&(i+="&"),i+=e[t])}}return 0===i.length?t:t+"?"+i}};var T=class{constructor(e,t,n){this.TAG="IOController",this._config=t,this._extraData=n,this._stashInitialSize=393216,null!=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||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===k?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new A(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",n=e.seekParamEnd||"bend";this._seekHandler=new x(t,n)}else{if("custom"!==e.seekType)throw new f("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new f("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=E;else if(w.isSupported())this._loaderClass=w;else if(S.isSupported())this._loaderClass=S;else{if(!k.isSupported())throw new h("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=k}}_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 n={from:e,to:-1};this._currentRange={from:n.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,n),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new f("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+10485760){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(n,0,t).set(e,0)}this._stashBuffer=n,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,n=t.length-1,r=0,i=0,o=n;if(e=t[r]&&e=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let n=1024*t+1048576;this._bufferSize0){let t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart);if(r0){let e=new Uint8Array(t,r);n.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=r}}else this._stashUsed=0,this._stashByteStart+=r;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let r=this._dispatchChunks(e,t);if(rthis._bufferSize&&(this._expandBuffer(i),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e,r),0),this._stashUsed+=i,this._stashByteStart=t+r}}}else if(0===this._stashUsed){let n=this._dispatchChunks(e,t);if(nthis._bufferSize&&this._expandBuffer(r),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(e,n),0),this._stashUsed+=r,this._stashByteStart=t+n}}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 n=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(n0){let e=new Uint8Array(this._stashBuffer,n);t.set(e,0)}this._stashUsed-=n,this._stashByteStart+=n}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart),r=t.byteLength-n;if(n0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),r=new Uint8Array(t,n);e.set(r,0),this._stashUsed=r.byteLength,this._stashByteStart+=n}return 0}u.w(this.TAG,r+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,r}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(u.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=g.UNRECOVERABLE_EARLY_EOF),e){case g.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e0){let t=I.getConfig();e.emit("change",t)}}static registerListener(e){I.emitter.addListener("change",e)}static removeListener(e){I.emitter.removeListener("change",e)}static addLogListener(e){u.emitter.addListener("log",e),u.emitter.listenerCount("log")>0&&(u.ENABLE_CALLBACK=!0,I._notifyChange())}static removeLogListener(e){u.emitter.removeListener("log",e),0===u.emitter.listenerCount("log")&&(u.ENABLE_CALLBACK=!1,I._notifyChange())}}I.emitter=new l.a;var D=I;var P=class{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,n=this._search(t.times,e);return{index:n,milliseconds:t.times[n],fileposition:t.filepositions[n]}}_search(e,t){let n=0,r=e.length-1,i=0,o=0,a=r;for(t=e[i]&&t=128){t.push(String.fromCharCode(65535&e)),r+=2;continue}}}else if(n[r]<240){if(B(n,r,2)){let e=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),r+=3;continue}}}else if(n[r]<248&&B(n,r,3)){let e=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")};let N=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class F{static parseScriptData(e,t,n){let r={};try{let i=F.parseValue(e,t,n),o=F.parseValue(e,t+i.size,n-i.size);r[i.data]=o.data}catch(e){u.e("AMF",e.toString())}return r}static parseObject(e,t,n){if(n<3)throw new p("Data not enough when parse ScriptDataObject");let r=F.parseString(e,t,n),i=F.parseValue(e,t+r.size,n-r.size),o=i.objectEnd;return{data:{name:r.data,value:i.data},size:r.size+i.size,objectEnd:o}}static parseVariable(e,t,n){return F.parseObject(e,t,n)}static parseString(e,t,n){if(n<2)throw new p("Data not enough when parse String");let r,i=new DataView(e,t,n).getUint16(0,!N);return r=i>0?U(new Uint8Array(e,t+2,i)):"",{data:r,size:2+i}}static parseLongString(e,t,n){if(n<4)throw new p("Data not enough when parse LongString");let r,i=new DataView(e,t,n).getUint32(0,!N);return r=i>0?U(new Uint8Array(e,t+4,i)):"",{data:r,size:4+i}}static parseDate(e,t,n){if(n<10)throw new p("Data size invalid when parse Date");let r=new DataView(e,t,n),i=r.getFloat64(0,!N);return i+=60*r.getInt16(8,!N)*1e3,{data:new Date(i),size:10}}static parseValue(e,t,n){if(n<1)throw new p("Data not enough when parse Value");let r,i=new DataView(e,t,n),o=1,a=i.getUint8(0),s=!1;try{switch(a){case 0:r=i.getFloat64(1,!N),o+=8;break;case 1:r=!!i.getUint8(1),o+=1;break;case 2:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}case 3:{r={};let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o32)throw new f("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 n=e-this._current_word_bits_left;this._fillCurrentWord();let r=Math.min(n,this._current_word_bits_left),i=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,t=t<>>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)}};class V{static _ebsp2rbsp(e){let t=e,n=t.byteLength,r=new Uint8Array(n),i=0;for(let e=0;e=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[i]=t[e],i++);return new Uint8Array(r.buffer,0,i)}static parseSPS(e){let t=V._ebsp2rbsp(e),n=new j(t);n.readByte();let r=n.readByte();n.readByte();let i=n.readByte();n.readUEG();let o=V.getProfileString(r),a=V.getLevelString(i),s=1,l=420,c=[0,420,422,444],u=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(s=n.readUEG(),3===s&&n.readBits(1),s<=3&&(l=c[s]),u=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool())){let e=3!==s?8:12;for(let t=0;t0&&e<16?(_=t[e-1],w=r[e-1]):255===e&&(_=n.readByte()<<8|n.readByte(),w=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){let e=n.readBits(32),t=n.readBits(32);k=n.readBool(),E=t,A=2*e,S=E/A}}let x=1;1===_&&1===w||(x=_/w);let T=0,R=0;if(0===s)T=1,R=2-m;else{T=3===s?1:2,R=(1===s?2:1)*(2-m)}let C=16*(p+1),M=16*(f+1)*(2-m);C-=(y+g)*T,M-=(v+b)*R;let L=Math.ceil(C*x);return n.destroy(),n=null,{profile_string:o,level_string:a,bit_depth:u,ref_frames:h,chroma_format:l,chroma_format_string:V.getChromaFormatString(l),frame_rate:{fixed:k,fps:S,fps_den:A,fps_num:E},sar_ratio:{width:_,height:w},codec_size:{width:C,height:M},present_size:{width:L,height:M}}}static _skipScalingList(e,t){let n=8,r=8,i=0;for(let o=0;o>>2!=0,i=0!=(1&t[4]),o=(a=t)[s=5]<<24|a[s+1]<<16|a[s+2]<<8|a[s+3];var a,s;return o<9?n:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:r,hasVideoTrack:i}}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 P}_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 p("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let n=0,r=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;n=z.probe(e).dataOffset}if(this._firstParse){this._firstParse=!1,t+n!==this._dataOffset&&u.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==new DataView(e,n).getUint32(0,!r)&&u.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4}for(;ne.byteLength)break;let o=i.getUint8(0),a=16777215&i.getUint32(0,!r);if(n+11+a+4>e.byteLength)break;if(8!==o&&9!==o&&18!==o){u.w(this.TAG,`Unsupported tag type ${o}, skipped`),n+=11+a+4;continue}let s=i.getUint8(4),l=i.getUint8(5),c=i.getUint8(6)|l<<8|s<<16|i.getUint8(7)<<24;0!==(16777215&i.getUint32(7,!r))&&u.w(this.TAG,"Meet tag which has StreamID != 0!");let d=n+11;switch(o){case 8:this._parseAudioData(e,d,a,c);break;case 9:this._parseVideoData(e,d,a,c,t+n);break;case 18:this._parseScriptData(e,d,a)}let h=i.getUint32(11+a,!r);h!==11+a&&u.w(this.TAG,"Invalid PrevTagSize "+h),n+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n}_parseScriptData(e,t,n){let r=q.parseScriptData(e,t,n);if(r.hasOwnProperty("onMetaData")){if(null==r.onMetaData||"object"!=typeof r.onMetaData)return void u.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&u.w(this.TAG,"Found another onMetaData tag!"),this._metadata=r;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,u.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(r).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},r))}_parseKeyframesIndex(e){let t=[],n=[];for(let r=1;r>>4;if(2!==o&&10!==o)return void this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+o);let a=0,s=(12&i)>>>2;if(!(s>=0&&s<=4))return void this._onError(W.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+s);a=this._flvSoundRateTable[s];let l=1&i,c=this._audioMetadata,d=this._audioTrack;if(c||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),c=this._audioMetadata={},c.type="audio",c.id=d.id,c.timescale=this._timescale,c.duration=this._duration,c.audioSampleRate=a,c.channelCount=0===l?1:2),10===o){let i=this._parseAACAudioData(e,t+1,n-1);if(null==i)return;if(0===i.packetType){c.config&&u.w(this.TAG,"Found another AudioSpecificConfig!");let e=i.data;c.audioSampleRate=e.samplingRate,c.channelCount=e.channelCount,c.codec=e.codec,c.originalCodec=e.originalCodec,c.config=e.config,c.refSampleDuration=1024/c.audioSampleRate*c.timescale,u.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",c);let t=this._mediaInfo;t.audioCodec=c.originalCodec,t.audioSampleRate=c.audioSampleRate,t.audioChannelCount=c.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===i.packetType){let e=this._timestampBase+r,t={unit:i.data,length:i.data.byteLength,dts:e,pts:e};d.samples.push(t),d.length+=i.data.length}else u.e(this.TAG,"Flv: Unsupported AAC data type "+i.packetType)}else if(2===o){if(!c.codec){let r=this._parseMP3AudioData(e,t+1,n-1,!0);if(null==r)return;c.audioSampleRate=r.samplingRate,c.channelCount=r.channelCount,c.codec=r.codec,c.originalCodec=r.originalCodec,c.refSampleDuration=1152/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",c);let i=this._mediaInfo;i.audioCodec=c.codec,i.audioSampleRate=c.audioSampleRate,i.audioChannelCount=c.channelCount,i.audioDataRate=r.bitRate,i.hasVideo?null!=i.videoCodec&&(i.mimeType='video/x-flv; codecs="'+i.videoCodec+","+i.audioCodec+'"'):i.mimeType='video/x-flv; codecs="'+i.audioCodec+'"',i.isComplete()&&this._onMediaInfo(i)}let i=this._parseMP3AudioData(e,t+1,n-1,!1);if(null==i)return;let o=this._timestampBase+r,a={unit:i,length:i.byteLength,dts:o,pts:o};d.samples.push(a),d.length+=i.length}}_parseAACAudioData(e,t,n){if(n<=1)return void u.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let r={},i=new Uint8Array(e,t,n);return r.packetType=i[0],0===i[0]?r.data=this._parseAACAudioSpecificConfig(e,t+1,n-1):r.data=i.subarray(1),r}_parseAACAudioSpecificConfig(e,t,n){let r=new Uint8Array(e,t,n),i=null,o=0,a=0,s=null,l=0,c=null;if(o=a=r[0]>>>3,l=(7&r[0])<<1|r[1]>>>7,l<0||l>=this._mpegSamplingRates.length)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let u=this._mpegSamplingRates[l],d=(120&r[1])>>>3;if(d<0||d>=8)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===o&&(c=(7&r[1])<<1|r[2]>>>7,s=(124&r[2])>>>2);let h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?l>=6?(o=5,i=new Array(4),c=l-3):(o=2,i=new Array(2),c=l):-1!==h.indexOf("android")?(o=2,i=new Array(2),c=l):(o=5,c=l,i=new Array(4),l>=6?c=l-3:1===d&&(o=2,i=new Array(2),c=l)),i[0]=o<<3,i[0]|=(15&l)>>>1,i[1]=(15&l)<<7,i[1]|=(15&d)<<3,5===o&&(i[1]|=(15&c)>>>1,i[2]=(1&c)<<7,i[2]|=8,i[3]=0),{config:i,samplingRate:u,channelCount:d,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,n,r){if(n<4)return void u.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let i=new Uint8Array(e,t,n),o=null;if(r){if(255!==i[0])return;let e=i[1]>>>3&3,t=(6&i[1])>>1,n=(240&i[2])>>>4,r=(12&i[2])>>>2,a=3!==(i[3]>>>6&3)?2:1,s=0,l=0,c=34,u="mp3";switch(e){case 0:s=this._mpegAudioV25SampleRateTable[r];break;case 2:s=this._mpegAudioV20SampleRateTable[r];break;case 3:s=this._mpegAudioV10SampleRateTable[r]}switch(t){case 1:c=34,n>>4,s=15&o;7===s?this._parseAVCVideoPacket(e,t+1,n-1,r,i,a):this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+s)}_parseAVCVideoPacket(e,t,n,r,i,o){if(n<4)return void u.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,s=new DataView(e,t,n),l=s.getUint8(0),c=(16777215&s.getUint32(0,!a))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,n-4);else if(1===l)this._parseAVCVideoData(e,t+4,n-4,r,i,o,c);else if(2!==l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,n){if(n<7)return void u.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let r=this._videoMetadata,i=this._videoTrack,o=this._littleEndian,a=new DataView(e,t,n);r?void 0!==r.avcc&&u.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),r=this._videoMetadata={},r.type="video",r.id=i.id,r.timescale=this._timescale,r.duration=this._duration);let s=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==s||0===l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(W.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let c=31&a.getUint8(5);if(0===c)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");c>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+c);let d=6;for(let n=0;n1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+h),d++;for(let e=0;e=n){u.w(this.TAG,`Malformed Nalu near timestamp ${f}, offset = ${h}, dataSize = ${n}`);break}let r=l.getUint32(h,!s);if(3===p&&(r>>>=8),r>n-p)return void u.w(this.TAG,`Malformed Nalus near timestamp ${f}, NaluSize > DataSize!`);let i=31&l.getUint8(h+p);5===i&&(m=!0);let o=new Uint8Array(e,t+h,p+r),a={type:i,data:o};c.push(a),d+=o.byteLength,h+=p+r}if(c.length){let e=this._videoTrack,t={units:c,length:d,isKeyframe:m,dts:f,cts:a,pts:f+a};m&&(t.fileposition=i),e.samples.push(t),e.length+=d}}}var H=z;class G{static init(){G.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 e in G.types)G.types.hasOwnProperty(e)&&(G.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=G.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,n=null,r=Array.prototype.slice.call(arguments,1),i=r.length;for(let e=0;e>>24&255,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n.set(e,4);let o=8;for(let e=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 G.box(G.types.trak,G.tkhd(e),G.mdia(e))}static tkhd(e){let t=e.id,n=e.duration,r=e.presentWidth,i=e.presentHeight;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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,r>>>8&255,255&r,0,0,i>>>8&255,255&i,0,0]))}static mdia(e){return G.box(G.types.mdia,G.mdhd(e),G.hdlr(e),G.minf(e))}static mdhd(e){let t=e.timescale,n=e.duration;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?G.constants.HDLR_AUDIO:G.constants.HDLR_VIDEO,G.box(G.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?G.box(G.types.smhd,G.constants.SMHD):G.box(G.types.vmhd,G.constants.VMHD),G.box(G.types.minf,t,G.dinf(),G.stbl(e))}static dinf(){return G.box(G.types.dinf,G.box(G.types.dref,G.constants.DREF))}static stbl(e){return G.box(G.types.stbl,G.stsd(e),G.box(G.types.stts,G.constants.STTS),G.box(G.types.stsc,G.constants.STSC),G.box(G.types.stsz,G.constants.STSZ),G.box(G.types.stco,G.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp3(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp4a(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.avc1(e))}static mp3(e){let t=e.channelCount,n=e.audioSampleRate,r=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,n>>>8&255,255&n,0,0]);return G.box(G.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,n=e.audioSampleRate,r=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,n>>>8&255,255&n,0,0]);return G.box(G.types.mp4a,r,G.esds(e))}static esds(e){let t=e.config||[],n=t.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return G.box(G.types.esds,r)}static avc1(e){let t=e.avcc,n=e.codecWidth,r=e.codecHeight,i=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,n>>>8&255,255&n,r>>>8&255,255&r,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 G.box(G.types.avc1,i,G.box(G.types.avcC,t))}static mvex(e){return G.box(G.types.mvex,G.trex(e))}static trex(e){let t=e.id,n=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 G.box(G.types.trex,n)}static moof(e,t){return G.box(G.types.moof,G.mfhd(e.sequenceNumber),G.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 G.box(G.types.mfhd,t)}static traf(e,t){let n=e.id,r=G.box(G.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),i=G.box(G.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),o=G.sdtp(e),a=G.trun(e,o.byteLength+16+16+8+16+8+8);return G.box(G.types.traf,r,i,a,o)}static sdtp(e){let t=e.samples||[],n=t.length,r=new Uint8Array(4+n);for(let e=0;e>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*e)}return G.box(G.types.trun,o)}static mdat(e){return G.box(G.types.mdat,e)}}G.init();var K=G;var Q=class{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}};class X{constructor(e,t,n,r,i){this.dts=e,this.pts=t,this.duration=n,this.originalDts=r,this.isSyncPoint=i,this.fileposition=null}}class Z{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 J{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts=t[i].dts&&et[r].lastSample.originalDts&&e=t[r].lastSample.originalDts&&(r===t.length-1||r0&&(i=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=i,this._list.splice(i,0,n)}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),n=this._list[t].syncPoints;for(;0===n.length&&t>0;)t--,n=this._list[t].syncPoints;return n.length>0?n[n.length-1]:null}}var ee=class{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 $("audio"),this._videoSegmentInfoList=new $("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!_.chrome||!(_.version.major<50||50===_.version.major&&_.version.build<2661)),this._fillSilentAfterSeek=_.msedge||_.msie,this._mp3UseMpegAudio=!_.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 p("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let n=null,r="mp4",i=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(r="mpeg",i="",n=new Uint8Array):n=K.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,n=K.generateInitSegment(t)}if(!this._onInitSegment)throw new p("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:n.buffer,codec:i,container:`${e}/${r}`,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,n={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(n.samples.push(e),n.length=e.length);let r={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(r.samples.push(t),r.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(n,!0),this._remuxAudio(r,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,c=this._dtsBaseInited&&void 0===this._audioNextDts,d=!1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let h=0,p=null,f=0;l?(h=0,f=n.length):(h=8,f=8+n.length);let m=null;if(r.length>1&&(m=r.pop(),f-=m.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(e),f+=e.length}null!=m&&(this._audioStashedLastSample=m);let y=r[0].dts-this._dtsBase;if(this._audioNextDts)i=y-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())i=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(d=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(y);if(null!=e){let t=y-(e.originalDts+e.duration);t<=3&&(t=0),i=y-(e.dts+e.duration+t)}else i=0}if(d){let e=y-i,t=this._videoSegmentInfoList.getLastSegmentBefore(y);if(null!=t&&t.beginDts=1?g[g.length-1].duration:Math.floor(s);let d=!1,h=null;if(c>1.5*s&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!_.safari){d=!0;let e=Math.abs(c-s),t=Math.ceil(e/s),r=l+s;u.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${l+c} ms, expected: ${l+Math.round(s)} ms, delta: ${Math.round(e)} ms, generate: ${t} frames`);let i=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==i&&(u.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),i=n),h=[];for(let e=0;e0){let t=h[h.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:i,size:i.byteLength,duration:0,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};h.push(t),f+=t.size,r+=s}let o=h[h.length-1];o.duration=l+c-o.dts,c=Math.round(s)}g.push({dts:l,pts:l,cts:0,unit:t.unit,size:t.unit.byteLength,duration:c,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,h)}l?p=new Uint8Array(f):(p=new Uint8Array(f),p[0]=f>>>24&255,p[1]=f>>>16&255,p[2]=f>>>8&255,p[3]=255&f,p.set(K.types.mdat,4));for(let e=0;e1&&(h=r.pop(),d-=h.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,r.unshift(e),d+=e.length}null!=h&&(this._videoStashedLastSample=h);let p=r[0].dts-this._dtsBase;if(this._videoNextDts)i=p-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())i=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0),i=p-(e.dts+e.duration+t)}else i=0}let f=new Z,m=[];for(let e=0;e=1?m[m.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(a){let e=new X(l,u,d,t.dts,!0);e.fileposition=t.fileposition,f.appendSyncPoint(e)}m.push({dts:l,pts:u,cts:c,units:t.units,size:t.length,isKeyframe:a,duration:d,originalDts:n,flags:{isLeading:0,dependsOn:a?2:1,isDependedOn:a?1:0,hasRedundancy:0,isNonSync:a?0:1}})}u=new Uint8Array(d),u[0]=d>>>24&255,u[1]=d>>>16&255,u[2]=d>>>8&255,u[3]=255&d,u.set(K.types.mdat,4);for(let e=0;e{r.timestampBase=n,n+=r.duration,r.cors=e.cors,r.withCredentials=e.withCredentials,t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy)}),isNaN(n)||this._mediaDataSource.duration===n||(this._mediaDataSource.duration=n),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 n=this._mediaDataSource.segments[e],r=this._ioctl=new T(n,this._config,e);r.onError=this._onIOException.bind(this),r.onSeeked=this._onIOSeeked.bind(this),r.onComplete=this._onIOComplete.bind(this),r.onRedirect=this._onIORedirect.bind(this),r.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):r.onDataArrival=this._onInitChunkArrival.bind(this),r.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 n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e;else{let t=n.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let r=n.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,r.fileposition),this._pendingResolveSeekPoint=r.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,n=t.length-1;for(let r=0;r0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=H.probe(e)).match){this._demuxer=new H(n,this._config),this._remuxer||(this._remuxer=new ee(this._config));let i=this._mediaDataSource;null==i.duration||isNaN(i.duration)||(this._demuxer.overridedDuration=i.duration),"boolean"==typeof i.hasAudio&&(this._demuxer.overridedHasAudio=i.hasAudio),"boolean"==typeof i.hasVideo&&(this._demuxer.overridedHasVideo=i.hasVideo),this._demuxer.timestampBase=i.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),r=this._demuxer.parseChunks(e,t)}else n=null,u.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(te.DEMUX_ERROR,W.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}_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,P.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,P.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(te.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t0&&e[0].originalDts===n&&(n=e[0].pts),this._emitter.emit(te.RECOMMEND_SEEKPOINT,n)}}_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],n=Object.assign({},t);n.duration=this._mediaInfo.duration,n.segmentCount=this._mediaInfo.segmentCount,delete n.segments,delete n.keyframesIndex,this._emitter.emit(te.MEDIA_INFO,n)}_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(te.STATISTICS_INFO,e)}};var re=function(e){let t=null,n=function(t,n){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:n}})}.bind(this);function r(t,n){let r={msg:te.INIT_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function i(t,n){let r={msg:te.MEDIA_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function o(){let t={msg:te.LOADING_COMPLETE};e.postMessage(t)}function s(){let t={msg:te.RECOVERED_EARLY_EOF};e.postMessage(t)}function l(t){let n={msg:te.MEDIA_INFO,data:t};e.postMessage(n)}function c(t){let n={msg:te.METADATA_ARRIVED,data:t};e.postMessage(n)}function u(t){let n={msg:te.SCRIPTDATA_ARRIVED,data:t};e.postMessage(n)}function d(t){let n={msg:te.STATISTICS_INFO,data:t};e.postMessage(n)}function h(t,n){e.postMessage({msg:te.IO_ERROR,data:{type:t,info:n}})}function p(t,n){e.postMessage({msg:te.DEMUX_ERROR,data:{type:t,info:n}})}function f(t){e.postMessage({msg:te.RECOMMEND_SEEKPOINT,data:t})}a.install(),e.addEventListener("message",(function(a){switch(a.data.cmd){case"init":t=new ne(a.data.param[0],a.data.param[1]),t.on(te.IO_ERROR,h.bind(this)),t.on(te.DEMUX_ERROR,p.bind(this)),t.on(te.INIT_SEGMENT,r.bind(this)),t.on(te.MEDIA_SEGMENT,i.bind(this)),t.on(te.LOADING_COMPLETE,o.bind(this)),t.on(te.RECOVERED_EARLY_EOF,s.bind(this)),t.on(te.MEDIA_INFO,l.bind(this)),t.on(te.METADATA_ARRIVED,c.bind(this)),t.on(te.SCRIPTDATA_ARRIVED,u.bind(this)),t.on(te.STATISTICS_INFO,d.bind(this)),t.on(te.RECOMMEND_SEEKPOINT,f.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(a.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=a.data.param;D.applyConfig(e),!0===e.enableCallback?D.addLogListener(n):D.removeLogListener(n);break}}}))};var ie=class{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new l.a,t.enableWorker&&"undefined"!=typeof Worker)try{let r=n(56);this._worker=r(re),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)},D.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:D.getConfig()})}catch(n){u.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ne(e,t)}else this._controller=new ne(e,t);if(this._controller){let e=this._controller;e.on(te.IO_ERROR,this._onIOError.bind(this)),e.on(te.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(te.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(te.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(te.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(te.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(te.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(te.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(te.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(te.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(te.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),D.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(te.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(te.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(te.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(te.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,n=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case te.INIT_SEGMENT:case te.MEDIA_SEGMENT:this._emitter.emit(t.msg,n.type,n.data);break;case te.LOADING_COMPLETE:case te.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case te.MEDIA_INFO:Object.setPrototypeOf(n,P.prototype),this._emitter.emit(t.msg,n);break;case te.METADATA_ARRIVED:case te.SCRIPTDATA_ARRIVED:case te.STATISTICS_INFO:this._emitter.emit(t.msg,n);break;case te.IO_ERROR:case te.DEMUX_ERROR:this._emitter.emit(t.msg,n.type,n.info);break;case te.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,n);break;case"logcat_callback":u.emitter.emit("log",n.type,n.logcat)}}};var oe={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var ae=class{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new l.a,this._config.isLive&&null==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 J}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 p("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 e=this._mediaSource;for(let t in this._sourceBuffers){let n=this._pendingSegments[t];n.splice(0,n.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let r=this._sourceBuffers[t];if(r){if("closed"!==e.readyState){try{e.removeSourceBuffer(r)}catch(e){u.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){u.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.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 n=e,r=""+n.container;n.codec&&n.codec.length>0&&(r+=";codecs="+n.codec);let i=!1;if(u.v(this.TAG,"Received Initialization Segment, mimeType: "+r),this._lastInitSegments[n.type]=n,r!==this._mimeTypes[n.type]){if(this._mimeTypes[n.type])u.v(this.TAG,`Notice: ${n.type} mimeType changed, origin: ${this._mimeTypes[n.type]}, target: ${r}`);else{i=!0;try{let e=this._sourceBuffers[n.type]=this._mediaSource.addSourceBuffer(r);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.e(this.TAG,e.message),void this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[n.type]=r}t||this._pendingSegments[n.type].push(n),i||this._sourceBuffers[n.type]&&!this._sourceBuffers[n.type].updating&&this._doAppendSegments(),_.safari&&"audio/mpeg"===n.container&&n.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=n.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let n=this._sourceBuffers[t.type];!n||n.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){u.e(this.TAG,e.message)}this._idrList.clear();let n=this._pendingSegments[e];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(let n=0;n=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 n=this._sourceBuffers[t];if(n){let r=n.buffered,i=!1;for(let n=0;n=this._config.autoCleanupMaxBackwardDuration){i=!0;let n=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:o,end:n})}}else a0&&(isNaN(t)||n>t)&&(u.v(this.TAG,`Update MediaSource duration from ${t} to ${n}`),this._mediaSource.duration=n),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],n=this._pendingRemoveRanges[e];for(;n.length&&!t.updating;){let e=n.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){let n=e[t].shift();if(n.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,r=n.timestampOffset/1e3;Math.abs(e-r)>.1&&(u.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${r}`),this._sourceBuffers[t].timestampOffset=r),delete n.timestampOffset}if(!n.data||0===n.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(n.data),this._isBufferFull=!1,"video"===t&&n.hasOwnProperty("info")&&this._idrList.appendArray(n.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(n),22===e.code?(this._isBufferFull||this._emitter.emit(oe.BUFFER_FULL),this._isBufferFull=!0):(u.e(this.TAG,e.message),this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(u.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;for(;e.length;){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(oe.SOURCE_OPEN)}_onSourceEnded(){u.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){u.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(oe.UPDATE_END)}_onSourceBufferError(e){u.e(this.TAG,"SourceBuffer Error: "+e)}};const se={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},le={NETWORK_EXCEPTION:g.EXCEPTION,NETWORK_STATUS_CODE_INVALID:g.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:g.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:g.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:W.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:W.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:W.CODEC_UNSUPPORTED};var ce=class{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f("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 n=_.chrome&&(_.version.major<50||50===_.version.major&&_.version.build<2661);this._alwaysSeekKeyframe=!!(n||_.msedge||_.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===O.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.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 ae(this._config),this._msectl.on(oe.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(oe.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(oe.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(oe.ERROR,e=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,le.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}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 p("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p("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 ie(this._mediaDataSource,this._config),this._transmuxer.on(te.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(te.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&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(te.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(O.LOADING_COMPLETE)}),this._transmuxer.on(te.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(O.RECOVERED_EARLY_EOF)}),this._transmuxer.on(te.IO_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.NETWORK_ERROR,e,t)}),this._transmuxer.on(te.DEMUX_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(te.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(O.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(te.METADATA_ARRIVED,e=>{this._emitter.emit(O.METADATA_ARRIVED,e)}),this._transmuxer.on(te.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(O.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(te.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(O.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(te.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,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,n=0,r=0;for(let i=0;i=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){u.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,n=!1;for(let r=0;r=i&&e=o-this._config.lazyLoadRecoverDuration&&(n=!0);break}}n&&(window.clearInterval(this._progressChecker),this._progressChecker=null,n&&(u.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let n=0;n=r&&e0){let t=this._mediaElement.buffered.start(0);(t<1&&e0&&t.currentTime0){let e=n.start(0);if(e<1&&t{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.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(e){}}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 p("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={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}};a.install();let de={createPlayer:function(e,t){let n=e;if(null==n||"object"!=typeof n)throw new f("MediaDataSource must be an javascript object!");if(!n.hasOwnProperty("type"))throw new f("MediaDataSource must has type field to indicate video file type!");switch(n.type){case"flv":return new ce(n,t);default:return new ue(n,t)}},isSupported:function(){return L.supportMSEH264Playback()},getFeatureList:function(){return L.getFeatureList()}};de.BaseLoader=v,de.LoaderStatus=y,de.LoaderErrors=g,de.Events=O,de.ErrorTypes=se,de.ErrorDetails=le,de.FlvPlayer=ce,de.NativePlayer=ue,de.LoggingControl=D,Object.defineProperty(de,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var he=de,pe=n(4),fe=n.n(pe),me=n(24),ye={insert:"head",singleton:!1};fe()(me.a,ye),me.a.locals;function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ve(e,t){for(var n=0;n=n.count?(n.flvPlayer.pause(),n.flvPlayer.unload(),n.flvPlayer.detachMediaElement(),setTimeout((function(){n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.flvPlayer.play()}),500)):(clearInterval(n.timer),n.timer=null,console.log("重连失败")))}))}}),t)})}},{key:"componentWillUnmount",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"getNewVideo",value:function(){var e=this.state.id,t=document.getElementById(e).getElementsByTagName("video")[0];if(t)for(var n=t.buffered,r=0;r-1&&(t.currentTime=i-.1)}}},{key:"render",value:function(){var e=this.state.id;return i.a.createElement("div",{className:"dplayerWaikuang"},i.a.createElement("div",{id:e,style:{width:"100%",height:"100%"}}))}}])&&Me(t.prototype,n),r&&Me(t,r),a}(r.Component),Be=n(17),Ue=n(26),Ne={insert:"head",singleton:!1};fe()(Ue.a,Ne),Ue.a.locals;function Fe(e){return(Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qe(e,t){for(var n=0;n=r+1){var l=((100-o*(r-1))/r).toFixed(2),c=(parseFloat(l)+o)*(t.length-r),u=document.getElementById("objectTransition");u.style.transition=s+"s all 0s",u.style.left=-c+"%"}return{children:t}}}],(n=[{key:"componentDidUpdate",value:function(){var e=this.props,t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length=1&&t<3?i.a.createElement("div",{style:{width:n+"%"},key:t},e):i.a.createElement("div",{style:{width:n+"%",left:(parseFloat(n)+a)*t+"%"},key:t},e)}))))}}])&&at(t.prototype,n),r&&at(t,r),a}(r.Component),ht=n(29),pt={insert:"head",singleton:!1};fe()(ht.a,pt),ht.a.locals;function ft(e){return(ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mt(e,t){for(var n=0;n0?n:null}}],(n=[{key:"shouldComponentUpdate",value:function(e){return this.props.serviceData.length!==e.serviceData}},{key:"componentDidMount",value:function(){this.init()}},{key:"init",value:function(){this.setCanvasSize()}},{key:"setCanvasSize",value:function(){var e=this.state.id,t=document.getElementById(e).parentNode,n=t.offsetWidth,r=t.offsetHeight;this.setData({width:n+"px",height:r+"px"})}},{key:"removeTags",value:function(e,t){for(var n=document.getElementsByTagName(e),r=n.length-1;r>=0;r--)n[r].className==t&&n[r].parentNode.removeChild(n[r])}},{key:"draw",value:function(){var e=this.state,t=e.id,n=e.serviceData,r=e.width,i=e.height,o=e.mode,a=e.disabled,s=document.getElementById(t).getContext("2d");s.clearRect(0,0,parseFloat(r),parseFloat(i)),this.removeTags("input",this.props.listId?this.props.listId:t+""),this.drawLine(s,n),this.drawCircleAll(s,n),this.drawWriting(s,n),"false"===a&&("click"===o?this.isontouchend()?this.touchMove():this.clickMove():this.isontouchend()?this.touchMove():this.mouseMove())}},{key:"isontouchend",value:function(){return"ontouchend"in document}},{key:"drawCircleAll",value:function(e,t){for(var n=0;nh&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])0)for(var v in u)g.style[v]=u[v];g.value=e,g.className=this.props.listId?this.props.listId+"":m+"",g.oninput=function(e){var t=a.split(/\n/);t[r]=e.target.value,i.setState({title:t.join("\n")}),i.props.wenziChange(t.join("\n"))},y.appendChild(g)}},{key:"clickMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData;document.getElementById(n).onclick=function(t){var n=t.layerX,i=t.layerY;e.selectedIndex||0===e.selectedIndex?(r[e.selectedIndex]=[n,i],e.selectedIndex=null,e.setData({serviceData:r}),e.sendFather(r)):(e.selectBox(n,i),e.setData({serviceData:r}))}}},{key:"mouseMove",value:function(){var e=this,t=this.state.id,n=document.getElementById(t);n.onmousedown=function(t){var r=e.state.serviceData,i=t.layerX,o=t.layerY;e.selectBox(i,o)&&(n.onmousemove=function(t){r[e.selectedIndex]=[t.layerX,t.layerY],e.setData({serviceData:r})})},n.onmouseup=function(t){n.onmousemove=null,e.selectedIndex=null,e.setData({serviceData:e.state.serviceData});var r=t.layerX,i=t.layerY;e.selectBox(r,i)&&e.sendFather(e.state.serviceData)}}},{key:"touchMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData,i=document.getElementById(n),o=i.parentNode,a=o.getBoundingClientRect().top,s=o.getBoundingClientRect().left;i.ontouchstart=function(t){var n=t.touches[0].pageX-s,o=t.touches[0].pageY-a;e.selectBox(n,o)&&(i.ontouchmove=function(t){r[e.selectedIndex]=[t.touches[0].pageX-s,t.touches[0].pageY-a],e.setData({serviceData:r})})},i.ontouchend=function(t){e.selectedIndex=null,i.ontouchmove=null,e.setData({serviceData:r});var n=t.changedTouches[0].pageX-s,o=t.changedTouches[0].pageY-a;e.selectBox(n,o)&&e.sendFather(r)}}},{key:"selectBox",value:function(e,t){var n=this.state,r=n.serviceData,i=n.circleRadius+n.circleBorderWidth;this.selectedIndex=null;for(var o=0;o0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.state.mode;"react"===e?this.setReact():this.setPolygon()}},{key:"isNull",value:function(){var e=this.state.id,t=document.getElementById(this[e].state.id),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,t.toDataURL()==n.toDataURL()}},{key:"setReact",value:function(){var e=this,t=this.state.id;this.count=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=e.state.serviceData,i=n.layerX,o=n.layerY;if(0===e.count)r[1][1]=o,r[2]=[i,o],r[3][0]=i;else if(e[t].selectedIndex||0===e[t].selectedIndex){switch(r[e[t].selectedIndex]=[i,o],e[t].selectedIndex){case 0:r[1][0]=i,r[3][1]=o;break;case 1:r[0][0]=i,r[2][1]=o;break;case 2:r[1][1]=o,r[3][0]=i;break;case 3:r[0][1]=o,r[2][0]=i}e.props.change(r)}e.setState({serviceData:r},(function(){e[t].draw()}))};n.addEventListener("mousedown",(function(i){if(2!==i.button){var o=i.layerX,a=i.layerY,s=[o,a];if(0===e.state.serviceData.length){e.count++;var l=[[].concat(s),[].concat(s),[].concat(s),[].concat(s)];e.setState({serviceData:l},(function(){e[t].draw()})),n.addEventListener("mousemove",r)}else e[t].selectBox(o,a)&&(e.count++,n.addEventListener("mousemove",r))}})),n.addEventListener("mouseup",(function(e){n.removeEventListener("mousemove",r)})),n.oncontextmenu=function(e){e.preventDefault()}}},{key:"setPolygon",value:function(){var e=this,t=this.state.id;this.state.serviceData.length>1?this.serviceDataFlag=!0:this.polygonCount=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=n.layerX,i=n.layerY,o=e.state.serviceData;o.push([r,i]),e.setState({serviceData:o},(function(){e[t].draw()}))};this.serviceDataFlag||n.addEventListener("click",r),n.oncontextmenu=function(t){t.preventDefault(),2===t.button&&(0==e.polygonCount&&(e.polygonCount++,e.sendFather(e.state.serviceData)),n.removeEventListener("click",r))}}},{key:"isInPolygon",value:function(e,t,n){var r,i,o,a=0,s=t.length;i=t[0];for(var l=1;l<=s;l++)o=t[l%s],e[0]>Math.min(i[0],o[0])&&e[0]<=Math.max(i[0],o[0])&&e[1]<=Math.max(i[1],o[1])&&i[0]!=o[0]&&(r=(e[0]-i[0])*(o[1]-i[1])/(o[0]-i[0])+i[1],(i[1]==o[1]||e[1]<=r)&&a++),i=o;return a%2!=0||!!n.selectBox(e[0],e[1])}},{key:"wenziChange",value:function(e){this.setState({title:e}),this.props.wenziChange(e)}},{key:"change",value:function(e){this.sendFather(e)}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"render",value:function(){var e=this,t=this.state,n=t.serviceData,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.inputStyle,k=t.position,E=t.id;return i.a.createElement(_t,{serviceData:n,disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:p,titleColor:f,titleFont:m,titleLineHeight:y,titleBackgroundColor:g,titlePadding:v,titleTextAlign:b,titleWidth:_,titleFillColor:w,position:k,inputStyle:S,listId:this.props.listId,ref:function(t){e[E]=t},wenziChange:function(t){return e.wenziChange(t)},change:function(t){return e.change(t)}})}}])&&kt(t.prototype,n),r&&kt(t,r),a}(r.Component),Ct=n(30),Mt={insert:"head",singleton:!1};fe()(Ct.a,Mt),Ct.a.locals;function Lt(e){return(Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e,t){for(var n=0;n0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.props.list;e&&e.length>0&&(this.selectIndex=e[e.length-1].id),this.selectArea()}},{key:"clickIt",value:function(e){var t=this.props.list,n=(new Date).getTime();t&&0!==t.length?this[t[t.length-1].id+t[t.length-1].mode].isNull()?this.props.err(!1,"画布为空,请先绘制在添加。"):t[t.length-1].serviceData?(t.push({id:n+"",title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n+""):this.props.err(!1,"画布没有保存,请先绘制完成在添加"):((t=[]).push({id:n,title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n),this.props.change(t)}},{key:"delete",value:function(){var e=this,t=this.state.list.filter((function(t){return t.id===e.selectIndex})),n=this[t[0].id+t[0].mode];n[n.state.id].removeTags("input",n.props.listId),this.props.delete(this.selectIndex,"发出删除指令")}},{key:"change",value:function(e){var t=this,n=this.props.list;n=n.map((function(n){return n.id===t.selectIndex&&(n.serviceData=JSON.parse(JSON.stringify(e))),n})),this.props.change(n)}},{key:"selectArea",value:function(){var e=this,t=this.state.id;document.getElementById(t).onclick=function(t){var n=e.props.list,r=t.layerX,i=t.layerY;if(e.indexflag=!1,n)for(var o=0;oi!=d>i&&r<(u-l)*(i-c)/(d-c)+l;h&&(o=!o)}return!(h||!n.selectBox(e[0],e[1]))||o}},{key:"wenziChange",value:function(e,t){this.props.wenziChange(e,t)}},{key:"render",value:function(){var e=this,t=this.state,n=t.id,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.position,k=this.props.list;return i.a.createElement("div",{id:n,style:{width:"100%",height:"100%",position:"relative"}},k&&k.map((function(t,n){return i.a.createElement(Rt,{disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:t.title?t.title:p,titleColor:t.titleColor?t.titleColor:f,titleFont:t.titleFont?t.titleFont:m,titleLineHeight:t.titleLineHeight?t.titleLineHeight:y,titleBackgroundColor:t.titleBackgroundColor?t.titleBackgroundColor:g,titlePadding:t.titlePadding?t.titlePadding:v,titleTextAlign:t.titleTextAlign?t.titleTextAlign:b,titleWidth:t.titleWidth?t.titleWidth:_,titleFillColor:t.titleFillColor?t.titleFillColor:w,position:S,key:t.id,listId:t.id,serviceData:t.serviceData,ref:function(n){e[t.id+t.mode]=n},mode:t.mode,wenziChange:function(t){return e.wenziChange(t,n)},change:function(t){return e.change(t)}})})))}}])&&It(t.prototype,n),r&&It(t,r),a}(r.Component),Ft=n(52),qt=n.n(Ft),jt=function(e){this.mqtt=qt.a,this.random=Vt,this.clientId=Vt();var t={clientId:this.clientId,username:"test",password:"test",connectTimeout:100,keepalive:100};this.client=this.mqtt.connect("ws://"+e+"/mqtt",t),this.reconnectNum=0,this.link=function(){var e=this;return new Promise((function(t,n){e.client.on("connect",(function(n){console.log("-----------------------链接成功-----------------------"),t(e.client)})),e.client.on("reconnect",(function(t){e.reconnectNum++,e.reconnectNum>=10&&e.client.end(!0),console.log("正在重连:",t)})),e.client.on("error",(function(e){console.log("订阅失败",e)}))}))},this.subscribe=function(e,t){this.client.subscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"订阅成功-----------------------")}))},this.unsubscribe=function(e,t){this.client.unsubscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"取消订阅成功-----------------------")}))},this.publish=function(e,t,n){this.client.publish(e,JSON.stringify(t),n,(function(t,n){if(t)throw new Error(t);console.log("-----------------------"+e+"发送成功-----------------------")}))},this.message=function(e){this.client.on("message",(function(t,n){var r=JSON.parse(n.toString());e(r,t)}))},this.close=function(){this.client.end(!0)}};function Vt(){for(var e=String.fromCharCode(65+Math.floor(26*Math.random())),t=0;t<31;++t){var n=Math.floor(62*Math.random());e+=n<10?n.toString():n<36?String.fromCharCode(65+n-10):String.fromCharCode(97+n-10-26)}return e}function Yt(e){for(var t=window.location.search.substring(1).split("&"),n=0;n1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=null,i=0;return new Promise((function(o,a){zt(e)?o(zt(e)):r=setInterval((function(){i0,(function(e){r||(r=e),e&&a.forEach(c),o||(a.forEach(c),i(r))}))}));return t.reduce(u)}},function(e,t,n){t.parser=n(74).parser,t.generate=n(80),t.writeToStream=n(41)},function(e,t,n){const r=n(75),i=n(1),o=n(77),a=n(40),s=n(8)("mqtt-packet:parser");class l extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new l).parser(e)}_resetState(){s("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),s("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,s("parse: state complete. _stateCounter is now: %d",this._stateCounter),s("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return s("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=a.types[e>>a.CMD_SHIFT],this.packet.retain=0!=(e&a.RETAIN_MASK),this.packet.qos=e>>a.QOS_SHIFT&a.QOS_MASK,this.packet.dup=0!=(e&a.DUP_MASK),s("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),s("_parseLength %d",e.value),!!e}_parsePayload(){s("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return s("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;s("_parseConnect");const i={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&a.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&a.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&a.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&a.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&a.WILL_QOS_MASK)>>a.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&a.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(o.clientId=c,s("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,s("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,s("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));o.username=r,s("_parseConnect: packet.username: %s",o.username)}if(i.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));o.password=n}return this.settings=o,s("_parseConnect: complete"),o}_parseConnack(){s("_parseConnack");const e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&a.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}s("_parseConnack: complete")}_parsePublish(){s("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),s("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){s("_parseSubscribe");const e=this.packet;let t,n,r,i,o,l,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&a.SUBSCRIBE_OPTIONS_QOS_MASK,l=0!=(n>>a.SUBSCRIBE_OPTIONS_NL_SHIFT&a.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(n>>a.SUBSCRIBE_OPTIONS_RAP_SHIFT&a.SUBSCRIBE_OPTIONS_RAP_MASK),i=n>>a.SUBSCRIBE_OPTIONS_RH_SHIFT&a.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:r},5===this.settings.protocolVersion&&(c.nl=l,c.rap=o,c.rh=i),s("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){s("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos2&&(e.reasonCode=this._parseByte(),s("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(s("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return s("_parseDisconnect result: true"),!0}_parseAuth(){s("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),s("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(s("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,s("_parseString: result: %s",r),r}_parseStringPair(){return s("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,s("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,s("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,s("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){s("_parseVarByteNum");let t,n=0,r=1,i=0,o=!1;const l=this._pos?this._pos:0;for(;n<4;){if(t=this._list.readUInt8(l+n++),i+=r*(t&a.VARBYTEINT_MASK),r*=128,0==(t&a.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=n)break}return!o&&4===n&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),o=!!o&&(e?{bytes:n,value:i}:i),s("_parseVarByteNum: result: %o",o),o}_parseByte(){const e=this._list.readUInt8(this._pos);return this._pos++,s("_parseByte: result: %o",e),e}_parseByType(e){switch(s("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){s("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._posthis.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,n,i){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof i||i>this.length)&&(i=this.length),n>=this.length)return e||r.alloc(0);if(i<=0)return e||r.alloc(0);const o=!!e,a=this._offset(n),s=i-n;let l=s,c=o&&t||0,u=a[1];if(0===n&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;tn)){this._bufs[t].copy(e,c,u,u+l),c+=n;break}this._bufs[t].copy(e,c,u),c+=n,l-=n,u&&(u=0)}return e.length>c?e.slice(0,c):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),i=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,r[1]),0!==n[1]&&(i[0]=i[0].slice(n[1])),this._new(i)},o.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;tthis.length?this.length:t;const i=this._offset(t);let o=i[0],a=i[1];for(;o=e.length){const n=t.indexOf(e,a);if(-1!==n)return this._reverseOffset([o,n]);a=t.length-e.length+1}else{const t=this._reverseOffset([o,a]);if(this._match(t,e))return t;a++}}a=0}return-1},o.prototype._match=function(e,t){if(this.length-e{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n}),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return 6048e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===s&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=i)return a(e,t,i,"hour");if(t>=r)return a(e,t,r,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=r)return Math.round(e/r)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,n){(function(t){const r=n(41),i=n(1);class o extends i{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const n=new Array(this._array.length),r=this._array;let i,o=0;for(i=0;i>8,0),n.writeUInt8(255&e,1),n}e.exports={cache:n,generateCache:function(){for(let e=0;e<65536;e++)n[e]=i(e)},generateNumber:i,genBufVariableByteInt:function(e){let n=0,i=0;const o=t.allocUnsafe(4);do{n=e%128|0,(e=e/128|0)>0&&(n|=128),o.writeUInt8(n,i++)}while(e>0&&i<4);return e>0&&(i=0),r?o.subarray(0,i):o.slice(0,i)},generate4ByteBuffer:function(e){const n=t.allocUnsafe(4);return n.writeUInt32BE(e,0),n}}}).call(this,n(3).Buffer)},function(e,t,n){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,n)}));case 3:return t.nextTick((function(){e.call(null,n,r)}));case 4:return t.nextTick((function(){e.call(null,n,r,i)}));default:for(o=new Array(s-1),a=0;a0){e=new Array(arguments.length-2);for(var t=0;t",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(89);function b(e,t,n){if(e&&i.isObject(e)&&e instanceof o)return e;var r=new o;return r.parse(e,t,n),r}o.prototype.parse=function(e,t,n){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),s=-1!==o&&o127?I+="x":I+=O[D];if(!I.match(p)){var B=M.slice(0,T),U=M.slice(T+1),N=O.match(f);N&&(B.push(N[1]),U.unshift(N[2])),U.length&&(b="/"+U.join(".")+b),this.hostname=B.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=r.toASCII(this.hostname));var F=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[S])for(T=0,L=u.length;T0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift());return n.search=e.search,n.query=e.query,i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=k.slice(-1)[0],x=(n.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,T=0,R=k.length;R>=0;R--)"."===(A=k[R])?k.splice(R,1):".."===A?(k.splice(R,1),T++):T&&(k.splice(R,1),T--);if(!w&&!S)for(;T--;T)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var C,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);E&&(n.hostname=n.host=M?"":k.length?k.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift()));return(w=w||n.host&&k.length)&&!M&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),i.isNull(n.pathname)&&i.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},o.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){(function(e,r){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(o){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof r&&r;a.global!==a&&a.window!==a&&a.self;var s,l=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,h={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=Math.floor,f=String.fromCharCode;function m(e){throw new RangeError(h[e])}function y(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function g(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+y((e=e.replace(d,".")).split("."),t).join(".")}function v(e){for(var t,n,r=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=f((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=f(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var r=0;for(e=n?p(e/700):e>>1,e+=p(e/t);e>455;r+=36)e=p(e/35);return p(r+36*e/(e+38))}function S(e){var t,n,r,i,o,a,s,c,u,d,h,f=[],y=e.length,g=0,v=128,_=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r=128&&m("not-basic"),f.push(e.charCodeAt(r));for(i=n>0?n+1:0;i=y&&m("invalid-input"),((c=(h=e.charCodeAt(i++))-48<10?h-22:h-65<26?h-65:h-97<26?h-97:36)>=36||c>p((l-g)/a))&&m("overflow"),g+=c*a,!(c<(u=s<=_?1:s>=_+26?26:s-_));s+=36)a>p(l/(d=36-u))&&m("overflow"),a*=d;_=w(g-o,t=f.length+1,0==o),p(g/t)>l-v&&m("overflow"),v+=p(g/t),g%=t,f.splice(g++,0,v)}return b(f)}function k(e){var t,n,r,i,o,a,s,c,u,d,h,y,g,b,S,k=[];for(y=(e=v(e)).length,t=128,n=0,o=72,a=0;a=t&&hp((l-n)/(g=r+1))&&m("overflow"),n+=(s-t)*g,t=s,a=0;al&&m("overflow"),h==t){for(c=n,u=36;!(c<(d=u<=o?1:u>=o+26?26:u-o));u+=36)S=c-d,b=36-d,k.push(f(_(d+S%b,0))),c=p(S/b);k.push(f(_(c,0))),o=w(n,g,r==i),n=0,++r}++n,++t}return k.join("")}s={version:"1.4.1",ucs2:{decode:v,encode:b},decode:S,encode:k,toASCII:function(e){return g(e,(function(e){return u.test(e)?"xn--"+k(e):e}))},toUnicode:function(e){return g(e,(function(e){return c.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(i=function(){return s}.call(t,n,t,e))||(e.exports=i)}()}).call(this,n(87)(e),n(6))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,n){"use strict";t.decode=t.parse=n(90),t.encode=t.stringify=n(91)},function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,o){t=t||"&",n=n||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u=0?(d=m.substr(0,y),h=m.substr(y+1)):(d=m,h=""),p=decodeURIComponent(d),f=decodeURIComponent(h),r(a,p)?i(a[p])?a[p].push(f):a[p]=[a[p],f]:a[p]=f}return a};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,n,s){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var s=encodeURIComponent(r(a))+n;return i(e[a])?o(e[a],(function(e){return s+encodeURIComponent(r(e))})).join(t):s+encodeURIComponent(r(e[a]))})).join(t):s?encodeURIComponent(r(s))+n+encodeURIComponent(r(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,i,o=r.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,n=o,i=s,t.copy(n,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,n){(function(t){function n(e){try{if(!t.localStorage)return!1}catch(e){return!1}var n=t.localStorage[e];return null!=n&&"true"===String(n).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,n(6))},function(e,t,n){"use strict";e.exports=o;var r=n(48),i=Object.create(n(14));function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}i.inherits=n(12),i.inherits(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){(function(t){var r=n(101),i=function(){},o=function(e,n,a){if("function"==typeof n)return o(e,null,n);n||(n={}),a=r(a||i);var s=e._writableState,l=e._readableState,c=n.readable||!1!==n.readable&&e.readable,u=n.writable||!1!==n.writable&&e.writable,d=!1,h=function(){e.writable||p()},p=function(){u=!1,c||a.call(e)},f=function(){c=!1,u||a.call(e)},m=function(t){a.call(e,t?new Error("exited with error code: "+t):null)},y=function(t){a.call(e,t)},g=function(){t.nextTick(v)},v=function(){if(!d)return(!c||l&&l.ended&&!l.destroyed)&&(!u||s&&s.ended&&!s.destroyed)?void 0:a.call(e,new Error("premature close"))},b=function(){e.req.on("finish",p)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?u&&!s&&(e.on("end",h),e.on("close",h)):(e.on("complete",p),e.on("abort",g),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",f),e.on("finish",p),!1!==n.error&&e.on("error",y),e.on("close",g),function(){d=!0,e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",b),e.req&&e.req.removeListener("finish",p),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",f),e.removeListener("error",y),e.removeListener("close",g)}};e.exports=o}).call(this,n(2))},function(e,t,n){var r=n(102);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}e.exports=r(i),e.exports.strict=r(o),i.proto=i((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},function(e,t){e.exports=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","error",n),c.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))}static i(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","info",n),c.ENABLE_INFO&&(console.info?console.info(n):console.log(n))}static w(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","warn",n),c.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))}static d(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","debug",n),c.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))}static v(e,t){e&&!c.FORCE_GLOBAL_TAG||(e=c.GLOBAL_TAG);let n=`[${e}] > ${t}`;c.ENABLE_CALLBACK&&c.emitter.emit("log","verbose",n),c.ENABLE_VERBOSE&&console.log(n)}}c.GLOBAL_TAG="flv.js",c.FORCE_GLOBAL_TAG=!1,c.ENABLE_ERROR=!0,c.ENABLE_INFO=!0,c.ENABLE_WARN=!0,c.ENABLE_DEBUG=!0,c.ENABLE_VERBOSE=!0,c.ENABLE_CALLBACK=!1,c.emitter=new l.a;var u=c;var d=class{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}};class h{constructor(e){this._message=e}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class p extends h{constructor(e){super(e)}get name(){return"IllegalStateException"}}class f extends h{constructor(e){super(e)}get name(){return"InvalidArgumentException"}}class m extends h{constructor(e){super(e)}get name(){return"NotImplementedException"}}const y={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},g={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class v{constructor(e){this._type=e||"undefined",this._status=y.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=y.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===y.kConnecting||this._status===y.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 b={};!function(){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)||[],n=/(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)||[],r={browser:t[5]||t[3]||t[1]||"",version:t[2]||t[4]||"0",majorVersion:t[4]||t[2]||"0",platform:n[0]||""},i={};if(r.browser){i[r.browser]=!0;let e=r.majorVersion.split(".");i.version={major:parseInt(r.majorVersion,10),string:r.version},e.length>1&&(i.version.minor=parseInt(e[1],10)),e.length>2&&(i.version.build=parseInt(e[2],10))}if(r.platform&&(i[r.platform]=!0),(i.chrome||i.opr||i.safari)&&(i.webkit=!0),i.rv||i.iemobile){i.rv&&delete i.rv;let e="msie";r.browser=e,i[e]=!0}if(i.edge){delete i.edge;let e="msedge";r.browser=e,i[e]=!0}if(i.opr){let e="opera";r.browser=e,i[e]=!0}if(i.safari&&i.android){let e="android";r.browser=e,i[e]=!0}i.name=r.browser,i.platform=r.platform;for(let e in b)b.hasOwnProperty(e)&&delete b[e];Object.assign(b,i)}();var _=b;var w=class extends v{static isSupported(){try{let e=_.msedge&&_.version.minor>=15048,t=!_.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 n=e.url;this._config.reuseRedirectedURL&&null!=e.redirectedURL&&(n=e.redirectedURL);let r=this._seekHandler.getConfig(n,t),i=new self.Headers;if("object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.append(t,e[t])}let o={method:"GET",headers:i,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==typeof this._config.headers)for(let e in this._config.headers)i.append(e,this._config.headers[e]);!1===e.cors&&(o.mode="same-origin"),e.withCredentials&&(o.credentials="include"),e.referrerPolicy&&(o.referrerPolicy=e.referrerPolicy),this._status=y.kConnecting,self.fetch(r.url,o).then(e=>{if(this._requestAbort)return this._requestAbort=!1,void(this._status=y.kIdle);if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==r.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=y.kError,!this._onError)throw new h("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})}).catch(e=>{if(this._status=y.kError,!this._onError)throw e;this._onError(g.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{if(11===e.code&&_.msedge)return;this._status=y.kError;let t=0,n=null;if(19!==e.code&&"network error"!==e.message||!(null===this._contentLength||null!==this._contentLength&&this._receivedLength299)){if(this._status=y.kError,!this._onError)throw new h("MozChunkedLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}else this._status=y.kBuffering}}_onProgress(e){if(this._status===y.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,n=this._range.from+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onLoadEnd(e){!0!==this._requestAbort?this._status!==y.kError&&(this._status=y.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)):this._requestAbort=!1}_onXhrError(e){this._status=y.kError;let t=0,n=null;if(this._contentLength&&e.loaded=this._contentLength&&(n=this._range.from+this._contentLength-1),this._currentRequestRange={from:t,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(e,t){this._lastTimeLoaded=0;let n=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?n=this._currentRedirectedURL:null!=e.redirectedURL&&(n=e.redirectedURL));let r=this._seekHandler.getConfig(n,t);this._currentRequestURL=r.url;let i=this._xhr=new XMLHttpRequest;if(i.open("GET",r.url,!0),i.responseType="arraybuffer",i.onreadystatechange=this._onReadyStateChange.bind(this),i.onprogress=this._onProgress.bind(this),i.onload=this._onLoad.bind(this),i.onerror=this._onXhrError.bind(this),e.withCredentials&&(i.withCredentials=!0),"object"==typeof r.headers){let e=r.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}if("object"==typeof this._config.headers){let e=this._config.headers;for(let t in e)e.hasOwnProperty(t)&&i.setRequestHeader(t,e[t])}i.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=y.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(null!=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=y.kBuffering}else{if(this._status=y.kError,!this._onError)throw new h("RangeLoader: Http code invalid, "+t.status+" "+t.statusText);this._onError(g.HTTP_STATUS_CODE_INVALID,{code:t.status,msg:t.statusText})}}}_onProgress(e){if(this._status===y.kError)return;if(null===this._contentLength){let t=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,t=!0;let n=e.total;this._internalAbort(),null!=n&0!==n&&(this._totalLength=n)}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,n=t.length-1,r=0,i=0,o=n;if(e=t[r]&&e=3&&(t=this._speedSampler.currentKBps)),0!==t){let e=this._normalizeSpeed(t);this._currentSpeedNormalized!==e&&(this._currentSpeedNormalized=e,this._currentChunkSizeKB=e)}let n=e.target.response,r=this._range.from+this._receivedLength;this._receivedLength+=n.byteLength;let i=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength{this._dispatchArrayBuffer(t.result)},t.readAsArrayBuffer(e.data)}else{this._status=y.kError;let t={code:-1,msg:"Unsupported WebSocket message type: "+e.data.constructor.name};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}}_dispatchArrayBuffer(e){let t=e,n=this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,n,this._receivedLength)}_onWebSocketError(e){this._status=y.kError;let t={code:e.code,msg:e.message};if(!this._onError)throw new h(t.msg);this._onError(g.EXCEPTION,t)}};var A=class{constructor(e){this._zeroStart=e||!1}getConfig(e,t){let n={};if(0!==t.from||-1!==t.to){let e;e=-1!==t.to?`bytes=${t.from.toString()}-${t.to.toString()}`:`bytes=${t.from.toString()}-`,n.Range=e}else this._zeroStart&&(n.Range="bytes=0-");return{url:e,headers:n}}removeURLParameters(e){return e}};var x=class{constructor(e,t){this._startName=e,this._endName=t}getConfig(e,t){let n=e;if(0!==t.from||-1!==t.to){let e=!0;-1===n.indexOf("?")&&(n+="?",e=!1),e&&(n+="&"),n+=`${this._startName}=${t.from.toString()}`,-1!==t.to&&(n+=`&${this._endName}=${t.to.toString()}`)}return{url:n,headers:{}}}removeURLParameters(e){let t=e.split("?")[0],n=void 0,r=e.indexOf("?");-1!==r&&(n=e.substring(r+1));let i="";if(null!=n&&n.length>0){let e=n.split("&");for(let t=0;t0;n[0]!==this._startName&&n[0]!==this._endName&&(r&&(i+="&"),i+=e[t])}}return 0===i.length?t:t+"?"+i}};var T=class{constructor(e,t,n){this.TAG="IOController",this._config=t,this._extraData=n,this._stashInitialSize=393216,null!=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||null!=this._dataSource.redirectedURL}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===k?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let e=this._config;if("range"===e.seekType)this._seekHandler=new A(this._config.rangeLoadZeroStart);else if("param"===e.seekType){let t=e.seekParamStart||"bstart",n=e.seekParamEnd||"bend";this._seekHandler=new x(t,n)}else{if("custom"!==e.seekType)throw new f("Invalid seekType in config: "+e.seekType);if("function"!=typeof e.customSeekHandler)throw new f("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=E;else if(w.isSupported())this._loaderClass=w;else if(S.isSupported())this._loaderClass=S;else{if(!k.isSupported())throw new h("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=k}}_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 n={from:e,to:-1};this._currentRange={from:n.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,n),this._onSeeked&&this._onSeeked()}updateUrl(e){if(!e||"string"!=typeof e||0===e.length)throw new f("Url must be a non-empty string!");this._dataSource.url=e}_expandBuffer(e){let t=this._stashSize;for(;t+10485760){let e=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(n,0,t).set(e,0)}this._stashBuffer=n,this._bufferSize=t}_normalizeSpeed(e){let t=this._speedNormalizeList,n=t.length-1,r=0,i=0,o=n;if(e=t[r]&&e=512&&e<=1024?Math.floor(1.5*e):2*e,t>8192&&(t=8192);let n=1024*t+1048576;this._bufferSize0){let t=this._stashBuffer.slice(0,this._stashUsed),r=this._dispatchChunks(t,this._stashByteStart);if(r0){let e=new Uint8Array(t,r);n.set(e,0),this._stashUsed=e.byteLength,this._stashByteStart+=r}}else this._stashUsed=0,this._stashByteStart+=r;this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else{let r=this._dispatchChunks(e,t);if(rthis._bufferSize&&(this._expandBuffer(i),n=new Uint8Array(this._stashBuffer,0,this._bufferSize)),n.set(new Uint8Array(e,r),0),this._stashUsed+=i,this._stashByteStart=t+r}}}else if(0===this._stashUsed){let n=this._dispatchChunks(e,t);if(nthis._bufferSize&&this._expandBuffer(r),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(e,n),0),this._stashUsed+=r,this._stashByteStart=t+n}}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 n=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(n0){let e=new Uint8Array(this._stashBuffer,n);t.set(e,0)}this._stashUsed-=n,this._stashByteStart+=n}}_flushStashBuffer(e){if(this._stashUsed>0){let t=this._stashBuffer.slice(0,this._stashUsed),n=this._dispatchChunks(t,this._stashByteStart),r=t.byteLength-n;if(n0){let e=new Uint8Array(this._stashBuffer,0,this._bufferSize),r=new Uint8Array(t,n);e.set(r,0),this._stashUsed=r.byteLength,this._stashByteStart+=n}return 0}u.w(this.TAG,r+" bytes unconsumed data remain when flush buffer, dropped")}return this._stashUsed=0,this._stashByteStart=0,r}return 0}_onLoaderComplete(e,t){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(e,t){switch(u.e(this.TAG,`Loader error, code = ${t.code}, msg = ${t.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=g.UNRECOVERABLE_EARLY_EOF),e){case g.EARLY_EOF:if(!this._config.isLive&&this._totalLength){let e=this._currentRange.to+1;return void(e0){let t=I.getConfig();e.emit("change",t)}}static registerListener(e){I.emitter.addListener("change",e)}static removeListener(e){I.emitter.removeListener("change",e)}static addLogListener(e){u.emitter.addListener("log",e),u.emitter.listenerCount("log")>0&&(u.ENABLE_CALLBACK=!0,I._notifyChange())}static removeLogListener(e){u.emitter.removeListener("log",e),0===u.emitter.listenerCount("log")&&(u.ENABLE_CALLBACK=!1,I._notifyChange())}}I.emitter=new l.a;var D=I;var P=class{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,n=this._search(t.times,e);return{index:n,milliseconds:t.times[n],fileposition:t.filepositions[n]}}_search(e,t){let n=0,r=e.length-1,i=0,o=0,a=r;for(t=e[i]&&t=128){t.push(String.fromCharCode(65535&e)),r+=2;continue}}}else if(n[r]<240){if(B(n,r,2)){let e=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(e>=2048&&55296!=(63488&e)){t.push(String.fromCharCode(65535&e)),r+=3;continue}}}else if(n[r]<248&&B(n,r,3)){let e=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(e>65536&&e<1114112){e-=65536,t.push(String.fromCharCode(e>>>10|55296)),t.push(String.fromCharCode(1023&e|56320)),r+=4;continue}}t.push(String.fromCharCode(65533)),++r}return t.join("")};let N=function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}();class F{static parseScriptData(e,t,n){let r={};try{let i=F.parseValue(e,t,n),o=F.parseValue(e,t+i.size,n-i.size);r[i.data]=o.data}catch(e){u.e("AMF",e.toString())}return r}static parseObject(e,t,n){if(n<3)throw new p("Data not enough when parse ScriptDataObject");let r=F.parseString(e,t,n),i=F.parseValue(e,t+r.size,n-r.size),o=i.objectEnd;return{data:{name:r.data,value:i.data},size:r.size+i.size,objectEnd:o}}static parseVariable(e,t,n){return F.parseObject(e,t,n)}static parseString(e,t,n){if(n<2)throw new p("Data not enough when parse String");let r,i=new DataView(e,t,n).getUint16(0,!N);return r=i>0?U(new Uint8Array(e,t+2,i)):"",{data:r,size:2+i}}static parseLongString(e,t,n){if(n<4)throw new p("Data not enough when parse LongString");let r,i=new DataView(e,t,n).getUint32(0,!N);return r=i>0?U(new Uint8Array(e,t+4,i)):"",{data:r,size:4+i}}static parseDate(e,t,n){if(n<10)throw new p("Data size invalid when parse Date");let r=new DataView(e,t,n),i=r.getFloat64(0,!N);return i+=60*r.getInt16(8,!N)*1e3,{data:new Date(i),size:10}}static parseValue(e,t,n){if(n<1)throw new p("Data not enough when parse Value");let r,i=new DataView(e,t,n),o=1,a=i.getUint8(0),s=!1;try{switch(a){case 0:r=i.getFloat64(1,!N),o+=8;break;case 1:r=!!i.getUint8(1),o+=1;break;case 2:{let i=F.parseString(e,t+1,n-1);r=i.data,o+=i.size;break}case 3:{r={};let a=0;for(9==(16777215&i.getUint32(n-4,!N))&&(a=3);o32)throw new f("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 n=e-this._current_word_bits_left;this._fillCurrentWord();let r=Math.min(n,this._current_word_bits_left),i=this._current_word>>>32-r;return this._current_word<<=r,this._current_word_bits_left-=r,t=t<>>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)}};class V{static _ebsp2rbsp(e){let t=e,n=t.byteLength,r=new Uint8Array(n),i=0;for(let e=0;e=2&&3===t[e]&&0===t[e-1]&&0===t[e-2]||(r[i]=t[e],i++);return new Uint8Array(r.buffer,0,i)}static parseSPS(e){let t=V._ebsp2rbsp(e),n=new j(t);n.readByte();let r=n.readByte();n.readByte();let i=n.readByte();n.readUEG();let o=V.getProfileString(r),a=V.getLevelString(i),s=1,l=420,c=[0,420,422,444],u=8;if((100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r)&&(s=n.readUEG(),3===s&&n.readBits(1),s<=3&&(l=c[s]),u=n.readUEG()+8,n.readUEG(),n.readBits(1),n.readBool())){let e=3!==s?8:12;for(let t=0;t0&&e<16?(_=t[e-1],w=r[e-1]):255===e&&(_=n.readByte()<<8|n.readByte(),w=n.readByte()<<8|n.readByte())}if(n.readBool()&&n.readBool(),n.readBool()&&(n.readBits(4),n.readBool()&&n.readBits(24)),n.readBool()&&(n.readUEG(),n.readUEG()),n.readBool()){let e=n.readBits(32),t=n.readBits(32);k=n.readBool(),E=t,A=2*e,S=E/A}}let x=1;1===_&&1===w||(x=_/w);let T=0,R=0;if(0===s)T=1,R=2-m;else{T=3===s?1:2,R=(1===s?2:1)*(2-m)}let C=16*(p+1),M=16*(f+1)*(2-m);C-=(y+g)*T,M-=(v+b)*R;let L=Math.ceil(C*x);return n.destroy(),n=null,{profile_string:o,level_string:a,bit_depth:u,ref_frames:h,chroma_format:l,chroma_format_string:V.getChromaFormatString(l),frame_rate:{fixed:k,fps:S,fps_den:A,fps_num:E},sar_ratio:{width:_,height:w},codec_size:{width:C,height:M},present_size:{width:L,height:M}}}static _skipScalingList(e,t){let n=8,r=8,i=0;for(let o=0;o>>2!=0,i=0!=(1&t[4]),o=(a=t)[s=5]<<24|a[s+1]<<16|a[s+2]<<8|a[s+3];var a,s;return o<9?n:{match:!0,consumed:o,dataOffset:o,hasAudioTrack:r,hasVideoTrack:i}}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 P}_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 p("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let n=0,r=this._littleEndian;if(0===t){if(!(e.byteLength>13))return 0;n=z.probe(e).dataOffset}if(this._firstParse){this._firstParse=!1,t+n!==this._dataOffset&&u.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==new DataView(e,n).getUint32(0,!r)&&u.w(this.TAG,"PrevTagSize0 !== 0 !!!"),n+=4}for(;ne.byteLength)break;let o=i.getUint8(0),a=16777215&i.getUint32(0,!r);if(n+11+a+4>e.byteLength)break;if(8!==o&&9!==o&&18!==o){u.w(this.TAG,`Unsupported tag type ${o}, skipped`),n+=11+a+4;continue}let s=i.getUint8(4),l=i.getUint8(5),c=i.getUint8(6)|l<<8|s<<16|i.getUint8(7)<<24;0!==(16777215&i.getUint32(7,!r))&&u.w(this.TAG,"Meet tag which has StreamID != 0!");let d=n+11;switch(o){case 8:this._parseAudioData(e,d,a,c);break;case 9:this._parseVideoData(e,d,a,c,t+n);break;case 18:this._parseScriptData(e,d,a)}let h=i.getUint32(11+a,!r);h!==11+a&&u.w(this.TAG,"Invalid PrevTagSize "+h),n+=11+a+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),n}_parseScriptData(e,t,n){let r=q.parseScriptData(e,t,n);if(r.hasOwnProperty("onMetaData")){if(null==r.onMetaData||"object"!=typeof r.onMetaData)return void u.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&u.w(this.TAG,"Found another onMetaData tag!"),this._metadata=r;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,u.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(r).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},r))}_parseKeyframesIndex(e){let t=[],n=[];for(let r=1;r>>4;if(2!==o&&10!==o)return void this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+o);let a=0,s=(12&i)>>>2;if(!(s>=0&&s<=4))return void this._onError(W.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+s);a=this._flvSoundRateTable[s];let l=1&i,c=this._audioMetadata,d=this._audioTrack;if(c||(!1===this._hasAudio&&!1===this._hasAudioFlagOverrided&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),c=this._audioMetadata={},c.type="audio",c.id=d.id,c.timescale=this._timescale,c.duration=this._duration,c.audioSampleRate=a,c.channelCount=0===l?1:2),10===o){let i=this._parseAACAudioData(e,t+1,n-1);if(null==i)return;if(0===i.packetType){c.config&&u.w(this.TAG,"Found another AudioSpecificConfig!");let e=i.data;c.audioSampleRate=e.samplingRate,c.channelCount=e.channelCount,c.codec=e.codec,c.originalCodec=e.originalCodec,c.config=e.config,c.refSampleDuration=1024/c.audioSampleRate*c.timescale,u.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",c);let t=this._mediaInfo;t.audioCodec=c.originalCodec,t.audioSampleRate=c.audioSampleRate,t.audioChannelCount=c.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===i.packetType){let e=this._timestampBase+r,t={unit:i.data,length:i.data.byteLength,dts:e,pts:e};d.samples.push(t),d.length+=i.data.length}else u.e(this.TAG,"Flv: Unsupported AAC data type "+i.packetType)}else if(2===o){if(!c.codec){let r=this._parseMP3AudioData(e,t+1,n-1,!0);if(null==r)return;c.audioSampleRate=r.samplingRate,c.channelCount=r.channelCount,c.codec=r.codec,c.originalCodec=r.originalCodec,c.refSampleDuration=1152/c.audioSampleRate*c.timescale,u.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",c);let i=this._mediaInfo;i.audioCodec=c.codec,i.audioSampleRate=c.audioSampleRate,i.audioChannelCount=c.channelCount,i.audioDataRate=r.bitRate,i.hasVideo?null!=i.videoCodec&&(i.mimeType='video/x-flv; codecs="'+i.videoCodec+","+i.audioCodec+'"'):i.mimeType='video/x-flv; codecs="'+i.audioCodec+'"',i.isComplete()&&this._onMediaInfo(i)}let i=this._parseMP3AudioData(e,t+1,n-1,!1);if(null==i)return;let o=this._timestampBase+r,a={unit:i,length:i.byteLength,dts:o,pts:o};d.samples.push(a),d.length+=i.length}}_parseAACAudioData(e,t,n){if(n<=1)return void u.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");let r={},i=new Uint8Array(e,t,n);return r.packetType=i[0],0===i[0]?r.data=this._parseAACAudioSpecificConfig(e,t+1,n-1):r.data=i.subarray(1),r}_parseAACAudioSpecificConfig(e,t,n){let r=new Uint8Array(e,t,n),i=null,o=0,a=0,s=null,l=0,c=null;if(o=a=r[0]>>>3,l=(7&r[0])<<1|r[1]>>>7,l<0||l>=this._mpegSamplingRates.length)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");let u=this._mpegSamplingRates[l],d=(120&r[1])>>>3;if(d<0||d>=8)return void this._onError(W.FORMAT_ERROR,"Flv: AAC invalid channel configuration");5===o&&(c=(7&r[1])<<1|r[2]>>>7,s=(124&r[2])>>>2);let h=self.navigator.userAgent.toLowerCase();return-1!==h.indexOf("firefox")?l>=6?(o=5,i=new Array(4),c=l-3):(o=2,i=new Array(2),c=l):-1!==h.indexOf("android")?(o=2,i=new Array(2),c=l):(o=5,c=l,i=new Array(4),l>=6?c=l-3:1===d&&(o=2,i=new Array(2),c=l)),i[0]=o<<3,i[0]|=(15&l)>>>1,i[1]=(15&l)<<7,i[1]|=(15&d)<<3,5===o&&(i[1]|=(15&c)>>>1,i[2]=(1&c)<<7,i[2]|=8,i[3]=0),{config:i,samplingRate:u,channelCount:d,codec:"mp4a.40."+o,originalCodec:"mp4a.40."+a}}_parseMP3AudioData(e,t,n,r){if(n<4)return void u.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");this._littleEndian;let i=new Uint8Array(e,t,n),o=null;if(r){if(255!==i[0])return;let e=i[1]>>>3&3,t=(6&i[1])>>1,n=(240&i[2])>>>4,r=(12&i[2])>>>2,a=3!==(i[3]>>>6&3)?2:1,s=0,l=0,c=34,u="mp3";switch(e){case 0:s=this._mpegAudioV25SampleRateTable[r];break;case 2:s=this._mpegAudioV20SampleRateTable[r];break;case 3:s=this._mpegAudioV10SampleRateTable[r]}switch(t){case 1:c=34,n>>4,s=15&o;7===s?this._parseAVCVideoPacket(e,t+1,n-1,r,i,a):this._onError(W.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: "+s)}_parseAVCVideoPacket(e,t,n,r,i,o){if(n<4)return void u.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");let a=this._littleEndian,s=new DataView(e,t,n),l=s.getUint8(0),c=(16777215&s.getUint32(0,!a))<<8>>8;if(0===l)this._parseAVCDecoderConfigurationRecord(e,t+4,n-4);else if(1===l)this._parseAVCVideoData(e,t+4,n-4,r,i,o,c);else if(2!==l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid video packet type "+l)}_parseAVCDecoderConfigurationRecord(e,t,n){if(n<7)return void u.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");let r=this._videoMetadata,i=this._videoTrack,o=this._littleEndian,a=new DataView(e,t,n);r?void 0!==r.avcc&&u.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(!1===this._hasVideo&&!1===this._hasVideoFlagOverrided&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),r=this._videoMetadata={},r.type="video",r.id=i.id,r.timescale=this._timescale,r.duration=this._duration);let s=a.getUint8(0),l=a.getUint8(1);a.getUint8(2),a.getUint8(3);if(1!==s||0===l)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");if(this._naluLengthSize=1+(3&a.getUint8(4)),3!==this._naluLengthSize&&4!==this._naluLengthSize)return void this._onError(W.FORMAT_ERROR,"Flv: Strange NaluLengthSizeMinusOne: "+(this._naluLengthSize-1));let c=31&a.getUint8(5);if(0===c)return void this._onError(W.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");c>1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = "+c);let d=6;for(let n=0;n1&&u.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = "+h),d++;for(let e=0;e=n){u.w(this.TAG,`Malformed Nalu near timestamp ${f}, offset = ${h}, dataSize = ${n}`);break}let r=l.getUint32(h,!s);if(3===p&&(r>>>=8),r>n-p)return void u.w(this.TAG,`Malformed Nalus near timestamp ${f}, NaluSize > DataSize!`);let i=31&l.getUint8(h+p);5===i&&(m=!0);let o=new Uint8Array(e,t+h,p+r),a={type:i,data:o};c.push(a),d+=o.byteLength,h+=p+r}if(c.length){let e=this._videoTrack,t={units:c,length:d,isKeyframe:m,dts:f,cts:a,pts:f+a};m&&(t.fileposition=i),e.samples.push(t),e.length+=d}}}var H=z;class G{static init(){G.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 e in G.types)G.types.hasOwnProperty(e)&&(G.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let e=G.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,n=null,r=Array.prototype.slice.call(arguments,1),i=r.length;for(let e=0;e>>24&255,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n.set(e,4);let o=8;for(let e=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 G.box(G.types.trak,G.tkhd(e),G.mdia(e))}static tkhd(e){let t=e.id,n=e.duration,r=e.presentWidth,i=e.presentHeight;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,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,r>>>8&255,255&r,0,0,i>>>8&255,255&i,0,0]))}static mdia(e){return G.box(G.types.mdia,G.mdhd(e),G.hdlr(e),G.minf(e))}static mdhd(e){let t=e.timescale,n=e.duration;return G.box(G.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,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}static hdlr(e){let t=null;return t="audio"===e.type?G.constants.HDLR_AUDIO:G.constants.HDLR_VIDEO,G.box(G.types.hdlr,t)}static minf(e){let t=null;return t="audio"===e.type?G.box(G.types.smhd,G.constants.SMHD):G.box(G.types.vmhd,G.constants.VMHD),G.box(G.types.minf,t,G.dinf(),G.stbl(e))}static dinf(){return G.box(G.types.dinf,G.box(G.types.dref,G.constants.DREF))}static stbl(e){return G.box(G.types.stbl,G.stsd(e),G.box(G.types.stts,G.constants.STTS),G.box(G.types.stsc,G.constants.STSC),G.box(G.types.stsz,G.constants.STSZ),G.box(G.types.stco,G.constants.STCO))}static stsd(e){return"audio"===e.type?"mp3"===e.codec?G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp3(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.mp4a(e)):G.box(G.types.stsd,G.constants.STSD_PREFIX,G.avc1(e))}static mp3(e){let t=e.channelCount,n=e.audioSampleRate,r=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,n>>>8&255,255&n,0,0]);return G.box(G.types[".mp3"],r)}static mp4a(e){let t=e.channelCount,n=e.audioSampleRate,r=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,n>>>8&255,255&n,0,0]);return G.box(G.types.mp4a,r,G.esds(e))}static esds(e){let t=e.config||[],n=t.length,r=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return G.box(G.types.esds,r)}static avc1(e){let t=e.avcc,n=e.codecWidth,r=e.codecHeight,i=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,n>>>8&255,255&n,r>>>8&255,255&r,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 G.box(G.types.avc1,i,G.box(G.types.avcC,t))}static mvex(e){return G.box(G.types.mvex,G.trex(e))}static trex(e){let t=e.id,n=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 G.box(G.types.trex,n)}static moof(e,t){return G.box(G.types.moof,G.mfhd(e.sequenceNumber),G.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 G.box(G.types.mfhd,t)}static traf(e,t){let n=e.id,r=G.box(G.types.tfhd,new Uint8Array([0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n])),i=G.box(G.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),o=G.sdtp(e),a=G.trun(e,o.byteLength+16+16+8+16+8+8);return G.box(G.types.traf,r,i,a,o)}static sdtp(e){let t=e.samples||[],n=t.length,r=new Uint8Array(4+n);for(let e=0;e>>24&255,r>>>16&255,r>>>8&255,255&r,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(let e=0;e>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.isNonSync,0,0,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*e)}return G.box(G.types.trun,o)}static mdat(e){return G.box(G.types.mdat,e)}}G.init();var K=G;var Q=class{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}};class X{constructor(e,t,n,r,i){this.dts=e,this.pts=t,this.duration=n,this.originalDts=r,this.isSyncPoint=i,this.fileposition=null}}class Z{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 J{constructor(){this._list=[]}clear(){this._list=[]}appendArray(e){let t=this._list;0!==e.length&&(t.length>0&&e[0].originalDts=t[i].dts&&et[r].lastSample.originalDts&&e=t[r].lastSample.originalDts&&(r===t.length-1||r0&&(i=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=i,this._list.splice(i,0,n)}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),n=this._list[t].syncPoints;for(;0===n.length&&t>0;)t--,n=this._list[t].syncPoints;return n.length>0?n[n.length-1]:null}}var ee=class{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 $("audio"),this._videoSegmentInfoList=new $("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!_.chrome||!(_.version.major<50||50===_.version.major&&_.version.build<2661)),this._fillSilentAfterSeek=_.msedge||_.msie,this._mp3UseMpegAudio=!_.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 p("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,t),this._remuxVideo(t),this._remuxAudio(e)}_onTrackMetadataReceived(e,t){let n=null,r="mp4",i=t.codec;if("audio"===e)this._audioMeta=t,"mp3"===t.codec&&this._mp3UseMpegAudio?(r="mpeg",i="",n=new Uint8Array):n=K.generateInitSegment(t);else{if("video"!==e)return;this._videoMeta=t,n=K.generateInitSegment(t)}if(!this._onInitSegment)throw new p("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:n.buffer,codec:i,container:`${e}/${r}`,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,n={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(n.samples.push(e),n.length=e.length);let r={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=t&&(r.samples.push(t),r.length=t.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(n,!0),this._remuxAudio(r,!0)}_remuxAudio(e,t){if(null==this._audioMeta)return;let n=e,r=n.samples,i=void 0,o=-1,a=-1,s=this._audioMeta.refSampleDuration,l="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,c=this._dtsBaseInited&&void 0===this._audioNextDts,d=!1;if(!r||0===r.length)return;if(1===r.length&&!t)return;let h=0,p=null,f=0;l?(h=0,f=n.length):(h=8,f=8+n.length);let m=null;if(r.length>1&&(m=r.pop(),f-=m.length),null!=this._audioStashedLastSample){let e=this._audioStashedLastSample;this._audioStashedLastSample=null,r.unshift(e),f+=e.length}null!=m&&(this._audioStashedLastSample=m);let y=r[0].dts-this._dtsBase;if(this._audioNextDts)i=y-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())i=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(d=!0);else{let e=this._audioSegmentInfoList.getLastSampleBefore(y);if(null!=e){let t=y-(e.originalDts+e.duration);t<=3&&(t=0),i=y-(e.dts+e.duration+t)}else i=0}if(d){let e=y-i,t=this._videoSegmentInfoList.getLastSegmentBefore(y);if(null!=t&&t.beginDts=1?g[g.length-1].duration:Math.floor(s);let d=!1,h=null;if(c>1.5*s&&"mp3"!==this._audioMeta.codec&&this._fillAudioTimestampGap&&!_.safari){d=!0;let e=Math.abs(c-s),t=Math.ceil(e/s),r=l+s;u.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\ndts: ${l+c} ms, expected: ${l+Math.round(s)} ms, delta: ${Math.round(e)} ms, generate: ${t} frames`);let i=Q.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);null==i&&(u.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),i=n),h=[];for(let e=0;e0){let t=h[h.length-1];t.duration=e-t.dts}let t={dts:e,pts:e,cts:0,unit:i,size:i.byteLength,duration:0,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};h.push(t),f+=t.size,r+=s}let o=h[h.length-1];o.duration=l+c-o.dts,c=Math.round(s)}g.push({dts:l,pts:l,cts:0,unit:t.unit,size:t.unit.byteLength,duration:c,originalDts:a,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),d&&g.push.apply(g,h)}l?p=new Uint8Array(f):(p=new Uint8Array(f),p[0]=f>>>24&255,p[1]=f>>>16&255,p[2]=f>>>8&255,p[3]=255&f,p.set(K.types.mdat,4));for(let e=0;e1&&(h=r.pop(),d-=h.length),null!=this._videoStashedLastSample){let e=this._videoStashedLastSample;this._videoStashedLastSample=null,r.unshift(e),d+=e.length}null!=h&&(this._videoStashedLastSample=h);let p=r[0].dts-this._dtsBase;if(this._videoNextDts)i=p-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())i=0;else{let e=this._videoSegmentInfoList.getLastSampleBefore(p);if(null!=e){let t=p-(e.originalDts+e.duration);t<=3&&(t=0),i=p-(e.dts+e.duration+t)}else i=0}let f=new Z,m=[];for(let e=0;e=1?m[m.length-1].duration:Math.floor(this._videoMeta.refSampleDuration);if(a){let e=new X(l,u,d,t.dts,!0);e.fileposition=t.fileposition,f.appendSyncPoint(e)}m.push({dts:l,pts:u,cts:c,units:t.units,size:t.length,isKeyframe:a,duration:d,originalDts:n,flags:{isLeading:0,dependsOn:a?2:1,isDependedOn:a?1:0,hasRedundancy:0,isNonSync:a?0:1}})}u=new Uint8Array(d),u[0]=d>>>24&255,u[1]=d>>>16&255,u[2]=d>>>8&255,u[3]=255&d,u.set(K.types.mdat,4);for(let e=0;e{r.timestampBase=n,n+=r.duration,r.cors=e.cors,r.withCredentials=e.withCredentials,t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy)}),isNaN(n)||this._mediaDataSource.duration===n||(this._mediaDataSource.duration=n),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 n=this._mediaDataSource.segments[e],r=this._ioctl=new T(n,this._config,e);r.onError=this._onIOException.bind(this),r.onSeeked=this._onIOSeeked.bind(this),r.onComplete=this._onIOComplete.bind(this),r.onRedirect=this._onIORedirect.bind(this),r.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),t?this._demuxer.bindDataSource(this._ioctl):r.onDataArrival=this._onInitChunkArrival.bind(this),r.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 n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e;else{let t=n.getNearestKeyframe(e);this._remuxer.seek(t.milliseconds),this._ioctl.seek(t.fileposition),this._pendingResolveSeekPoint=t.milliseconds}}else{let n=this._mediaInfo.segments[t];if(null==n)this._pendingSeekTime=e,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(t);else{let r=n.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,r.fileposition),this._pendingResolveSeekPoint=r.milliseconds,this._reportSegmentMediaInfo(t)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(e){let t=this._mediaDataSource.segments,n=t.length-1;for(let r=0;r0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,r=this._demuxer.parseChunks(e,t);else if((n=H.probe(e)).match){this._demuxer=new H(n,this._config),this._remuxer||(this._remuxer=new ee(this._config));let i=this._mediaDataSource;null==i.duration||isNaN(i.duration)||(this._demuxer.overridedDuration=i.duration),"boolean"==typeof i.hasAudio&&(this._demuxer.overridedHasAudio=i.hasAudio),"boolean"==typeof i.hasVideo&&(this._demuxer.overridedHasVideo=i.hasVideo),this._demuxer.timestampBase=i.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),r=this._demuxer.parseChunks(e,t)}else n=null,u.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(te.DEMUX_ERROR,W.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),r=0;return r}_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,P.prototype));let t=Object.assign({},e);Object.setPrototypeOf(t,P.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(te.METADATA_ARRIVED,e)}_onScriptDataArrived(e){this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(e){let t=e+1;t0&&e[0].originalDts===n&&(n=e[0].pts),this._emitter.emit(te.RECOMMEND_SEEKPOINT,n)}}_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],n=Object.assign({},t);n.duration=this._mediaInfo.duration,n.segmentCount=this._mediaInfo.segmentCount,delete n.segments,delete n.keyframesIndex,this._emitter.emit(te.MEDIA_INFO,n)}_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(te.STATISTICS_INFO,e)}};var re=function(e){let t=null,n=function(t,n){e.postMessage({msg:"logcat_callback",data:{type:t,logcat:n}})}.bind(this);function r(t,n){let r={msg:te.INIT_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function i(t,n){let r={msg:te.MEDIA_SEGMENT,data:{type:t,data:n}};e.postMessage(r,[n.data])}function o(){let t={msg:te.LOADING_COMPLETE};e.postMessage(t)}function s(){let t={msg:te.RECOVERED_EARLY_EOF};e.postMessage(t)}function l(t){let n={msg:te.MEDIA_INFO,data:t};e.postMessage(n)}function c(t){let n={msg:te.METADATA_ARRIVED,data:t};e.postMessage(n)}function u(t){let n={msg:te.SCRIPTDATA_ARRIVED,data:t};e.postMessage(n)}function d(t){let n={msg:te.STATISTICS_INFO,data:t};e.postMessage(n)}function h(t,n){e.postMessage({msg:te.IO_ERROR,data:{type:t,info:n}})}function p(t,n){e.postMessage({msg:te.DEMUX_ERROR,data:{type:t,info:n}})}function f(t){e.postMessage({msg:te.RECOMMEND_SEEKPOINT,data:t})}a.install(),e.addEventListener("message",(function(a){switch(a.data.cmd){case"init":t=new ne(a.data.param[0],a.data.param[1]),t.on(te.IO_ERROR,h.bind(this)),t.on(te.DEMUX_ERROR,p.bind(this)),t.on(te.INIT_SEGMENT,r.bind(this)),t.on(te.MEDIA_SEGMENT,i.bind(this)),t.on(te.LOADING_COMPLETE,o.bind(this)),t.on(te.RECOVERED_EARLY_EOF,s.bind(this)),t.on(te.MEDIA_INFO,l.bind(this)),t.on(te.METADATA_ARRIVED,c.bind(this)),t.on(te.SCRIPTDATA_ARRIVED,u.bind(this)),t.on(te.STATISTICS_INFO,d.bind(this)),t.on(te.RECOMMEND_SEEKPOINT,f.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(a.data.param);break;case"pause":t.pause();break;case"resume":t.resume();break;case"logging_config":{let e=a.data.param;D.applyConfig(e),!0===e.enableCallback?D.addLogListener(n):D.removeLogListener(n);break}}}))};var ie=class{constructor(e,t){if(this.TAG="Transmuxer",this._emitter=new l.a,t.enableWorker&&"undefined"!=typeof Worker)try{let r=n(56);this._worker=r(re),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)},D.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:D.getConfig()})}catch(n){u.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ne(e,t)}else this._controller=new ne(e,t);if(this._controller){let e=this._controller;e.on(te.IO_ERROR,this._onIOError.bind(this)),e.on(te.DEMUX_ERROR,this._onDemuxError.bind(this)),e.on(te.INIT_SEGMENT,this._onInitSegment.bind(this)),e.on(te.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),e.on(te.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),e.on(te.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),e.on(te.MEDIA_INFO,this._onMediaInfo.bind(this)),e.on(te.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),e.on(te.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),e.on(te.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),e.on(te.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),D.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(te.INIT_SEGMENT,e,t)})}_onMediaSegment(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_SEGMENT,e,t)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(te.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(te.RECOVERED_EARLY_EOF)})}_onMediaInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.MEDIA_INFO,e)})}_onMetaDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.METADATA_ARRIVED,e)})}_onScriptDataArrived(e){Promise.resolve().then(()=>{this._emitter.emit(te.SCRIPTDATA_ARRIVED,e)})}_onStatisticsInfo(e){Promise.resolve().then(()=>{this._emitter.emit(te.STATISTICS_INFO,e)})}_onIOError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.IO_ERROR,e,t)})}_onDemuxError(e,t){Promise.resolve().then(()=>{this._emitter.emit(te.DEMUX_ERROR,e,t)})}_onRecommendSeekpoint(e){Promise.resolve().then(()=>{this._emitter.emit(te.RECOMMEND_SEEKPOINT,e)})}_onLoggingConfigChanged(e){this._worker&&this._worker.postMessage({cmd:"logging_config",param:e})}_onWorkerMessage(e){let t=e.data,n=t.data;if("destroyed"===t.msg||this._workerDestroying)return this._workerDestroying=!1,this._worker.terminate(),void(this._worker=null);switch(t.msg){case te.INIT_SEGMENT:case te.MEDIA_SEGMENT:this._emitter.emit(t.msg,n.type,n.data);break;case te.LOADING_COMPLETE:case te.RECOVERED_EARLY_EOF:this._emitter.emit(t.msg);break;case te.MEDIA_INFO:Object.setPrototypeOf(n,P.prototype),this._emitter.emit(t.msg,n);break;case te.METADATA_ARRIVED:case te.SCRIPTDATA_ARRIVED:case te.STATISTICS_INFO:this._emitter.emit(t.msg,n);break;case te.IO_ERROR:case te.DEMUX_ERROR:this._emitter.emit(t.msg,n.type,n.info);break;case te.RECOMMEND_SEEKPOINT:this._emitter.emit(t.msg,n);break;case"logcat_callback":u.emitter.emit("log",n.type,n.logcat)}}};var oe={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};var ae=class{constructor(e){this.TAG="MSEController",this._config=e,this._emitter=new l.a,this._config.isLive&&null==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 J}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 p("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 e=this._mediaSource;for(let t in this._sourceBuffers){let n=this._pendingSegments[t];n.splice(0,n.length),this._pendingSegments[t]=null,this._pendingRemoveRanges[t]=null,this._lastInitSegments[t]=null;let r=this._sourceBuffers[t];if(r){if("closed"!==e.readyState){try{e.removeSourceBuffer(r)}catch(e){u.e(this.TAG,e.message)}r.removeEventListener("error",this.e.onSourceBufferError),r.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[t]=null,this._sourceBuffers[t]=null}}if("open"===e.readyState)try{e.endOfStream()}catch(e){u.e(this.TAG,e.message)}e.removeEventListener("sourceopen",this.e.onSourceOpen),e.removeEventListener("sourceended",this.e.onSourceEnded),e.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 n=e,r=""+n.container;n.codec&&n.codec.length>0&&(r+=";codecs="+n.codec);let i=!1;if(u.v(this.TAG,"Received Initialization Segment, mimeType: "+r),this._lastInitSegments[n.type]=n,r!==this._mimeTypes[n.type]){if(this._mimeTypes[n.type])u.v(this.TAG,`Notice: ${n.type} mimeType changed, origin: ${this._mimeTypes[n.type]}, target: ${r}`);else{i=!0;try{let e=this._sourceBuffers[n.type]=this._mediaSource.addSourceBuffer(r);e.addEventListener("error",this.e.onSourceBufferError),e.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return u.e(this.TAG,e.message),void this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message})}}this._mimeTypes[n.type]=r}t||this._pendingSegments[n.type].push(n),i||this._sourceBuffers[n.type]&&!this._sourceBuffers[n.type].updating&&this._doAppendSegments(),_.safari&&"audio/mpeg"===n.container&&n.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=n.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(e){let t=e;this._pendingSegments[t.type].push(t),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let n=this._sourceBuffers[t.type];!n||n.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()}seek(e){for(let e in this._sourceBuffers){if(!this._sourceBuffers[e])continue;let t=this._sourceBuffers[e];if("open"===this._mediaSource.readyState)try{t.abort()}catch(e){u.e(this.TAG,e.message)}this._idrList.clear();let n=this._pendingSegments[e];if(n.splice(0,n.length),"closed"!==this._mediaSource.readyState){for(let n=0;n=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 n=this._sourceBuffers[t];if(n){let r=n.buffered,i=!1;for(let n=0;n=this._config.autoCleanupMaxBackwardDuration){i=!0;let n=e-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[t].push({start:o,end:n})}}else a0&&(isNaN(t)||n>t)&&(u.v(this.TAG,`Update MediaSource duration from ${t} to ${n}`),this._mediaSource.duration=n),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],n=this._pendingRemoveRanges[e];for(;n.length&&!t.updating;){let e=n.shift();t.remove(e.start,e.end)}}}_doAppendSegments(){let e=this._pendingSegments;for(let t in e)if(this._sourceBuffers[t]&&!this._sourceBuffers[t].updating&&e[t].length>0){let n=e[t].shift();if(n.timestampOffset){let e=this._sourceBuffers[t].timestampOffset,r=n.timestampOffset/1e3;Math.abs(e-r)>.1&&(u.v(this.TAG,`Update MPEG audio timestampOffset from ${e} to ${r}`),this._sourceBuffers[t].timestampOffset=r),delete n.timestampOffset}if(!n.data||0===n.data.byteLength)continue;try{this._sourceBuffers[t].appendBuffer(n.data),this._isBufferFull=!1,"video"===t&&n.hasOwnProperty("info")&&this._idrList.appendArray(n.info.syncPoints)}catch(e){this._pendingSegments[t].unshift(n),22===e.code?(this._isBufferFull||this._emitter.emit(oe.BUFFER_FULL),this._isBufferFull=!0):(u.e(this.TAG,e.message),this._emitter.emit(oe.ERROR,{code:e.code,msg:e.message}))}}}_onSourceOpen(){if(u.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let e=this._pendingSourceBufferInit;for(;e.length;){let t=e.shift();this.appendInitSegment(t,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(oe.SOURCE_OPEN)}_onSourceEnded(){u.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){u.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(oe.UPDATE_END)}_onSourceBufferError(e){u.e(this.TAG,"SourceBuffer Error: "+e)}};const se={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},le={NETWORK_EXCEPTION:g.EXCEPTION,NETWORK_STATUS_CODE_INVALID:g.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:g.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:g.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:W.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:W.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:W.CODEC_UNSUPPORTED};var ce=class{constructor(e,t){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new l.a,this._config=C(),"object"==typeof t&&Object.assign(this._config,t),"flv"!==e.type.toLowerCase())throw new f("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 n=_.chrome&&(_.version.major<50||50===_.version.major&&_.version.build<2661);this._alwaysSeekKeyframe=!!(n||_.msedge||_.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===O.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then(()=>{this._emitter.emit(O.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 ae(this._config),this._msectl.on(oe.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(oe.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(oe.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(oe.ERROR,e=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,le.MEDIA_MSE_ERROR,e)}),this._msectl.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}}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 p("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new p("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 ie(this._mediaDataSource,this._config),this._transmuxer.on(te.INIT_SEGMENT,(e,t)=>{this._msectl.appendInitSegment(t)}),this._transmuxer.on(te.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&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(te.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(O.LOADING_COMPLETE)}),this._transmuxer.on(te.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(O.RECOVERED_EARLY_EOF)}),this._transmuxer.on(te.IO_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.NETWORK_ERROR,e,t)}),this._transmuxer.on(te.DEMUX_ERROR,(e,t)=>{this._emitter.emit(O.ERROR,se.MEDIA_ERROR,e,{code:-1,msg:t})}),this._transmuxer.on(te.MEDIA_INFO,e=>{this._mediaInfo=e,this._emitter.emit(O.MEDIA_INFO,Object.assign({},e))}),this._transmuxer.on(te.METADATA_ARRIVED,e=>{this._emitter.emit(O.METADATA_ARRIVED,e)}),this._transmuxer.on(te.SCRIPTDATA_ARRIVED,e=>{this._emitter.emit(O.SCRIPTDATA_ARRIVED,e)}),this._transmuxer.on(te.STATISTICS_INFO,e=>{this._statisticsInfo=this._fillStatisticsInfo(e),this._emitter.emit(O.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(te.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,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let e=this._mediaElement.buffered,t=this._mediaElement.currentTime,n=0,r=0;for(let i=0;i=t+this._config.lazyLoadMaxDuration&&null==this._progressChecker&&(u.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){u.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,n=!1;for(let r=0;r=i&&e=o-this._config.lazyLoadRecoverDuration&&(n=!0);break}}n&&(window.clearInterval(this._progressChecker),this._progressChecker=null,n&&(u.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(e){let t=this._mediaElement.buffered;for(let n=0;n=r&&e0){let t=this._mediaElement.buffered.start(0);(t<1&&e0&&t.currentTime0){let e=n.start(0);if(e<1&&t{this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}):e===O.STATISTICS_INFO&&null!=this._mediaElement&&0!==this._mediaElement.readyState&&Promise.resolve().then(()=>{this._emitter.emit(O.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(e){}}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 p("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={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(e.duration=Math.floor(1e3*this._mediaElement.duration),this._mediaElement instanceof HTMLVideoElement&&(e.width=this._mediaElement.videoWidth,e.height=this._mediaElement.videoHeight)),e}get statisticsInfo(){let e={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return e;let t=!0,n=0,r=0;if(this._mediaElement.getVideoPlaybackQuality){let e=this._mediaElement.getVideoPlaybackQuality();n=e.totalVideoFrames,r=e.droppedVideoFrames}else null!=this._mediaElement.webkitDecodedFrameCount?(n=this._mediaElement.webkitDecodedFrameCount,r=this._mediaElement.webkitDroppedFrameCount):t=!1;return t&&(e.decodedFrames=n,e.droppedFrames=r),e}_onvLoadedMetadata(e){null!=this._pendingSeekTime&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(O.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(O.STATISTICS_INFO,this.statisticsInfo)}};a.install();let de={createPlayer:function(e,t){let n=e;if(null==n||"object"!=typeof n)throw new f("MediaDataSource must be an javascript object!");if(!n.hasOwnProperty("type"))throw new f("MediaDataSource must has type field to indicate video file type!");switch(n.type){case"flv":return new ce(n,t);default:return new ue(n,t)}},isSupported:function(){return L.supportMSEH264Playback()},getFeatureList:function(){return L.getFeatureList()}};de.BaseLoader=v,de.LoaderStatus=y,de.LoaderErrors=g,de.Events=O,de.ErrorTypes=se,de.ErrorDetails=le,de.FlvPlayer=ce,de.NativePlayer=ue,de.LoggingControl=D,Object.defineProperty(de,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var he=de,pe=n(4),fe=n.n(pe),me=n(24),ye={insert:"head",singleton:!1};fe()(me.a,ye),me.a.locals;function ge(e){return(ge="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ve(e,t){for(var n=0;n=n.count?(n.flvPlayer.pause(),n.flvPlayer.unload(),n.flvPlayer.detachMediaElement(),setTimeout((function(){n.flvPlayer.attachMediaElement(e),n.flvPlayer.load(),n.flvPlayer.play()}),500)):(clearInterval(n.timer),n.timer=null,console.log("重连失败")))}))}}),t)})}},{key:"componentWillUnmount",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"getNewVideo",value:function(){var e=this.state.id,t=document.getElementById(e).getElementsByTagName("video")[0];if(t)for(var n=t.buffered,r=0;r-1&&(t.currentTime=i-.1)}}},{key:"render",value:function(){var e=this.state.id;return i.a.createElement("div",{className:"dplayerWaikuang"},i.a.createElement("div",{id:e,style:{width:"100%",height:"100%"}}))}}])&&Me(t.prototype,n),r&&Me(t,r),a}(r.Component),Be=n(17),Ue=n(26),Ne={insert:"head",singleton:!1};fe()(Ue.a,Ne),Ue.a.locals;function Fe(e){return(Fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function qe(e,t){for(var n=0;n=r+1){var l=((100-o*(r-1))/r).toFixed(2),c=(parseFloat(l)+o)*(t.length-r),u=document.getElementById("objectTransition");u.style.transition=s+"s all 0s",u.style.left=-c+"%"}return{children:t}}}],(n=[{key:"componentDidUpdate",value:function(){var e=this.props,t=e.children,n=e.count,r=void 0===n?3:n,i=e.leftSpance,o=void 0===i?2:i,a=e.timeSlide,s=void 0===a?1:a;if(t.length=1&&t<3?i.a.createElement("div",{style:{width:n+"%"},key:t},e):i.a.createElement("div",{style:{width:n+"%",left:(parseFloat(n)+a)*t+"%"},key:t},e)}))))}}])&&at(t.prototype,n),r&&at(t,r),a}(r.Component),ht=n(29),pt={insert:"head",singleton:!1};fe()(ht.a,pt),ht.a.locals;function ft(e){return(ft="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mt(e,t){for(var n=0;n0?n:null}}],(n=[{key:"shouldComponentUpdate",value:function(e){return this.props.serviceData.length!==e.serviceData}},{key:"componentDidMount",value:function(){this.init()}},{key:"init",value:function(){this.setCanvasSize()}},{key:"setCanvasSize",value:function(){var e=this.state.id,t=document.getElementById(e).parentNode,n=t.offsetWidth,r=t.offsetHeight;this.setData({width:n+"px",height:r+"px"})}},{key:"removeTags",value:function(e,t){for(var n=document.getElementsByTagName(e),r=n.length-1;r>=0;r--)n[r].className==t&&n[r].parentNode.removeChild(n[r])}},{key:"draw",value:function(){var e=this.state,t=e.id,n=e.serviceData,r=e.width,i=e.height,o=e.mode,a=e.disabled,s=document.getElementById(t).getContext("2d");s.clearRect(0,0,parseFloat(r),parseFloat(i)),this.removeTags("input",this.props.listId?this.props.listId:t+""),this.drawLine(s,n),this.drawCircleAll(s,n),this.drawWriting(s,n),"false"===a&&("click"===o?this.isontouchend()?this.touchMove():this.clickMove():this.isontouchend()?this.touchMove():this.mouseMove())}},{key:"isontouchend",value:function(){return"ontouchend"in document}},{key:"drawCircleAll",value:function(e,t){for(var n=0;nh&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])h&&(h=parseFloat(t[f][0])),parseFloat(t[f][1])0)for(var v in u)g.style[v]=u[v];g.value=e,g.className=this.props.listId?this.props.listId+"":m+"",g.oninput=function(e){var t=a.split(/\n/);t[r]=e.target.value,i.setState({title:t.join("\n")}),i.props.wenziChange(t.join("\n"))},y.appendChild(g)}},{key:"clickMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData;document.getElementById(n).onclick=function(t){var n=t.layerX,i=t.layerY;e.selectedIndex||0===e.selectedIndex?(r[e.selectedIndex]=[n,i],e.selectedIndex=null,e.setData({serviceData:r}),e.sendFather(r)):(e.selectBox(n,i),e.setData({serviceData:r}))}}},{key:"mouseMove",value:function(){var e=this,t=this.state.id,n=document.getElementById(t);n.onmousedown=function(t){var r=e.state.serviceData,i=t.layerX,o=t.layerY;e.selectBox(i,o)&&(n.onmousemove=function(t){r[e.selectedIndex]=[t.layerX,t.layerY],e.setData({serviceData:r})})},n.onmouseup=function(t){n.onmousemove=null,e.selectedIndex=null,e.setData({serviceData:e.state.serviceData});var r=t.layerX,i=t.layerY;e.selectBox(r,i)&&e.sendFather(e.state.serviceData)}}},{key:"touchMove",value:function(){var e=this,t=this.state,n=t.id,r=t.serviceData,i=document.getElementById(n),o=i.parentNode,a=o.getBoundingClientRect().top,s=o.getBoundingClientRect().left;i.ontouchstart=function(t){var n=t.touches[0].pageX-s,o=t.touches[0].pageY-a;e.selectBox(n,o)&&(i.ontouchmove=function(t){r[e.selectedIndex]=[t.touches[0].pageX-s,t.touches[0].pageY-a],e.setData({serviceData:r})})},i.ontouchend=function(t){e.selectedIndex=null,i.ontouchmove=null,e.setData({serviceData:r});var n=t.changedTouches[0].pageX-s,o=t.changedTouches[0].pageY-a;e.selectBox(n,o)&&e.sendFather(r)}}},{key:"selectBox",value:function(e,t){var n=this.state,r=n.serviceData,i=n.circleRadius+n.circleBorderWidth;this.selectedIndex=null;for(var o=0;o0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.state.mode;"react"===e?this.setReact():this.setPolygon()}},{key:"isNull",value:function(){var e=this.state.id,t=document.getElementById(this[e].state.id),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,t.toDataURL()==n.toDataURL()}},{key:"setReact",value:function(){var e=this,t=this.state.id;this.count=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=e.state.serviceData,i=n.layerX,o=n.layerY;if(0===e.count)r[1][1]=o,r[2]=[i,o],r[3][0]=i;else if(e[t].selectedIndex||0===e[t].selectedIndex){switch(r[e[t].selectedIndex]=[i,o],e[t].selectedIndex){case 0:r[1][0]=i,r[3][1]=o;break;case 1:r[0][0]=i,r[2][1]=o;break;case 2:r[1][1]=o,r[3][0]=i;break;case 3:r[0][1]=o,r[2][0]=i}e.props.change(r)}e.setState({serviceData:r},(function(){e[t].draw()}))};n.addEventListener("mousedown",(function(i){if(2!==i.button){var o=i.layerX,a=i.layerY,s=[o,a];if(0===e.state.serviceData.length){e.count++;var l=[[].concat(s),[].concat(s),[].concat(s),[].concat(s)];e.setState({serviceData:l},(function(){e[t].draw()})),n.addEventListener("mousemove",r)}else e[t].selectBox(o,a)&&(e.count++,n.addEventListener("mousemove",r))}})),n.addEventListener("mouseup",(function(e){n.removeEventListener("mousemove",r)})),n.oncontextmenu=function(e){e.preventDefault()}}},{key:"setPolygon",value:function(){var e=this,t=this.state.id;this.state.serviceData.length>1?this.serviceDataFlag=!0:this.polygonCount=0;var n=document.getElementById(this[t].state.id),r=function(n){var r=n.layerX,i=n.layerY,o=e.state.serviceData;o.push([r,i]),e.setState({serviceData:o},(function(){e[t].draw()}))};this.serviceDataFlag||n.addEventListener("click",r),n.oncontextmenu=function(t){t.preventDefault(),2===t.button&&(0==e.polygonCount&&(e.polygonCount++,e.sendFather(e.state.serviceData)),n.removeEventListener("click",r))}}},{key:"isInPolygon",value:function(e,t,n){var r,i,o,a=0,s=t.length;i=t[0];for(var l=1;l<=s;l++)o=t[l%s],e[0]>Math.min(i[0],o[0])&&e[0]<=Math.max(i[0],o[0])&&e[1]<=Math.max(i[1],o[1])&&i[0]!=o[0]&&(r=(e[0]-i[0])*(o[1]-i[1])/(o[0]-i[0])+i[1],(i[1]==o[1]||e[1]<=r)&&a++),i=o;return a%2!=0||!!n.selectBox(e[0],e[1])}},{key:"wenziChange",value:function(e){this.setState({title:e}),this.props.wenziChange(e)}},{key:"change",value:function(e){this.sendFather(e)}},{key:"sendFather",value:function(e){"true"!==this.state.disabled&&this.props.change(e)}},{key:"render",value:function(){var e=this,t=this.state,n=t.serviceData,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.inputStyle,k=t.position,E=t.id;return i.a.createElement(_t,{serviceData:n,disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:p,titleColor:f,titleFont:m,titleLineHeight:y,titleBackgroundColor:g,titlePadding:v,titleTextAlign:b,titleWidth:_,titleFillColor:w,position:k,inputStyle:S,listId:this.props.listId,ref:function(t){e[E]=t},wenziChange:function(t){return e.wenziChange(t)},change:function(t){return e.change(t)}})}}])&&kt(t.prototype,n),r&&kt(t,r),a}(r.Component),Ct=n(30),Mt={insert:"head",singleton:!1};fe()(Ct.a,Mt),Ct.a.locals;function Lt(e){return(Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e,t){for(var n=0;n0?n:null}}],(n=[{key:"componentDidMount",value:function(){var e=this.props.list;e&&e.length>0&&(this.selectIndex=e[e.length-1].id),this.selectArea()}},{key:"clickIt",value:function(e){var t=this.props.list,n=(new Date).getTime();t&&0!==t.length?this[t[t.length-1].id+t[t.length-1].mode].isNull()?this.props.err(!1,"画布为空,请先绘制在添加。"):t[t.length-1].serviceData?(t.push({id:n+"",title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n+""):this.props.err(!1,"画布没有保存,请先绘制完成在添加"):((t=[]).push({id:n,title:this.props.placeholder?this.props.placeholder:"请输入",mode:e}),this.selectIndex=n),this.props.change(t)}},{key:"delete",value:function(){var e=this,t=this.state.list.filter((function(t){return t.id===e.selectIndex})),n=this[t[0].id+t[0].mode];n[n.state.id].removeTags("input",n.props.listId),this.props.delete(this.selectIndex,"发出删除指令")}},{key:"change",value:function(e){var t=this,n=this.props.list;n=n.map((function(n){return n.id===t.selectIndex&&(n.serviceData=JSON.parse(JSON.stringify(e))),n})),this.props.change(n)}},{key:"selectArea",value:function(){var e=this,t=this.state.id;document.getElementById(t).onclick=function(t){var n=e.props.list,r=t.layerX,i=t.layerY;if(e.indexflag=!1,n)for(var o=0;oi!=d>i&&r<(u-l)*(i-c)/(d-c)+l;h&&(o=!o)}return!(h||!n.selectBox(e[0],e[1]))||o}},{key:"wenziChange",value:function(e,t){this.props.wenziChange(e,t)}},{key:"render",value:function(){var e=this,t=this.state,n=t.id,r=t.disabled,o=t.circleRadius,a=t.circleBorderWidth,s=t.circleBorderColor,l=t.circleInColor,c=t.circleSelectColor,u=t.lineColor,d=t.lineWidth,h=t.areaColor,p=t.title,f=t.titleColor,m=t.titleFont,y=t.titleLineHeight,g=t.titleBackgroundColor,v=t.titlePadding,b=t.titleTextAlign,_=t.titleWidth,w=t.titleFillColor,S=t.position,k=this.props.list;return i.a.createElement("div",{id:n,style:{width:"100%",height:"100%",position:"relative"}},k&&k.map((function(t,n){return i.a.createElement(Rt,{disabled:r,circleRadius:o,circleBorderWidth:a,circleBorderColor:s,circleSelectColor:c,circleInColor:l,lineColor:u,lineWidth:d,areaColor:h,title:t.title?t.title:p,titleColor:t.titleColor?t.titleColor:f,titleFont:t.titleFont?t.titleFont:m,titleLineHeight:t.titleLineHeight?t.titleLineHeight:y,titleBackgroundColor:t.titleBackgroundColor?t.titleBackgroundColor:g,titlePadding:t.titlePadding?t.titlePadding:v,titleTextAlign:t.titleTextAlign?t.titleTextAlign:b,titleWidth:t.titleWidth?t.titleWidth:_,titleFillColor:t.titleFillColor?t.titleFillColor:w,position:S,key:t.id,listId:t.id,serviceData:t.serviceData,ref:function(n){e[t.id+t.mode]=n},mode:t.mode,wenziChange:function(t){return e.wenziChange(t,n)},change:function(t){return e.change(t)}})})))}}])&&It(t.prototype,n),r&&It(t,r),a}(r.Component),Ft=n(52),qt=n.n(Ft),jt=function(e){this.mqtt=qt.a,this.random=Vt,this.clientId=Vt();var t={clientId:this.clientId,username:"test",password:"test",connectTimeout:100,keepalive:100};this.client=this.mqtt.connect("ws://"+e+"/mqtt",t),this.reconnectNum=0,this.link=function(){var e=this;return new Promise((function(t,n){e.client.on("connect",(function(n){console.log("-----------------------链接成功-----------------------"),t(e.client)})),e.client.on("reconnect",(function(t){e.reconnectNum++,e.reconnectNum>=10&&e.client.end(!0),console.log("正在重连:",t)})),e.client.on("error",(function(e){console.log("订阅失败",e)}))}))},this.subscribe=function(e,t){this.client.subscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"订阅成功-----------------------")}))},this.unsubscribe=function(e,t){this.client.unsubscribe(e,t,(function(t){if(t)throw new Error(t);console.log("-----------------------"+e+"取消订阅成功-----------------------")}))},this.publish=function(e,t,n){this.client.publish(e,JSON.stringify(t),n,(function(t,n){if(t)throw new Error(t);console.log("-----------------------"+e+"发送成功-----------------------")}))},this.message=function(e){this.client.on("message",(function(t,n){var r=JSON.parse(n.toString());e(r,t)}))},this.close=function(){this.client.end(!0)}};function Vt(){for(var e=String.fromCharCode(65+Math.floor(26*Math.random())),t=0;t<31;++t){var n=Math.floor(62*Math.random());e+=n<10?n.toString():n<36?String.fromCharCode(65+n-10):String.fromCharCode(97+n-10-26)}return e}function Yt(e){for(var t=window.location.search.substring(1).split("&"),n=0;n1&&void 0!==arguments[1]?arguments[1]:10,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=null,i=0;return new Promise((function(o,a){zt(e)?o(zt(e)):r=setInterval((function(){i - {/* */} + {/* { listArr.map((item,index)=>{ @@ -144,7 +144,7 @@ class App extends Component { delete={(selectIndex) => { this.delete(selectIndex) }} err={(falg, msg) => { this.err(falg, msg) }}> */} {/* */} -
+ {/*
{ arr.map(item => { return ( this.changeSelect(val)}>) }) } -
+
*/} {/* */} - {/* */} + {/* */} {/* */} -- libgit2 0.21.4