@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.10 → 1.0.0-cg.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rtm.min.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rtm=t():e.rtm=t()}("undefined"!=typeof globalThis?globalThis:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=18)}([function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1),i=o.msgpack,s=o.Int64BE,a=o.Uint64BE,u={RTM_EC_UNKNOWN_METHOD:20004,RTM_EC_INVALID_PROJECT_ID_OR_USER_ID:200001,RTM_EC_INVALID_PROJECT_ID_OR_SIGN:200002,RTM_EC_INVALID_FILE_OR_SIGN_OR_TOKEN:200003,RTM_EC_ATTRS_WITHOUT_SIGN_OR_EXT:200004,RTM_EC_API_FREQUENCY_LIMITED:200010,RTM_EC_MESSAGE_FREQUENCY_LIMITED:200011,RTM_EC_FORBIDDEN_METHOD:200020,RTM_EC_PERMISSION_DENIED:200021,RTM_EC_UNAUTHORIZED:200022,RTM_EC_DUPLCATED_AUTH:200023,RTM_EC_AUTH_DENIED:200024,RTM_EC_ADMIN_LOGIN:200025,RTM_EC_ADMIN_ONLY:200026,RTM_EC_INVALID_AUTH_TOEKN:200027,RTM_EC_LARGE_MESSAGE_OR_ATTRS:200030,RTM_EC_LARGE_FILE_OR_ATTRS:200031,RTM_EC_TOO_MANY_ITEMS_IN_PARAMETERS:200032,RTM_EC_EMPTY_PARAMETER:200033,RTM_EC_INVALID_PARAMETER:200034,RTM_EC_NOT_IN_ROOM:200040,RTM_EC_NOT_GROUP_MEMBER:200041,RTM_EC_MAX_GROUP_MEMBER_COUNT:200042,RTM_EC_NOT_FRIEND:200043,RTM_EC_BANNED_IN_GROUP:200044,RTM_EC_BANNED_IN_ROOM:200045,RTM_EC_EMPTY_GROUP:200046,RTM_EC_ENTER_TOO_MANY_ROOMS:200047,RTM_EC_UNSUPPORTED_LANGUAGE:200050,RTM_EC_EMPTY_TRANSLATION:200051,RTM_EC_SEND_TO_SELF:200052,RTM_EC_DUPLCATED_MID:200053,RTM_EC_SENSITIVE_WORDS:200054,RTM_EC_UNKNOWN_ERROR:200999},c={image:40,audio:41,video:42,file:50},f={text:30,audio:31,cmd:32},l={kickOut:"kickout",kickOutRoom:"kickoutroom",recvMessage:"pushmsg",recvGroupMessage:"pushgroupmsg",recvRoomMessage:"pushroommsg",recvBroadcastMessage:"pushbroadcastmsg",recvFile:"pushfile",recvGroupFile:"pushgroupfile",recvRoomFile:"pushroomfile",recvBroadcastFile:"pushbroadcastfile",recvPing:"ping",recvChat:"pushchat",recvAudio:"pushaudio",recvCmd:"pushcmd",recvGroupChat:"pushgroupchat",recvGroupAudio:"pushgroupaudio",recvGroupCmd:"pushgroupcmd",recvRoomChat:"pushroomchat",recvRoomAudio:"pushroomaudio",recvRoomCmd:"pushroomcmd",recvBroadcastChat:"pushbroadcastchat",recvBroadcastAudio:"pushbroadcastaudio",recvBroadcastCmd:"pushbroadcastcmd"},h={kickOut:"event.kicked",kickOutRoom:"event.room_removed",recvBroadcastMessage:"event.broadcast",recvGroupMessage:"event.group",recvMessage:"event.direct",recvRoomMessage:"event.room"},d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"ERROR_CODE",get:function(){return u}},{key:"MsgPack",get:function(){return i}},{key:"FILE_TYPE",get:function(){return c}},{key:"CHAT_TYPE",get:function(){return f}},{key:"SERVER_PUSH",get:function(){return l}},{key:"TLV_SERVER_PUSH",get:function(){return h}},{key:"MID_TTL",get:function(){return 5e3}},{key:"API_VERSION",get:function(){return"2.7.3"}},{key:"SDK_VERSION",get:function(){return"2.7.6"}},{key:"MAX_PING_SECONDS",get:function(){return 60}}]),e}();d.Int64=function(e){return new s(""+e)},d.Uint64=function(e){return new a(""+e)},e.exports=d},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=function(){if(i.fpnn)return i.fpnn;var e="undefined"!=typeof self&&"function"==typeof self.importScripts&&"function"==typeof self.WebSocket;return"undefined"!=typeof window||e?r(22):{FPClient:function e(){throw o(this,e),new Error('protocol: "fpnn" requires the browser FPNN runtime; use protocol: "tlv-v1" with WebSocket or webSocketFactory')},FPConfig:{ERROR_CODE:{FPNN_EC_OK:0,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_INVALID_CONNECTION:20012}},FPError:function(e){function t(e,r){o(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n.message));return i.code=e,i.name="FPError",i.stack=n.stack||i.stack,i.error=n,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),n(t,[{key:"toString",value:function(){return"code: "+this.code+" ex: "+this.message}}]),t}(),FPEvent:{assign:function(e){if(!e||Object.prototype.hasOwnProperty.call(e,"events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(Object.prototype.hasOwnProperty.call(e,"on")||Object.prototype.hasOwnProperty.call(e,"emit")||Object.prototype.hasOwnProperty.call(e,"removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){Object.prototype.hasOwnProperty.call(e.events,t)||(e.events[t]=[]),-1===e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(t){var r=Array.prototype.slice.call(arguments,1);(e.events[t]||[]).slice().forEach((function(t){t&&t.apply(e,r)}))},e.removeEvent=function(t,r){if(0===arguments.length)e.events={};else if(1===arguments.length)Object.prototype.hasOwnProperty.call(e.events,t)&&delete e.events[t];else if(e.events[t]){var n=e.events[t].indexOf(r);-1!==n&&e.events[t].splice(n,1)}},e.listenerCount=function(t){return Object.prototype.hasOwnProperty.call(e.events,t)?e.events[t].length:0}}}}}(),a=i.msgpack||r(23),u=i.md5||r(24),c=i.Int64BE&&i.Uint64BE?{Int64BE:i.Int64BE,Uint64BE:i.Uint64BE}:r(27);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:c.Int64BE,Uint64BE:c.Uint64BE}},function(e,t,r){"use strict";(function(t){var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(0),i=r(8),s=r(9),a=r(5),u=r(1),c=u.fpnn,f=u.md5,l=r(6).normalizeFpnnEndpoint,h=r(12).normalizeClientOptions;function d(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function p(e){var t=c.FPConfig.ERROR_CODE;return e===t.FPNN_EC_CORE_INVALID_CONNECTION||e===t.FPNN_EC_CORE_CONNECTION_CLOSED||e===t.FPNN_EC_CORE_UNKNOWN_ERROR||e===o.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function g(e,t){return!e&&!p(t)}function y(e,t){if(this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),null!=this._baseClient){var r=this._baseClient;this._baseClient=null,r.destroy()}"tlv-v1"===this._protocol?this._baseClient=new s({endpoint:this._tlvEndpoint,heartbeatIdleMs:this._tlvHeartbeatIdleMs,heartbeatTimeoutMs:this._tlvHeartbeatTimeoutMs,connectionTimeout:this._connectionTimeout,legacyMsgOptions:this._msgOptions,pushDedupTtlMs:this._pushDedupTtlMs,requestMetadata:this._requestMetadata,requestTimeout:this._requestTimeout,webSocketFactory:this._webSocketFactory}):this._baseClient=new c.FPClient({endpoint:d.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,o=this,i=!1,a=!1,u=!1,f=!1;function l(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===o._baseClient&&(a||f||(f=!0,l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===o._protocol&&_.call(o)))})),n.on("error",(function(e){n===o._baseClient&&(a||b.call(o,e),i||l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===o._baseClient&&(i||(i=!0,o._requireClose=!1,m.call(o,(function(e,t){if(e)a=!0;else if("tlv-v1"===o._protocol&&g(e,t))o._canReconnect=!1;else if("tlv-v1"===o._protocol&&!f&&n===o._baseClient)return l(e,t),void n.close();l(e,t)}),t)))})),n.processor=this._processor,n.connect()}function m(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+o.SDK_VERSION};this._attrs&&(n.attrs=this._attrs),"tlv-v1"===this._protocol&&(void 0!==this._authSec&&(n.ts=this._authSec),void 0!==this._authVer&&(n.authv=this._authVer),void 0!==this._locale&&(n.lang=this._locale));var i={flag:1,method:"auth",payload:o.MsgPack.encode(n,this._msgOptions)},s=this;A.call(this,r,i,(function(t,n){if(r===s._baseClient){var i=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(i)return s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0,s._canReconnect=!0,r.on("close",(function(){r===s._baseClient&&_.call(s)})),r.on("error",(function(e){r===s._baseClient&&b.call(s,e)})),"tlv-v1"===s._protocol?r.markAuthenticated():(s._lastPingTime=parseInt(Date.now()/1e3),s._checkLastPingTimerID=setInterval((function(){parseInt(Date.now()/1e3)-s._lastPingTime>=s._maxPingIntervalSeconds&&(b.call(s,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,Error("Close connection for no ping, start reconnect"))),s.startAutoReconnect())}),1e3*s._maxPingIntervalSeconds/2)),void(e&&e(!0,c.FPConfig.ERROR_CODE.FPNN_EC_OK));var a=!1;if(n&&!i){var u="tlv-v1"===s._protocol?o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&b.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),b.call(s,t),a="tlv-v1"===s._protocol?p(t.code):!!s._reconnectTimeout),a||(s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0)}}),t)}else e&&e(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION)}function _(){return this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this._requireClose?(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_OK),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1)):this._autoReconnect?(b.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void v.call(this)):(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1))}function v(){if(!this._requireClose&&this._canReconnect&&!this._reconnectTimeout){var e=0;this._reconnectCount>=this._regressiveStrategy.startConnectFailedCount&&((e=this._reconnectInterval+1e3*this._regressiveStrategy.maxIntervalSeconds/this._regressiveStrategy.linearRegressiveCount)>1e3*this._regressiveStrategy.maxIntervalSeconds&&(e=1e3*this._regressiveStrategy.maxIntervalSeconds),this._reconnectInterval=e),this._reconnectCount+=1;var t=this._reconnectCount,r=this;this._reconnectTimeout=setTimeout((function(){r._reconnectTimeout=0;var n="tlv-v1"===r._protocol?void 0:e;r.login(r._uid,r._token,(function(e,n){n==c.FPConfig.ERROR_CODE.FPNN_EC_OK?e?(r.emit("ReloginCompleted",!0,!1,c.FPConfig.ERROR_CODE.FPNN_EC_OK,t),b.call(r,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_OK,new Error("relogin successfully, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0):(r.emit("ReloginCompleted",!1,!1,o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, token error, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):"tlv-v1"===r._protocol&&g(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),b.call(r,new c.FPError(n,new Error("relogin terminal auth failure, errorCode: "+n+", reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):(r.emit("ReloginCompleted",!1,!0,n,t),"tlv-v1"!==r._protocol&&v.call(r),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function b(e){this.emit("ErrorRecorder",e)}function w(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function E(e,r,n,i,s){var a=this;n&&"0"!=n.toString()||(n=P.call(this)),k.call(a,e,(function(u,f){if(u)i&&i({mid:n,error:u},null);else{var l=f.token,h=f.endpoint,d=null;if(null!=r&&void 0!==r.name){var p=r.name.lastIndexOf(".");-1!=p&&(d=r.name.slice(p+1))}if(l&&h){var g=new FileReader;g.onload=function(r){var u=t.from(r.target.result);if(console.log("content:"),console.log(u.length),u){var f=w.call(a,u).toLowerCase(),p=w.call(a,f+":"+l).toLowerCase(),g=a._endpoint.split(":"),y="ws://fileproxy-"+g[0]+":13461/service/websocket";a._ssl&&(y="wss://fileproxy-"+g[0]+":13462/service/websocket");var m=new c.FPClient({endpoint:y,autoReconnect:!1,connectionTimeout:s,platformImpl:a._platformImpl});m.on("close",(function(){})),m.on("error",(function(e){var t=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),b.call(a,new c.FPError(t,e))})),m.on("connect",(function(){var t={token:l,sign:p,ext:d,file:u,endpoint:h};for(var r in e)t[r]=e[r];R.call(a,m,t,n,i,s)})),m.connect()}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function k(e,t,r){var n={};for(var i in e)"mtype"!=i&&(n[i]=e[i]);var s={flag:1,method:"filetoken",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,s,t,r)}function R(e,t,r,n,i){var s={pid:this._pid,from:this._uid,mid:r,endpoint:t.endpoint};for(var a in t)"sign"!=a?"ext"!=a&&"cmd"!=a&&(s[a]=t[a]):s.attrs=JSON.stringify({rtm:{sign:t.sign,ext:t.ext}});var u={flag:1,method:t.cmd,payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,e,u,(function(t,r){e.destroy(),t?n&&n({mid:s.mid,error:t},null):(void 0!==r.mtime&&(r.mtime=new o.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),i)}function P(){++this._midSeq>=999&&(this._midSeq=0);var e=this._midSeq.toString();return this._midSeq<100&&(e="0"+e),this._midSeq<10&&(e="0"+e),new o.Int64(Date.now().toString()+e)}function C(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:P.call(this)}function O(e,t,r){var n="boolean"==typeof e;return n?"function"==typeof t&&void 0===r&&(r=t,t=void 0):"function"==typeof t&&void 0===r?(r=t,t=e):void 0===t&&("function"==typeof e&&void 0===r?r=e:void 0!==e&&(t=e)),{value:n?e:void 0,provided:n,timeout:t,callback:r}}function T(e,t){if(!t)return new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;return void 0!==t.code&&(r=t.code),new c.FPError(r,t)}if(e){if(t.hasOwnProperty("code")&&t.hasOwnProperty("ex"))return new c.FPError(t.code,new Error(t.ex));if(t.hasOwnProperty("status")&&t.hasOwnProperty("reason")){var n=new c.FPError(t.status,new Error(t.reason));return n.status=t.status,n.reason=t.reason,n}}return null}function A(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=this;e?e.sendQuest(t,(function(e){if(r){var t=null,n=!1;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload"))return 2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,e._tlvPayload))?void(r&&r(t,null)):void(r&&r(null,e._tlvPayload));if(e&&e.payload){var a=null;return a=i?o.MsgPack.decode(e.payload,s._binaryOptions):o.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=T.call(s,n,e))?r&&r(t,null):r&&r(null,e)}}),n):r&&r(new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION,Error("invalid connection")),null)}function S(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var M=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=h(t),c.FPEvent.assign(this),this._protocol=t.protocol,this._endpoint=t.endpoint,this._pid=t.pid,this._attrs=t.attrs,this._autoReconnect=void 0===t.autoReconnect||t.autoReconnect,this._connectionTimeout=t.connectionTimeout||3e4,this._maxPingIntervalSeconds=o.MAX_PING_SECONDS,this._platformImpl=void 0,this._requestMetadata=t.requestMetadata||t.requestMetadataProvider,this._requestTimeout=t.requestTimeout||2e4,this._tlvHeartbeatIdleMs=t.tlvHeartbeatIdleMs||3e4,this._tlvHeartbeatTimeoutMs=t.tlvHeartbeatTimeoutMs||1e4,this._pushDedupTtlMs=t.pushDedupTtlMs||3e4,this._webSocketFactory=t.webSocketFactory,this._authSec=t.authSec,this._authVer=t.authVer,this._locale=t.locale,this._clientVersion=t.clientVersion,void 0!==t.maxPingIntervalSeconds&&(this._maxPingIntervalSeconds=t.maxPingIntervalSeconds),this._lastPingTime=0,this._checkLastPingTimerID=0,this._regressiveStrategy={startConnectFailedCount:3,maxIntervalSeconds:8,linearRegressiveCount:4},void 0!==t.regressiveStrategy&&void 0!==t.regressiveStrategy.startConnectFailedCount&&void 0!==t.regressiveStrategy.maxIntervalSeconds&&void 0!==t.regressiveStrategy.linearRegressiveCount&&(this._regressiveStrategy.startConnectFailedCount=t.regressiveStrategy.startConnectFailedCount,this._regressiveStrategy.maxIntervalSeconds=t.regressiveStrategy.maxIntervalSeconds,this._regressiveStrategy.linearRegressiveCount=t.regressiveStrategy.linearRegressiveCount),this._canReconnect=!1,this._reconnectCount=0,this._reconnectInterval=0,this._ssl=!1,"tlv-v1"===this._protocol)this._tlvEndpoint=t.tlvEndpoint;else{var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:t.endpoint;this._endpoint=r?n:l(n),this._ssl=r}void 0!==t.platformImpl&&(this._platformImpl=t.platformImpl),this._md5=t.md5||null,this._midSeq=0,this._saltSeq=0,this._baseClient=null,this._reconnectTimeout=0,this._requireClose=!1,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})};var s=this;this._processor=new i(this);var u=function(){s._requireClose=!0,s._canReconnect=!1,"tlv-v1"!==s._protocol&&s._baseClient&&s._baseClient.close()};this._processor.on(o.SERVER_PUSH.kickOut,u),this._processor.on(o.TLV_SERVER_PUSH.kickOut,u),this.promises=a(this,e.prototype)}return n(e,[{key:"login",value:function(e,t,r,n){this._uid=e,this._token=t,this._processor&&(this._processor.uid=this._uid),y.call(this,r,n)}},{key:"bye",value:function(e,t){"function"==typeof e&&(t=e,e=void 0);var r={flag:1,method:"bye",payload:o.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,A.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(b.call(n,e),n._baseClient&&n._baseClient.close()):n._baseClient&&n._baseClient.close(),t&&t(e||null,r)}),e)}},{key:"getServerTime",value:function(e,t){var r={flag:1,method:"getservertime",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new o.Int64(""+r.mts)),t&&t(null,r))}),e)}},{key:"close",value:function(){this._requireClose=!0,this._baseClient&&this._baseClient.close()}},{key:"startAutoReconnect",value:function(){this._requireClose=!1,this._baseClient&&this._baseClient.close()}},{key:"destroy",value:function(){this.close(),this._midSeq=0,this._saltSeq=0,this._processor&&(this._processor.destroy(),this._processor=null),this._baseClient&&(this._baseClient.destroy(),this._baseClient=null),this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this.removeEvent()}},{key:"sendMessage",value:function(e,t,r,n,i,s,a){var u={to:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendMessages",value:function(e,t,r,n,i,s,a){var u={tos:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendGroupMessage",value:function(e,t,r,n,i,s,a){var u={gid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendRoomMessage",value:function(e,t,r,n,i,s,a){var u={rid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"getUnreadMessage",value:function(e,t,r,n){var i=O(t,r,n);t=i.value,r=i.timeout,n=i.callback;var s={clear:void 0!==e&&e};void 0!==t&&(s.gettime=t);var a={flag:1,method:"getunread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(""+e)})),t.p2p=i}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,i){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,i){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,i){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var i=[];n.forEach((function(e,t){i[t]=new o.Int64(""+e)})),r.p2p=i}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,i,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,i,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,i,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==i&&(c.lastid=i),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,(function(e,t){if(e)u&&u(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,i,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,o,i,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==o&&(u.end=o),void 0!==i&&(u.mtypes=i),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,i){var s={flag:1,method:e,payload:o.MsgPack.encode(t,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?i&&i(e,null):i&&i(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var i={id:new o.Int64(""+e[0]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:S(e[5]),binary:e[5],attrs:S(e[6]),mtime:new o.Int64(""+e[7])};t?i.direction=Number(e[1]):i.from=new o.Int64(""+e[1]),r[n]=i})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getGroupMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getRoomMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,o){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,o)}},{key:"_getMessageCount",value:function(e,t,r,n){var i={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(i[e]=t[e])}));var s={flag:1,method:e,payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,o,i,s){var a={cmd:e};void 0!==t&&(a.tos=t),void 0!==r&&(a.to=r),void 0!==n&&(a.rid=n),void 0!==o&&(a.gid=o),k.call(this,a,s,i)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},i={flag:1,method:"addattrs",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var i={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var i={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},i={flag:1,method:"removedevice",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},i={flag:1,method:"setlang",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"translate",value:function(e,t,r,n,i,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==i&&(u.profanity=i);var c={flag:1,method:"translate",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var i={text:e};void 0!==t&&(i.classify=t);var s={flag:1,method:"profanity",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"textCheck",value:function(e,t,r,n){"function"==typeof t?(n=t,t=void 0,r=void 0):arguments.length<4&&"number"==typeof t&&(void 0===r||"function"==typeof r)&&(n="function"==typeof r?r:n,r=t,t=void 0);var i={text:e};void 0!==t&&(i.strategyId=t);var s={flag:1,method:"tcheck",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,i){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"audioCheck",value:function(e,t,r,n,i,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==i&&(c.srate=i),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,i,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"speech2Text",value:function(e,t,r,n,i,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==i&&(u.srate=i);var c={flag:1,method:"speech2text",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},i={flag:1,method:"getgroupsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroommembers",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomcount",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"addfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"delfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(t&&t(null,i))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(e)})),t.uids=i}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupcount",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?n&&n(e,null):n&&n(null,t)}),r)}},{key:"getUserGroups",value:function(e,t){var r={flag:1,method:"getusergroups",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"enterroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},i={flag:1,method:"enterrooms",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"leaveroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"getUserRoomsAndLastMessage",value:function(e,t,r){var n={};void 0!==e&&(n.mtypes=e);var i={flag:1,method:"getuserroomsandlastmsg",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getonlineusers",payload:o.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";A.call(this,this._baseClient,i,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(r&&r(null,i))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"getMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new o.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new o.Int64(""+t.mtime)),s&&s(null,t))}),i,!0)}},{key:"sendChat",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendAudio",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendCmd",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendGroupChat",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendRoomChat",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"getGroupChat",value:function(e,t,r,n,i,s,a,u){this.getGroupMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,i,s,a,u){this.getRoomMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,i,s,a,u){this.getP2PMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,i,s,a){this.getBroadcastMessage.call(this,e,t,r,n,i,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,o,i){this.deleteMessage(e,t,r,n,o,i)}},{key:"getChat",value:function(e,t,r,n,o,i){this.getMessage(e,t,r,n,o,i)}},{key:"setUserInfo",value:function(e,t,r,n){var i={};void 0!==e&&(i.oinfo=e),void 0!==t&&(i.pinfo=t);var s={flag:1,method:"setuserinfo",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getuseropeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,i){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupinfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,i){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"setRoomProfile",value:function(e,t,r,n,i,s,a){var u={rid:e};void 0!==t&&(u.oinfo=t),void 0!==r&&(u.pinfo=r),void 0!==n&&(u.name=n),void 0!==i&&(u.icon=i);var c={flag:1,method:"setroominfo",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroominfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroomopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataSet",value:function(e,t,r,n){var i={key:e,val:t},s={flag:1,method:"dataset",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},i={flag:1,method:"dataget",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},i={flag:1,method:"datadel",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"addblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"delblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,o,i){var s={to:t,mtype:e,cmd:"sendfile"};E.call(this,s,r,n,i,o)}},{key:"sendGroupFile",value:function(e,t,r,n,o,i){var s={gid:t,mtype:e,cmd:"sendgroupfile"};E.call(this,s,r,n,i,o)}},{key:"sendRoomFile",value:function(e,t,r,n,o,i){var s={rid:t,mtype:e,cmd:"sendroomfile"};E.call(this,s,r,n,i,o)}},{key:"getP2PConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,i){var s={};void 0!==e&&(s.clear=e),void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getunreadconversationlist",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeSession",value:function(e,t,r,n){var i=O(t,r,n),s=i.provided;t=!!s&&i.value,r=i.timeout,n=i.callback;var a={to:e};("tlv-v1"===this._protocol||s)&&(a.oneway=t);var u={flag:1,method:"removesession",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=M}).call(this,r(7).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(e){function t(e){i(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVMsgPackError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}(),a=function(){function e(t,r,n){i(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return o(e,[{key:"isNegative",value:function(){return this.signed&&0!=(2147483648&this.high)}},{key:"toString",value:function(){if(!this.isNegative())return c(this.high,this.low);var e=u(this.high,this.low);return"-"+c(e.high,e.low)}},{key:"valueOf",value:function(){return Number(this.toString())}}]),e}();function u(e,t){var r=1+~t>>>0,n=~e>>>0;return 0===r&&(n=n+1>>>0),{high:n,low:r}}function c(e,t){var r=[e>>>0];f(r,65536),f(r,65536),function(e,t){var r=t,n=0;for(;r>0;){n===e.length&&e.push(0);var o=e[n]+r;e[n]=o%1e7,r=Math.floor(o/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),o=r.length-2;o>=0;o-=1)n+=String(r[o]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var o=e[n]*t+r;e[n]=o%1e7,r=Math.floor(o/1e7)}for(;r>0;)e.push(r%1e7),r=Math.floor(r/1e7)}function l(e){return Number.isSafeInteger?Number.isSafeInteger(e):"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}function h(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function d(e){if(e instanceof Uint8Array)return e;if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer)return new Uint8Array(e);if("undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if("undefined"!=typeof ArrayBuffer&&e&&"[object ArrayBuffer]"===Object.prototype.toString.call(e))try{return new Uint8Array(ArrayBuffer.prototype.slice.call(e,0))}catch(e){}return null}function p(e){var t=d(e);if(!t)throw new s("expected binary data");return t}function g(e){if("string"!=typeof e)throw new s("expected UTF-8 string");if(function(e){for(var t=0;t<e.length;t+=1){var r=e.charCodeAt(t);if(r>=55296&&r<=56319){var n=e.charCodeAt(t+1);if(n<56320||n>57343)throw new s("string contains an unpaired surrogate");t+=1}else if(r>=56320&&r<=57343)throw new s("string contains an unpaired surrogate")}}(e),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var t=[],r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319)n=65536+(n-55296<<10)+(e.charCodeAt(r+1)-56320),r+=1;n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):n<=65535?t.push(224|n>>12,128|n>>6&63,128|63&n):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function y(e){var t=p(e);if("undefined"!=typeof TextDecoder)try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(e){throw new s("invalid UTF-8 string")}for(var r="",n=0;n<t.length;n+=1){var o=t[n],i=void 0;if(o<=127)i=o;else if(o>=194&&o<=223){i=(31&o)<<6|63&m(t,n+1),n+=1}else if(o>=224&&o<=239){var a=m(t,n+1),u=m(t,n+2);if(224===o&&a<160||237===o&&a>159)throw new s("invalid UTF-8 string");i=(15&o)<<12|(63&a)<<6|63&u,n+=2}else{if(!(o>=240&&o<=244))throw new s("invalid UTF-8 string");var c=m(t,n+1),f=m(t,n+2),l=m(t,n+3);if(240===o&&c<144||244===o&&c>143)throw new s("invalid UTF-8 string");i=(7&o)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(i<=65535)r+=String.fromCharCode(i);else{var h=i-65536;r+=String.fromCharCode(55296|h>>10,56320|1023&h)}}return r}function m(e,t){if(t>=e.length||128!=(192&e[t]))throw new s("invalid UTF-8 string");return e[t]}var _=function(){function e(){i(this,e),this.chunks=[],this.length=0}return o(e,[{key:"byte",value:function(e){this.chunks.push(new Uint8Array([255&e])),this.length+=1}},{key:"bytes",value:function(e){var t=p(e);this.chunks.push(t),this.length+=t.length}},{key:"uint16",value:function(e){this.byte(e>>>8),this.byte(e)}},{key:"uint32",value:function(e){var t=e>>>0;this.byte(t>>>24),this.byte(t>>>16),this.byte(t>>>8),this.byte(t)}},{key:"uint64",value:function(e,t){this.uint32(e),this.uint32(t)}},{key:"finish",value:function(){var e=new Uint8Array(this.length),t=0;return this.chunks.forEach((function(r){e.set(r,t),t+=r.length})),e}}]),e}();function v(e,t,r){if(r>128)throw new s("MessagePack nesting is too deep");if(null==e)throw new s("nil and undefined are not allowed in TLV payloads");var o=void 0===e?"undefined":n(e);if("boolean"!==o)if("string"!==o)if("number"!==o)if("bigint"!==o){if("object"!==o)throw new s("unsupported MessagePack value type: "+o);if(e instanceof a)!function(e,t){if(e.isNegative())return t.byte(211),void t.uint64(e.high,e.low);if(k(e),0===e.high)return void w(e.low,t);t.byte(207),t.uint64(e.high,e.low)}(e,t);else{var i=d(e);if(i)!function(e,t){e.length<=255?(t.byte(196),t.byte(e.length)):e.length<=65535?(t.byte(197),t.uint16(e.length)):(t.byte(198),t.uint32(e.length));t.bytes(e)}(i,t);else if(function(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||e instanceof a)return!1;if("number"!=typeof e.offset||"function"!=typeof e.toString||!e.buffer)return!1;var t=e.buffer,r="number"==typeof t.length?t.length:t.byteLength;return"number"==typeof r&&e.offset>=0&&e.offset+8<=r}(e))!function(e,t){var r=function(e){var t=e.buffer,r=e.offset,n=function(e){return 255&t[r+e]};return{high:16777216*n(0)+65536*n(1)+256*n(2)+n(3)>>>0,low:16777216*n(4)+65536*n(5)+256*n(6)+n(7)>>>0,signed:"-"===String(e).charAt(0)}}(e);if(r.signed)return t.byte(211),void t.uint64(r.high,r.low);if(k(r),0===r.high)return void w(r.low,t);t.byte(207),t.uint64(r.high,r.low)}(e,t);else if(Array.isArray(e))!function(e,t,r){e.length<=15?t.byte(144|e.length):e.length<=65535?(t.byte(220),t.uint16(e.length)):(t.byte(221),t.uint32(e.length));e.forEach((function(e){v(e,t,r)}))}(e,t,r+1);else{if(!h(e))throw new s("unsupported MessagePack object");!function(e,t,r){var n=Object.keys(e);n.length<=15?t.byte(128|n.length):n.length<=65535?(t.byte(222),t.uint16(n.length)):(t.byte(223),t.uint32(n.length));n.forEach((function(n){b(n,t),v(e[n],t,r)}))}(e,t,r+1)}}}else!function(e,t){var r="-"===e.charAt(0),n=function(e){if(!/^[0-9]+$/.test(e))throw new s("invalid integer text");for(var t=0,r=0,n=0;n<e.length;n+=1){var o=10*r+(e.charCodeAt(n)-48);r=o%4294967296;var i=10*t+Math.floor(o/4294967296);if(i>=4294967296)throw new s("integer exceeds uint64");t=i}return{high:t>>>0,low:r>>>0}}(r?e.slice(1):e);if(r){if(n.high>2147483648||2147483648===n.high&&0!==n.low)throw new s("integer is below int64 minimum");var o=u(n.high,n.low);return t.byte(211),void t.uint64(o.high,o.low)}if(k(n),0===n.high)return void w(n.low,t);t.byte(207),t.uint64(n.high,n.low)}(e.toString(),t);else!function(e,t){if(!isFinite(e))throw new s("non-finite numbers are not allowed");if(!l(e))throw new s("floating-point and unsafe integer numbers are not allowed");w(e,t)}(e,t);else b(e,t);else t.byte(e?195:194)}function b(e,t){var r=g(e);r.length<=31?t.byte(160|r.length):r.length<=255?(t.byte(217),t.byte(r.length)):r.length<=65535?(t.byte(218),t.uint16(r.length)):(t.byte(219),t.uint32(r.length)),t.bytes(r)}function w(e,t){if(e>=0)if(e<=127)t.byte(e);else if(e<=255)t.byte(204),t.byte(e);else if(e<=65535)t.byte(205),t.uint16(e);else if(e<=4294967295)t.byte(206),t.uint32(e);else{var r=E(e);t.byte(207),t.uint64(r.high,r.low)}else if(e>=-32)t.byte(256+e);else if(e>=-128)t.byte(208),t.byte(e);else if(e>=-32768)t.byte(209),t.uint16(e);else if(e>=-2147483648)t.byte(210),t.uint32(e);else{var n=function(e){if(e>=0)return E(e);var t=E(-e);return u(t.high,t.low)}(e);t.byte(211),t.uint64(n.high,n.low)}}function E(e){var t=Math.floor(e/4294967296);return{high:t>>>0,low:e-4294967296*t>>>0}}function k(e){if(e.high>=2147483648)throw new s("unsigned integer exceeds the supported int64 range")}var R=function(){function e(t,r){i(this,e),this.bytes=p(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return o(e,[{key:"ensure",value:function(e){if(e<0||this.offset+e>this.bytes.length)throw new s("truncated MessagePack value")}},{key:"byte",value:function(){this.ensure(1);var e=this.bytes[this.offset];return this.offset+=1,e}},{key:"uint16",value:function(){this.ensure(2);var e=256*this.bytes[this.offset]+this.bytes[this.offset+1];return this.offset+=2,e}},{key:"uint32",value:function(){this.ensure(4);var e=16777216*this.bytes[this.offset]+65536*this.bytes[this.offset+1]+256*this.bytes[this.offset+2]+this.bytes[this.offset+3];return this.offset+=4,e>>>0}},{key:"uint64",value:function(e){var t=this.uint32(),r=this.uint32();if(e&&0!=(2147483648&t)){var n=u(t,r);return n.high<2097152?-(4294967296*n.high+n.low):new a(t,r,!0)}if(t>=2147483648)throw new s("unsigned integer exceeds the supported int64 range");return t<2097152?4294967296*t+r:new a(t,r,!!e)}},{key:"int8",value:function(){var e=this.byte();return 128&e?e-256:e}},{key:"int16",value:function(){var e=this.uint16();return 32768&e?e-65536:e}},{key:"int32",value:function(){var e=this.uint32();return e>2147483647?e-4294967296:e}},{key:"float32",value:function(){this.ensure(4);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getFloat32(0,!1);if(this.offset+=4,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"float64",value:function(){this.ensure(8);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,8).getFloat64(0,!1);if(this.offset+=8,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"binary",value:function(e){this.ensure(e);var t=new Uint8Array(e);return t.set(this.bytes.subarray(this.offset,this.offset+e)),this.offset+=e,t}},{key:"string",value:function(e){this.ensure(e);var t=y(this.bytes.subarray(this.offset,this.offset+e));return this.offset+=e,t}},{key:"array",value:function(e,t,r){if(e>this.bytes.length-this.offset)throw new s("truncated MessagePack array");for(var n=new Array(e),o=0;o<e;o+=1)n[o]=this.value(t+1,r.concat(String(o)));return n}},{key:"map",value:function(e,t,r){if(e>Math.floor((this.bytes.length-this.offset)/2))throw new s("truncated MessagePack map");for(var n,o={},i=0;i<e;i+=1){var u=this.value(t+1,r);if("string"!=typeof u){if(!(this._allowsIntegerMapKey(r)&&(n=u,l(n)||n instanceof a)))throw new s("MessagePack map key must be a string");u=String(u)}if(Object.prototype.hasOwnProperty.call(o,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return o}},{key:"_allowsIntegerMapKey",value:function(e){if(!this.allowIntegerMapKeyAtPath||e.length!==this.allowIntegerMapKeyAtPath.length)return!1;for(var t=0;t<e.length;t+=1)if(e[t]!==this.allowIntegerMapKeyAtPath[t])return!1;return!0}},{key:"value",value:function(e,t){if(e>128)throw new s("MessagePack nesting is too deep");var r=this.byte();if(r<=127)return r;if(r>=224)return r-256;if(r>=160&&r<=191)return this.string(31&r);if(r>=144&&r<=159)return this.array(15&r,e,t);if(r>=128&&r<=143)return this.map(15&r,e,t);switch(r){case 192:throw new s("nil is not allowed in TLV payloads");case 194:return!1;case 195:return!0;case 196:return this.binary(this.byte());case 197:return this.binary(this.uint16());case 198:return this.binary(this.uint32());case 202:return this.float32();case 203:return this.float64();case 204:return this.byte();case 205:return this.uint16();case 206:return this.uint32();case 207:return this.uint64(!1);case 208:return this.int8();case 209:return this.int16();case 210:return this.int32();case 211:return this.uint64(!0);case 217:return this.string(this.byte());case 218:return this.string(this.uint16());case 219:return this.string(this.uint32());case 220:return this.array(this.uint16(),e,t);case 221:return this.array(this.uint32(),e,t);case 222:return this.map(this.uint16(),e,t);case 223:return this.map(this.uint32(),e,t);default:throw new s("MessagePack extension and reserved values are not allowed")}}}]),e}();e.exports={Int64Value:a,MsgPackError:s,decodeMap:function(e,t){var r=new R(e,t),n=r.value(0,[]);if(!h(n))throw new s("TLV payload must be a map");if(r.offset!==r.bytes.length)throw new s("MessagePack payload has trailing bytes or values");return n},encodeMap:function(e){if(!h(e))throw new s("TLV payload must be a map");var t=new _;return v(e,t,0),t.finish()},getByteView:d,isPlainMap:h,toUint8Array:p,utf8Decode:y,utf8Encode:g}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,listenerCount:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function o(e,t,r,n){try{e[t].apply(e,r)}catch(e){n(e)}}e.exports=function(e,t){var r={};return Object.getOwnPropertyNames(t).forEach((function(i){if(!n[i]&&"_"!==i.charAt(0)){var s=t[i];if("function"==typeof s){var a="login"===i?2:s.length-1;a<0||Object.defineProperty(r,i,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===i){if(t.length>3)return Promise.reject(new TypeError("promises.login(uid, credential, timeout?)"));var r=t.length>2?t[2]:void 0;return t.length=2,new Promise((function(n,s){t.push((function(e,t){if(e instanceof Error)s(e);else if(e)n({accepted:!0,errorCode:t||0});else{var r=new Error("RTM login rejected ("+String(t)+")");r.code=t,r.status=t,s(r)}}),r),o(e,i,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+i+"()"));for(var n="textCheck"===i&&2===t.length&&"number"==typeof t[1]?2:a;t.length<n;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),o(e,i,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";function n(e){var t=e.split(".");return 4===t.length&&t.every((function(e){return/^\d{1,3}$/.test(e)&&Number(e)<=255}))}function o(e){return/^[0-9a-f]{1,4}$/i.test(e)}e.exports={isValidFpnnEndpoint:function(e){if("string"!=typeof e||0===e.length||e!==e.trim()||/[\s\\/?#@%]/.test(e))return!1;var t=void 0,r=void 0;if("["===e.charAt(0)){var i=e.indexOf("]");if(i<0)return!1;t=e.slice(0,i+1);var s=e.slice(i+1);if(s){if(!/^:\d+$/.test(s))return!1;r=s.slice(1)}if(!/^\[[0-9a-f:.]+\]$/i.test(t))return!1}else{var a=e.indexOf(":");if(a>=0){if(e.indexOf(":",a+1)>=0)return!1;if(t=e.slice(0,a),r=e.slice(a+1),!/^\d+$/.test(r))return!1}else t=e}if(!t||void 0!==r&&(Number(r)<1||Number(r)>65535))return!1;if("function"!=typeof URL)return function(e){if("["===e.charAt(0))return function(e){if(!e||e.indexOf(":")<0||e.indexOf(":::")>=0)return!1;if(e.indexOf(".")>=0){var t=e.lastIndexOf(":");if(t<0||!n(e.slice(t+1)))return!1;e=e.slice(0,t)+":0:0"}var r=e.indexOf("::");if(r>=0){if(e.indexOf("::",r+2)>=0)return!1;var i=e.slice(0,r).split(":").filter(Boolean),s=e.slice(r+2).split(":").filter(Boolean);return i.length+s.length<8&&i.concat(s).every(o)}var a=e.split(":");return 8===a.length&&a.every(o)}(e.slice(1,-1));var t=e.replace(/\.$/,"");return!(!t||t.length>253)&&(/^[0-9.]+$/.test(t)?n(t):t.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9\u0080-\uFFFF](?:[a-z0-9\u0080-\uFFFF-]*[a-z0-9\u0080-\uFFFF])?$/i.test(e)})))}(t);try{var u=new URL("ws://"+e);if("ws:"!==u.protocol||u.username||u.password||"/"!==u.pathname||u.search||u.hash||!u.hostname)return!1;if("["===t.charAt(0))return"["===u.hostname.charAt(0);var c=u.hostname.replace(/\.$/,"");return!(!c||c.length>253)&&c.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e)}))}catch(e){return!1}},normalizeFpnnEndpoint:function(e){if("string"!=typeof e)return e;var t=/^(\[[^\]]+\]|[^:]+):13325$/.exec(e);return t?t[1]+":13321":e}}},function(e,t,r){"use strict";(function(e){
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.rtm=t():e.rtm=t()}("undefined"!=typeof globalThis?globalThis:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=18)}([function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(1),i=o.msgpack,s=o.Int64BE,a=o.Uint64BE,u={RTM_EC_UNKNOWN_METHOD:20004,RTM_EC_INVALID_PROJECT_ID_OR_USER_ID:200001,RTM_EC_INVALID_PROJECT_ID_OR_SIGN:200002,RTM_EC_INVALID_FILE_OR_SIGN_OR_TOKEN:200003,RTM_EC_ATTRS_WITHOUT_SIGN_OR_EXT:200004,RTM_EC_API_FREQUENCY_LIMITED:200010,RTM_EC_MESSAGE_FREQUENCY_LIMITED:200011,RTM_EC_FORBIDDEN_METHOD:200020,RTM_EC_PERMISSION_DENIED:200021,RTM_EC_UNAUTHORIZED:200022,RTM_EC_DUPLCATED_AUTH:200023,RTM_EC_AUTH_DENIED:200024,RTM_EC_ADMIN_LOGIN:200025,RTM_EC_ADMIN_ONLY:200026,RTM_EC_INVALID_AUTH_TOEKN:200027,RTM_EC_LARGE_MESSAGE_OR_ATTRS:200030,RTM_EC_LARGE_FILE_OR_ATTRS:200031,RTM_EC_TOO_MANY_ITEMS_IN_PARAMETERS:200032,RTM_EC_EMPTY_PARAMETER:200033,RTM_EC_INVALID_PARAMETER:200034,RTM_EC_NOT_IN_ROOM:200040,RTM_EC_NOT_GROUP_MEMBER:200041,RTM_EC_MAX_GROUP_MEMBER_COUNT:200042,RTM_EC_NOT_FRIEND:200043,RTM_EC_BANNED_IN_GROUP:200044,RTM_EC_BANNED_IN_ROOM:200045,RTM_EC_EMPTY_GROUP:200046,RTM_EC_ENTER_TOO_MANY_ROOMS:200047,RTM_EC_UNSUPPORTED_LANGUAGE:200050,RTM_EC_EMPTY_TRANSLATION:200051,RTM_EC_SEND_TO_SELF:200052,RTM_EC_DUPLCATED_MID:200053,RTM_EC_SENSITIVE_WORDS:200054,RTM_EC_UNKNOWN_ERROR:200999},c={image:40,audio:41,video:42,file:50},f={text:30,audio:31,cmd:32},l={kickOut:"kickout",kickOutRoom:"kickoutroom",recvMessage:"pushmsg",recvGroupMessage:"pushgroupmsg",recvRoomMessage:"pushroommsg",recvBroadcastMessage:"pushbroadcastmsg",recvFile:"pushfile",recvGroupFile:"pushgroupfile",recvRoomFile:"pushroomfile",recvBroadcastFile:"pushbroadcastfile",recvPing:"ping",recvChat:"pushchat",recvAudio:"pushaudio",recvCmd:"pushcmd",recvGroupChat:"pushgroupchat",recvGroupAudio:"pushgroupaudio",recvGroupCmd:"pushgroupcmd",recvRoomChat:"pushroomchat",recvRoomAudio:"pushroomaudio",recvRoomCmd:"pushroomcmd",recvBroadcastChat:"pushbroadcastchat",recvBroadcastAudio:"pushbroadcastaudio",recvBroadcastCmd:"pushbroadcastcmd"},h={kickOut:"event.kicked",kickOutRoom:"event.room_removed",recvBroadcastMessage:"event.broadcast",recvGroupMessage:"event.group",recvMessage:"event.direct",recvRoomMessage:"event.room"},d=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return n(e,null,[{key:"ERROR_CODE",get:function(){return u}},{key:"MsgPack",get:function(){return i}},{key:"FILE_TYPE",get:function(){return c}},{key:"CHAT_TYPE",get:function(){return f}},{key:"SERVER_PUSH",get:function(){return l}},{key:"TLV_SERVER_PUSH",get:function(){return h}},{key:"MID_TTL",get:function(){return 5e3}},{key:"API_VERSION",get:function(){return"2.7.3"}},{key:"SDK_VERSION",get:function(){return"2.7.6"}},{key:"MAX_PING_SECONDS",get:function(){return 60}}]),e}();d.Int64=function(e){return new s(""+e)},d.Uint64=function(e){return new a(""+e)},e.exports=d},function(e,t,r){"use strict";var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=function(){if(i.fpnn)return i.fpnn;var e="undefined"!=typeof self&&"function"==typeof self.importScripts&&"function"==typeof self.WebSocket;return"undefined"!=typeof window||e?r(22):{FPClient:function e(){throw o(this,e),new Error('protocol: "fpnn" requires the browser FPNN runtime; use protocol: "tlv-v1" with WebSocket or webSocketFactory')},FPConfig:{ERROR_CODE:{FPNN_EC_OK:0,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_INVALID_CONNECTION:20012}},FPError:function(e){function t(e,r){o(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,n.message));return i.code=e,i.name="FPError",i.stack=n.stack||i.stack,i.error=n,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),n(t,[{key:"toString",value:function(){return"code: "+this.code+" ex: "+this.message}}]),t}(),FPEvent:{assign:function(e){if(!e||Object.prototype.hasOwnProperty.call(e,"events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(Object.prototype.hasOwnProperty.call(e,"on")||Object.prototype.hasOwnProperty.call(e,"emit")||Object.prototype.hasOwnProperty.call(e,"removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){Object.prototype.hasOwnProperty.call(e.events,t)||(e.events[t]=[]),-1===e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(t){var r=Array.prototype.slice.call(arguments,1);(e.events[t]||[]).slice().forEach((function(t){t&&t.apply(e,r)}))},e.removeEvent=function(t,r){if(0===arguments.length)e.events={};else if(1===arguments.length)Object.prototype.hasOwnProperty.call(e.events,t)&&delete e.events[t];else if(e.events[t]){var n=e.events[t].indexOf(r);-1!==n&&e.events[t].splice(n,1)}},e.listenerCount=function(t){return Object.prototype.hasOwnProperty.call(e.events,t)?e.events[t].length:0}}}}}(),a=i.msgpack||r(23),u=i.md5||r(24),c=i.Int64BE&&i.Uint64BE?{Int64BE:i.Int64BE,Uint64BE:i.Uint64BE}:r(27);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:c.Int64BE,Uint64BE:c.Uint64BE}},function(e,t,r){"use strict";(function(t){var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();var o=r(0),i=r(8),s=r(9),a=r(5),u=r(1),c=u.fpnn,f=u.md5,l=r(6).normalizeFpnnEndpoint,h=r(12).normalizeClientOptions;function d(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function p(e){var t=c.FPConfig.ERROR_CODE;return e===t.FPNN_EC_CORE_INVALID_CONNECTION||e===t.FPNN_EC_CORE_CONNECTION_CLOSED||e===t.FPNN_EC_CORE_UNKNOWN_ERROR||e===o.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function g(e,t){return!e&&!p(t)}function y(e,t){if(this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),null!=this._baseClient){var r=this._baseClient;this._baseClient=null,r.destroy()}"tlv-v1"===this._protocol?this._baseClient=new s({endpoint:this._tlvEndpoint,heartbeatIdleMs:this._tlvHeartbeatIdleMs,heartbeatTimeoutMs:this._tlvHeartbeatTimeoutMs,connectionTimeout:this._connectionTimeout,legacyMsgOptions:this._msgOptions,pushDedupTtlMs:this._pushDedupTtlMs,requestMetadata:this._requestMetadata,requestTimeout:this._requestTimeout,webSocketFactory:this._webSocketFactory}):this._baseClient=new c.FPClient({endpoint:d.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,o=this,i=!1,a=!1,u=!1,f=!1;function l(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===o._baseClient&&(a||f||(f=!0,l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===o._protocol&&_.call(o)))})),n.on("error",(function(e){n===o._baseClient&&(a||b.call(o,e),i||l(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===o._baseClient&&(i||(i=!0,o._requireClose=!1,m.call(o,(function(e,t){if(e)a=!0;else if("tlv-v1"===o._protocol&&g(e,t))o._canReconnect=!1;else if("tlv-v1"===o._protocol&&!f&&n===o._baseClient)return l(e,t),void n.close();l(e,t)}),t)))})),n.processor=this._processor,n.connect()}function m(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+o.SDK_VERSION};this._attrs&&(n.attrs=this._attrs),"tlv-v1"===this._protocol&&(void 0!==this._authSec&&(n.ts=this._authSec),void 0!==this._authVer&&(n.authv=this._authVer),void 0!==this._locale&&(n.lang=this._locale));var i={flag:1,method:"auth",payload:o.MsgPack.encode(n,this._msgOptions)},s=this;A.call(this,r,i,(function(t,n){if(r===s._baseClient){var i=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(i)return s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0,s._canReconnect=!0,r.on("close",(function(){r===s._baseClient&&_.call(s)})),r.on("error",(function(e){r===s._baseClient&&b.call(s,e)})),"tlv-v1"===s._protocol?r.markAuthenticated():(s._lastPingTime=parseInt(Date.now()/1e3),s._checkLastPingTimerID=setInterval((function(){parseInt(Date.now()/1e3)-s._lastPingTime>=s._maxPingIntervalSeconds&&(b.call(s,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,Error("Close connection for no ping, start reconnect"))),s.startAutoReconnect())}),1e3*s._maxPingIntervalSeconds/2)),void(e&&e(!0,c.FPConfig.ERROR_CODE.FPNN_EC_OK));var a=!1;if(n&&!i){var u="tlv-v1"===s._protocol?o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&b.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),b.call(s,t),a="tlv-v1"===s._protocol?p(t.code):!!s._reconnectTimeout),a||(s._reconnectTimeout&&(clearTimeout(s._reconnectTimeout),s._reconnectTimeout=0),s._reconnectCount=0,s._reconnectInterval=0)}}),t)}else e&&e(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION)}function _(){return this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this._requireClose?(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_OK),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1)):this._autoReconnect?(b.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void v.call(this)):(this.emit("SessionClosed",c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR),this._reconnectCount=0,this._reconnectInterval=0,void(this._canReconnect=!1))}function v(){if(!this._requireClose&&this._canReconnect&&!this._reconnectTimeout){var e=0;this._reconnectCount>=this._regressiveStrategy.startConnectFailedCount&&((e=this._reconnectInterval+1e3*this._regressiveStrategy.maxIntervalSeconds/this._regressiveStrategy.linearRegressiveCount)>1e3*this._regressiveStrategy.maxIntervalSeconds&&(e=1e3*this._regressiveStrategy.maxIntervalSeconds),this._reconnectInterval=e),this._reconnectCount+=1;var t=this._reconnectCount,r=this;this._reconnectTimeout=setTimeout((function(){r._reconnectTimeout=0;var n="tlv-v1"===r._protocol?void 0:e;r.login(r._uid,r._token,(function(e,n){n==c.FPConfig.ERROR_CODE.FPNN_EC_OK?e?(r.emit("ReloginCompleted",!0,!1,c.FPConfig.ERROR_CODE.FPNN_EC_OK,t),b.call(r,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_OK,new Error("relogin successfully, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0):(r.emit("ReloginCompleted",!1,!1,o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",o.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, token error, reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):"tlv-v1"===r._protocol&&g(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),b.call(r,new c.FPError(n,new Error("relogin terminal auth failure, errorCode: "+n+", reconnectCount: "+t))),r._reconnectCount=0,r._reconnectInterval=0,r._canReconnect=!1):(r.emit("ReloginCompleted",!1,!0,n,t),"tlv-v1"!==r._protocol&&v.call(r),b.call(r,new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function b(e){this.emit("ErrorRecorder",e)}function w(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function E(e,r,n,i,s){var a=this;n&&"0"!=n.toString()||(n=P.call(this)),k.call(a,e,(function(u,f){if(u)i&&i({mid:n,error:u},null);else{var l=f.token,h=f.endpoint,d=null;if(null!=r&&void 0!==r.name){var p=r.name.lastIndexOf(".");-1!=p&&(d=r.name.slice(p+1))}if(l&&h){var g=new FileReader;g.onload=function(r){var u=t.from(r.target.result);if(console.log("content:"),console.log(u.length),u){var f=w.call(a,u).toLowerCase(),p=w.call(a,f+":"+l).toLowerCase(),g=a._endpoint.split(":"),y="ws://fileproxy-"+g[0]+":13461/service/websocket";a._ssl&&(y="wss://fileproxy-"+g[0]+":13462/service/websocket");var m=new c.FPClient({endpoint:y,autoReconnect:!1,connectionTimeout:s,platformImpl:a._platformImpl});m.on("close",(function(){})),m.on("error",(function(e){var t=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),b.call(a,new c.FPError(t,e))})),m.on("connect",(function(){var t={token:l,sign:p,ext:d,file:u,endpoint:h};for(var r in e)t[r]=e[r];R.call(a,m,t,n,i,s)})),m.connect()}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else i&&i({mid:n,error:new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function k(e,t,r){var n={};for(var i in e)"mtype"!=i&&(n[i]=e[i]);var s={flag:1,method:"filetoken",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,s,t,r)}function R(e,t,r,n,i){var s={pid:this._pid,from:this._uid,mid:r,endpoint:t.endpoint};for(var a in t)"sign"!=a?"ext"!=a&&"cmd"!=a&&(s[a]=t[a]):s.attrs=JSON.stringify({rtm:{sign:t.sign,ext:t.ext}});var u={flag:1,method:t.cmd,payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,e,u,(function(t,r){e.destroy(),t?n&&n({mid:s.mid,error:t},null):(void 0!==r.mtime&&(r.mtime=new o.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),i)}function P(){++this._midSeq>=999&&(this._midSeq=0);var e=this._midSeq.toString();return this._midSeq<100&&(e="0"+e),this._midSeq<10&&(e="0"+e),new o.Int64(Date.now().toString()+e)}function C(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:P.call(this)}function O(e,t,r){var n="boolean"==typeof e;return n?"function"==typeof t&&void 0===r&&(r=t,t=void 0):"function"==typeof t&&void 0===r?(r=t,t=e):void 0===t&&("function"==typeof e&&void 0===r?r=e:void 0!==e&&(t=e)),{value:n?e:void 0,provided:n,timeout:t,callback:r}}function T(e,t){if(!t)return new c.FPError(o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=o.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;return void 0!==t.code&&(r=t.code),new c.FPError(r,t)}if(e){if(t.hasOwnProperty("code")&&t.hasOwnProperty("ex"))return new c.FPError(t.code,new Error(t.ex));if(t.hasOwnProperty("status")&&t.hasOwnProperty("reason")){var n=new c.FPError(t.status,new Error(t.reason));return n.status=t.status,n.reason=t.reason,n}}return null}function A(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=this;e?e.sendQuest(t,(function(e){if(r){var t=null,n=!1;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload"))return 2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,e._tlvPayload))?void(r&&r(t,null)):void(r&&r(null,e._tlvPayload));if(e&&e.payload){var a=null;return a=i?o.MsgPack.decode(e.payload,s._binaryOptions):o.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=T.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=T.call(s,n,e))?r&&r(t,null):r&&r(null,e)}}),n):r&&r(new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION,Error("invalid connection")),null)}function S(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var M=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=h(t),c.FPEvent.assign(this),this._protocol=t.protocol,this._endpoint=t.endpoint,this._pid=t.pid,this._attrs=t.attrs,this._autoReconnect=void 0===t.autoReconnect||t.autoReconnect,this._connectionTimeout=t.connectionTimeout||3e4,this._maxPingIntervalSeconds=o.MAX_PING_SECONDS,this._platformImpl=void 0,this._requestMetadata=t.requestMetadata||t.requestMetadataProvider,this._requestTimeout=t.requestTimeout||2e4,this._tlvHeartbeatIdleMs=t.tlvHeartbeatIdleMs||3e4,this._tlvHeartbeatTimeoutMs=t.tlvHeartbeatTimeoutMs||1e4,this._pushDedupTtlMs=t.pushDedupTtlMs||3e4,this._webSocketFactory=t.webSocketFactory,this._authSec=t.authSec,this._authVer=t.authVer,this._locale=t.locale,this._clientVersion=t.clientVersion,void 0!==t.maxPingIntervalSeconds&&(this._maxPingIntervalSeconds=t.maxPingIntervalSeconds),this._lastPingTime=0,this._checkLastPingTimerID=0,this._regressiveStrategy={startConnectFailedCount:3,maxIntervalSeconds:8,linearRegressiveCount:4},void 0!==t.regressiveStrategy&&void 0!==t.regressiveStrategy.startConnectFailedCount&&void 0!==t.regressiveStrategy.maxIntervalSeconds&&void 0!==t.regressiveStrategy.linearRegressiveCount&&(this._regressiveStrategy.startConnectFailedCount=t.regressiveStrategy.startConnectFailedCount,this._regressiveStrategy.maxIntervalSeconds=t.regressiveStrategy.maxIntervalSeconds,this._regressiveStrategy.linearRegressiveCount=t.regressiveStrategy.linearRegressiveCount),this._canReconnect=!1,this._reconnectCount=0,this._reconnectInterval=0,this._ssl=!1,"tlv-v1"===this._protocol)this._tlvEndpoint=t.tlvEndpoint;else{var r=void 0!==t.ssl_endpoint,n=r?t.ssl_endpoint:t.endpoint;this._endpoint=r?n:l(n),this._ssl=r}void 0!==t.platformImpl&&(this._platformImpl=t.platformImpl),this._md5=t.md5||null,this._midSeq=0,this._saltSeq=0,this._baseClient=null,this._reconnectTimeout=0,this._requireClose=!1,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})};var s=this;this._processor=new i(this);var u=function(){s._requireClose=!0,s._canReconnect=!1,"tlv-v1"!==s._protocol&&s._baseClient&&s._baseClient.close()};this._processor.on(o.SERVER_PUSH.kickOut,u),this._processor.on(o.TLV_SERVER_PUSH.kickOut,u),this.promises=a(this,e.prototype)}return n(e,[{key:"login",value:function(e,t,r,n){this._uid=e,this._token=t,this._processor&&(this._processor.uid=this._uid),y.call(this,r,n)}},{key:"bye",value:function(e,t){"function"==typeof e&&(t=e,e=void 0);var r={flag:1,method:"bye",payload:o.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,A.call(this,this._baseClient,r,(function(e,r){var o,i=e||null;"tlv-v1"!==n._protocol&&((o=e)&&o.code===c.FPConfig.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED&&"Connection Closed"===o.message)&&(i=null,r={closed:!0}),"tlv-v1"===n._protocol?e&&(b.call(n,e),n._baseClient&&n._baseClient.close()):n._baseClient&&n._baseClient.close(),t&&t(i,r)}),e)}},{key:"getServerTime",value:function(e,t){var r={flag:1,method:"getservertime",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new o.Int64(""+r.mts)),t&&t(null,r))}),e)}},{key:"close",value:function(){this._requireClose=!0,this._baseClient&&this._baseClient.close()}},{key:"startAutoReconnect",value:function(){this._requireClose=!1,this._baseClient&&this._baseClient.close()}},{key:"destroy",value:function(){this.close(),this._midSeq=0,this._saltSeq=0,this._processor&&(this._processor.destroy(),this._processor=null),this._baseClient&&(this._baseClient.destroy(),this._baseClient=null),this._reconnectTimeout&&(clearTimeout(this._reconnectTimeout),this._reconnectTimeout=0),this._checkLastPingTimerID&&(clearInterval(this._checkLastPingTimerID),this._checkLastPingTimerID=0),this.removeEvent()}},{key:"sendMessage",value:function(e,t,r,n,i,s,a){var u={to:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendMessages",value:function(e,t,r,n,i,s,a){var u={tos:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendGroupMessage",value:function(e,t,r,n,i,s,a){var u={gid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"sendRoomMessage",value:function(e,t,r,n,i,s,a){var u={rid:e,mid:i=C.call(this,i),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:o.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;A.call(this,this._baseClient,c,(function(e,t){e?a&&a(f?{message_ref:u.mid,error:e}:{mid:u.mid,error:e},null):(f||void 0===t.mtime||(t.mtime=new o.Int64(t.mtime)),a&&a(null,f?{message_ref:t.message_ref,payload:t}:{mid:u.mid,payload:t}))}),s)}},{key:"getUnreadMessage",value:function(e,t,r,n){var i=O(t,r,n);t=i.value,r=i.timeout,n=i.callback;var s={clear:void 0!==e&&e};void 0!==t&&(s.gettime=t);var a={flag:1,method:"getunread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(""+e)})),t.p2p=i}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,i){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,i){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:o.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;A.call(this,this._baseClient,a,(function(e,t){if(e)i&&i(e,null);else if(u)i&&i(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new o.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new o.Int64(""+s)]=new o.Int64(""+a[s]);i&&i(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,i){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var i=[];n.forEach((function(e,t){i[t]=new o.Int64(""+e)})),r.p2p=i}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,i,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,i,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,i,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==i&&(c.lastid=i),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,(function(e,t){if(e)u&&u(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),from:new o.Int64(""+e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,i,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==i&&(f.end=i),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:o.MsgPack.encode(f,this._msgOptions)};A.call(this,this._baseClient,l,(function(e,t){if(e)c&&c(e,null);else{var r=t.msgs;r&&r.forEach((function(e,t){var n=e[5],i=S(e[5]),s=S(e[6]);r[t]={id:new o.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:i,binary:n,attrs:s,mtime:new o.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,o,i,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==o&&(c.begin=o),void 0!==i&&(c.end=i),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,o,i,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==o&&(u.end=o),void 0!==i&&(u.mtypes=i),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,i){var s={flag:1,method:e,payload:o.MsgPack.encode(t,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?i&&i(e,null):i&&i(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var i={id:new o.Int64(""+e[0]),mtype:Number(e[2]),mid:new o.Int64(""+e[3]),deleted:e[4],msg:S(e[5]),binary:e[5],attrs:S(e[6]),mtime:new o.Int64(""+e[7])};t?i.direction=Number(e[1]):i.from=new o.Int64(""+e[1]),r[n]=i})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getGroupMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getRoomMessageCount",value:function(e,t,r,n,o,i){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},o,i)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,o){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,o)}},{key:"_getMessageCount",value:function(e,t,r,n){var i={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(i[e]=t[e])}));var s={flag:1,method:e,payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,o,i,s){var a={cmd:e};void 0!==t&&(a.tos=t),void 0!==r&&(a.to=r),void 0!==n&&(a.rid=n),void 0!==o&&(a.gid=o),k.call(this,a,s,i)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},i={flag:1,method:"addattrs",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var i={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var i={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},i={flag:1,method:"removedevice",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},i={flag:1,method:"setlang",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"translate",value:function(e,t,r,n,i,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==i&&(u.profanity=i);var c={flag:1,method:"translate",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var i={text:e};void 0!==t&&(i.classify=t);var s={flag:1,method:"profanity",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"textCheck",value:function(e,t,r,n){"function"==typeof t?(n=t,t=void 0,r=void 0):arguments.length<4&&"number"==typeof t&&(void 0===r||"function"==typeof r)&&(n="function"==typeof r?r:n,r=t,t=void 0);var i={text:e};void 0!==t&&(i.strategyId=t);var s={flag:1,method:"tcheck",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,i){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"audioCheck",value:function(e,t,r,n,i,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==i&&(c.srate=i),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:o.MsgPack.encode(c,this._msgOptions)};A.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,i,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"speech2Text",value:function(e,t,r,n,i,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==i&&(u.srate=i);var c={flag:1,method:"speech2text",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},i={flag:1,method:"getgroupsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomsopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroommembers",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},i={flag:1,method:"getroomcount",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,i){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"addfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},i={flag:1,method:"delfriends",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(t&&t(null,i))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var i={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupmembers",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var i=[];r.forEach((function(e,t){i[t]=new o.Int64(e)})),t.uids=i}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new o.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var i={gid:e};void 0!==t&&(i.online=t);var s={flag:1,method:"getgroupcount",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,(function(e,t){e?n&&n(e,null):n&&n(null,t)}),r)}},{key:"getUserGroups",value:function(e,t){var r={flag:1,method:"getusergroups",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"enterroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},i={flag:1,method:"enterrooms",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},i={flag:1,method:"leaveroom",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"getUserRoomsAndLastMessage",value:function(e,t,r){var n={};void 0!==e&&(n.mtypes=e);var i={flag:1,method:"getuserroomsandlastmsg",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getonlineusers",payload:o.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";A.call(this,this._baseClient,i,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var i=[];return n.forEach((function(e,t){i[t]=new o.Int64(e)})),void(r&&r(null,i))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,s,i)}},{key:"getMessage",value:function(e,t,r,n,i,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new o.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new o.Int64(""+t.mtime)),s&&s(null,t))}),i,!0)}},{key:"sendChat",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendAudio",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendCmd",value:function(e,t,r,n,i,s){this.sendMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendGroupChat",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,i,s){this.sendGroupMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"sendRoomChat",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.text,t,r,n,i,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.audio,t,r,n,i,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,i,s){this.sendRoomMessage.call(this,e,o.CHAT_TYPE.cmd,t,r,n,i,s)}},{key:"getGroupChat",value:function(e,t,r,n,i,s,a,u){this.getGroupMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,i,s,a,u){this.getRoomMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,i,s,a,u){this.getP2PMessage.call(this,e,t,r,n,i,s,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,i,s,a){this.getBroadcastMessage.call(this,e,t,r,n,i,[o.CHAT_TYPE.text,o.CHAT_TYPE.audio,o.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,o,i){this.deleteMessage(e,t,r,n,o,i)}},{key:"getChat",value:function(e,t,r,n,o,i){this.getMessage(e,t,r,n,o,i)}},{key:"setUserInfo",value:function(e,t,r,n){var i={};void 0!==e&&(i.oinfo=e),void 0!==t&&(i.pinfo=t);var s={flag:1,method:"setuserinfo",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:o.MsgPack.encode({},this._msgOptions)};A.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},i={flag:1,method:"getuseropeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,i){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupinfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},i={flag:1,method:"getgroupopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,i){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"setRoomProfile",value:function(e,t,r,n,i,s,a){var u={rid:e};void 0!==t&&(u.oinfo=t),void 0!==r&&(u.pinfo=r),void 0!==n&&(u.name=n),void 0!==i&&(u.icon=i);var c={flag:1,method:"setroominfo",payload:o.MsgPack.encode(u,this._msgOptions)};A.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroominfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},i={flag:1,method:"getroomopeninfo",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataSet",value:function(e,t,r,n){var i={key:e,val:t},s={flag:1,method:"dataset",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},i={flag:1,method:"dataget",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},i={flag:1,method:"datadel",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"addblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},i={flag:1,method:"delblacks",payload:o.MsgPack.encode(n,this._msgOptions)};A.call(this,this._baseClient,i,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:o.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";A.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var i=r[n];if(i){var s=[];return i.forEach((function(e,t){s[t]=new o.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,o,i){var s={to:t,mtype:e,cmd:"sendfile"};E.call(this,s,r,n,i,o)}},{key:"sendGroupFile",value:function(e,t,r,n,o,i){var s={gid:t,mtype:e,cmd:"sendgroupfile"};E.call(this,s,r,n,i,o)}},{key:"sendRoomFile",value:function(e,t,r,n,o,i){var s={rid:t,mtype:e,cmd:"sendroomfile"};E.call(this,s,r,n,i,o)}},{key:"getP2PConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var i={};void 0!==e&&(i.mtime=e),void 0!==t&&(i.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:o.MsgPack.encode(i,this._msgOptions)};A.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,i){var s={};void 0!==e&&(s.clear=e),void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getunreadconversationlist",payload:o.MsgPack.encode(s,this._msgOptions)};A.call(this,this._baseClient,a,i,n)}},{key:"removeSession",value:function(e,t,r,n){var i=O(t,r,n),s=i.provided;t=!!s&&i.value,r=i.timeout,n=i.callback;var a={to:e};("tlv-v1"===this._protocol||s)&&(a.oneway=t);var u={flag:1,method:"removesession",payload:o.MsgPack.encode(a,this._msgOptions)};A.call(this,this._baseClient,u,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=M}).call(this,r(7).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=function(e){function t(e){i(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.name="TLVMsgPackError",r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Error),t}(),a=function(){function e(t,r,n){i(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return o(e,[{key:"isNegative",value:function(){return this.signed&&0!=(2147483648&this.high)}},{key:"toString",value:function(){if(!this.isNegative())return c(this.high,this.low);var e=u(this.high,this.low);return"-"+c(e.high,e.low)}},{key:"valueOf",value:function(){return Number(this.toString())}}]),e}();function u(e,t){var r=1+~t>>>0,n=~e>>>0;return 0===r&&(n=n+1>>>0),{high:n,low:r}}function c(e,t){var r=[e>>>0];f(r,65536),f(r,65536),function(e,t){var r=t,n=0;for(;r>0;){n===e.length&&e.push(0);var o=e[n]+r;e[n]=o%1e7,r=Math.floor(o/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),o=r.length-2;o>=0;o-=1)n+=String(r[o]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var o=e[n]*t+r;e[n]=o%1e7,r=Math.floor(o/1e7)}for(;r>0;)e.push(r%1e7),r=Math.floor(r/1e7)}function l(e){return Number.isSafeInteger?Number.isSafeInteger(e):"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}function h(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||Array.isArray(e))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function d(e){if(e instanceof Uint8Array)return e;if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer)return new Uint8Array(e);if("undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if("undefined"!=typeof ArrayBuffer&&e&&"[object ArrayBuffer]"===Object.prototype.toString.call(e))try{return new Uint8Array(ArrayBuffer.prototype.slice.call(e,0))}catch(e){}return null}function p(e){var t=d(e);if(!t)throw new s("expected binary data");return t}function g(e){if("string"!=typeof e)throw new s("expected UTF-8 string");if(function(e){for(var t=0;t<e.length;t+=1){var r=e.charCodeAt(t);if(r>=55296&&r<=56319){var n=e.charCodeAt(t+1);if(n<56320||n>57343)throw new s("string contains an unpaired surrogate");t+=1}else if(r>=56320&&r<=57343)throw new s("string contains an unpaired surrogate")}}(e),"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var t=[],r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319)n=65536+(n-55296<<10)+(e.charCodeAt(r+1)-56320),r+=1;n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):n<=65535?t.push(224|n>>12,128|n>>6&63,128|63&n):t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function y(e){var t=p(e);if("undefined"!=typeof TextDecoder)try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(e){throw new s("invalid UTF-8 string")}for(var r="",n=0;n<t.length;n+=1){var o=t[n],i=void 0;if(o<=127)i=o;else if(o>=194&&o<=223){i=(31&o)<<6|63&m(t,n+1),n+=1}else if(o>=224&&o<=239){var a=m(t,n+1),u=m(t,n+2);if(224===o&&a<160||237===o&&a>159)throw new s("invalid UTF-8 string");i=(15&o)<<12|(63&a)<<6|63&u,n+=2}else{if(!(o>=240&&o<=244))throw new s("invalid UTF-8 string");var c=m(t,n+1),f=m(t,n+2),l=m(t,n+3);if(240===o&&c<144||244===o&&c>143)throw new s("invalid UTF-8 string");i=(7&o)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(i<=65535)r+=String.fromCharCode(i);else{var h=i-65536;r+=String.fromCharCode(55296|h>>10,56320|1023&h)}}return r}function m(e,t){if(t>=e.length||128!=(192&e[t]))throw new s("invalid UTF-8 string");return e[t]}var _=function(){function e(){i(this,e),this.chunks=[],this.length=0}return o(e,[{key:"byte",value:function(e){this.chunks.push(new Uint8Array([255&e])),this.length+=1}},{key:"bytes",value:function(e){var t=p(e);this.chunks.push(t),this.length+=t.length}},{key:"uint16",value:function(e){this.byte(e>>>8),this.byte(e)}},{key:"uint32",value:function(e){var t=e>>>0;this.byte(t>>>24),this.byte(t>>>16),this.byte(t>>>8),this.byte(t)}},{key:"uint64",value:function(e,t){this.uint32(e),this.uint32(t)}},{key:"finish",value:function(){var e=new Uint8Array(this.length),t=0;return this.chunks.forEach((function(r){e.set(r,t),t+=r.length})),e}}]),e}();function v(e,t,r){if(r>128)throw new s("MessagePack nesting is too deep");if(null==e)throw new s("nil and undefined are not allowed in TLV payloads");var o=void 0===e?"undefined":n(e);if("boolean"!==o)if("string"!==o)if("number"!==o)if("bigint"!==o){if("object"!==o)throw new s("unsupported MessagePack value type: "+o);if(e instanceof a)!function(e,t){if(e.isNegative())return t.byte(211),void t.uint64(e.high,e.low);if(k(e),0===e.high)return void w(e.low,t);t.byte(207),t.uint64(e.high,e.low)}(e,t);else{var i=d(e);if(i)!function(e,t){e.length<=255?(t.byte(196),t.byte(e.length)):e.length<=65535?(t.byte(197),t.uint16(e.length)):(t.byte(198),t.uint32(e.length));t.bytes(e)}(i,t);else if(function(e){if(!e||"object"!==(void 0===e?"undefined":n(e))||e instanceof a)return!1;if("number"!=typeof e.offset||"function"!=typeof e.toString||!e.buffer)return!1;var t=e.buffer,r="number"==typeof t.length?t.length:t.byteLength;return"number"==typeof r&&e.offset>=0&&e.offset+8<=r}(e))!function(e,t){var r=function(e){var t=e.buffer,r=e.offset,n=function(e){return 255&t[r+e]};return{high:16777216*n(0)+65536*n(1)+256*n(2)+n(3)>>>0,low:16777216*n(4)+65536*n(5)+256*n(6)+n(7)>>>0,signed:"-"===String(e).charAt(0)}}(e);if(r.signed)return t.byte(211),void t.uint64(r.high,r.low);if(k(r),0===r.high)return void w(r.low,t);t.byte(207),t.uint64(r.high,r.low)}(e,t);else if(Array.isArray(e))!function(e,t,r){e.length<=15?t.byte(144|e.length):e.length<=65535?(t.byte(220),t.uint16(e.length)):(t.byte(221),t.uint32(e.length));e.forEach((function(e){v(e,t,r)}))}(e,t,r+1);else{if(!h(e))throw new s("unsupported MessagePack object");!function(e,t,r){var n=Object.keys(e);n.length<=15?t.byte(128|n.length):n.length<=65535?(t.byte(222),t.uint16(n.length)):(t.byte(223),t.uint32(n.length));n.forEach((function(n){b(n,t),v(e[n],t,r)}))}(e,t,r+1)}}}else!function(e,t){var r="-"===e.charAt(0),n=function(e){if(!/^[0-9]+$/.test(e))throw new s("invalid integer text");for(var t=0,r=0,n=0;n<e.length;n+=1){var o=10*r+(e.charCodeAt(n)-48);r=o%4294967296;var i=10*t+Math.floor(o/4294967296);if(i>=4294967296)throw new s("integer exceeds uint64");t=i}return{high:t>>>0,low:r>>>0}}(r?e.slice(1):e);if(r){if(n.high>2147483648||2147483648===n.high&&0!==n.low)throw new s("integer is below int64 minimum");var o=u(n.high,n.low);return t.byte(211),void t.uint64(o.high,o.low)}if(k(n),0===n.high)return void w(n.low,t);t.byte(207),t.uint64(n.high,n.low)}(e.toString(),t);else!function(e,t){if(!isFinite(e))throw new s("non-finite numbers are not allowed");if(!l(e))throw new s("floating-point and unsafe integer numbers are not allowed");w(e,t)}(e,t);else b(e,t);else t.byte(e?195:194)}function b(e,t){var r=g(e);r.length<=31?t.byte(160|r.length):r.length<=255?(t.byte(217),t.byte(r.length)):r.length<=65535?(t.byte(218),t.uint16(r.length)):(t.byte(219),t.uint32(r.length)),t.bytes(r)}function w(e,t){if(e>=0)if(e<=127)t.byte(e);else if(e<=255)t.byte(204),t.byte(e);else if(e<=65535)t.byte(205),t.uint16(e);else if(e<=4294967295)t.byte(206),t.uint32(e);else{var r=E(e);t.byte(207),t.uint64(r.high,r.low)}else if(e>=-32)t.byte(256+e);else if(e>=-128)t.byte(208),t.byte(e);else if(e>=-32768)t.byte(209),t.uint16(e);else if(e>=-2147483648)t.byte(210),t.uint32(e);else{var n=function(e){if(e>=0)return E(e);var t=E(-e);return u(t.high,t.low)}(e);t.byte(211),t.uint64(n.high,n.low)}}function E(e){var t=Math.floor(e/4294967296);return{high:t>>>0,low:e-4294967296*t>>>0}}function k(e){if(e.high>=2147483648)throw new s("unsigned integer exceeds the supported int64 range")}var R=function(){function e(t,r){i(this,e),this.bytes=p(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return o(e,[{key:"ensure",value:function(e){if(e<0||this.offset+e>this.bytes.length)throw new s("truncated MessagePack value")}},{key:"byte",value:function(){this.ensure(1);var e=this.bytes[this.offset];return this.offset+=1,e}},{key:"uint16",value:function(){this.ensure(2);var e=256*this.bytes[this.offset]+this.bytes[this.offset+1];return this.offset+=2,e}},{key:"uint32",value:function(){this.ensure(4);var e=16777216*this.bytes[this.offset]+65536*this.bytes[this.offset+1]+256*this.bytes[this.offset+2]+this.bytes[this.offset+3];return this.offset+=4,e>>>0}},{key:"uint64",value:function(e){var t=this.uint32(),r=this.uint32();if(e&&0!=(2147483648&t)){var n=u(t,r);return n.high<2097152?-(4294967296*n.high+n.low):new a(t,r,!0)}if(t>=2147483648)throw new s("unsigned integer exceeds the supported int64 range");return t<2097152?4294967296*t+r:new a(t,r,!!e)}},{key:"int8",value:function(){var e=this.byte();return 128&e?e-256:e}},{key:"int16",value:function(){var e=this.uint16();return 32768&e?e-65536:e}},{key:"int32",value:function(){var e=this.uint32();return e>2147483647?e-4294967296:e}},{key:"float32",value:function(){this.ensure(4);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getFloat32(0,!1);if(this.offset+=4,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"float64",value:function(){this.ensure(8);var e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,8).getFloat64(0,!1);if(this.offset+=8,!isFinite(e))throw new s("non-finite float is not allowed");return e}},{key:"binary",value:function(e){this.ensure(e);var t=new Uint8Array(e);return t.set(this.bytes.subarray(this.offset,this.offset+e)),this.offset+=e,t}},{key:"string",value:function(e){this.ensure(e);var t=y(this.bytes.subarray(this.offset,this.offset+e));return this.offset+=e,t}},{key:"array",value:function(e,t,r){if(e>this.bytes.length-this.offset)throw new s("truncated MessagePack array");for(var n=new Array(e),o=0;o<e;o+=1)n[o]=this.value(t+1,r.concat(String(o)));return n}},{key:"map",value:function(e,t,r){if(e>Math.floor((this.bytes.length-this.offset)/2))throw new s("truncated MessagePack map");for(var n,o={},i=0;i<e;i+=1){var u=this.value(t+1,r);if("string"!=typeof u){if(!(this._allowsIntegerMapKey(r)&&(n=u,l(n)||n instanceof a)))throw new s("MessagePack map key must be a string");u=String(u)}if(Object.prototype.hasOwnProperty.call(o,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return o}},{key:"_allowsIntegerMapKey",value:function(e){if(!this.allowIntegerMapKeyAtPath||e.length!==this.allowIntegerMapKeyAtPath.length)return!1;for(var t=0;t<e.length;t+=1)if(e[t]!==this.allowIntegerMapKeyAtPath[t])return!1;return!0}},{key:"value",value:function(e,t){if(e>128)throw new s("MessagePack nesting is too deep");var r=this.byte();if(r<=127)return r;if(r>=224)return r-256;if(r>=160&&r<=191)return this.string(31&r);if(r>=144&&r<=159)return this.array(15&r,e,t);if(r>=128&&r<=143)return this.map(15&r,e,t);switch(r){case 192:throw new s("nil is not allowed in TLV payloads");case 194:return!1;case 195:return!0;case 196:return this.binary(this.byte());case 197:return this.binary(this.uint16());case 198:return this.binary(this.uint32());case 202:return this.float32();case 203:return this.float64();case 204:return this.byte();case 205:return this.uint16();case 206:return this.uint32();case 207:return this.uint64(!1);case 208:return this.int8();case 209:return this.int16();case 210:return this.int32();case 211:return this.uint64(!0);case 217:return this.string(this.byte());case 218:return this.string(this.uint16());case 219:return this.string(this.uint32());case 220:return this.array(this.uint16(),e,t);case 221:return this.array(this.uint32(),e,t);case 222:return this.map(this.uint16(),e,t);case 223:return this.map(this.uint32(),e,t);default:throw new s("MessagePack extension and reserved values are not allowed")}}}]),e}();e.exports={Int64Value:a,MsgPackError:s,decodeMap:function(e,t){var r=new R(e,t),n=r.value(0,[]);if(!h(n))throw new s("TLV payload must be a map");if(r.offset!==r.bytes.length)throw new s("MessagePack payload has trailing bytes or values");return n},encodeMap:function(e){if(!h(e))throw new s("TLV payload must be a map");var t=new _;return v(e,t,0),t.finish()},getByteView:d,isPlainMap:h,toUint8Array:p,utf8Decode:y,utf8Encode:g}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,listenerCount:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function o(e,t,r,n){try{e[t].apply(e,r)}catch(e){n(e)}}e.exports=function(e,t){var r={};return Object.getOwnPropertyNames(t).forEach((function(i){if(!n[i]&&"_"!==i.charAt(0)){var s=t[i];if("function"==typeof s){var a="login"===i?2:s.length-1;a<0||Object.defineProperty(r,i,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===i){if(t.length>3)return Promise.reject(new TypeError("promises.login(uid, credential, timeout?)"));var r=t.length>2?t[2]:void 0;return t.length=2,new Promise((function(n,s){t.push((function(e,t){if(e instanceof Error)s(e);else if(e)n({accepted:!0,errorCode:t||0});else{var r=new Error("RTM login rejected ("+String(t)+")");r.code=t,r.status=t,s(r)}}),r),o(e,i,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+i+"()"));for(var n="textCheck"===i&&2===t.length&&"number"==typeof t[1]?2:a;t.length<n;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),o(e,i,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";function n(e){var t=e.split(".");return 4===t.length&&t.every((function(e){return/^\d{1,3}$/.test(e)&&Number(e)<=255}))}function o(e){return/^[0-9a-f]{1,4}$/i.test(e)}e.exports={isValidFpnnEndpoint:function(e){if("string"!=typeof e||0===e.length||e!==e.trim()||/[\s\\/?#@%]/.test(e))return!1;var t=void 0,r=void 0;if("["===e.charAt(0)){var i=e.indexOf("]");if(i<0)return!1;t=e.slice(0,i+1);var s=e.slice(i+1);if(s){if(!/^:\d+$/.test(s))return!1;r=s.slice(1)}if(!/^\[[0-9a-f:.]+\]$/i.test(t))return!1}else{var a=e.indexOf(":");if(a>=0){if(e.indexOf(":",a+1)>=0)return!1;if(t=e.slice(0,a),r=e.slice(a+1),!/^\d+$/.test(r))return!1}else t=e}if(!t||void 0!==r&&(Number(r)<1||Number(r)>65535))return!1;if("function"!=typeof URL)return function(e){if("["===e.charAt(0))return function(e){if(!e||e.indexOf(":")<0||e.indexOf(":::")>=0)return!1;if(e.indexOf(".")>=0){var t=e.lastIndexOf(":");if(t<0||!n(e.slice(t+1)))return!1;e=e.slice(0,t)+":0:0"}var r=e.indexOf("::");if(r>=0){if(e.indexOf("::",r+2)>=0)return!1;var i=e.slice(0,r).split(":").filter(Boolean),s=e.slice(r+2).split(":").filter(Boolean);return i.length+s.length<8&&i.concat(s).every(o)}var a=e.split(":");return 8===a.length&&a.every(o)}(e.slice(1,-1));var t=e.replace(/\.$/,"");return!(!t||t.length>253)&&(/^[0-9.]+$/.test(t)?n(t):t.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9\u0080-\uFFFF](?:[a-z0-9\u0080-\uFFFF-]*[a-z0-9\u0080-\uFFFF])?$/i.test(e)})))}(t);try{var u=new URL("ws://"+e);if("ws:"!==u.protocol||u.username||u.password||"/"!==u.pathname||u.search||u.hash||!u.hostname)return!1;if("["===t.charAt(0))return"["===u.hostname.charAt(0);var c=u.hostname.replace(/\.$/,"");return!(!c||c.length>253)&&c.split(".").every((function(e){return e.length>0&&e.length<=63&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e)}))}catch(e){return!1}},normalizeFpnnEndpoint:function(e){if("string"!=typeof e)return e;var t=/^(\[[^\]]+\]|[^:]+):13325$/.exec(e);return t?t[1]+":13321":e}}},function(e,t,r){"use strict";(function(e){
2
2
  /*!
3
3
  * The buffer module from node.js, for the browser.
4
4
  *