socket.io-v4.msgpack.js 82 KB

12345678910
  1. !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=16)}([function(t,e){t.exports=function(){return function(){}}},function(t,e,r){const n=r(26),s=r(27),i=String.fromCharCode(30);t.exports={protocol:4,encodePacket:n,encodePayload:(t,e)=>{const r=t.length,s=new Array(r);let o=0;t.forEach((t,h)=>{n(t,!1,t=>{s[h]=t,++o===r&&e(s.join(i))})})},decodePacket:s,decodePayload:(t,e)=>{const r=t.split(i),n=[];for(let t=0;t<r.length;t++){const i=s(r[t],e);if(n.push(i),"error"===i.type)break}return n}}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var s=0;s<n.length;s++)if((r=n[s])===e||r.fn===e){n.splice(s,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var s=(r=r.slice(0)).length;n<s;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports.pick=(t,...e)=>e.reduce((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e),{}),t.exports.installTimerFunctions=(t,e)=>{t.setTimeoutFn=function(t,e){return setTimeout(()=>{t()},e)},t.clearTimeoutFn=function(t){clearTimeout(t)}}},function(t,e,r){var n=r(42),s=r(2);e.protocol=5;var i=e.PacketType={CONNECT:0,DISCONNECT:1,EVENT:2,ACK:3,CONNECT_ERROR:4},o=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},h=function(t){return"string"==typeof t},a=function(t){return"[object Object]"===Object.prototype.toString.call(t)};function c(){}function u(){}c.prototype.encode=function(t){return[n.encode(t)]},s(u.prototype),u.prototype.add=function(t){var e=n.decode(t);this.checkPacket(e),this.emit("decoded",e)},u.prototype.checkPacket=function(t){if(!(o(t.type)&&t.type>=i.CONNECT&&t.type<=i.CONNECT_ERROR))throw new Error("invalid packet type");if(!h(t.nsp))throw new Error("invalid namespace");if(!function(t){switch(t.type){case i.CONNECT:return void 0===t.data||a(t.data);case i.DISCONNECT:return void 0===t.data;case i.CONNECT_ERROR:return h(t.data)||a(t.data);default:return Array.isArray(t.data)}}(t))throw new Error("invalid payload");if(!(void 0===t.id||o(t.id)))throw new Error("invalid packet id")},u.prototype.destroy=function(){},e.Encoder=c,e.Decoder=u},function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,s=t.indexOf("["),i=t.indexOf("]");-1!=s&&-1!=i&&(t=t.substring(0,s)+t.substring(s,i).replace(/:/g,";")+t.substring(i,t.length));for(var o,h,a=r.exec(t||""),c={},u=14;u--;)c[n[u]]=a[u]||"";return-1!=s&&-1!=i&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=function(t,e){var r=e.replace(/\/{2,9}/g,"/").split("/");"/"!=e.substr(0,1)&&0!==e.length||r.splice(0,1);"/"==e.substr(e.length-1,1)&&r.splice(r.length-1,1);return r}(0,c.path),c.queryKey=(o=c.query,h={},o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,r){e&&(h[e]=r)})),h),c}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Manager=void 0;const n=r(19),s=r(12),i=r(13),o=r(4),h=r(14),a=r(45),c=r(15),u=r(0)("socket.io-client:manager");class f extends c.StrictEventEmitter{constructor(t,e){var r;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,(0,s.installTimerFunctions)(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=e.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new a({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||o;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(u("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;u("opening %s",this.uri),this.engine=n(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=(0,h.on)(e,"open",(function(){r.onopen(),t&&t()})),i=(0,h.on)(e,"error",e=>{u("error"),r.cleanup(),r._readyState="closed",this.emitReserved("error",e),t?t(e):r.maybeReconnectOnOpen()});if(!1!==this._timeout){const t=this._timeout;u("connect attempt will timeout after %d",t),0===t&&s();const r=this.setTimeoutFn(()=>{u("connect attempt timed out after %d",t),s(),e.close(),e.emit("error",new Error("timeout"))},t);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}return this.subs.push(s),this.subs.push(i),this}connect(t){return this.open(t)}onopen(){u("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push((0,h.on)(t,"ping",this.onping.bind(this)),(0,h.on)(t,"data",this.ondata.bind(this)),(0,h.on)(t,"error",this.onerror.bind(this)),(0,h.on)(t,"close",this.onclose.bind(this)),(0,h.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){this.decoder.add(t)}ondecoded(t){this.emitReserved("packet",t)}onerror(t){u("error",t),this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r||(r=new i.Socket(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const t of e){if(this.nsps[t].active)return void u("socket %s is still active, skipping close",t)}this._close()}_packet(t){u("writing packet %j",t);const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){u("cleanup"),this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){u("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,"opening"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState="closed",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t){u("onclose"),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)u("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();u("will wait %dms before reconnect attempt",e),this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(u("attempting reconnect"),this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open(e=>{e?(u("reconnect attempt error"),t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):(u("reconnect success"),t.onreconnect())}))},e);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}e.Manager=f},function(t,e,r){const n=r(21);e.websocket=n},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){const n=r(1),s=r(2),{installTimerFunctions:i}=r(3),o=r(0)("engine.io-client:transport");t.exports=class extends s{constructor(t){super(),i(this,t),this.opts=t,this.query=t.query,this.readyState="",this.socket=t.socket}onError(t,e){const r=new Error(t);return r.type="TransportError",r.description=e,this.emit("error",r),this}open(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState?this.write(t):o("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,this.emit("open")}onData(t){const e=n.decodePacket(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){this.emit("packet",t)}onClose(){this.readyState="closed",this.emit("close")}}},function(t,e){const r=Object.create(null);r.open="0",r.close="1",r.ping="2",r.pong="3",r.message="4",r.upgrade="5",r.noop="6";const n=Object.create(null);Object.keys(r).forEach(t=>{n[r[t]]=t});t.exports={PACKET_TYPES:r,PACKET_TYPES_REVERSE:n,ERROR_PACKET:{type:"error",data:"parser error"}}},function(t,e){e.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},e.decode=function(t){for(var e={},r=t.split("&"),n=0,s=r.length;n<s;n++){var i=r[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}},function(t,e,r){const n=r(30);t.exports.pick=(t,...e)=>e.reduce((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e),{});const s=setTimeout,i=clearTimeout;t.exports.installTimerFunctions=(t,e)=>{e.useNativeTimers?(t.setTimeoutFn=s.bind(n),t.clearTimeoutFn=i.bind(n)):(t.setTimeoutFn=setTimeout.bind(n),t.clearTimeoutFn=clearTimeout.bind(n))}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Socket=void 0;const n=r(4),s=r(14),i=r(15),o=r(0)("socket.io-client:socket"),h=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class a extends i.StrictEventEmitter{constructor(t,e,r){super(),this.connected=!1,this.disconnected=!0,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[(0,s.on)(t,"open",this.onopen.bind(this)),(0,s.on)(t,"packet",this.onpacket.bind(this)),(0,s.on)(t,"error",this.onerror.bind(this)),(0,s.on)(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(h.hasOwnProperty(t))throw new Error('"'+t+'" is a reserved event name');e.unshift(t);const r={type:n.PacketType.EVENT,data:e,options:{}};r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(o("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),r.id=this.ids++);const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?o("discard packet as the transport is not currently writable"):this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){o("transport is open - connecting"),"function"==typeof this.auth?this.auth(t=>{this.packet({type:n.PacketType.CONNECT,data:t})}):this.packet({type:n.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t){o("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved("disconnect",t)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case n.PacketType.CONNECT:if(t.data&&t.data.sid){const e=t.data.sid;this.onconnect(e)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(t);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(t);break;case n.PacketType.DISCONNECT:this.ondisconnect();break;case n.PacketType.CONNECT_ERROR:const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];o("emitting event %j",e),null!=t.id&&(o("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t)}ack(t){const e=this;let r=!1;return function(...s){r||(r=!0,o("sending ack %j",s),e.packet({type:n.PacketType.ACK,id:t,data:s}))}}onack(t){const e=this.acks[t.id];"function"==typeof e?(o("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):o("bad ack %s",t.id)}onconnect(t){o("socket connected with id %s",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){o("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(o("performing disconnect (%s)",this.nsp),this.packet({type:n.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}e.Socket=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.on=void 0,e.on=function(t,e,r){return t.on(e,r),function(){t.off(e,r)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StrictEventEmitter=void 0;const n=r(2);e.StrictEventEmitter=class extends n{on(t,e){return super.on(t,e),this}once(t,e){return super.once(t,e),this}emit(t,...e){return super.emit(t,...e),this}emitReserved(t,...e){return super.emit(t,...e),this}listeners(t){return super.listeners(t)}}},function(t,e,r){t.exports=r(17)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.io=e.Socket=e.Manager=e.protocol=void 0;const n=r(18),s=r(6),i=r(0)("socket.io-client");t.exports=e=h;const o=e.managers={};function h(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};const r=(0,n.url)(t,e.path||"/socket.io"),h=r.source,a=r.id,c=r.path,u=o[a]&&c in o[a].nsps;let f;return e.forceNew||e["force new connection"]||!1===e.multiplex||u?(i("ignoring socket cache for %s",h),f=new s.Manager(h,e)):(o[a]||(i("new io instance for %s",h),o[a]=new s.Manager(h,e)),f=o[a]),r.query&&!e.query&&(e.query=r.queryKey),f.socket(r.path,e)}e.io=h;var a=r(4);Object.defineProperty(e,"protocol",{enumerable:!0,get:function(){return a.protocol}}),e.connect=h;var c=r(6);Object.defineProperty(e,"Manager",{enumerable:!0,get:function(){return c.Manager}});var u=r(13);Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return u.Socket}}),e.default=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.url=void 0;const n=r(5),s=r(0)("socket.io-client:url");e.url=function(t,e="",r){let i=t;r=r||"undefined"!=typeof location&&location,null==t&&(t=r.protocol+"//"+r.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?r.protocol+t:r.host+t),/^(https?|wss?):\/\//.test(t)||(s("protocol-less url %s",t),t=void 0!==r?r.protocol+"//"+t:"https://"+t),s("parse %s",t),i=n(t)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const o=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+o+":"+i.port+e,i.href=i.protocol+"://"+o+(r&&r.port===i.port?"":":"+i.port),i}},function(t,e,r){const n=r(20);t.exports=(t,e)=>new n(t,e),t.exports.Socket=n,t.exports.protocol=n.protocol,t.exports.Transport=r(9),t.exports.transports=r(7),t.exports.parser=r(1)},function(t,e,r){const n=r(7),s=r(2),i=r(0)("engine.io-client:socket"),o=r(1),h=r(5),a=r(11),{installTimerFunctions:c}=r(3);class u extends s{constructor(t,e={}){super(),t&&"object"==typeof t&&(e=t,t=null),t?(t=h(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=h(e.host).host),c(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.transports=e.transports||["websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=a.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close")},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){i('creating transport "%s"',t);const e=function(t){const e={};for(let r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}(this.opts.query);e.EIO=o.protocol,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return i("options: %j",r),new n[t](r)}open(){let t;if(this.opts.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emit("error","No transports available")},0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return i("error while creating transport: %s",t),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){i("setting transport %s",t.name),this.transport&&(i("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",()=>{this.onClose("transport close")})}probe(t){i('probing transport "%s"',t);let e=this.createTransport(t,{probe:1}),r=!1;u.priorWebsocketSuccess=!1;const n=()=>{r||(i('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",n=>{if(!r)if("pong"===n.type&&"probe"===n.data){if(i('probe transport "%s" pong',t),this.upgrading=!0,this.emit("upgrading",e),!e)return;u.priorWebsocketSuccess="websocket"===e.name,i('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||"closed"!==this.readyState&&(i("changing transport and sending upgrade packet"),f(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emit("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{i('probe transport "%s" failed',t);const r=new Error("probe error");r.transport=e.name,this.emit("upgradeError",r)}}))};function s(){r||(r=!0,f(),e.close(),e=null)}const o=r=>{const n=new Error("probe error: "+r);n.transport=e.name,s(),i('probe transport "%s" failed because of error: %s',t,r),this.emit("upgradeError",n)};function h(){o("transport closed")}function a(){o("socket closed")}function c(t){e&&t.name!==e.name&&(i('"%s" works - aborting "%s"',t.name,e.name),s())}const f=()=>{e.removeListener("open",n),e.removeListener("error",o),e.removeListener("close",h),this.removeListener("close",a),this.removeListener("upgrading",c)};e.once("open",n),e.once("error",o),e.once("close",h),this.once("close",a),this.once("upgrading",c),e.open()}onOpen(){if(i("socket open"),this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){i("starting upgrade probes");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(i('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emit("ping"),this.emit("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data)}else i('packet received with socket readyState "%s"',this.readyState)}onHandshake(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()}flush(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(i("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))}write(t,e,r){return this.sendPacket("message",t,e,r),this}send(t,e,r){return this.sendPacket("message",t,e,r),this}sendPacket(t,e,r,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const s={type:t,data:e,options:r};this.emit("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this.onClose("forced close"),i("socket closing - telling transport to close"),this.transport.close()},e=()=>{this.removeListener("upgrade",e),this.removeListener("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){i("socket error %j",t),u.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(i('socket close with reason: "%s"',t),this.clearTimeoutFn(this.pingIntervalTimer),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emit("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let r=0;const n=t.length;for(;r<n;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}}u.priorWebsocketSuccess=!1,u.protocol=o.protocol,t.exports=u},function(t,e,r){(function(e){const n=r(9),s=r(1),i=r(11),o=r(29),{pick:h}=r(12),{WebSocket:a,usingBrowserWebSocket:c,defaultBinaryType:u,nextTick:f}=r(31),p=r(0)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class d extends n{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,r=l?{}:h(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=c&&!l?e?new a(t,e):new a(t):new a(t,e,r)}catch(t){return this.emit("error",t)}this.ws.binaryType=this.socket.binaryType||u,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],i=r===t.length-1;s.encodePacket(n,this.supportsBinary,t=>{const r={};if(!c&&(n.options&&(r.compress=n.options.compress),this.opts.perMessageDeflate)){("string"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(r.compress=!1)}try{c?this.ws.send(t):this.ws.send(t,r)}catch(t){p("websocket closed before onclose event")}i&&f(()=>{this.writable=!0,this.emit("drain")},this.setTimeoutFn)})}}onClose(){n.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let t=this.query||{};const e=this.opts.secure?"wss":"ws";let r="";return this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"===e&&80!==Number(this.opts.port))&&(r=":"+this.opts.port),this.opts.timestampRequests&&(t[this.opts.timestampParam]=o()),this.supportsBinary||(t.b64=1),t=i.encode(t),t.length&&(t="?"+t),e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+t}check(){return!(!a||"__initialize"in a&&this.name===d.prototype.name)}}t.exports=d}).call(this,r(22).Buffer)},function(t,e,r){"use strict";(function(t){
  2. /*!
  3. * The buffer module from node.js, for the browser.
  4. *
  5. * @author Feross Aboukhadijeh <http://feross.org>
  6. * @license MIT
  7. */
  8. var n=r(23),s=r(24),i=r(25);function o(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=a.prototype:(null===t&&(t=new a(e)),t.length=e),t}function a(t,e,r){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,r)}function c(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);a.TYPED_ARRAY_SUPPORT?(t=e).__proto__=a.prototype:t=p(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!a.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),s=(t=h(t,n)).write(e,r);s!==n&&(t=t.slice(0,s));return t}(t,e,r):function(t,e){if(a.isBuffer(e)){var r=0|l(e.length);return 0===(t=h(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?h(t,0):p(t,e);if("Buffer"===e.type&&i(e.data))return p(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(u(e),t=h(t,e<0?0:0|l(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function p(t,e){var r=e.length<0?0:0|l(e.length);t=h(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function d(t,e){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return F(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,s);if("number"==typeof e)return e&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,s){var i,o=1,h=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,h/=2,a/=2,r/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(s){var u=-1;for(i=r;i<h;i++)if(c(t,i)===c(e,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===a)return u*o}else-1!==u&&(i-=i-u),u=-1}else for(r+a>h&&(r=h-a),i=r;i>=0;i--){for(var f=!0,p=0;p<a;p++)if(c(t,i+p)!==c(e,p)){f=!1;break}if(f)return i}return-1}function _(t,e,r,n){r=Number(r)||0;var s=t.length-r;n?(n=Number(n))>s&&(n=s):n=s;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;o<n;++o){var h=parseInt(e.substr(2*o,2),16);if(isNaN(h))return o;t[r+o]=h}return o}function w(t,e,r,n){return q(F(e,t.length-r),t,r,n)}function b(t,e,r,n){return q(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return b(t,e,r,n)}function k(t,e,r,n){return q(Y(e),t,r,n)}function O(t,e,r,n){return q(function(t,e){for(var r,n,s,i=[],o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,s=r%256,i.push(s),i.push(n);return i}(e,t.length-r),t,r,n)}function S(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],s=e;s<r;){var i,o,h,a,c=t[s],u=null,f=c>239?4:c>223?3:c>191?2:1;if(s+f<=r)switch(f){case 1:c<128&&(u=c);break;case 2:128==(192&(i=t[s+1]))&&(a=(31&c)<<6|63&i)>127&&(u=a);break;case 3:i=t[s+1],o=t[s+2],128==(192&i)&&128==(192&o)&&(a=(15&c)<<12|(63&i)<<6|63&o)>2047&&(a<55296||a>57343)&&(u=a);break;case 4:i=t[s+1],o=t[s+2],h=t[s+3],128==(192&i)&&128==(192&o)&&128==(192&h)&&(a=(15&c)<<18|(63&i)<<12|(63&o)<<6|63&h)>65535&&a<1114112&&(u=a)}null===u?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),s+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=a,e.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},e.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),a.poolSize=8192,a._augment=function(t){return t.__proto__=a.prototype,t},a.from=function(t,e,r){return c(null,t,e,r)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(t,e,r){return function(t,e,r,n){return u(e),e<=0?h(t,e):void 0!==r?"string"==typeof n?h(t,e).fill(r,n):h(t,e).fill(r):h(t,e)}(null,t,e,r)},a.allocUnsafe=function(t){return f(null,t)},a.allocUnsafeSlow=function(t){return f(null,t)},a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,s=0,i=Math.min(r,n);s<i;++s)if(t[s]!==e[s]){r=t[s],n=e[s];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=a.allocUnsafe(e),s=0;for(r=0;r<t.length;++r){var o=t[r];if(!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n},a.byteLength=d,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},a.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):g.apply(this,arguments)},a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},a.prototype.compare=function(t,e,r,n,s){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),e<0||r>t.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&e>=r)return 0;if(n>=s)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(s>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),h=Math.min(i,o),c=this.slice(n,s),u=t.slice(e,r),f=0;f<h;++f)if(c[f]!==u[f]){i=c[f],o=u[f];break}return i<o?-1:o<i?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var s=this.length-e;if((void 0===r||r>s)&&(r=s),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return E(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(t,e,r){var n="";r=Math.min(t.length,r);for(var s=e;s<r;++s)n+=String.fromCharCode(127&t[s]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var s=e;s<r;++s)n+=String.fromCharCode(t[s]);return n}function x(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var s="",i=e;i<r;++i)s+=D(t[i]);return s}function R(t,e,r){for(var n=t.slice(e,r),s="",i=0;i<n.length;i+=2)s+=String.fromCharCode(n[i]+256*n[i+1]);return s}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,r,n,s,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function U(t,e,r,n){e<0&&(e=65535+e+1);for(var s=0,i=Math.min(t.length-r,2);s<i;++s)t[r+s]=(e&255<<8*(n?s:1-s))>>>8*(n?s:1-s)}function B(t,e,r,n){e<0&&(e=4294967295+e+1);for(var s=0,i=Math.min(t.length-r,4);s<i;++s)t[r+s]=e>>>8*(n?s:3-s)&255}function j(t,e,r,n,s,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return i||j(t,0,r,4),s.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return i||j(t,0,r,8),s.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),a.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=a.prototype;else{var s=e-t;r=new a(s,void 0);for(var i=0;i<s;++i)r[i]=this[i+t]}return r},a.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],s=1,i=0;++i<e&&(s*=256);)n+=this[t+i]*s;return n},a.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t+--e],s=1;e>0&&(s*=256);)n+=this[t+--e]*s;return n},a.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],s=1,i=0;++i<e&&(s*=256);)n+=this[t+i]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=e,s=1,i=this[t+--n];n>0&&(s*=256);)i+=this[t+--n]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),s.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),s.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),s.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),s.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var s=1,i=0;for(this[e]=255&t;++i<r&&(s*=256);)this[e+i]=t/s&255;return e+r},a.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||L(this,t,e,r,Math.pow(2,8*r)-1,0);var s=r-1,i=1;for(this[e+s]=255&t;--s>=0&&(i*=256);)this[e+s]=t/i&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*r-1);L(this,t,e,r,s-1,-s)}var i=0,o=1,h=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===h&&0!==this[e+i-1]&&(h=1),this[e+i]=(t/o>>0)-h&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var s=Math.pow(2,8*r-1);L(this,t,e,r,s-1,-s)}var i=r-1,o=1,h=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===h&&0!==this[e+i+1]&&(h=1),this[e+i]=(t/o>>0)-h&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var s,i=n-r;if(this===t&&r<e&&e<n)for(s=i-1;s>=0;--s)t[s+e]=this[s+r];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<i;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var s=t.charCodeAt(0);s<256&&(t=s)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var o=a.isBuffer(t)?t:F(new a(t,n).toString()),h=o.length;for(i=0;i<r-e;++i)this[i+e]=o[i%h]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function D(t){return t<16?"0"+t.toString(16):t.toString(16)}function F(t,e){var r;e=e||1/0;for(var n=t.length,s=null,i=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!s){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}s=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),s=r;continue}r=65536+(s-55296<<10|r-56320)}else s&&(e-=3)>-1&&i.push(239,191,189);if(s=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,r,n){for(var s=0;s<n&&!(s+r>=e.length||s>=t.length);++s)e[s+r]=t[s];return s}}).call(this,r(8))},function(t,e,r){"use strict";e.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=c(t),o=n[0],h=n[1],a=new i(function(t,e,r){return 3*(e+r)/4-r}(0,o,h)),u=0,f=h>0?o-4:o;for(r=0;r<f;r+=4)e=s[t.charCodeAt(r)]<<18|s[t.charCodeAt(r+1)]<<12|s[t.charCodeAt(r+2)]<<6|s[t.charCodeAt(r+3)],a[u++]=e>>16&255,a[u++]=e>>8&255,a[u++]=255&e;2===h&&(e=s[t.charCodeAt(r)]<<2|s[t.charCodeAt(r+1)]>>4,a[u++]=255&e);1===h&&(e=s[t.charCodeAt(r)]<<10|s[t.charCodeAt(r+1)]<<4|s[t.charCodeAt(r+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e);return a},e.fromByteArray=function(t){for(var e,r=t.length,s=r%3,i=[],o=0,h=r-s;o<h;o+=16383)i.push(u(t,o,o+16383>h?h:o+16383));1===s?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return i.join("")};for(var n=[],s=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,a=o.length;h<a;++h)n[h]=o[h],s[o.charCodeAt(h)]=h;function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var s,i,o=[],h=e;h<r;h+=3)s=(t[h]<<16&16711680)+(t[h+1]<<8&65280)+(255&t[h+2]),o.push(n[(i=s)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},function(t,e){
  9. /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
  10. e.read=function(t,e,r,n,s){var i,o,h=8*s-n-1,a=(1<<h)-1,c=a>>1,u=-7,f=r?s-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-u)-1,l>>=-u,u+=h;u>0;i=256*i+t[e+f],f+=p,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=n;u>0;o=256*o+t[e+f],f+=p,u-=8);if(0===i)i=1-c;else{if(i===a)return o?NaN:1/0*(l?-1:1);o+=Math.pow(2,n),i-=c}return(l?-1:1)*o*Math.pow(2,i-n)},e.write=function(t,e,r,n,s,i){var o,h,a,c=8*i-s-1,u=(1<<c)-1,f=u>>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),(e+=o+f>=1?p/a:p*Math.pow(2,1-f))*a>=2&&(o++,a/=2),o+f>=u?(h=0,o=u):o+f>=1?(h=(e*a-1)*Math.pow(2,s),o+=f):(h=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[r+l]=255&h,l+=d,h/=256,s-=8);for(o=o<<s|h,c+=s;c>0;t[r+l]=255&o,l+=d,o/=256,c-=8);t[r+l-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){const{PACKET_TYPES:n}=r(10),s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,o=(t,e)=>{const r=new FileReader;return r.onload=function(){const t=r.result.split(",")[1];e("b"+t)},r.readAsDataURL(t)};t.exports=({type:t,data:e},r,h)=>{return s&&e instanceof Blob?r?h(e):o(e,h):i&&(e instanceof ArrayBuffer||(a=e,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(a):a&&a.buffer instanceof ArrayBuffer))?r?h(e):o(new Blob([e]),h):h(n[t]+(e||""));var a}},function(t,e,r){const{PACKET_TYPES_REVERSE:n,ERROR_PACKET:s}=r(10);let i;"function"==typeof ArrayBuffer&&(i=r(28));const o=(t,e)=>{if(i){const r=i.decode(t);return h(r,e)}return{base64:!0,data:t}},h=(t,e)=>{switch(e){case"blob":return t instanceof ArrayBuffer?new Blob([t]):t;case"arraybuffer":default:return t}};t.exports=(t,e)=>{if("string"!=typeof t)return{type:"message",data:h(t,e)};const r=t.charAt(0);return"b"===r?{type:"message",data:o(t.substring(1),e)}:n[r]?t.length>1?{type:n[r],data:t.substring(1)}:{type:n[r]}:s}},function(t,e){!function(t){"use strict";e.encode=function(e){var r,n=new Uint8Array(e),s=n.length,i="";for(r=0;r<s;r+=3)i+=t[n[r]>>2],i+=t[(3&n[r])<<4|n[r+1]>>4],i+=t[(15&n[r+1])<<2|n[r+2]>>6],i+=t[63&n[r+2]];return s%3==2?i=i.substring(0,i.length-1)+"=":s%3==1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(e){var r,n,s,i,o,h=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(h--,"="===e[e.length-2]&&h--);var u=new ArrayBuffer(h),f=new Uint8Array(u);for(r=0;r<a;r+=4)n=t.indexOf(e[r]),s=t.indexOf(e[r+1]),i=t.indexOf(e[r+2]),o=t.indexOf(e[r+3]),f[c++]=n<<2|s>>4,f[c++]=(15&s)<<4|i>>2,f[c++]=(3&i)<<6|63&o;return u}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},function(t,e,r){"use strict";var n,s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i={},o=0,h=0;function a(t){var e="";do{e=s[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function c(){var t=a(+new Date);return t!==n?(o=0,n=t):t+"."+a(o++)}for(;h<64;h++)i[s[h]]=h;c.encode=a,c.decode=function(t){var e=0;for(h=0;h<t.length;h++)e=64*e+i[t.charAt(h)];return e},t.exports=c},function(t,e){t.exports="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},function(t,e,r){t.exports={WebSocket:r(32),usingBrowserWebSocket:!1,defaultBinaryType:"nodebuffer",nextTick:t=>{setTimeout(()=>{t()})}}},function(t,e,r){const n=r(33),{URL:s}=r(34),{addEventListener:i,removeEventListener:o}=r(40),h=r(41),a=r(0)("wx-ws:wx-ws"),c=["nodebuffer","arraybuffer"],u=["CONNECTING","OPEN","CLOSING","CLOSED"];class f extends n{constructor(t,e,r){super(),a("constructor: ",t,e,r),this.readyState=f.CONNECTING,this.protocol="",this._closeCode=1006,this._closeMessage="",this._binaryType=c[0],this._socket=null,this.supports={binary:!0},null!==t&&(this._bufferedAmount=0,this._redirects=0,"object"==typeof e&&null!==e&&(r=e,e=void 0),function(t,e,r,n){const s={maxPayload:104857600,perMessageDeflate:!0,...n};a("initAsClient: opts: ",s),t.url=e;const i=function(t,e){a("start create conn: ",t);const r=wx.connectSocket(t);if(r)return r;return{onClose:wx.onSocketClose,onOpen:wx.onSocketOpen,onError:wx.onSocketError,onMessage:wx.onSocketMessage,send:wx.sendSocketMessage,close:wx.closeSocket}}({url:t.url,header:s.headers,protocols:r,perMessageDeflate:!!s.perMessageDeflate,tcpNoDelay:!!s.tcpNoDelay});t.setSocket(i)}(this,t,e,r))}get CONNECTING(){return f.CONNECTING}get CLOSING(){return f.CLOSING}get CLOSED(){return f.CLOSED}get OPEN(){return f.OPEN}get bufferedAmount(){return this._socket?(this._socket.bufferSize||0)+this._sender._bufferedBytes:this._bufferedAmount}get binaryType(){return this._binaryType}set binaryType(t){a("set binaryType: ",t),c.includes(t)&&(this._binaryType=t)}setSocket(t,e){this._socket=t,this._sender=new h(t),a("set socket: socket =",t,", head =",e,", this: ",this),this._socket.onOpen(t=>{a("socket onopen: ",t),this.readyState=f.OPEN,this.emit("open",t)}),this._socket.onClose(t=>{a("socket onclose: ",t),this._closeCode=t.code,this._closeMessage=t.reason,this.emitClose()}),this._socket.onError(t=>{a("socket onerror: ",t),this.emit("error",t)}),this._socket.onMessage(t=>{a("socket onmessage: ",t,this),this.emit("message",t.data)})}emitClose(){this.readyState=f.CLOSED,this.removeEventListener(),this.emit("close",this._closeCode,this._closeMessage)}send(t,e,r){if(a("socket send msg: ",t,this.readyState,", sender: ",this._sender),this.readyState===f.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("number"==typeof t&&(t=t.toString()),this.readyState===f.OPEN)this._sender.send(t,e,r);else if(r){r(new Error(`WebSocket is not open: readyState ${this.readyState} `+`(${u[this.readyState]})`))}}close(t,e){if(a("closing connection: ",this.readyState),this.readyState!==f.CLOSED){if(this.readyState===f.CONNECTING){throw new Error("WebSocket was closed before the connection was established")}this.readyState!==f.CLOSING&&(this.readyState=f.CLOSING,this._socket.close({code:t,reason:e,success:()=>{a("connection closed..."),this.readyState=f.CLOSED,this._socket=null}}))}}}u.forEach((t,e)=>{f[t]=e}),["open","error","close","message"].forEach(t=>{Object.defineProperty(f.prototype,`on${t}`,{get(){const e=this.listeners(t);for(let t=0;t<e.length;t++)if(e[t]._listener)return e[t]._listener},set(e){const r=this.listeners(t);for(let e=0;e<r.length;e++)r[e]._listener&&this.removeListener(t,r[e]);this.addEventListener(t,e)}})}),f.prototype.addEventListener=i,f.prototype.removeEventListener=o,t.exports=f},function(t,e,r){"use strict";var n,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function h(){h.init.call(this)}t.exports=h,h.EventEmitter=h,h.prototype._events=void 0,h.prototype._eventsCount=0,h.prototype._maxListeners=void 0;var a=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?h.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var s,i,o,h;if(c(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),o=i[e]),void 0===o)o=i[e]=r,++t._eventsCount;else if("function"==typeof o?o=i[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(s=u(t))>0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,h=a,console&&console.warn&&console.warn(h)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=p.bind(n);return s.listener=r,n.wrapFn=s,s}function d(t,e,r){var n=t._events;if(void 0===n)return[];var s=n[e];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(s):y(s,s.length)}function g(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}Object.defineProperty(h,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),h.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},h.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},h.prototype.getMaxListeners=function(){return u(this)},h.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,s=this._events;if(void 0!==s)n=n&&void 0===s.error;else if(!n)return!1;if(n){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var h=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw h.context=o,h}var a=s[t];if(void 0===a)return!1;if("function"==typeof a)i(a,this,e);else{var c=a.length,u=y(a,c);for(r=0;r<c;++r)i(u[r],this,e)}return!0},h.prototype.addListener=function(t,e){return f(this,t,e,!1)},h.prototype.on=h.prototype.addListener,h.prototype.prependListener=function(t,e){return f(this,t,e,!0)},h.prototype.once=function(t,e){return c(e),this.on(t,l(this,t,e)),this},h.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,l(this,t,e)),this},h.prototype.removeListener=function(t,e){var r,n,s,i,o;if(c(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){o=r[i].listener,s=i;break}if(s<0)return this;0===s?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,s),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,o||e)}return this},h.prototype.off=h.prototype.removeListener,h.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var s,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(s=i[n])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},h.prototype.listeners=function(t){return d(this,t,!0)},h.prototype.rawListeners=function(t){return d(this,t,!1)},h.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},h.prototype.listenerCount=g,h.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,r){"use strict";var n=r(35),s=r(3);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=_,e.resolve=function(t,e){return _(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?_(t,!1,!0).resolveObject(e):e},e.format=function(t){s.isString(t)&&(t=_(t));return t instanceof i?t.format():i.prototype.format.call(t)},e.Url=i;var o=/^([a-z0-9.+-]+:)/i,h=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),f=["%","/","?",";","#"].concat(u),p=["/","?","#"],l=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=r(37);function _(t,e,r){if(t&&s.isObject(t)&&t instanceof i)return t;var n=new i;return n.parse(t,e,r),n}i.prototype.parse=function(t,e,r){if(!s.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),h=-1!==i&&i<t.indexOf("#")?"?":"#",c=t.split(h);c[0]=c[0].replace(/\\/g,"/");var _=t=c.join(h);if(_=_.trim(),!r&&1===t.split("#").length){var w=a.exec(_);if(w)return this.path=_,this.href=_,this.pathname=w[1],w[2]?(this.search=w[2],this.query=e?v.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var b=o.exec(_);if(b){var E=(b=b[0]).toLowerCase();this.protocol=E,_=_.substr(b.length)}if(r||b||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===_.substr(0,2);!k||b&&y[b]||(_=_.substr(2),this.slashes=!0)}if(!y[b]&&(k||b&&!m[b])){for(var O,S,A=-1,T=0;T<p.length;T++){-1!==(C=_.indexOf(p[T]))&&(-1===A||C<A)&&(A=C)}-1!==(S=-1===A?_.lastIndexOf("@"):_.lastIndexOf("@",A))&&(O=_.slice(0,S),_=_.slice(S+1),this.auth=decodeURIComponent(O)),A=-1;for(T=0;T<f.length;T++){var C;-1!==(C=_.indexOf(f[T]))&&(-1===A||C<A)&&(A=C)}-1===A&&(A=_.length),this.host=_.slice(0,A),_=_.slice(A),this.parseHost(),this.hostname=this.hostname||"";var x="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!x)for(var R=this.hostname.split(/\./),P=(T=0,R.length);T<P;T++){var L=R[T];if(L&&!L.match(l)){for(var U="",B=0,j=L.length;B<j;B++)L.charCodeAt(B)>127?U+="x":U+=L[B];if(!U.match(l)){var I=R.slice(0,T),N=R.slice(T+1),M=L.match(d);M&&(I.push(M[1]),N.unshift(M[2])),N.length&&(_="/"+N.join(".")+_),this.hostname=I.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),x||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,x&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[E])for(T=0,P=u.length;T<P;T++){var Y=u[T];if(-1!==_.indexOf(Y)){var q=encodeURIComponent(Y);q===Y&&(q=escape(Y)),_=_.split(Y).join(q)}}var z=_.indexOf("#");-1!==z&&(this.hash=_.substr(z),_=_.slice(0,z));var K=_.indexOf("?");if(-1!==K?(this.search=_.substr(K),this.query=_.substr(K+1),e&&(this.query=v.parse(this.query)),_=_.slice(0,K)):e&&(this.search="",this.query={}),_&&(this.pathname=_),m[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){D=this.pathname||"";var $=this.search||"";this.path=D+$}return this.href=this.format(),this},i.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&s.isObject(this.query)&&Object.keys(this.query).length&&(o=v.stringify(this.query));var h=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||m[e])&&!1!==i?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),h&&"?"!==h.charAt(0)&&(h="?"+h),e+i+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(h=h.replace("#","%23"))+n},i.prototype.resolve=function(t){return this.resolveObject(_(t,!1,!0)).format()},i.prototype.resolveObject=function(t){if(s.isString(t)){var e=new i;e.parse(t,!1,!0),t=e}for(var r=new i,n=Object.keys(this),o=0;o<n.length;o++){var h=n[o];r[h]=this[h]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),c=0;c<a.length;c++){var u=a[c];"protocol"!==u&&(r[u]=t[u])}return m[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!m[t.protocol]){for(var f=Object.keys(t),p=0;p<f.length;p++){var l=f[p];r[l]=t[l]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||y[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var g=r.pathname||"",v=r.search||"";r.path=g+v}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var _=r.pathname&&"/"===r.pathname.charAt(0),w=t.host||t.pathname&&"/"===t.pathname.charAt(0),b=w||_||r.host&&t.pathname,E=b,k=r.pathname&&r.pathname.split("/")||[],O=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!m[r.protocol]);if(O&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),b=b&&(""===d[0]||""===k[0])),w)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,k=d;else if(d.length)k||(k=[]),k.pop(),k=k.concat(d),r.search=t.search,r.query=t.query;else if(!s.isNullOrUndefined(t.search)){if(O)r.hostname=r.host=k.shift(),(x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=x.shift(),r.host=r.hostname=x.shift());return r.search=t.search,r.query=t.query,s.isNull(r.pathname)&&s.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var S=k.slice(-1)[0],A=(r.host||t.host||k.length>1)&&("."===S||".."===S)||""===S,T=0,C=k.length;C>=0;C--)"."===(S=k[C])?k.splice(C,1):".."===S?(k.splice(C,1),T++):T&&(k.splice(C,1),T--);if(!b&&!E)for(;T--;T)k.unshift("..");!b||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var x,R=""===k[0]||k[0]&&"/"===k[0].charAt(0);O&&(r.hostname=r.host=R?"":k.length?k.shift():"",(x=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=x.shift(),r.host=r.hostname=x.shift()));return(b=b||r.host&&k.length)&&!R&&k.unshift(""),k.length?r.pathname=k.join("/"):(r.pathname=null,r.path=null),s.isNull(r.pathname)&&s.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var t=this.host,e=h.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){(function(t,n){var s;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){e&&e.nodeType,t&&t.nodeType;var o="object"==typeof n&&n;o.global!==o&&o.window!==o&&o.self;var h,a=2147483647,c=/^xn--/,u=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,d=String.fromCharCode;function g(t){throw new RangeError(p[t])}function y(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function m(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+y((t=t.replace(f,".")).split("."),e).join(".")}function v(t){for(var e,r,n=[],s=0,i=t.length;s<i;)(e=t.charCodeAt(s++))>=55296&&e<=56319&&s<i?56320==(64512&(r=t.charCodeAt(s++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),s--):n.push(e);return n}function _(t){return y(t,(function(t){var e="";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=d(t)})).join("")}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function b(t,e,r){var n=0;for(t=r?l(t/700):t>>1,t+=l(t/e);t>455;n+=36)t=l(t/35);return l(n+36*t/(t+38))}function E(t){var e,r,n,s,i,o,h,c,u,f,p,d=[],y=t.length,m=0,v=128,w=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&g("not-basic"),d.push(t.charCodeAt(n));for(s=r>0?r+1:0;s<y;){for(i=m,o=1,h=36;s>=y&&g("invalid-input"),((c=(p=t.charCodeAt(s++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||c>l((a-m)/o))&&g("overflow"),m+=c*o,!(c<(u=h<=w?1:h>=w+26?26:h-w));h+=36)o>l(a/(f=36-u))&&g("overflow"),o*=f;w=b(m-i,e=d.length+1,0==i),l(m/e)>a-v&&g("overflow"),v+=l(m/e),m%=e,d.splice(m++,0,v)}return _(d)}function k(t){var e,r,n,s,i,o,h,c,u,f,p,y,m,_,E,k=[];for(y=(t=v(t)).length,e=128,r=0,i=72,o=0;o<y;++o)(p=t[o])<128&&k.push(d(p));for(n=s=k.length,s&&k.push("-");n<y;){for(h=a,o=0;o<y;++o)(p=t[o])>=e&&p<h&&(h=p);for(h-e>l((a-r)/(m=n+1))&&g("overflow"),r+=(h-e)*m,e=h,o=0;o<y;++o)if((p=t[o])<e&&++r>a&&g("overflow"),p==e){for(c=r,u=36;!(c<(f=u<=i?1:u>=i+26?26:u-i));u+=36)E=c-f,_=36-f,k.push(d(w(f+E%_,0))),c=l(E/_);k.push(d(w(c,0))),i=b(r,m,n==s),r=0,++n}++r,++e}return k.join("")}h={version:"1.4.1",ucs2:{decode:v,encode:_},decode:E,encode:k,toASCII:function(t){return m(t,(function(t){return u.test(t)?"xn--"+k(t):t}))},toUnicode:function(t){return m(t,(function(t){return c.test(t)?E(t.slice(4).toLowerCase()):t}))}},void 0===(s=function(){return h}.call(e,r,e,t))||(t.exports=s)}()}).call(this,r(36)(t),r(8))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";e.decode=e.parse=r(38),e.encode=e.stringify=r(39)},function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var h=/\+/g;t=t.split(e);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var c=t.length;a>0&&c>a&&(c=a);for(var u=0;u<c;++u){var f,p,l,d,g=t[u].replace(h,"%20"),y=g.indexOf(r);y>=0?(f=g.substr(0,y),p=g.substr(y+1)):(f=g,p=""),l=decodeURIComponent(f),d=decodeURIComponent(p),n(o,l)?s(o[l])?o[l].push(d):o[l]=[o[l],d]:o[l]=d}return o};var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,h){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?i(o(t),(function(o){var h=encodeURIComponent(n(o))+r;return s(t[o])?i(t[o],(function(t){return h+encodeURIComponent(n(t))})).join(e):h+encodeURIComponent(n(t[o]))})).join(e):h?encodeURIComponent(n(h))+r+encodeURIComponent(n(t)):""};var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var o=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},function(t,e,r){"use strict";class n{constructor(t,e){this.target=e,this.type=t}}class s extends n{constructor(t,e){super("message",e),this.data=t}}class i extends n{constructor(t,e,r){super("close",r),this.wasClean=r._closeFrameReceived&&r._closeFrameSent,this.reason=e,this.code=t}}class o extends n{constructor(t){super("open",t)}}class h extends n{constructor(t,e){super("error",e),this.message=t.message,this.error=t}}const a={addEventListener(t,e){function r(t){e.call(this,new s(t,this))}function n(t,r){e.call(this,new i(t,r,this))}function a(t){e.call(this,new h(t,this))}function c(){e.call(this,new o(this))}"function"==typeof e&&("message"===t?(r._listener=e,this.on(t,r)):"close"===t?(n._listener=e,this.on(t,n)):"error"===t?(a._listener=e,this.on(t,a)):"open"===t?(c._listener=e,this.on(t,c)):this.on(t,e))},removeEventListener(t,e){const r=this.listeners(t);for(let n=0;n<r.length;n++)r[n]!==e&&r[n]._listener!==e||this.removeListener(t,r[n])}};t.exports=a},function(t,e,r){const n=r(0)("wx-ws:sender");t.exports=class{constructor(t){this._socket=t,this._queue=[],this._bufferedBytes=0,this._deflating=!1}send(t,e,r){n("send msg: ",t," sender: ",this,this._deflating),this._deflating?this.enqueue([this.dispatch,t,e,r]):this.dispatch(t,e,r)}dispatch(t,e,r){n("dispatch msg: ",t,", sender: ",this),this._deflating=!0,"function"==typeof e&&(r=e,e={}),this._deflating=!1,this._socket.send({data:t,success:t=>r&&r(null,t),fail:t=>r&&r(t)}),this.dequeue()}dequeue(){for(;!this._deflating&&this._queue.length;){const t=this._queue.shift();this._bufferedBytes-=t[1].length,Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[1].length,this._queue.push(t)}}},function(t,e,r){e.encode=r(43),e.decode=r(44)},function(t,e,r){"use strict";function n(t,e,r){for(var n=0,s=0,i=r.length;s<i;s++)(n=r.charCodeAt(s))<128?t.setUint8(e++,n):n<2048?(t.setUint8(e++,192|n>>6),t.setUint8(e++,128|63&n)):n<55296||n>=57344?(t.setUint8(e++,224|n>>12),t.setUint8(e++,128|n>>6&63),t.setUint8(e++,128|63&n)):(s++,n=65536+((1023&n)<<10|1023&r.charCodeAt(s)),t.setUint8(e++,240|n>>18),t.setUint8(e++,128|n>>12&63),t.setUint8(e++,128|n>>6&63),t.setUint8(e++,128|63&n))}t.exports=function(t){var e=[],r=[],s=function t(e,r,n){var s=typeof n,i=0,o=0,h=0,a=0,c=0,u=0;if("string"===s){if((c=function(t){for(var e=0,r=0,n=0,s=t.length;n<s;n++)(e=t.charCodeAt(n))<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(n++,r+=4);return r}(n))<32)e.push(160|c),u=1;else if(c<256)e.push(217,c),u=2;else if(c<65536)e.push(218,c>>8,c),u=3;else{if(!(c<4294967296))throw new Error("String too long");e.push(219,c>>24,c>>16,c>>8,c),u=5}return r.push({_str:n,_length:c,_offset:e.length}),u+c}if("number"===s)return Math.floor(n)===n&&isFinite(n)?n>=0?n<128?(e.push(n),1):n<256?(e.push(204,n),2):n<65536?(e.push(205,n>>8,n),3):n<4294967296?(e.push(206,n>>24,n>>16,n>>8,n),5):(h=n/Math.pow(2,32)>>0,a=n>>>0,e.push(207,h>>24,h>>16,h>>8,h,a>>24,a>>16,a>>8,a),9):n>=-32?(e.push(n),1):n>=-128?(e.push(208,n),2):n>=-32768?(e.push(209,n>>8,n),3):n>=-2147483648?(e.push(210,n>>24,n>>16,n>>8,n),5):(h=Math.floor(n/Math.pow(2,32)),a=n>>>0,e.push(211,h>>24,h>>16,h>>8,h,a>>24,a>>16,a>>8,a),9):(e.push(203),r.push({_float:n,_length:8,_offset:e.length}),9);if("object"===s){if(null===n)return e.push(192),1;if(Array.isArray(n)){if((c=n.length)<16)e.push(144|c),u=1;else if(c<65536)e.push(220,c>>8,c),u=3;else{if(!(c<4294967296))throw new Error("Array too large");e.push(221,c>>24,c>>16,c>>8,c),u=5}for(i=0;i<c;i++)u+=t(e,r,n[i]);return u}if(n instanceof Date){var f=n.getTime();return h=Math.floor(f/Math.pow(2,32)),a=f>>>0,e.push(215,0,h>>24,h>>16,h>>8,h,a>>24,a>>16,a>>8,a),10}if(n instanceof ArrayBuffer){if((c=n.byteLength)<256)e.push(196,c),u=2;else if(c<65536)e.push(197,c>>8,c),u=3;else{if(!(c<4294967296))throw new Error("Buffer too large");e.push(198,c>>24,c>>16,c>>8,c),u=5}return r.push({_bin:n,_length:c,_offset:e.length}),u+c}if("function"==typeof n.toJSON)return t(e,r,n.toJSON());var p=[],l="",d=Object.keys(n);for(i=0,o=d.length;i<o;i++)"function"!=typeof n[l=d[i]]&&p.push(l);if((c=p.length)<16)e.push(128|c),u=1;else if(c<65536)e.push(222,c>>8,c),u=3;else{if(!(c<4294967296))throw new Error("Object too large");e.push(223,c>>24,c>>16,c>>8,c),u=5}for(i=0;i<c;i++)u+=t(e,r,l=p[i]),u+=t(e,r,n[l]);return u}if("boolean"===s)return e.push(n?195:194),1;if("undefined"===s)return e.push(212,0,0),3;throw new Error("Could not encode")}(e,r,t),i=new ArrayBuffer(s),o=new DataView(i),h=0,a=0,c=-1;r.length>0&&(c=r[0]._offset);for(var u,f=0,p=0,l=0,d=e.length;l<d;l++)if(o.setUint8(a+l,e[l]),l+1===c){if(f=(u=r[h])._length,p=a+c,u._bin)for(var g=new Uint8Array(u._bin),y=0;y<f;y++)o.setUint8(p+y,g[y]);else u._str?n(o,p,u._str):void 0!==u._float&&o.setFloat64(p,u._float);a+=f,r[++h]&&(c=r[h]._offset)}return i}},function(t,e,r){"use strict";function n(t){if(this._offset=0,t instanceof ArrayBuffer)this._buffer=t,this._view=new DataView(this._buffer);else{if(!ArrayBuffer.isView(t))throw new Error("Invalid argument");this._buffer=t.buffer,this._view=new DataView(this._buffer,t.byteOffset,t.byteLength)}}n.prototype._array=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=this._parse();return e},n.prototype._map=function(t){for(var e={},r=0;r<t;r++)e[this._parse()]=this._parse();return e},n.prototype._str=function(t){var e=function(t,e,r){for(var n="",s=0,i=e,o=e+r;i<o;i++){var h=t.getUint8(i);if(0!=(128&h))if(192!=(224&h))if(224!=(240&h)){if(240!=(248&h))throw new Error("Invalid byte "+h.toString(16));(s=(7&h)<<18|(63&t.getUint8(++i))<<12|(63&t.getUint8(++i))<<6|(63&t.getUint8(++i))<<0)>=65536?(s-=65536,n+=String.fromCharCode(55296+(s>>>10),56320+(1023&s))):n+=String.fromCharCode(s)}else n+=String.fromCharCode((15&h)<<12|(63&t.getUint8(++i))<<6|(63&t.getUint8(++i))<<0);else n+=String.fromCharCode((31&h)<<6|63&t.getUint8(++i));else n+=String.fromCharCode(h)}return n}(this._view,this._offset,t);return this._offset+=t,e},n.prototype._bin=function(t){var e=this._buffer.slice(this._offset,this._offset+t);return this._offset+=t,e},n.prototype._parse=function(){var t,e=this._view.getUint8(this._offset++),r=0,n=0,s=0,i=0;if(e<192)return e<128?e:e<144?this._map(15&e):e<160?this._array(15&e):this._str(31&e);if(e>223)return-1*(255-e+1);switch(e){case 192:return null;case 194:return!1;case 195:return!0;case 196:return r=this._view.getUint8(this._offset),this._offset+=1,this._bin(r);case 197:return r=this._view.getUint16(this._offset),this._offset+=2,this._bin(r);case 198:return r=this._view.getUint32(this._offset),this._offset+=4,this._bin(r);case 199:return r=this._view.getUint8(this._offset),n=this._view.getInt8(this._offset+1),this._offset+=2,[n,this._bin(r)];case 200:return r=this._view.getUint16(this._offset),n=this._view.getInt8(this._offset+2),this._offset+=3,[n,this._bin(r)];case 201:return r=this._view.getUint32(this._offset),n=this._view.getInt8(this._offset+4),this._offset+=5,[n,this._bin(r)];case 202:return t=this._view.getFloat32(this._offset),this._offset+=4,t;case 203:return t=this._view.getFloat64(this._offset),this._offset+=8,t;case 204:return t=this._view.getUint8(this._offset),this._offset+=1,t;case 205:return t=this._view.getUint16(this._offset),this._offset+=2,t;case 206:return t=this._view.getUint32(this._offset),this._offset+=4,t;case 207:return s=this._view.getUint32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,s+i;case 208:return t=this._view.getInt8(this._offset),this._offset+=1,t;case 209:return t=this._view.getInt16(this._offset),this._offset+=2,t;case 210:return t=this._view.getInt32(this._offset),this._offset+=4,t;case 211:return s=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,s+i;case 212:return n=this._view.getInt8(this._offset),this._offset+=1,0===n?void(this._offset+=1):[n,this._bin(1)];case 213:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(2)];case 214:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(4)];case 215:return n=this._view.getInt8(this._offset),this._offset+=1,0===n?(s=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,new Date(s+i)):[n,this._bin(8)];case 216:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(16)];case 217:return r=this._view.getUint8(this._offset),this._offset+=1,this._str(r);case 218:return r=this._view.getUint16(this._offset),this._offset+=2,this._str(r);case 219:return r=this._view.getUint32(this._offset),this._offset+=4,this._str(r);case 220:return r=this._view.getUint16(this._offset),this._offset+=2,this._array(r);case 221:return r=this._view.getUint32(this._offset),this._offset+=4,this._array(r);case 222:return r=this._view.getUint16(this._offset),this._offset+=2,this._map(r);case 223:return r=this._view.getUint32(this._offset),this._offset+=4,this._map(r)}throw new Error("Could not parse")},t.exports=function(t){var e=new n(t),r=e._parse();if(e._offset!==t.byteLength)throw new Error(t.byteLength-e._offset+" trailing bytes");return r}},function(t,e){function r(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=r,r.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-r:t+r}return 0|Math.min(t,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(t){this.ms=t},r.prototype.setMax=function(t){this.max=t},r.prototype.setJitter=function(t){this.jitter=t}}])}));