@cg-devcenter/rtc-fpnn-webjs-sdk 1.0.0-cg.3 → 1.0.0-cg.4
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/README.md +23 -3
- package/dist/rtm.d.ts +42 -8
- package/dist/rtm.min.js +6 -6
- package/dist/rtm.shared-worker.js +4 -4
- package/dist/rtm.vite.d.ts +1 -0
- package/dist/rtm.vite.mjs +13 -2
- package/docs/CAPABILITIES.md +11 -5
- package/docs/PROTOCOL_MIGRATION.md +146 -0
- package/docs/USAGE.md +106 -6
- package/package.json +3 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=6)}([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 i=r(1),o=i.msgpack,s=i.Int64BE,a=i.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"},p=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 o}},{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}();p.Int64=function(e){return new s(""+e)},p.Uint64=function(e){return new a(""+e)},e.exports=p},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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=o.fpnn?o.fpnn:"undefined"==typeof window?{FPClient:function e(){throw i(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){i(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),o=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 o.code=e,o.name="FPError",o.stack=n.stack||o.stack,o.error=n,o}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}}}}:r(11),a=o.msgpack||r(12),u=o.md5||r(13),c=o.Int64BE&&o.Uint64BE?{Int64BE:o.Int64BE,Uint64BE:o.Uint64BE}:r(16);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:c.Int64BE,Uint64BE:c.Uint64BE}},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},i=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 s=function(e){function t(e){o(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){o(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return i(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 i=e[n]+r;e[n]=i%1e7,r=Math.floor(i/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),i=r.length-2;i>=0;i-=1)n+=String(r[i]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var i=e[n]*t+r;e[n]=i%1e7,r=Math.floor(i/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 p(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 d(e){var t=p(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=d(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 i=t[n],o=void 0;if(i<=127)o=i;else if(i>=194&&i<=223){o=(31&i)<<6|63&m(t,n+1),n+=1}else if(i>=224&&i<=239){var a=m(t,n+1),u=m(t,n+2);if(224===i&&a<160||237===i&&a>159)throw new s("invalid UTF-8 string");o=(15&i)<<12|(63&a)<<6|63&u,n+=2}else{if(!(i>=240&&i<=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===i&&c<144||244===i&&c>143)throw new s("invalid UTF-8 string");o=(7&i)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(o<=65535)r+=String.fromCharCode(o);else{var h=o-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(){o(this,e),this.chunks=[],this.length=0}return i(e,[{key:"byte",value:function(e){this.chunks.push(new Uint8Array([255&e])),this.length+=1}},{key:"bytes",value:function(e){var t=d(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 i=void 0===e?"undefined":n(e);if("boolean"!==i)if("string"!==i)if("number"!==i)if("bigint"!==i){if("object"!==i)throw new s("unsupported MessagePack value type: "+i);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 o=p(e);if(o)!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)}(o,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 i=10*r+(e.charCodeAt(n)-48);r=i%4294967296;var o=10*t+Math.floor(i/4294967296);if(o>=4294967296)throw new s("integer exceeds uint64");t=o}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 i=u(n.high,n.low);return t.byte(211),void t.uint64(i.high,i.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){o(this,e),this.bytes=d(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return i(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),i=0;i<e;i+=1)n[i]=this.value(t+1,r.concat(String(i)));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,i={},o=0;o<e;o+=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(i,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(i,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return i}},{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:p,isPlainMap:h,toUint8Array:d,utf8Decode:y,utf8Encode:g}},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 i=r(0),o=r(17),s=r(18),a=r(21),u=r(1),c=u.fpnn,f=u.md5;function l(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function h(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===i.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function p(e,t){return!e&&!h(t)}function d(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:l.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,i=this,o=!1,a=!1,u=!1,f=!1;function h(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===i._baseClient&&(a||f||(f=!0,h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===i._protocol&&y.call(i)))})),n.on("error",(function(e){n===i._baseClient&&(a||_.call(i,e),o||h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===i._baseClient&&(o||(o=!0,i._requireClose=!1,g.call(i,(function(e,t){if(e)a=!0;else if("tlv-v1"===i._protocol&&p(e,t))i._canReconnect=!1;else if("tlv-v1"===i._protocol&&!f&&n===i._baseClient)return h(e,t),void n.close();h(e,t)}),t)))})),n.processor=this._processor,n.connect()}function g(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+i.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 o={flag:1,method:"auth",payload:i.MsgPack.encode(n,this._msgOptions)},s=this;C.call(this,r,o,(function(t,n){if(r===s._baseClient){var o=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(o)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&&y.call(s)})),r.on("error",(function(e){r===s._baseClient&&_.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&&(_.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&&!o){var u="tlv-v1"===s._protocol?i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&_.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),_.call(s,t),a="tlv-v1"===s._protocol?h(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 y(){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?(_.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void m.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 m(){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),_.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,i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),_.call(r,new c.FPError(i.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&&p(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),_.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&&m.call(r),_.call(r,new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function _(e){this.emit("ErrorRecorder",e)}function v(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function b(e,r,n,o,s){var a=this;n&&"0"!=n.toString()||(n=k.call(this)),w.call(a,e,(function(u,f){if(u)o&&o({mid:n,error:u},null);else{var l=f.token,h=f.endpoint,p=null;if(null!=r&&void 0!==r.name){var d=r.name.lastIndexOf(".");-1!=d&&(p=r.name.slice(d+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=v.call(a,u).toLowerCase(),d=v.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=i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),_.call(a,new c.FPError(t,e))})),m.on("connect",(function(){var t={token:l,sign:d,ext:p,file:u,endpoint:h};for(var r in e)t[r]=e[r];E.call(a,m,t,n,o,s)})),m.connect()}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function w(e,t,r){var n={};for(var o in e)"mtype"!=o&&(n[o]=e[o]);var s={flag:1,method:"filetoken",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,s,t,r)}function E(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.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 i.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),o)}function k(){++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 i.Int64(Date.now().toString()+e)}function R(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:k.call(this)}function P(e,t){if(!t)return new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=i.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 C(e,t,r,n){var o=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=P.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=o?i.MsgPack.decode(e.payload,s._binaryOptions):i.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=P.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=P.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 O(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var T=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c.FPEvent.assign(this),this._protocol=t.protocol||"fpnn","fpnn"!==this._protocol&&"tlv-v1"!==this._protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if(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=i.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){if(this._tlvEndpoint=t.tlvEndpoint||t.tlv_endpoint,!this._tlvEndpoint&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(this._tlvEndpoint=t.endpoint),!this._tlvEndpoint&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(this._tlvEndpoint=t.ssl_endpoint),"string"!=typeof this._tlvEndpoint||!/^wss?:\/\//i.test(this._tlvEndpoint))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL")}else{if(null!=this._endpoint){var r=this._endpoint.split(":");2==r.length&&"13325"==r[1]&&(this._endpoint=r[0]+":13321")}null!=t.ssl_endpoint&&(this._endpoint=t.ssl_endpoint,this._ssl=!0)}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:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})};var n=this;this._processor=new o(this);var s=function(){n._requireClose=!0,n._canReconnect=!1,"tlv-v1"!==n._protocol&&n._baseClient&&n._baseClient.close()};this._processor.on(i.SERVER_PUSH.kickOut,s),this._processor.on(i.TLV_SERVER_PUSH.kickOut,s),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),d.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:i.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,C.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(_.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:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new i.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,o,s,a){var u={to:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={tos:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={gid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={rid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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){"boolean"!=typeof t&&("function"==typeof r&&void 0===n&&(n=r,r=t),t=void 0);var o={clear:void 0!==e&&e};void 0!==t&&(o.gettime=t);var s={flag:1,method:"getunread",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(""+e)})),t.p2p=o}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,o){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,o){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,o){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var o=[];n.forEach((function(e,t){o[t]=new i.Int64(""+e)})),r.p2p=o}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,o,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,o,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,o,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==o&&(c.lastid=o),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,o,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,i,o,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==i&&(u.end=i),void 0!==o&&(u.mtypes=o),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,o){var s={flag:1,method:e,payload:i.MsgPack.encode(t,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){e?o&&o(e,null):o&&o(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var o={id:new i.Int64(""+e[0]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:O(e[5]),binary:e[5],attrs:O(e[6]),mtime:new i.Int64(""+e[7])};t?o.direction=Number(e[1]):o.from=new i.Int64(""+e[1]),r[n]=o})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getGroupMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getRoomMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,i){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,i)}},{key:"_getMessageCount",value:function(e,t,r,n){var o={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(o[e]=t[e])}));var s={flag:1,method:e,payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,i,o,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!==i&&(a.gid=i),w.call(this,a,s,o)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},o={flag:1,method:"addattrs",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var o={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var o={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},o={flag:1,method:"removedevice",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},o={flag:1,method:"setlang",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"translate",value:function(e,t,r,n,o,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==o&&(u.profanity=o);var c={flag:1,method:"translate",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var o={text:e};void 0!==t&&(o.classify=t);var s={flag:1,method:"profanity",payload:i.MsgPack.encode(o,this._msgOptions)};C.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):"number"!=typeof t||void 0!==r&&"function"!=typeof r||(n="function"==typeof r?r:n,r=t,t=void 0);var o={text:e};void 0!==t&&(o.strategyId=t);var s={flag:1,method:"tcheck",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,o){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"audioCheck",value:function(e,t,r,n,o,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==o&&(c.srate=o),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,o,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"speech2Text",value:function(e,t,r,n,o,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==o&&(u.srate=o);var c={flag:1,method:"speech2text",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},o={flag:1,method:"getgroupsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroommembers",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomcount",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"addfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"delfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(t&&t(null,o))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(e)})),t.uids=o}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupcount",payload:i.MsgPack.encode(o,this._msgOptions)};C.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:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"enterroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},o={flag:1,method:"enterrooms",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"leaveroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.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 o={flag:1,method:"getuserroomsandlastmsg",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getonlineusers",payload:i.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";C.call(this,this._baseClient,o,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(r&&r(null,o))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"getMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new i.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new i.Int64(""+t.mtime)),s&&s(null,t))}),o,!0)}},{key:"sendChat",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendAudio",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendCmd",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendGroupChat",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendRoomChat",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"getGroupChat",value:function(e,t,r,n,o,s,a,u){this.getGroupMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,o,s,a,u){this.getRoomMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,o,s,a,u){this.getP2PMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,o,s,a){this.getBroadcastMessage.call(this,e,t,r,n,o,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,i,o){this.deleteMessage(e,t,r,n,i,o)}},{key:"getChat",value:function(e,t,r,n,i,o){this.getMessage(e,t,r,n,i,o)}},{key:"setUserInfo",value:function(e,t,r,n){var o={};void 0!==e&&(o.oinfo=e),void 0!==t&&(o.pinfo=t);var s={flag:1,method:"setuserinfo",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getuseropeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,o){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupinfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,o){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"setRoomProfile",value:function(e,t,r,n,o,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!==o&&(u.icon=o);var c={flag:1,method:"setroominfo",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroominfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroomopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataSet",value:function(e,t,r,n){var o={key:e,val:t},s={flag:1,method:"dataset",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},o={flag:1,method:"dataget",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},o={flag:1,method:"datadel",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"addblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"delblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,i,o){var s={to:t,mtype:e,cmd:"sendfile"};b.call(this,s,r,n,o,i)}},{key:"sendGroupFile",value:function(e,t,r,n,i,o){var s={gid:t,mtype:e,cmd:"sendgroupfile"};b.call(this,s,r,n,o,i)}},{key:"sendRoomFile",value:function(e,t,r,n,i,o){var s={rid:t,mtype:e,cmd:"sendroomfile"};b.call(this,s,r,n,o,i)}},{key:"getP2PConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeSession",value:function(e,t,r,n){var o="boolean"==typeof t;o||("function"==typeof r&&void 0===n&&(n=r,r=t),t=!1);var s={to:e};("tlv-v1"===this._protocol||o)&&(s.oneway=t);var a={flag:1,method:"removesession",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=T}).call(this,r(5).Buffer)},function(e,t,r){"use strict";(function(e){
|
|
1
|
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=6)}([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 i=r(1),o=i.msgpack,s=i.Int64BE,a=i.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"},p=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 o}},{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}();p.Int64=function(e){return new s(""+e)},p.Uint64=function(e){return new a(""+e)},e.exports=p},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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};var s=function(){if(o.fpnn)return o.fpnn;var e="undefined"!=typeof self&&"function"==typeof self.importScripts&&"function"==typeof self.WebSocket;return"undefined"!=typeof window||e?r(11):{FPClient:function e(){throw i(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){i(this,t);var n=r instanceof Error?r:new Error(String(r||"FPNN error")),o=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 o.code=e,o.name="FPError",o.stack=n.stack||o.stack,o.error=n,o}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=o.msgpack||r(12),u=o.md5||r(13),c=o.Int64BE&&o.Uint64BE?{Int64BE:o.Int64BE,Uint64BE:o.Uint64BE}:r(16);e.exports={fpnn:s,msgpack:a,md5:u,Int64BE:c.Int64BE,Uint64BE:c.Uint64BE}},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},i=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 s=function(e){function t(e){o(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){o(this,e),this.high=t>>>0,this.low=r>>>0,this.signed=!!n}return i(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 i=e[n]+r;e[n]=i%1e7,r=Math.floor(i/1e7),n+=1}}(r,t>>>0);for(var n=String(r[r.length-1]),i=r.length-2;i>=0;i-=1)n+=String(r[i]).padStart(7,"0");return n}function f(e,t){for(var r=0,n=0;n<e.length;n+=1){var i=e[n]*t+r;e[n]=i%1e7,r=Math.floor(i/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 p(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 d(e){var t=p(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=d(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 i=t[n],o=void 0;if(i<=127)o=i;else if(i>=194&&i<=223){o=(31&i)<<6|63&m(t,n+1),n+=1}else if(i>=224&&i<=239){var a=m(t,n+1),u=m(t,n+2);if(224===i&&a<160||237===i&&a>159)throw new s("invalid UTF-8 string");o=(15&i)<<12|(63&a)<<6|63&u,n+=2}else{if(!(i>=240&&i<=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===i&&c<144||244===i&&c>143)throw new s("invalid UTF-8 string");o=(7&i)<<18|(63&c)<<12|(63&f)<<6|63&l,n+=3}if(o<=65535)r+=String.fromCharCode(o);else{var h=o-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(){o(this,e),this.chunks=[],this.length=0}return i(e,[{key:"byte",value:function(e){this.chunks.push(new Uint8Array([255&e])),this.length+=1}},{key:"bytes",value:function(e){var t=d(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 i=void 0===e?"undefined":n(e);if("boolean"!==i)if("string"!==i)if("number"!==i)if("bigint"!==i){if("object"!==i)throw new s("unsupported MessagePack value type: "+i);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 o=p(e);if(o)!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)}(o,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 i=10*r+(e.charCodeAt(n)-48);r=i%4294967296;var o=10*t+Math.floor(i/4294967296);if(o>=4294967296)throw new s("integer exceeds uint64");t=o}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 i=u(n.high,n.low);return t.byte(211),void t.uint64(i.high,i.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){o(this,e),this.bytes=d(t),this.offset=0,this.allowIntegerMapKeyAtPath=r&&Array.isArray(r.allowIntegerMapKeyAtPath)?r.allowIntegerMapKeyAtPath.slice():null}return i(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),i=0;i<e;i+=1)n[i]=this.value(t+1,r.concat(String(i)));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,i={},o=0;o<e;o+=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(i,u))throw new s("duplicate MessagePack map key: "+u);Object.defineProperty(i,u,{configurable:!0,enumerable:!0,value:this.value(t+1,r.concat(u)),writable:!0})}return i}},{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:p,isPlainMap:h,toUint8Array:d,utf8Decode:y,utf8Encode:g}},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 i=r(0),o=r(17),s=r(18),a=r(21),u=r(1),c=u.fpnn,f=u.md5;function l(e){var t="ws://";return this._ssl&&(t="wss://"),t+e+"/service/websocket"}function h(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===i.ERROR_CODE.RTM_EC_API_FREQUENCY_LIMITED||e===i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR}function p(e,t){return!e&&!h(t)}function d(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:l.call(this,this._endpoint),autoReconnect:!1,connectionTimeout:this._connectionTimeout,platformImpl:this._platformImpl});var n=this._baseClient,i=this,o=!1,a=!1,u=!1,f=!1;function h(t,r){u||(u=!0,e&&e(t,r))}"tlv-v1"===this._protocol&&(this._canReconnect=this._autoReconnect),n.on("close",(function(){n===i._baseClient&&(a||f||(f=!0,h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION),"tlv-v1"===i._protocol&&y.call(i)))})),n.on("error",(function(e){n===i._baseClient&&(a||_.call(i,e),o||h(!1,c.FPConfig.ERROR_CODE.FPNN_EC_CORE_INVALID_CONNECTION))})),n.on("connect",(function(){n===i._baseClient&&(o||(o=!0,i._requireClose=!1,g.call(i,(function(e,t){if(e)a=!0;else if("tlv-v1"===i._protocol&&p(e,t))i._canReconnect=!1;else if("tlv-v1"===i._protocol&&!f&&n===i._baseClient)return h(e,t),void n.close();h(e,t)}),t)))})),n.processor=this._processor,n.connect()}function g(e,t){var r=this._baseClient;if(r){var n={pid:this._pid,uid:this._uid,token:this._token,version:this._clientVersion||"WebSocket_"+i.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 o={flag:1,method:"auth",payload:i.MsgPack.encode(n,this._msgOptions)},s=this;C.call(this,r,o,(function(t,n){if(r===s._baseClient){var o=n&&("tlv-v1"===s._protocol?n.accepted:n.ok);if(o)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&&y.call(s)})),r.on("error",(function(e){r===s._baseClient&&_.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&&(_.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&&!o){var u="tlv-v1"===s._protocol?i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN:c.FPConfig.ERROR_CODE.FPNN_EC_OK;e&&e(!1,u),"tlv-v1"===s._protocol&&_.call(s,new c.FPError(u,new Error("Gate rejected auth.login (accepted=false)")))}t&&(e&&e(!1,t.code),_.call(s,t),a="tlv-v1"===s._protocol?h(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 y(){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?(_.call(this,new c.FPError(c.FPConfig.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,new Error("connection closed, requireClose: "+this._requireClose))),void m.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 m(){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),_.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,i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN,t),r.emit("SessionClosed",i.ERROR_CODE.RTM_EC_INVALID_AUTH_TOEKN),_.call(r,new c.FPError(i.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&&p(e,n)?(r.emit("ReloginCompleted",!1,!1,n,t),r.emit("SessionClosed",n),_.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&&m.call(r),_.call(r,new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("relogin fail, errorCode: "+n+", reconnectCount: "+t))))}),n)}),e)}}function _(e){this.emit("ErrorRecorder",e)}function v(e){return this._md5?this._md5(e).toUpperCase():f(e).toUpperCase()}function b(e,r,n,o,s){var a=this;n&&"0"!=n.toString()||(n=k.call(this)),w.call(a,e,(function(u,f){if(u)o&&o({mid:n,error:u},null);else{var l=f.token,h=f.endpoint,p=null;if(null!=r&&void 0!==r.name){var d=r.name.lastIndexOf(".");-1!=d&&(p=r.name.slice(d+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=v.call(a,u).toLowerCase(),d=v.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=i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR;void 0!==e.code&&(t=e.code),_.call(a,new c.FPError(t,e))})),m.on("connect",(function(){var t={token:l,sign:d,ext:p,file:u,endpoint:h};for(var r in e)t[r]=e[r];E.call(a,m,t,n,o,s)})),m.connect()}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error("no file content!"))},null)},g.readAsArrayBuffer(r)}else o&&o({mid:n,error:new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,new Error(JSON.stringify(f)))},null)}}))}function w(e,t,r){var n={};for(var o in e)"mtype"!=o&&(n[o]=e[o]);var s={flag:1,method:"filetoken",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,s,t,r)}function E(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.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 i.Int64(""+r.mtime)),n&&n(null,{mid:s.mid,payload:r}))}),o)}function k(){++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 i.Int64(Date.now().toString()+e)}function R(e){return"tlv-v1"===this._protocol?null==e?0:e:e&&"0"!=e.toString()?e:k.call(this)}function P(e,t){if(!t)return new c.FPError(i.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,Error("data is null"));if(t instanceof Error){var r=i.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 C(e,t,r,n){var o=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=P.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=o?i.MsgPack.decode(e.payload,s._binaryOptions):i.MsgPack.decode(e.payload,s._msgOptions),2==e.mtype&&(n=0!=e.ss),(t=P.call(s,n,a))?void(r&&r(t,null)):void(r&&r(null,a))}(t=P.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 O(e){if("string"==typeof e)return e;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(e){return}}var T=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c.FPEvent.assign(this),this._protocol=t.protocol||"fpnn","fpnn"!==this._protocol&&"tlv-v1"!==this._protocol)throw new Error('options.protocol must be "fpnn" or "tlv-v1"');if(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=i.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){if(this._tlvEndpoint=t.tlvEndpoint||t.tlv_endpoint,!this._tlvEndpoint&&"string"==typeof t.endpoint&&/^wss?:\/\//i.test(t.endpoint)&&(this._tlvEndpoint=t.endpoint),!this._tlvEndpoint&&"string"==typeof t.ssl_endpoint&&/^wss?:\/\//i.test(t.ssl_endpoint)&&(this._tlvEndpoint=t.ssl_endpoint),"string"!=typeof this._tlvEndpoint||!/^wss?:\/\//i.test(this._tlvEndpoint))throw new Error("tlv-v1 requires options.tlvEndpoint as the deployment-provided ws:// or wss:// URL")}else{if(null!=this._endpoint){var r=this._endpoint.split(":");2==r.length&&"13325"==r[1]&&(this._endpoint=r[0]+":13321")}null!=t.ssl_endpoint&&(this._endpoint=t.ssl_endpoint,this._ssl=!0)}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:i.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:i.MsgPack.createCodec({int64:!0,useraw:!0})};var n=this;this._processor=new o(this);var s=function(){n._requireClose=!0,n._canReconnect=!1,"tlv-v1"!==n._protocol&&n._baseClient&&n._baseClient.close()};this._processor.on(i.SERVER_PUSH.kickOut,s),this._processor.on(i.TLV_SERVER_PUSH.kickOut,s),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),d.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:i.MsgPack.encode({},this._msgOptions)},n=this;this._requireClose=!0,C.call(this,this._baseClient,r,(function(e,r){"tlv-v1"===n._protocol?e&&(_.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:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){e?t&&t(e,null):(r&&void 0!==r.mts&&(r.mts=new i.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,o,s,a){var u={to:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={tos:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendmsgs",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={gid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendgroupmsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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,o,s,a){var u={rid:e,mid:o=R.call(this,o),mtype:t,msg:r,attrs:n},c={flag:1,method:"sendroommsg",payload:"tlv-v1"===this._protocol?u:i.MsgPack.encode(u,this._msgOptions)},f="tlv-v1"===this._protocol;C.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 i.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){"boolean"!=typeof t&&("function"==typeof r&&void 0===n&&(n=r,r=t),t=void 0);var o={clear:void 0!==e&&e};void 0!==t&&(o.gettime=t);var s={flag:1,method:"getunread",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.p2p;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(""+e)})),t.p2p=o}var s=t.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),t.group=a}n&&n(null,t)}}),r)}},{key:"getP2PUnreadMessageNum",value:function(e,t,r,n,o){var s={uids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getp2punread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={p2p:{},ltime:{}},n=t.p2p;if(n)for(var s in n)r.p2p[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"getGroupUnreadMessageNum",value:function(e,t,r,n,o){var s={gids:e};void 0!==t&&(s.mtime=t),void 0!==r&&(s.mtypes=r);var a={flag:1,method:"getgroupunread",payload:i.MsgPack.encode(s,this._msgOptions)},u="tlv-v1"===this._protocol;C.call(this,this._baseClient,a,(function(e,t){if(e)o&&o(e,null);else if(u)o&&o(null,t);else{var r={group:{},ltime:{}},n=t.group;if(n)for(var s in n)r.group[new i.Int64(""+s)]=n[s];var a=t.ltime;if(a)for(var s in a)r.ltime[new i.Int64(""+s)]=new i.Int64(""+a[s]);o&&o(null,r)}}),n)}},{key:"cleanUnreadMessage",value:function(e,t){var r={flag:1,method:"cleanunread",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"setSessionRead",value:function(e,t,r,n,o){var s={category:e,xid:t,read_seq:r},a={flag:1,method:"setsessionread",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getSession",value:function(e,t){var r={flag:1,method:"getsession",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.p2p;if(n){var o=[];n.forEach((function(e,t){o[t]=new i.Int64(""+e)})),r.p2p=o}var s=r.group;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(""+e)})),r.group=a}t&&t(null,r)}}),e)}},{key:"getGroupMessage",value:function(e,t,r,n,o,s,a,u,c){var f={gid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getgroupmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getRoomMessage",value:function(e,t,r,n,o,s,a,u,c){var f={rid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getroommsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getBroadcastMessage",value:function(e,t,r,n,o,s,a,u){var c={desc:e,num:t};void 0!==r&&(c.begin=r),void 0!==n&&(c.end=n),void 0!==o&&(c.lastid=o),void 0!==s&&(c.mtypes=s);var f={flag:1,method:"getbroadcastmsg",payload:i.MsgPack.encode(c,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),from:new i.Int64(""+e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),u&&u(null,t)}}),a,!0)}},{key:"getP2PMessage",value:function(e,t,r,n,o,s,a,u,c){var f={ouid:e,desc:t,num:r};void 0!==n&&(f.begin=n),void 0!==o&&(f.end=o),void 0!==s&&(f.lastid=s),void 0!==a&&(f.mtypes=a);var l={flag:1,method:"getp2pmsg",payload:i.MsgPack.encode(f,this._msgOptions)};C.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],o=O(e[5]),s=O(e[6]);r[t]={id:new i.Int64(""+e[0]),direction:Number(e[1]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:o,binary:n,attrs:s,mtime:new i.Int64(""+e[7])}})),c&&c(null,t)}}),u,!0)}},{key:"getP2PMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={ouid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getp2pmsgbymessageid",c,!0,a,u)}},{key:"getGroupMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={gid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getgroupmsgbymessageid",c,!1,a,u)}},{key:"getRoomMessageByMessageId",value:function(e,t,r,n,i,o,s,a,u){var c={rid:e,mid:t,desc:r,num:n};void 0!==i&&(c.begin=i),void 0!==o&&(c.end=o),void 0!==s&&(c.mtypes=s),this._getMessageByAnchor("getroommsgbymessageid",c,!1,a,u)}},{key:"getBroadcastMessageByMessageId",value:function(e,t,r,n,i,o,s,a){var u={mid:e,desc:t,num:r};void 0!==n&&(u.begin=n),void 0!==i&&(u.end=i),void 0!==o&&(u.mtypes=o),this._getMessageByAnchor("getbroadcastmsgbymessageid",u,!1,s,a)}},{key:"_getMessageByAnchor",value:function(e,t,r,n,o){var s={flag:1,method:e,payload:i.MsgPack.encode(t,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){e?o&&o(e,null):o&&o(null,function(e,t){var r=e&&e.msgs;return r?(r.forEach((function(e,n){var o={id:new i.Int64(""+e[0]),mtype:Number(e[2]),mid:new i.Int64(""+e[3]),deleted:e[4],msg:O(e[5]),binary:e[5],attrs:O(e[6]),mtime:new i.Int64(""+e[7])};t?o.direction=Number(e[1]):o.from=new i.Int64(""+e[1]),r[n]=o})),e):e}(t,r))}),n,!0)}},{key:"getP2PMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getp2pmsgcount",{ouid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getGroupMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getgroupmsgcount",{gid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getRoomMessageCount",value:function(e,t,r,n,i,o){this._getMessageCount("getroommsgcount",{rid:e,begin:t,end:r,mtypes:n},i,o)}},{key:"getBroadcastMessageCount",value:function(e,t,r,n,i){this._getMessageCount("getbroadcastmsgcount",{begin:e,end:t,mtypes:r},n,i)}},{key:"_getMessageCount",value:function(e,t,r,n){var o={};Object.keys(t).forEach((function(e){void 0!==t[e]&&(o[e]=t[e])}));var s={flag:1,method:e,payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"fileToken",value:function(e,t,r,n,i,o,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!==i&&(a.gid=i),w.call(this,a,s,o)}},{key:"addAttrs",value:function(e,t,r){var n={attrs:e},o={flag:1,method:"addattrs",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getAttrs",value:function(e,t){var r={flag:1,method:"getattrs",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addDebugLog",value:function(e,t,r,n){var o={msg:e,attrs:t},s={flag:1,method:"adddebuglog",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"addDevice",value:function(e,t,r,n){var o={apptype:e,devicetoken:t},s={flag:1,method:"adddevice",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"removeDevice",value:function(e,t,r){var n={devicetoken:e},o={flag:1,method:"removedevice",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setTranslationLanguage",value:function(e,t,r){var n={lang:e},o={flag:1,method:"setlang",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"translate",value:function(e,t,r,n,o,s,a){var u={text:e,dst:r};void 0!==t&&(u.src=t),void 0!==n&&(u.type=n),void 0!==o&&(u.profanity=o);var c={flag:1,method:"translate",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"profanity",value:function(e,t,r,n){var o={text:e};void 0!==t&&(o.classify=t);var s={flag:1,method:"profanity",payload:i.MsgPack.encode(o,this._msgOptions)};C.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):"number"!=typeof t||void 0!==r&&"function"!=typeof r||(n="function"==typeof r?r:n,r=t,t=void 0);var o={text:e};void 0!==t&&(o.strategyId=t);var s={flag:1,method:"tcheck",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"imageCheck",value:function(e,t,r,n,o){var s={image:e,type:t};void 0!==r&&(s.strategyId=r);var a={flag:1,method:"icheck",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"audioCheck",value:function(e,t,r,n,o,s,a,u){var c={audio:e,type:t,lang:r};void 0!==n&&(c.codec=n),void 0!==o&&(c.srate=o),void 0!==s&&(c.strategyId=s);var f={flag:1,method:"acheck",payload:i.MsgPack.encode(c,this._msgOptions)};C.call(this,this._baseClient,f,u,a)}},{key:"videoCheck",value:function(e,t,r,n,o,s){var a={video:e,type:t,videoName:r};void 0!==n&&(a.strategyId=n);var u={flag:1,method:"vcheck",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"speech2Text",value:function(e,t,r,n,o,s,a){var u={audio:e,type:t,lang:r};void 0!==n&&(u.codec=n),void 0!==o&&(u.srate=o);var c={flag:1,method:"speech2text",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getGroupsOpenInfo",value:function(e,t,r){var n={gids:e},o={flag:1,method:"getgroupsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomsOpenInfo",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomsopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomMembers",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroommembers",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomCount",value:function(e,t,r){var n={rids:e},o={flag:1,method:"getroomcount",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"addoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeDevicePushOption",value:function(e,t,r,n,o){var s={type:e,xid:t};void 0!==r&&(s.mtypes=r);var a={flag:1,method:"removeoption",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getDevicePushOption",value:function(e,t){var r={flag:1,method:"getoption",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"addFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"addfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteFriends",value:function(e,t,r){var n={friends:e},o={flag:1,method:"delfriends",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getFriends",value:function(e,t){var r={flag:1,method:"getfriends",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var n=r.uids;if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(t&&t(null,o))}t&&t(null,r)}}),e)}},{key:"addGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"addgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"deleteGroupMembers",value:function(e,t,r,n){var o={gid:e,uids:t},s={flag:1,method:"delgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupMembers",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupmembers",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,(function(e,t){if(e)n&&n(e,null);else{var r=t.uids;if(r){var o=[];r.forEach((function(e,t){o[t]=new i.Int64(e)})),t.uids=o}var s=t.onlines;if(s){var a=[];s.forEach((function(e,t){a[t]=new i.Int64(e)})),t.onlines=a}n&&n(null,t)}}),r)}},{key:"getGroupCount",value:function(e,t,r,n){var o={gid:e};void 0!==t&&(o.online=t);var s={flag:1,method:"getgroupcount",payload:i.MsgPack.encode(o,this._msgOptions)};C.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:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"group_refs":"gids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"enterRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"enterroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"enterRooms",value:function(e,t,r){var n={rids:e},o={flag:1,method:"enterrooms",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"leaveRoom",value:function(e,t,r){var n={rid:e},o={flag:1,method:"leaveroom",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getUserRooms",value:function(e,t){var r={flag:1,method:"getuserrooms",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"room_refs":"rooms";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.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 o={flag:1,method:"getuserroomsandlastmsg",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getOnlineUsers",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getonlineusers",payload:i.MsgPack.encode(n,this._msgOptions)},s="tlv-v1"===this._protocol?"online_users":"uids";C.call(this,this._baseClient,o,(function(e,t){if(e)r&&r(e,null);else{var n=t[s];if(n){var o=[];return n.forEach((function(e,t){o[t]=new i.Int64(e)})),void(r&&r(null,o))}r&&r(null,t)}}),t)}},{key:"deleteMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"delmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,s,o)}},{key:"getMessage",value:function(e,t,r,n,o,s){var a={from:e,mid:t,xid:r,type:n},u={flag:1,method:"getmsg",payload:i.MsgPack.encode(a,this._msgOptions)};C.call(this,this._baseClient,u,(function(e,t){e?s&&s(e,null):(void 0!==t.id&&(t.id=new i.Int64(""+t.id)),void 0!==t.mtime&&(t.mtime=new i.Int64(""+t.mtime)),s&&s(null,t))}),o,!0)}},{key:"sendChat",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendAudio",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendCmd",value:function(e,t,r,n,o,s){this.sendMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendGroupChat",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendGroupAudio",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendGroupCmd",value:function(e,t,r,n,o,s){this.sendGroupMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"sendRoomChat",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.text,t,r,n,o,s)}},{key:"sendRoomAudio",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.audio,t,r,n,o,s)}},{key:"sendRoomCmd",value:function(e,t,r,n,o,s){this.sendRoomMessage.call(this,e,i.CHAT_TYPE.cmd,t,r,n,o,s)}},{key:"getGroupChat",value:function(e,t,r,n,o,s,a,u){this.getGroupMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getRoomChat",value:function(e,t,r,n,o,s,a,u){this.getRoomMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getP2PChat",value:function(e,t,r,n,o,s,a,u){this.getP2PMessage.call(this,e,t,r,n,o,s,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],a,u)}},{key:"getBroadcastChat",value:function(e,t,r,n,o,s,a){this.getBroadcastMessage.call(this,e,t,r,n,o,[i.CHAT_TYPE.text,i.CHAT_TYPE.audio,i.CHAT_TYPE.cmd],s,a)}},{key:"deleteChat",value:function(e,t,r,n,i,o){this.deleteMessage(e,t,r,n,i,o)}},{key:"getChat",value:function(e,t,r,n,i,o){this.getMessage(e,t,r,n,i,o)}},{key:"setUserInfo",value:function(e,t,r,n){var o={};void 0!==e&&(o.oinfo=e),void 0!==t&&(o.pinfo=t);var s={flag:1,method:"setuserinfo",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUserInfo",value:function(e,t){var r={flag:1,method:"getuserinfo",payload:i.MsgPack.encode({},this._msgOptions)};C.call(this,this._baseClient,r,t,e)}},{key:"getUserOpenInfo",value:function(e,t,r){var n={uids:e},o={flag:1,method:"getuseropeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setGroupInfo",value:function(e,t,r,n,o){var s={gid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setgroupinfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"getGroupInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupinfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getGroupOpenInfo",value:function(e,t,r){var n={gid:e},o={flag:1,method:"getgroupopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"setRoomInfo",value:function(e,t,r,n,o){var s={rid:e};void 0!==t&&(s.oinfo=t),void 0!==r&&(s.pinfo=r);var a={flag:1,method:"setroominfo",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"setRoomProfile",value:function(e,t,r,n,o,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!==o&&(u.icon=o);var c={flag:1,method:"setroominfo",payload:i.MsgPack.encode(u,this._msgOptions)};C.call(this,this._baseClient,c,a,s)}},{key:"getRoomInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroominfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getRoomOpenInfo",value:function(e,t,r){var n={rid:e},o={flag:1,method:"getroomopeninfo",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataSet",value:function(e,t,r,n){var o={key:e,val:t},s={flag:1,method:"dataset",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"dataGet",value:function(e,t,r){var n={key:e},o={flag:1,method:"dataget",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"dataDelete",value:function(e,t,r){var n={key:e},o={flag:1,method:"datadel",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"addBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"addblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"deleteBlacks",value:function(e,t,r){var n={blacks:e},o={flag:1,method:"delblacks",payload:i.MsgPack.encode(n,this._msgOptions)};C.call(this,this._baseClient,o,r,t)}},{key:"getBlacks",value:function(e,t){var r={flag:1,method:"getblacks",payload:i.MsgPack.encode({},this._msgOptions)},n="tlv-v1"===this._protocol?"blocked_users":"uids";C.call(this,this._baseClient,r,(function(e,r){if(e)t&&t(e,null);else{var o=r[n];if(o){var s=[];return o.forEach((function(e,t){s[t]=new i.Int64(""+e)})),void(t&&t(null,s))}t&&t(null,r)}}),e)}},{key:"sendFile",value:function(e,t,r,n,i,o){var s={to:t,mtype:e,cmd:"sendfile"};b.call(this,s,r,n,o,i)}},{key:"sendGroupFile",value:function(e,t,r,n,i,o){var s={gid:t,mtype:e,cmd:"sendgroupfile"};b.call(this,s,r,n,o,i)}},{key:"sendRoomFile",value:function(e,t,r,n,i,o){var s={rid:t,mtype:e,cmd:"sendroomfile"};b.call(this,s,r,n,o,i)}},{key:"getP2PConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2pconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getP2PUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getp2punreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getGroupUnreadConversationList",value:function(e,t,r,n){var o={};void 0!==e&&(o.mtime=e),void 0!==t&&(o.mtypes=t);var s={flag:1,method:"getgroupunreadconversationlist",payload:i.MsgPack.encode(o,this._msgOptions)};C.call(this,this._baseClient,s,n,r)}},{key:"getUnreadConversationList",value:function(e,t,r,n,o){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:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,o,n)}},{key:"removeSession",value:function(e,t,r,n){var o="boolean"==typeof t;o||("function"==typeof r&&void 0===n&&(n=r,r=t),t=!1);var s={to:e};("tlv-v1"===this._protocol||o)&&(s.oneway=t);var a={flag:1,method:"removesession",payload:i.MsgPack.encode(s,this._msgOptions)};C.call(this,this._baseClient,a,n,r)}},{key:"processor",get:function(){return this._processor}}]),e}();e.exports=T}).call(this,r(5).Buffer)},function(e,t,r){"use strict";(function(e){
|
|
2
2
|
/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
|
5
5
|
* @author Feross Aboukhadijeh <http://feross.org>
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
var n=r(8),i=r(9),o=r(10);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|p(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|p(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){l=!1;break}if(l)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return Y(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return Y(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return w(e,t,r,n)}function k(e,t,r,n){return Y(q(t),e,r,n)}function R(e,t,r,n){return Y(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],f=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return f(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){o=c[l],s=f[l];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function A(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=L(e[o]);return i}function S(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var F=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(2))},function(e,t,r){"use strict";r(7)(self)},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};function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=r(4),s=r(0),a=r(1),u=a.Int64BE,c=a.Uint64BE,f="__rtmSharedWorkerType__",l={constructor:!0,destroy:!0,emit:!0,on:!0,removeEvent:!0},h={sendFile:!0,sendGroupFile:!0,sendRoomFile:!0},p={client:null,optionsKey:null,attachedPorts:new Set,readyPorts:new Set,portConversations:new Map,idleShutdownTimeout:5e3,idleShutdownTimer:null,loginStatus:"idle",loginUid:null,loginToken:null,loginWaiters:[]};function d(e,t){S(e,t,void 0,!0),g(e)}function g(e){var t=p.attachedPorts.delete(e);p.readyPorts.delete(e),p.portConversations.delete(e),e.onmessage=null,e.onmessageerror=null,e.onclose=null,t&&m()}function y(){null!==p.idleShutdownTimer&&(clearTimeout(p.idleShutdownTimer),p.idleShutdownTimer=null)}function m(){y(),!p.client||p.attachedPorts.size>0||(p.idleShutdownTimer=setTimeout((function(){if(p.idleShutdownTimer=null,p.client&&!(p.attachedPorts.size>0)){var e=p.client;p.client=null,p.optionsKey=null,p.idleShutdownTimeout=5e3,p.loginStatus="idle",p.loginUid=null,p.loginToken=null,p.loginWaiters=[],p.readyPorts.clear(),p.portConversations.clear(),e.destroy()}}),p.idleShutdownTimeout))}function _(e,t,r,n,i){var o=p.client;p.loginStatus="connecting",p.loginUid=P(e),p.loginToken=String(t),p.loginWaiters=n?[n]:[],E();try{o.login(e,t,(function(e,t){if(p.client===o){var r=p.loginWaiters.slice();p.loginWaiters=[],p.loginStatus=e?"authenticated":"idle",e||(p.loginUid=null,p.loginToken=null),E(),r.forEach((function(r){r(e,t)}))}}),r)}catch(e){if(p.client!==o)return;p.loginStatus="idle",p.loginUid=null,p.loginToken=null,E();var a=p.loginWaiters.slice();p.loginWaiters=[],a.forEach((function(e){e(!1,s.ERROR_CODE.RTM_EC_UNKNOWN_ERROR)})),i&&S(i,e)}}function v(e,t,r,n){M(e,{type:"login-result",requestId:t,result:r?R(r):void 0,error:n?R(n):void 0})}function b(e,t){var r=e.emit;e.emit=function(n){var i="client"===t?p.client===e:p.client&&p.client.processor===e;if(!i)return r.apply(this,arguments);var o=Array.prototype.slice.call(arguments,1);return"client"===t&&"SessionClosed"===n&&(p.loginStatus="idle",p.loginUid=null,p.loginToken=null),I({type:"event",channel:t,name:n,args:R(o)},{channel:t,name:n,args:o}),"client"===t&&"SessionClosed"===n&&E(),r.apply(this,arguments)}}function w(){return{status:p.loginStatus,uid:"idle"===p.loginStatus?null:p.loginUid}}function E(){I({type:"session-state",session:w()})}function k(e,t){if(Array.isArray(e))return e.map((function(e){return k(e,t)}));if(!O(e))return e;if(void 0!==e.__rtmSharedWorkerCallback__){var r=e.__rtmSharedWorkerCallback__;return function(){A(t,{type:"callback",callbackId:r,args:R(Array.prototype.slice.call(arguments))})}}if("int64"===e[f])return s.Int64(e.value);if("uint64"===e[f])return s.Uint64(e.value);var n={};return Object.keys(e).forEach((function(r){n[r]=k(e[r],t)})),n}function R(e){if(e instanceof Error){var t,r=(i(t={},f,"error"),i(t,"name",e.name),i(t,"message",e.message),i(t,"stack",e.stack),t);return void 0!==e.code&&(r.code=e.code),void 0!==e.status&&(r.status=e.status),void 0!==e.reason&&(r.reason=e.reason),r}if(e&&"object"===(void 0===e?"undefined":n(e))){var o,s;if(u.isInt64BE(e))return i(o={},f,"int64"),i(o,"value",e.toString()),o;if(c.isUint64BE(e))return i(s={},f,"uint64"),i(s,"value",e.toString()),s;if(Array.isArray(e))return e.map(R);if(O(e)){var a={};return Object.keys(e).forEach((function(t){a[t]=R(e[t])})),a}}return e}function P(e){return e&&"function"==typeof e.toString?e.toString():String(e)}function C(e){return Array.isArray(e)?"["+e.map(C).join(",")+"]":O(e)?"{"+Object.keys(e).sort().map((function(t){return JSON.stringify(t)+":"+C(e[t])})).join(",")+"}":JSON.stringify(e)}function O(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function T(e){if(null==e)return null;if(!O(e)||-1===["direct","group","room"].indexOf(e.type)||"string"!=typeof e.id||!/^\d+$/.test(e.id)||/^0+$/.test(e.id))throw new Error('conversation must contain type "direct", "group", or "room" and a positive int64 id');var t=e.id.replace(/^0+(?=\d)/,"");if(t.length>19||19===t.length&&t>"9223372036854775807")throw new Error("conversation.id exceeds the positive int64 range");return{type:e.type,id:t}}function A(e,t){try{e.postMessage(t)}catch(t){S(e,t)}}function S(e,t,r,n){var i={type:"error",error:R(t instanceof Error?t:new Error(String(t)))};void 0!==r&&(i.requestId=r),n&&(i.fatal=!0),M(e,i)}function M(e,t){try{e.postMessage(t)}catch(t){var r=p.attachedPorts.delete(e);p.readyPorts.delete(e),p.portConversations.delete(e),r&&m()}}function I(e,t){p.readyPorts.forEach((function(r){(function(e,t){if(!t||"processor"!==t.channel)return!0;var r=p.portConversations.get(e);if(!r)return!0;var n=t.args&&t.args[0];if("event.direct"===t.name)return"direct"===r.type&&U(n&&n.sender)===r.id;if("event.group"===t.name)return"group"===r.type&&U(n&&n.group_ref)===r.id;if("event.room"===t.name)return"room"===r.type&&U(n&&n.room_ref)===r.id;if("event.room_removed"===t.name)return"room"===r.type&&U(n&&n.room_ref)===r.id;return!0})(r,t)&&M(r,e)}))}function U(e){return e&&"function"==typeof e.toString?e.toString():String(e)}e.exports=function(e){(e||self).onconnect=function(e){var t=e.ports[0];p.attachedPorts.add(t),y(),t.onmessage=function(e){!function(e,t){if(!t||"string"!=typeof t.type)return;if("detach"===t.type)return void g(e);if("init"===t.type)return void function(e,t,r,n){if("tlv-v1"!==t.protocol)return void d(e,new Error('SharedWorker transport only supports protocol: "tlv-v1"'));var i=void 0;try{i=T(r)}catch(t){return void d(e,t)}var s=(u=n,"number"==typeof u&&isFinite(u)&&u>=0?n:5e3),a=C({clientOptions:t,idleShutdownTimeout:s});var u;if(p.client){if(p.optionsKey!==a)return void d(e,new Error("All tabs sharing one RTM SharedWorker must use identical clientOptions and idleShutdownTimeout"))}else try{p.client=new o(t),p.optionsKey=a,p.idleShutdownTimeout=s,b(p.client,"client"),b(p.client.processor,"processor")}catch(t){return void d(e,t)}p.readyPorts.add(e),i?p.portConversations.set(e,i):p.portConversations.delete(e);A(e,{type:"ready",session:w()})}(e,t.options||{},t.conversation,t.idleShutdownTimeout);if("setConversation"===t.type){if(!p.readyPorts.has(e))return void S(e,new Error("Shared RTM client is not initialized"),t.requestId);try{!function(e,t){var r=T(t);r?p.portConversations.set(e,r):p.portConversations.delete(e)}(e,t.conversation),void 0!==t.requestId&&A(e,{type:"conversation-set",requestId:t.requestId})}catch(r){S(e,r,t.requestId)}return}if("login-if-needed"===t.type)return p.client&&p.readyPorts.has(e)?void function(e,t){var r=void 0;try{r=k(t.uid,e)}catch(o){return void v(e,t.requestId,null,o)}var n=P(r),i=function(r,i,o){v(e,t.requestId,{accepted:Boolean(r),errorCode:void 0===i?0:i,reused:Boolean(o),uid:r?n:p.loginUid||null})};if("authenticated"===p.loginStatus)return void(p.loginUid===n?i(!0,0,!0):i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH,!1));if("connecting"===p.loginStatus)return p.loginUid!==n?void i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH,!1):void p.loginWaiters.push((function(e,t){i(e,t,!0)}));if("string"!=typeof t.credential||0===t.credential.length){var o=new Error("This RTM UID is not logged in yet; provide its server-issued credential in one tab first.");return o.code="RTM_SHARED_CREDENTIAL_REQUIRED",void v(e,t.requestId,null,o)}_(r,t.credential,t.timeout,(function(e,t){i(e,t,!1)}),e)}(e,t):void v(e,t.requestId,null,new Error("Shared RTM client is not initialized"));if("invoke"===t.type){if(!p.client||!p.readyPorts.has(e))return void S(e,new Error("Shared RTM client is not initialized"));!function(e,t,r){var n=o.prototype;if("string"!=typeof t||"_"===t.charAt(0)||l[t]||!Object.prototype.hasOwnProperty.call(n,t)||"function"!=typeof p.client[t])return void S(e,new Error("Unsupported RTMClient method: "+String(t)));var i=k(r,e);if(h[t]){var a="function"==typeof i[5]?i[5]:null;if(a){var u=new Error("File sending is not supported by RTMSharedWorkerClient");u.code=s.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,a({mid:i[3],error:u},null)}return}if("login"===t)return void function(e,t){var r=t[0],n=t[1],i="function"==typeof t[2]?t[2]:null,o=P(r);String(n);if("connecting"===p.loginStatus)return p.loginUid===o?void(i&&p.loginWaiters.push(i)):void(i&&i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH));if("authenticated"===p.loginStatus)return p.loginUid===o?void(i&&i(!0,0)):void(i&&i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH));_(r,n,t[3],i,e)}(e,i);try{p.client[t].apply(p.client,i)}catch(u){var c=function(e){for(var t=e.length-1;t>=0;t-=1)if("function"==typeof e[t])return e[t];return null}(i);c?c(u,null):S(e,u)}}(e,t.method,t.args||[])}}(t,e&&e.data)},t.onmessageerror=function(){S(t,new Error("Failed to decode a message from a client tab"))},t.onclose=function(){g(t)},t.start()}}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(f(e,s,s+16383>a?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
8
|
+
var n=r(8),i=r(9),o=r(10);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,r),i=(e=a(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|p(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(f(t),e=a(e,t<0?0:0|p(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|p(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return A(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===u)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){l=!1;break}if(l)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function b(e,t,r,n){return Y(j(t,e.length-r),e,r,n)}function w(e,t,r,n){return Y(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function E(e,t,r,n){return w(e,t,r,n)}function k(e,t,r,n){return Y(q(t),e,r,n)}function R(e,t,r,n){return Y(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function P(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function C(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],f=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=u,t.SlowBuffer=function(e){+e!=e&&(e=0);return u.alloc(+e)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return f(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},u.byteLength=d,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?C(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;l<a;++l)if(c[l]!==f[l]){o=c[l],s=f[l];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return b(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return E(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function A(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=L(e[o]);return i}function S(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,r,n,i,o){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function U(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||M(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||M(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||M(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||M(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readInt8=function(e,t){return t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||M(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||M(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||I(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);I(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||I(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=u.isBuffer(e)?e:j(new u(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var F=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(2))},function(e,t,r){"use strict";r(7)(self)},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};function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=r(4),s=r(0),a=r(1),u=a.Int64BE,c=a.Uint64BE,f=r(22),l=f.normalizeClientOptions,h=f.conversationRoute,p="__rtmSharedWorkerType__",d={constructor:!0,destroy:!0,emit:!0,on:!0,removeEvent:!0},g={sendFile:!0,sendGroupFile:!0,sendRoomFile:!0},y={client:null,protocol:null,optionsKey:null,attachedPorts:new Set,readyPorts:new Set,portConversations:new Map,idleShutdownTimeout:5e3,idleShutdownTimer:null,loginStatus:"idle",loginUid:null,loginToken:null,loginWaiters:[]};function m(e,t){U(e,t,void 0,!0),_(e)}function _(e){var t=y.attachedPorts.delete(e);y.readyPorts.delete(e),y.portConversations.delete(e),e.onmessage=null,e.onmessageerror=null,e.onclose=null,t&&b()}function v(){null!==y.idleShutdownTimer&&(clearTimeout(y.idleShutdownTimer),y.idleShutdownTimer=null)}function b(){v(),!y.client||y.attachedPorts.size>0||(y.idleShutdownTimer=setTimeout((function(){if(y.idleShutdownTimer=null,y.client&&!(y.attachedPorts.size>0)){var e=y.client;y.client=null,y.protocol=null,y.optionsKey=null,y.idleShutdownTimeout=5e3,y.loginStatus="idle",y.loginUid=null,y.loginToken=null,y.loginWaiters=[],y.readyPorts.clear(),y.portConversations.clear(),e.destroy()}}),y.idleShutdownTimeout))}function w(e,t,r,n,i){var o=y.client;y.loginStatus="connecting",y.loginUid=T(e),y.loginToken=String(t),y.loginWaiters=n?[n]:[],P();try{o.login(e,t,(function(e,t){if(y.client===o){var r=y.loginWaiters.slice();y.loginWaiters=[],y.loginStatus=e?"authenticated":"idle",e||(y.loginUid=null,y.loginToken=null),P(),r.forEach((function(r){r(e,t)}))}}),r)}catch(e){if(y.client!==o)return;y.loginStatus="idle",y.loginUid=null,y.loginToken=null,P();var a=y.loginWaiters.slice();y.loginWaiters=[],a.forEach((function(e){e(!1,s.ERROR_CODE.RTM_EC_UNKNOWN_ERROR)})),i&&U(i,e)}}function E(e,t,r,n){B(e,{type:"login-result",requestId:t,result:r?O(r):void 0,error:n?O(n):void 0})}function k(e,t){var r=e.emit;e.emit=function(n){var i="client"===t?y.client===e:y.client&&y.client.processor===e;if(!i)return r.apply(this,arguments);var o=Array.prototype.slice.call(arguments,1);return"client"===t&&"SessionClosed"===n&&(y.loginStatus="idle",y.loginUid=null,y.loginToken=null),N({type:"event",channel:t,name:n,args:O(o)},{channel:t,name:n,args:o}),"client"===t&&"SessionClosed"===n&&P(),r.apply(this,arguments)}}function R(){return{status:y.loginStatus,uid:"idle"===y.loginStatus?null:y.loginUid}}function P(){N({type:"session-state",session:R()})}function C(e,t){if(Array.isArray(e))return e.map((function(e){return C(e,t)}));if(!S(e))return e;if(void 0!==e.__rtmSharedWorkerCallback__){var r=e.__rtmSharedWorkerCallback__;return function(){I(t,{type:"callback",callbackId:r,args:O(Array.prototype.slice.call(arguments))})}}if("int64"===e[p])return s.Int64(e.value);if("uint64"===e[p])return s.Uint64(e.value);var n={};return Object.keys(e).forEach((function(r){n[r]=C(e[r],t)})),n}function O(e){if(e instanceof Error){var t,r=(i(t={},p,"error"),i(t,"name",e.name),i(t,"message",e.message),i(t,"stack",e.stack),t);return void 0!==e.code&&(r.code=e.code),void 0!==e.status&&(r.status=e.status),void 0!==e.reason&&(r.reason=e.reason),r}if(e&&"object"===(void 0===e?"undefined":n(e))){var o,s;if(u.isInt64BE(e))return i(o={},p,"int64"),i(o,"value",e.toString()),o;if(c.isUint64BE(e))return i(s={},p,"uint64"),i(s,"value",e.toString()),s;if(Array.isArray(e))return e.map(O);if(S(e)){var a={};return Object.keys(e).forEach((function(t){a[t]=O(e[t])})),a}}return e}function T(e){return e&&"function"==typeof e.toString?e.toString():String(e)}function A(e){return Array.isArray(e)?"["+e.map(A).join(",")+"]":S(e)?"{"+Object.keys(e).sort().map((function(t){return JSON.stringify(t)+":"+A(e[t])})).join(",")+"}":JSON.stringify(e)}function S(e){if(null===e||"object"!==(void 0===e?"undefined":n(e)))return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function M(e){if(null==e)return null;if(!S(e)||-1===["direct","group","room"].indexOf(e.type)||"string"!=typeof e.id||!/^\d+$/.test(e.id)||/^0+$/.test(e.id))throw new Error('conversation must contain type "direct", "group", or "room" and a positive int64 id');var t=e.id.replace(/^0+(?=\d)/,"");if(t.length>19||19===t.length&&t>"9223372036854775807")throw new Error("conversation.id exceeds the positive int64 range");return{type:e.type,id:t}}function I(e,t){try{e.postMessage(t)}catch(t){U(e,t)}}function U(e,t,r,n){var i={type:"error",error:O(t instanceof Error?t:new Error(String(t)))};void 0!==r&&(i.requestId=r),n&&(i.fatal=!0),B(e,i)}function B(e,t){try{e.postMessage(t)}catch(t){var r=y.attachedPorts.delete(e);y.readyPorts.delete(e),y.portConversations.delete(e),r&&b()}}function N(e,t){y.readyPorts.forEach((function(r){(function(e,t){if(!t||"processor"!==t.channel)return!0;var r=y.portConversations.get(e);if(!r)return!0;var n=h(y.protocol,t.name,t.args&&t.args[0]);return!n||r.type===n.type&&function(e){return e&&"function"==typeof e.toString?e.toString():String(e)}(n.id)===r.id})(r,t)&&B(r,e)}))}e.exports=function(e){(e||self).onconnect=function(e){var t=e.ports[0];y.attachedPorts.add(t),v(),t.onmessage=function(e){!function(e,t){if(!t||"string"!=typeof t.type)return;if("detach"===t.type)return void _(e);if("init"===t.type)return void function(e,t,r,n){try{t=l(t)}catch(t){return void m(e,t)}var i=void 0;try{i=M(r)}catch(t){return void m(e,t)}var s=(u=n,"number"==typeof u&&isFinite(u)&&u>=0?n:5e3),a=A({clientOptions:t,idleShutdownTimeout:s});var u;if(y.client){if(y.optionsKey!==a)return void m(e,new Error("All tabs sharing one RTM SharedWorker must use identical clientOptions and idleShutdownTimeout"))}else try{y.client=new o(t),y.protocol=t.protocol,y.optionsKey=a,y.idleShutdownTimeout=s,k(y.client,"client"),k(y.client.processor,"processor")}catch(t){return void m(e,t)}y.readyPorts.add(e),i?y.portConversations.set(e,i):y.portConversations.delete(e);I(e,{type:"ready",session:R()})}(e,t.options||{},t.conversation,t.idleShutdownTimeout);if("setConversation"===t.type){if(!y.readyPorts.has(e))return void U(e,new Error("Shared RTM client is not initialized"),t.requestId);try{!function(e,t){var r=M(t);r?y.portConversations.set(e,r):y.portConversations.delete(e)}(e,t.conversation),void 0!==t.requestId&&I(e,{type:"conversation-set",requestId:t.requestId})}catch(r){U(e,r,t.requestId)}return}if("login-if-needed"===t.type)return y.client&&y.readyPorts.has(e)?void function(e,t){var r=void 0;try{r=C(t.uid,e)}catch(o){return void E(e,t.requestId,null,o)}var n=T(r),i=function(r,i,o){E(e,t.requestId,{accepted:Boolean(r),errorCode:void 0===i?0:i,reused:Boolean(o),uid:r?n:y.loginUid||null})};if("authenticated"===y.loginStatus)return void(y.loginUid===n?i(!0,0,!0):i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH,!1));if("connecting"===y.loginStatus)return y.loginUid!==n?void i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH,!1):void y.loginWaiters.push((function(e,t){i(e,t,!0)}));if("string"!=typeof t.credential||0===t.credential.length){var o=new Error("This RTM UID is not logged in yet; provide its server-issued credential in one tab first.");return o.code="RTM_SHARED_CREDENTIAL_REQUIRED",void E(e,t.requestId,null,o)}w(r,t.credential,t.timeout,(function(e,t){i(e,t,!1)}),e)}(e,t):void E(e,t.requestId,null,new Error("Shared RTM client is not initialized"));if("invoke"===t.type){if(!y.client||!y.readyPorts.has(e))return void U(e,new Error("Shared RTM client is not initialized"));!function(e,t,r){var n=o.prototype;if("string"!=typeof t||"_"===t.charAt(0)||d[t]||!Object.prototype.hasOwnProperty.call(n,t)||"function"!=typeof y.client[t])return void U(e,new Error("Unsupported RTMClient method: "+String(t)));var i=C(r,e);if(g[t]){var a="function"==typeof i[5]?i[5]:null;if(a){var u=new Error("File sending is not supported by RTMSharedWorkerClient");u.code=s.ERROR_CODE.RTM_EC_UNKNOWN_ERROR,a({mid:i[3],error:u},null)}return}if("login"===t)return void function(e,t){var r=t[0],n=t[1],i="function"==typeof t[2]?t[2]:null,o=T(r);String(n);if("connecting"===y.loginStatus)return y.loginUid===o?void(i&&y.loginWaiters.push(i)):void(i&&i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH));if("authenticated"===y.loginStatus)return y.loginUid===o?void(i&&i(!0,0)):void(i&&i(!1,s.ERROR_CODE.RTM_EC_DUPLCATED_AUTH));w(r,n,t[3],i,e)}(e,i);try{y.client[t].apply(y.client,i)}catch(u){var c=function(e){for(var t=e.length-1;t>=0;t-=1)if("function"==typeof e[t])return e[t];return null}(i);c?c(u,null):U(e,u)}}(e,t.method,t.args||[])}}(t,e&&e.data)},t.onmessageerror=function(){U(t,new Error("Failed to decode a message from a client tab"))},t.onclose=function(){_(t)},t.start()}}},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[f++]=t>>16&255,u[f++]=t>>8&255,u[f++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[f++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[f++]=t>>8&255,u[f++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(f(e,s,s+16383>a?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a<u;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
9
9
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
-
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){window,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=8)}([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}}(),i=r(10).Buffer,o={FPNN_EC_OK:0,FPNN_EC_PROTO_UNKNOWN_ERROR:10001,FPNN_EC_PROTO_NOT_SUPPORTED:10002,FPNN_EC_PROTO_INVALID_PACKAGE:10003,FPNN_EC_PROTO_JSON_CONVERT:10004,FPNN_EC_PROTO_STRING_KEY:10005,FPNN_EC_PROTO_MAP_VALUE:10006,FPNN_EC_PROTO_METHOD_TYPE:10007,FPNN_EC_PROTO_PROTO_TYPE:10008,FPNN_EC_PROTO_KEY_NOT_FOUND:10009,FPNN_EC_PROTO_TYPE_CONVERT:10010,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_TIMEOUT:20003,FPNN_EC_CORE_UNKNOWN_METHOD:20004,FPNN_EC_CORE_ENCODING:20005,FPNN_EC_CORE_DECODING:20006,FPNN_EC_CORE_SEND_ERROR:20007,FPNN_EC_CORE_RECV_ERROR:20008,FPNN_EC_CORE_INVALID_PACKAGE:20009,FPNN_EC_CORE_HTTP_ERROR:20010,FPNN_EC_CORE_WORK_QUEUE_FULL:20011,FPNN_EC_CORE_INVALID_CONNECTION:20012,FPNN_EC_CORE_FORBIDDEN:20013,FPNN_EC_CORE_SERVER_STOPPING:20014},s=i.from([0,1]),a=i.from([64,128]),u=i.from([0,1,2]),c=i.from("FPNN"),f=i.from("POST"),l=["secp256k1","secp224r1"],h=["aes-128-cfb","aes-256-cfb"],p=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:"SDK_VERSION",get:function(){return"2.0.0"}},{key:"BUFFER",get:function(){return i}},{key:"ERROR_CODE",get:function(){return o}},{key:"FP_FLAG",get:function(){return a}},{key:"FP_MESSAGE_TYPE",get:function(){return u}},{key:"TCP_MAGIC",get:function(){return c}},{key:"HTTP_MAGIC",get:function(){return f}},{key:"FPNN_VERSION",get:function(){return s}},{key:"READ_BUFFER_LEN",get:function(){return 1024}},{key:"CHECK_CBS_INTERVAL",get:function(){return 1e3}},{key:"SEND_TIMEOUT",get:function(){return 2e4}},{key:"CRYPTO_CURVES",get:function(){return l}},{key:"CRYPTO_ALGORITHM",get:function(){return h}}]),e}();e.exports=p},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}}(),i=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:"assign",value:function(e){if(!e||e.hasOwnProperty("events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(e.hasOwnProperty("on")||e.hasOwnProperty("emit")||e.hasOwnProperty("removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){e.events.hasOwnProperty(t)||(e.events[t]=[]),-1==e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(){if(0!=arguments.length)for(var t=e.events[arguments[0]]||[],r=0;r<t.length;r++){var n=t[r];if(n){for(var i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];n.apply(e,i)}}},e.removeEvent=function(){if(0!=arguments.length)if(1!=arguments.length){var t=arguments[0],r=e.events[t].indexOf(arguments[1]);r>-1&&e.events[t].splice(r,1)}else{var n=arguments[0];e.events.hasOwnProperty(n)&&delete e.events[n]}else e.events={}},e.listenerCount=function(t){return e.events.hasOwnProperty(t)?(e.events[t]||[]).length:0}}}]),e}();e.exports=i},function(e,t,r){"use strict";function n(e,t){this.code=e,this.name="FPError",this.message=t.message||"",this.stack=t.stack,this.error=t}n.prototype=Object.create(Error.prototype),n.prototype.toString=function(){return"code: "+this.code+" ex: "+this.message},e.exports=n},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}}();r(0);var i=r(1),o=r(4),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new o,this._connectTimeout=0,this._queue=[];var r=this;i.assign(this._platform),this._platform.on("open",(function(){c.call(r)})),this._platform.on("message",(function(e){u.call(r,e)})),this._platform.on("close",(function(){f.call(r)})),this._platform.on("error",(function(e){l.call(r,e)}))}return n(e,[{key:"write",value:function(e){if(e)if("[object String]"===Object.prototype.toString.call(e))this._queue.push(e);else{var t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this._queue.push(t)}a.call(this)}},{key:"close",value:function(e){e&&this.emit("error",e),this._platform.close()}},{key:"open",value:function(){if(this.isConnecting||this.isOpen||!this._endpoint)this.emit("error",new Error("has connected or worng endpoint!"));else{var e=this;this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._connectTimeout=setTimeout((function(){var t=new Error("connect timeout!");if(e.isOpen)e.close(t);else{if(e.isConnecting)return e.close(t),void f.call(e);l.call(e,t),f.call(e)}}),this._timeout),this._platform.open(this._endpoint)}}},{key:"destroy",value:function(){this.removeEvent(),this.close(),this._platform.removeEvent(),f.call(this)}},{key:"endpoint",get:function(){return this._endpoint}},{key:"isOpen",get:function(){return this._platform.isOpen}},{key:"isConnecting",get:function(){return this._platform.isConnecting}}]),e}();function a(){if(this.isOpen)for(;this._queue.length;)this._platform.send(this._queue.shift())}function u(e){this.emit("data",e)}function c(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),a.call(this),this.emit("connect")}function f(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._queue=[],this.emit("close")}function l(e){this.emit("error",e)}e.exports=s},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}}(),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._socket=null}return n(e,[{key:"open",value:function(e){var t=this;try{this._socket=new WebSocket(e)}catch(e){return void this.emit("error",e)}this._socket.binaryType="arraybuffer",this._socket.onopen=function(e){t.emit("open")},this._socket.onmessage=function(e){t.emit("message",e.data)},this._socket.onclose=function(e){t.emit("close")},this._socket.onerror=function(e){t.emit("error",e)}}},{key:"send",value:function(e){try{this._socket.send(e)}catch(e){return void this.emit("error",e)}}},{key:"close",value:function(){this._socket&&this._socket.close()}},{key:"isOpen",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.OPEN}},{key:"isConnecting",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.CONNECTING}}]),e}();e.exports=i},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}}(),i=r(0),o=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,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||i.TCP_MAGIC,t.version=e.version||0,t.flag=e.flag||0,t.mtype=e.mtype||0,t.ss=e.ss||0,t.method=e.method||null,t.seq=e.seq||0,t.payload=e.payload||null,t.payload&&(t.psize=i.BUFFER.byteLength(t.payload)),t.method&&(t.ss=i.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return i.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return i.TCP_MAGIC.equals(e.magic)}},{key:"isMsgPack",value:function(e){return 1==e.flag}},{key:"isJson",value:function(e){return 0==e.flag}},{key:"isOneWay",value:function(e){return 0==e.mtype}},{key:"isTwoWay",value:function(e){return 1==e.mtype}},{key:"isQuest",value:function(e){return this.isTwoWay(e)||this.isOneWay(e)}},{key:"isAnswer",value:function(e){return 2==e.mtype}},{key:"isSupportPack",value:function(e){return this.isMsgPack(e)!=this.isJson(e)}},{key:"enCode",value:function(e){return this.isOneWay(e)?this.enCodeOneway(e):this.isTwoWay(e)?this.enCodeTwoway(e):this.isAnswer(e)?this.enCodeAnswer(e):null}},{key:"enCodeOneway",value:function(e){var t=s.call(this,e,12+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos);var r=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(this.wpos+=this.payload.copy(t,this.wpos,0)),t}},{key:"enCodeTwoway",value:function(e){var t=s.call(this,e,16+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos);var r=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"enCodeAnswer",value:function(e){var t=s.call(this,e,16+e.psize);if(e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos),this.isJson(e)){var r=i.BUFFER.from(e.payload);e.wpos+=r.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"peekHead",value:function(e){var t={},r=0,n=i.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=i.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=i.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=i.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=i.FP_MESSAGE_TYPE.indexOf(n),r+=e.copy(n,0,r,r+1),t.ss=n.readUInt8(0),t.psize=e.readUInt32LE(r),t.wpos=r+4,t}},{key:"deCode",value:function(e){var t=this.peekHead(e);return this.isOneWay(t)&&this.deCodeOneWay(e,t),this.isTwoWay(t)&&this.deCodeTwoWay(e,t),this.isAnswer(t)&&this.deCodeAnswer(e,t),t}},{key:"deCodeOneWay",value:function(e,t){if(e.length==12+t.ss+t.psize){var r=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeTwoWay",value:function(e,t){if(e.length==16+t.ss+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeAnswer",value:function(e,t){if(e.length==16+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(r,0,t.wpos),this.isJson(t)&&(t.payload=r.toString()),this.isMsgPack(t)&&(t.payload=r)}else t=null}}]),e}();function s(e,t){var r=i.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=i.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=i.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=i.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=i.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}e.exports=o},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}}(),i=r(0),o=r(2),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cbMap={},this._exMap={},a.call(this)}return n(e,[{key:"addCb",value:function(e,t,r){this._cbMap.hasOwnProperty(e)||(this._cbMap[e]=t),r||(r=i.SEND_TIMEOUT),this._exMap[e]=r+Date.now()}},{key:"removeCb",value:function(e){if(e)f.call(this,e);else for(var t in this._cbMap)u.call(this,t,new o(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"execCb",value:function(e,t){u.call(this,e,t)}}]),e}();function a(){var e=this;setInterval((function(){for(var t in e._exMap)e._exMap[t]>Date.now()||u.call(e,t,new o(i.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),i.CHECK_CBS_INTERVAL)}function u(e,t){var r=this;setTimeout((function(){c.call(r,e,t)}),0)}function c(e,t){if(this._cbMap.hasOwnProperty(e)){var r=this._cbMap[e];l.call(this,e),r&&r(t)}}function f(e){var t=this;setTimeout((function(){l.call(t,e)}),0)}function l(e){this._cbMap.hasOwnProperty(e)&&delete this._cbMap[e],this._exMap.hasOwnProperty(e)&&delete this._exMap[e]}e.exports=s},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}}(),i=r(1),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this)}return n(e,[{key:"service",value:function(e,t){this.emit(e.method,e.payload,t)}},{key:"destroy",value:function(){}}]),e}();e.exports=o},function(e,t,r){"use strict";var n=r(9),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=r(4),h=r(13);e.exports={FPClient:n,FPConfig:i,FPEvent:o,FPSocket:s,FPPackage:a,FPCallback:u,FPProcessor:c,FPError:f,BrowserImpl:l,WechatImpl:h}},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}}(),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this),this._autoReconnect=t.autoReconnect||!1,this._conn=new s(t);var r=this;this._conn.on("connect",(function(){p.call(r)})),this._conn.on("close",(function(){d.call(r)})),this._conn.on("data",(function(e){y.call(r,e)})),this._conn.on("error",(function(e){h.call(r,new f(i.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,e))})),this._pkg=new a,this._cbs=new u,this._psr=new c,this._seq=0,this._wpos=0,this._peekData=null,this._readID=0,this._reconnectID=0,this._buffer=i.BUFFER.allocUnsafe(i.READ_BUFFER_LEN)}return n(e,[{key:"connect",value:function(){this.hasConnect||this._conn.open()}},{key:"sendQuest",value:function(e,t,r){if(this._conn.isOpen){var n={};n.magic=e.magic||i.TCP_MAGIC,n.version=e.version||1,n.flag=e.flag||0,n.mtype=e.hasOwnProperty("mtype")?e.mtype:1,n.method=e.method,n.seq=e.hasOwnProperty("seq")?e.seq:++this._seq,n.payload=e.payload,n=this._pkg.buildPkgData(n),t&&this._cbs.addCb(this._pkg.cbKey(n),t,r);var o=this._pkg.enCode(n);this._conn.write(o)}else t&&t(new f(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||i.TCP_MAGIC,t.version=e.version||1,t.flag=e.flag||0,t.mtype=e.mtype||0,t.method=e.method,t.payload=e.payload,t=this._pkg.buildPkgData(t);var r=this._pkg.enCode(t);this._conn.write(r)}},{key:"close",value:function(e){e&&h.call(this,e),this._conn.close()}},{key:"destroy",value:function(){this._autoReconnect=!1,this.removeEvent(),this._psr.destroy(),this._conn.destroy(),d.call(this)}},{key:"processor",get:function(){return this._psr},set:function(e){return this._psr=e}},{key:"isOpen",get:function(){return this._conn.isOpen}},{key:"hasConnect",get:function(){return this._conn.isOpen||this._conn.isConnecting}}]),e}();function h(e){this.emit("error",e)}function p(){this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this.emit("connect")}function d(){this._readID&&(clearInterval(this._readID),this._readID=0),this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this._seq=0,this._wpos=0,this._peekData=null,this._cbs.removeCb(),this._buffer=i.BUFFER.allocUnsafe(i.READ_BUFFER_LEN),this.emit("close"),this._autoReconnect&&g.call(this)}function g(){if(!this._reconnectID){var e=this;this._reconnectID=setTimeout((function(){e.connect()}),100)}}function y(e){e=i.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&m.call(this,t,2*i.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){_.call(r)}),0)}}function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),o=i.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(o,0,r,this._wpos),this._buffer=o}function _(){if(!(this._wpos<12))if(this._peekData||(this._peekData=b.call(this,this._buffer),this._peekData)){var e=this._wpos-this._peekData.pkgLen;if(!(e<0)){this._buffer.copy(this._peekData.buffer,0,0,this._peekData.pkgLen);var t=this._pkg.deCode(this._peekData.buffer);if(m.call(this,2*e,i.READ_BUFFER_LEN,this._peekData.pkgLen),delete this._peekData,this._peekData=null,this._pkg.isAnswer(t)){var r=this._pkg.cbKey(t);this._cbs.execCb(r,t)}if(this._pkg.isQuest(t)){var n=this;this._psr.service(t,(function(e,r){v.call(n,t.flag,t.seq,e,r)}))}}}else this.conn.close(new f(i.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var i={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(i)}function b(e){var t=null;if(e.length>=12){if(t=this._pkg.peekHead(e),!w.call(this,t))return null;this._pkg.isOneWay(t)&&(t.pkgLen=12+t.ss+t.psize),this._pkg.isTwoWay(t)&&(t.pkgLen=16+t.ss+t.psize),this._pkg.isAnswer(t)&&(t.pkgLen=16+t.psize),t.pkgLen>0&&(t.buffer=i.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!i.TCP_MAGIC.equals(e.magic)&&!i.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=i.FPNN_VERSION.length||e.flag<0||e.flag>=i.FP_FLAG.length||e.mtype<0||e.mtype>=i.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
|
|
10
|
+
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=8)}([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}}(),i=r(10).Buffer,o={FPNN_EC_OK:0,FPNN_EC_PROTO_UNKNOWN_ERROR:10001,FPNN_EC_PROTO_NOT_SUPPORTED:10002,FPNN_EC_PROTO_INVALID_PACKAGE:10003,FPNN_EC_PROTO_JSON_CONVERT:10004,FPNN_EC_PROTO_STRING_KEY:10005,FPNN_EC_PROTO_MAP_VALUE:10006,FPNN_EC_PROTO_METHOD_TYPE:10007,FPNN_EC_PROTO_PROTO_TYPE:10008,FPNN_EC_PROTO_KEY_NOT_FOUND:10009,FPNN_EC_PROTO_TYPE_CONVERT:10010,FPNN_EC_CORE_UNKNOWN_ERROR:20001,FPNN_EC_CORE_CONNECTION_CLOSED:20002,FPNN_EC_CORE_TIMEOUT:20003,FPNN_EC_CORE_UNKNOWN_METHOD:20004,FPNN_EC_CORE_ENCODING:20005,FPNN_EC_CORE_DECODING:20006,FPNN_EC_CORE_SEND_ERROR:20007,FPNN_EC_CORE_RECV_ERROR:20008,FPNN_EC_CORE_INVALID_PACKAGE:20009,FPNN_EC_CORE_HTTP_ERROR:20010,FPNN_EC_CORE_WORK_QUEUE_FULL:20011,FPNN_EC_CORE_INVALID_CONNECTION:20012,FPNN_EC_CORE_FORBIDDEN:20013,FPNN_EC_CORE_SERVER_STOPPING:20014},s=i.from([0,1]),a=i.from([64,128]),u=i.from([0,1,2]),c=i.from("FPNN"),f=i.from("POST"),l=["secp256k1","secp224r1"],h=["aes-128-cfb","aes-256-cfb"],p=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:"SDK_VERSION",get:function(){return"2.0.0"}},{key:"BUFFER",get:function(){return i}},{key:"ERROR_CODE",get:function(){return o}},{key:"FP_FLAG",get:function(){return a}},{key:"FP_MESSAGE_TYPE",get:function(){return u}},{key:"TCP_MAGIC",get:function(){return c}},{key:"HTTP_MAGIC",get:function(){return f}},{key:"FPNN_VERSION",get:function(){return s}},{key:"READ_BUFFER_LEN",get:function(){return 1024}},{key:"CHECK_CBS_INTERVAL",get:function(){return 1e3}},{key:"SEND_TIMEOUT",get:function(){return 2e4}},{key:"CRYPTO_CURVES",get:function(){return l}},{key:"CRYPTO_ALGORITHM",get:function(){return h}}]),e}();e.exports=p},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}}(),i=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:"assign",value:function(e){if(!e||e.hasOwnProperty("events"))throw new Error(e+" is null or hasOwnProperty [ events ]");if(e.hasOwnProperty("on")||e.hasOwnProperty("emit")||e.hasOwnProperty("removeEvent"))throw new Error(e+" hasOwnProperty [ on | emit | removeEvent | listenerCount]");e.events={},e.on=function(t,r){e.events.hasOwnProperty(t)||(e.events[t]=[]),-1==e.events[t].indexOf(r)&&e.events[t].push(r)},e.emit=function(){if(0!=arguments.length)for(var t=e.events[arguments[0]]||[],r=0;r<t.length;r++){var n=t[r];if(n){for(var i=[],o=1;o<arguments.length;o++)i[o-1]=arguments[o];n.apply(e,i)}}},e.removeEvent=function(){if(0!=arguments.length)if(1!=arguments.length){var t=arguments[0],r=e.events[t].indexOf(arguments[1]);r>-1&&e.events[t].splice(r,1)}else{var n=arguments[0];e.events.hasOwnProperty(n)&&delete e.events[n]}else e.events={}},e.listenerCount=function(t){return e.events.hasOwnProperty(t)?(e.events[t]||[]).length:0}}}]),e}();e.exports=i},function(e,t,r){"use strict";function n(e,t){this.code=e,this.name="FPError",this.message=t.message||"",this.stack=t.stack,this.error=t}n.prototype=Object.create(Error.prototype),n.prototype.toString=function(){return"code: "+this.code+" ex: "+this.message},e.exports=n},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}}();r(0);var i=r(1),o=r(4),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this),this._endpoint=t.endpoint||null,this._timeout=t.connectionTimeout||1e4,this._platform=t.platformImpl||new o,this._connectTimeout=0,this._queue=[];var r=this;i.assign(this._platform),this._platform.on("open",(function(){c.call(r)})),this._platform.on("message",(function(e){u.call(r,e)})),this._platform.on("close",(function(){f.call(r)})),this._platform.on("error",(function(e){l.call(r,e)}))}return n(e,[{key:"write",value:function(e){if(e)if("[object String]"===Object.prototype.toString.call(e))this._queue.push(e);else{var t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);this._queue.push(t)}a.call(this)}},{key:"close",value:function(e){e&&this.emit("error",e),this._platform.close()}},{key:"open",value:function(){if(this.isConnecting||this.isOpen||!this._endpoint)this.emit("error",new Error("has connected or worng endpoint!"));else{var e=this;this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._connectTimeout=setTimeout((function(){var t=new Error("connect timeout!");if(e.isOpen)e.close(t);else{if(e.isConnecting)return e.close(t),void f.call(e);l.call(e,t),f.call(e)}}),this._timeout),this._platform.open(this._endpoint)}}},{key:"destroy",value:function(){this.removeEvent(),this.close(),this._platform.removeEvent(),f.call(this)}},{key:"endpoint",get:function(){return this._endpoint}},{key:"isOpen",get:function(){return this._platform.isOpen}},{key:"isConnecting",get:function(){return this._platform.isConnecting}}]),e}();function a(){if(this.isOpen)for(;this._queue.length;)this._platform.send(this._queue.shift())}function u(e){this.emit("data",e)}function c(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),a.call(this),this.emit("connect")}function f(){this._connectTimeout&&(clearTimeout(this._connectTimeout),this._connectTimeout=0),this._queue=[],this.emit("close")}function l(e){this.emit("error",e)}e.exports=s},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}}(),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._socket=null}return n(e,[{key:"open",value:function(e){var t=this;try{this._socket=new WebSocket(e)}catch(e){return void this.emit("error",e)}this._socket.binaryType="arraybuffer",this._socket.onopen=function(e){t.emit("open")},this._socket.onmessage=function(e){t.emit("message",e.data)},this._socket.onclose=function(e){t.emit("close")},this._socket.onerror=function(e){t.emit("error",e)}}},{key:"send",value:function(e){try{this._socket.send(e)}catch(e){return void this.emit("error",e)}}},{key:"close",value:function(){this._socket&&this._socket.close()}},{key:"isOpen",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.OPEN}},{key:"isConnecting",get:function(){return!!this._socket&&this._socket.readyState==WebSocket.CONNECTING}}]),e}();e.exports=i},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}}(),i=r(0),o=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,[{key:"buildPkgData",value:function(e){var t={};return t.magic=e.magic||i.TCP_MAGIC,t.version=e.version||0,t.flag=e.flag||0,t.mtype=e.mtype||0,t.ss=e.ss||0,t.method=e.method||null,t.seq=e.seq||0,t.payload=e.payload||null,t.payload&&(t.psize=i.BUFFER.byteLength(t.payload)),t.method&&(t.ss=i.BUFFER.byteLength(t.method)),t.wpos=0,t}},{key:"cbKey",value:function(e){return e.magic+"_"+e.seq}},{key:"isHTTP",value:function(e){return i.HTTP_MAGIC.equals(e.magic)}},{key:"isTCP",value:function(e){return i.TCP_MAGIC.equals(e.magic)}},{key:"isMsgPack",value:function(e){return 1==e.flag}},{key:"isJson",value:function(e){return 0==e.flag}},{key:"isOneWay",value:function(e){return 0==e.mtype}},{key:"isTwoWay",value:function(e){return 1==e.mtype}},{key:"isQuest",value:function(e){return this.isTwoWay(e)||this.isOneWay(e)}},{key:"isAnswer",value:function(e){return 2==e.mtype}},{key:"isSupportPack",value:function(e){return this.isMsgPack(e)!=this.isJson(e)}},{key:"enCode",value:function(e){return this.isOneWay(e)?this.enCodeOneway(e):this.isTwoWay(e)?this.enCodeTwoway(e):this.isAnswer(e)?this.enCodeAnswer(e):null}},{key:"enCodeOneway",value:function(e){var t=s.call(this,e,12+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos);var r=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(this.wpos+=this.payload.copy(t,this.wpos,0)),t}},{key:"enCodeTwoway",value:function(e){var t=s.call(this,e,16+e.ss+e.psize);e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos);var r=i.BUFFER.from(e.method);if(e.wpos+=r.copy(t,e.wpos,0),this.isJson(e)){var n=i.BUFFER.from(e.payload);e.wpos+=n.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"enCodeAnswer",value:function(e){var t=s.call(this,e,16+e.psize);if(e.wpos=t.writeUInt8(e.ss,e.wpos),e.wpos=t.writeUInt32LE(e.psize,e.wpos),e.wpos=t.writeUInt32LE(e.seq,e.wpos),this.isJson(e)){var r=i.BUFFER.from(e.payload);e.wpos+=r.copy(t,e.wpos,0)}return this.isMsgPack(e)&&(e.wpos+=e.payload.copy(t,e.wpos,0)),t}},{key:"peekHead",value:function(e){var t={},r=0,n=i.BUFFER.allocUnsafe(4);return r+=e.copy(n,0,r,r+4),t.magic=n,n=i.BUFFER.allocUnsafe(1),r+=e.copy(n,0,r,r+1),t.version=i.FPNN_VERSION.indexOf(n),r+=e.copy(n,0,r,r+1),t.flag=i.FP_FLAG.indexOf(n),r+=e.copy(n,0,r,r+1),t.mtype=i.FP_MESSAGE_TYPE.indexOf(n),r+=e.copy(n,0,r,r+1),t.ss=n.readUInt8(0),t.psize=e.readUInt32LE(r),t.wpos=r+4,t}},{key:"deCode",value:function(e){var t=this.peekHead(e);return this.isOneWay(t)&&this.deCodeOneWay(e,t),this.isTwoWay(t)&&this.deCodeTwoWay(e,t),this.isAnswer(t)&&this.deCodeAnswer(e,t),t}},{key:"deCodeOneWay",value:function(e,t){if(e.length==12+t.ss+t.psize){var r=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeTwoWay",value:function(e,t){if(e.length==16+t.ss+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=i.BUFFER.allocUnsafe(t.ss);t.wpos+=e.copy(r,0,t.wpos,t.wpos+t.ss),t.method=r.toString();var n=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(n,0,t.wpos),this.isJson(t)&&(t.payload=n.toString()),this.isMsgPack(t)&&(t.payload=n)}else t=null}},{key:"deCodeAnswer",value:function(e,t){if(e.length==16+t.psize){t.seq=e.readUInt32LE(t.wpos),t.wpos+=4;var r=i.BUFFER.allocUnsafe(t.psize);t.wpos+=e.copy(r,0,t.wpos),this.isJson(t)&&(t.payload=r.toString()),this.isMsgPack(t)&&(t.payload=r)}else t=null}}]),e}();function s(e,t){var r=i.BUFFER.allocUnsafe(t);return this.isHTTP(e)&&(e.wpos+=i.HTTP_MAGIC.copy(r,e.wpos,0)),this.isTCP(e)&&(e.wpos+=i.TCP_MAGIC.copy(r,e.wpos,0)),e.wpos+=i.FPNN_VERSION.copy(r,e.wpos,e.version,e.version+1),this.isJson(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),this.isMsgPack(e)&&(e.wpos+=i.FP_FLAG.copy(r,e.wpos,e.flag,e.flag+1)),e.wpos+=i.FP_MESSAGE_TYPE.copy(r,e.wpos,e.mtype,e.mtype+1),r}e.exports=o},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}}(),i=r(0),o=r(2),s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._cbMap={},this._exMap={},a.call(this)}return n(e,[{key:"addCb",value:function(e,t,r){this._cbMap.hasOwnProperty(e)||(this._cbMap[e]=t),r||(r=i.SEND_TIMEOUT),this._exMap[e]=r+Date.now()}},{key:"removeCb",value:function(e){if(e)f.call(this,e);else for(var t in this._cbMap)u.call(this,t,new o(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"execCb",value:function(e,t){u.call(this,e,t)}}]),e}();function a(){var e=this;setInterval((function(){for(var t in e._exMap)e._exMap[t]>Date.now()||u.call(e,t,new o(i.ERROR_CODE.FPNN_EC_CORE_TIMEOUT,Error("Timeout")))}),i.CHECK_CBS_INTERVAL)}function u(e,t){var r=this;setTimeout((function(){c.call(r,e,t)}),0)}function c(e,t){if(this._cbMap.hasOwnProperty(e)){var r=this._cbMap[e];l.call(this,e),r&&r(t)}}function f(e){var t=this;setTimeout((function(){l.call(t,e)}),0)}function l(e){this._cbMap.hasOwnProperty(e)&&delete this._cbMap[e],this._exMap.hasOwnProperty(e)&&delete this._exMap[e]}e.exports=s},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}}(),i=r(1),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.assign(this)}return n(e,[{key:"service",value:function(e,t){this.emit(e.method,e.payload,t)}},{key:"destroy",value:function(){}}]),e}();e.exports=o},function(e,t,r){"use strict";var n=r(9),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=r(4),h=r(13);e.exports={FPClient:n,FPConfig:i,FPEvent:o,FPSocket:s,FPPackage:a,FPCallback:u,FPProcessor:c,FPError:f,BrowserImpl:l,WechatImpl:h}},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}}(),i=r(0),o=r(1),s=r(3),a=r(5),u=r(6),c=r(7),f=r(2),l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o.assign(this),this._autoReconnect=t.autoReconnect||!1,this._conn=new s(t);var r=this;this._conn.on("connect",(function(){p.call(r)})),this._conn.on("close",(function(){d.call(r)})),this._conn.on("data",(function(e){y.call(r,e)})),this._conn.on("error",(function(e){h.call(r,new f(i.ERROR_CODE.FPNN_EC_CORE_UNKNOWN_ERROR,e))})),this._pkg=new a,this._cbs=new u,this._psr=new c,this._seq=0,this._wpos=0,this._peekData=null,this._readID=0,this._reconnectID=0,this._buffer=i.BUFFER.allocUnsafe(i.READ_BUFFER_LEN)}return n(e,[{key:"connect",value:function(){this.hasConnect||this._conn.open()}},{key:"sendQuest",value:function(e,t,r){if(this._conn.isOpen){var n={};n.magic=e.magic||i.TCP_MAGIC,n.version=e.version||1,n.flag=e.flag||0,n.mtype=e.hasOwnProperty("mtype")?e.mtype:1,n.method=e.method,n.seq=e.hasOwnProperty("seq")?e.seq:++this._seq,n.payload=e.payload,n=this._pkg.buildPkgData(n),t&&this._cbs.addCb(this._pkg.cbKey(n),t,r);var o=this._pkg.enCode(n);this._conn.write(o)}else t&&t(new f(i.ERROR_CODE.FPNN_EC_CORE_CONNECTION_CLOSED,new Error("Connection Closed")))}},{key:"sendNotify",value:function(e){var t={};t.magic=e.magic||i.TCP_MAGIC,t.version=e.version||1,t.flag=e.flag||0,t.mtype=e.mtype||0,t.method=e.method,t.payload=e.payload,t=this._pkg.buildPkgData(t);var r=this._pkg.enCode(t);this._conn.write(r)}},{key:"close",value:function(e){e&&h.call(this,e),this._conn.close()}},{key:"destroy",value:function(){this._autoReconnect=!1,this.removeEvent(),this._psr.destroy(),this._conn.destroy(),d.call(this)}},{key:"processor",get:function(){return this._psr},set:function(e){return this._psr=e}},{key:"isOpen",get:function(){return this._conn.isOpen}},{key:"hasConnect",get:function(){return this._conn.isOpen||this._conn.isConnecting}}]),e}();function h(e){this.emit("error",e)}function p(){this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this.emit("connect")}function d(){this._readID&&(clearInterval(this._readID),this._readID=0),this._reconnectID&&(clearTimeout(this._reconnectID),this._reconnectID=0),this._seq=0,this._wpos=0,this._peekData=null,this._cbs.removeCb(),this._buffer=i.BUFFER.allocUnsafe(i.READ_BUFFER_LEN),this.emit("close"),this._autoReconnect&&g.call(this)}function g(){if(!this._reconnectID){var e=this;this._reconnectID=setTimeout((function(){e.connect()}),100)}}function y(e){e=i.BUFFER.from(e);var t=this._wpos+e.length;if(t>this._buffer.length&&m.call(this,t,2*i.READ_BUFFER_LEN),this._wpos+=e.copy(this._buffer,this._wpos,0),!this._readID){var r=this;this._readID=setInterval((function(){_.call(r)}),0)}}function m(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=Math.max(e,t),o=i.BUFFER.allocUnsafe(n);this._wpos=this._buffer.copy(o,0,r,this._wpos),this._buffer=o}function _(){if(!(this._wpos<12))if(this._peekData||(this._peekData=b.call(this,this._buffer),this._peekData)){var e=this._wpos-this._peekData.pkgLen;if(!(e<0)){this._buffer.copy(this._peekData.buffer,0,0,this._peekData.pkgLen);var t=this._pkg.deCode(this._peekData.buffer);if(m.call(this,2*e,i.READ_BUFFER_LEN,this._peekData.pkgLen),delete this._peekData,this._peekData=null,this._pkg.isAnswer(t)){var r=this._pkg.cbKey(t);this._cbs.execCb(r,t)}if(this._pkg.isQuest(t)){var n=this;this._psr.service(t,(function(e,r){v.call(n,t.flag,t.seq,e,r)}))}}}else this.conn.close(new f(i.ERROR_CODE.FPNN_EC_PROTO_INVALID_PACKAGE,new Error("Invalid Protocol Package")))}function v(e,t,r,n){var i={flag:e,mtype:2,seq:t,ss:(n=n||!1)?1:0,payload:r};this.sendQuest(i)}function b(e){var t=null;if(e.length>=12){if(t=this._pkg.peekHead(e),!w.call(this,t))return null;this._pkg.isOneWay(t)&&(t.pkgLen=12+t.ss+t.psize),this._pkg.isTwoWay(t)&&(t.pkgLen=16+t.ss+t.psize),this._pkg.isAnswer(t)&&(t.pkgLen=16+t.psize),t.pkgLen>0&&(t.buffer=i.BUFFER.allocUnsafe(t.pkgLen))}return t}function w(e){return!(!i.TCP_MAGIC.equals(e.magic)&&!i.HTTP_MAGIC.equals(e.magic)||e.version<0||e.version>=i.FPNN_VERSION.length||e.flag<0||e.flag>=i.FP_FLAG.length||e.mtype<0||e.mtype>=i.FP_MESSAGE_TYPE.length)}e.exports=l},function(e,t,r){"use strict";
|
|
11
11
|
/*!
|
|
12
12
|
* The buffer module from node.js, for the browser.
|
|
13
13
|
*
|
|
@@ -24,4 +24,4 @@ t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=
|
|
|
24
24
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
25
25
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
26
26
|
* @license MIT
|
|
27
|
-
*/!function(){"use strict";function t(e){if(e)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=l;else if(a){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var r="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1);var s=!e&&"object"==typeof self,h=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;h?i=global:s&&(i=self);var f=!i.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o=__webpack_require__(15),a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){return function(r){return new t(!0).update(r)[e]()}},v=function(){var e=b("hex");h&&(e=w(e)),e.create=function(){return new t},e.update=function(t){return e.create().update(t)};for(var r=0;r<c.length;++r){var n=c[r];e[n]=b(n)}return e},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(n){if("string"==typeof n)return e.createHash("md5").update(n,"utf8").digest("hex");if(null==n)throw r;return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===i?e.createHash("md5").update(new i(n)).digest("hex"):t(n)};return s};t.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"!==n)throw r;if(null===e)throw r;if(a&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||a&&ArrayBuffer.isView(e)))throw r;t=!0}for(var i,o,s=0,u=e.length,c=this.blocks,f=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),t)if(a)for(o=this.start;s<u&&o<64;++s)f[o++]=e[s];else for(o=this.start;s<u&&o<64;++s)c[o>>2]|=e[s]<<y[3&o++];else if(a)for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?f[o++]=i:i<2048?(f[o++]=192|i>>6,f[o++]=128|63&i):i<55296||i>=57344?(f[o++]=224|i>>12,f[o++]=128|i>>6&63,f[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),f[o++]=240|i>>18,f[o++]=128|i>>12&63,f[o++]=128|i>>6&63,f[o++]=128|63&i);else for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?c[o>>2]|=i<<y[3&o++]:i<2048?(c[o>>2]|=(192|i>>6)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):i<55296||i>=57344?(c[o>>2]|=(224|i>>12)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),c[o>>2]|=(240|i>>18)<<y[3&o++],c[o>>2]|=(128|i>>12&63)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=u[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var e,t,r,n,i,o,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+s[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+s[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+s[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+s[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+s[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+s[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+s[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+s[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+s[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+s[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+s[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[1]-165796510)<<5|e>>>27)+t<<0)^t))+s[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[11]+643717713)<<14|r>>>18)+n<<0)^n))+s[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[5]-701558691)<<5|e>>>27)+t<<0)^t))+s[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[15]-660478335)<<14|r>>>18)+n<<0)^n))+s[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[9]+568446438)<<5|e>>>27)+t<<0)^t))+s[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[3]-187363961)<<14|r>>>18)+n<<0)^n))+s[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[13]-1444681467)<<5|e>>>27)+t<<0)^t))+s[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[7]+1735328473)<<14|r>>>18)+n<<0)^n))+s[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[15]+530742520)<<16|r>>>16)+n<<0))+s[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[0]-198630844)<<6|e>>>26)+t<<0)|~r))+s[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+s[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+s[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[10]-1051523)<<15|r>>>17)+n<<0)|~e))+s[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+s[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+s[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[4]-145523070)<<6|e>>>26)+t<<0)|~r))+s[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[2]+718787259)<<15|r>>>17)+n<<0)|~e))+s[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},t.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3;return n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var e,t,r,n="",i=this.array(),o=0;o<15;)e=i[o++],t=i[o++],r=i[o++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=i[o],n+(p[e>>>2]+p[e<<4&63]+"==")};var _=v();f?module.exports=_:(i.md5=_,o&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return _}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(14),__webpack_require__(2))},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new d(e,t)),1!==c.length||f||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){!function(t){function r(e,r,g){function _(e,t,r,n){return this instanceof _?function(e,t,r,n,i){if(h&&p&&(t instanceof p&&(t=new h(t)),n instanceof p&&(n=new h(n))),t||r||n||c){if(!s(t,r))i=r,n=t,r=0,t=new(c||Array)(8);e.buffer=t,e.offset=r|=0,f!==typeof n&&("string"==typeof n?function(e,t,r,n){var i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var c=parseInt(r[i++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/y),a%=y}u&&(s=~s,a?a=y-a:s++),b(e,t+E,s),b(e,t+k,a)}(t,r,n,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(b(t,r+E,n),b(t,r+k,i)):n>0?T(t,r,n):n<0?A(t,r,n):a(t,r,d,0))}else e.buffer=u(d,0)}(this,e,t,r,n):new _(e,t,r,n)}function v(){var e=this.buffer,t=this.offset,r=w(e,t+E),n=w(e,t+k);return g||(r|=0),r?r*y+n:n}function b(e,t,r){e[t+O]=255&r,r>>=8,e[t+C]=255&r,r>>=8,e[t+P]=255&r,r>>=8,e[t+R]=255&r}function w(e,t){return e[t+R]*m+(e[t+P]<<16)+(e[t+C]<<8)+e[t+O]}var E=r?0:4,k=r?4:0,R=r?0:3,P=r?1:2,C=r?2:1,O=r?3:0,T=r?function(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}:function(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256},A=r?function(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}:function(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256},S=_.prototype,M="is"+e,I="_"+M;return S.buffer=void 0,S.offset=0,S[I]=!0,S.toNumber=v,S.toString=function(e){var t=this.buffer,r=this.offset,n=w(t,r+E),i=w(t,r+k),o="",s=!g&&2147483648&n;for(s&&(n=~n,i=y-i),e=e||10;;){var a=n%e*y+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=i),h&&(S.toArrayBuffer=o),_[M]=function(e){return!(!e||!e[I])},t[e]=_,_}function n(e){var t=this.buffer,r=this.offset;return c=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function i(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new l(8);return a(i,0,r,n),i}function o(e){var t=this.buffer,r=this.offset,n=t.buffer;if(c=h,!1!==e&&0===r&&n instanceof p&&8===n.byteLength)return n;var i=new h(8);return a(i,0,t,r),i.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var i=0;i<8;i++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var c,f="undefined",l=f!==typeof e&&e,h=f!==typeof Uint8Array&&Uint8Array,p=f!==typeof ArrayBuffer&&ArrayBuffer,d=[0,0,0,0,0,0,0,0],g=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},y=4294967296,m=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("string"!=typeof t.nodeName?t:this||{})}).call(this,r(5).Buffer)},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 i=r(1).fpnn,o=r(0),s=(r(4),function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[o.SERVER_PUSH.recvMessage,o.SERVER_PUSH.recvGroupMessage,o.SERVER_PUSH.recvRoomMessage,o.SERVER_PUSH.recvBroadcastMessage,o.SERVER_PUSH.recvFile,o.SERVER_PUSH.recvGroupFile,o.SERVER_PUSH.recvRoomFile,o.SERVER_PUSH.recvBroadcastFile],u.call(this)}return n(e,[{key:"service",value:function(e,t){if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(r=e.method,n=o.TLV_SERVER_PUSH,r===n.recvMessage||r===n.recvGroupMessage||r===n.recvRoomMessage||r===n.recvBroadcastMessage||r===n.kickOut||r===n.kickOutRoom))this._serviceTLVPush(e);else{var r,n,i=!0;o.SERVER_PUSH.kickOut==e.method&&(i=!1),o.SERVER_PUSH.kickOutRoom==e.method&&(i=!1),i&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(o.MsgPack.encode({},this._msgOptions),!1));var s=null;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(s=e._tlvPayload,e._tlvBinaryPayload&&(s.binary=s.msg)),s||0!=e.flag||(s=JSON.parse(e.payload)),!s&&1==e.flag)if(-1!==this._binaryMessageMethodList.indexOf(e.method))if((s=o.MsgPack.decode(e.payload,this._binaryOptions)).mtype==o.CHAT_TYPE.text)s=o.MsgPack.decode(e.payload,this._msgOptions);else{s.binary=s.msg;try{s.msg=new TextDecoder("utf-8",{fatal:!0}).decode(s.msg)}catch(e){s.msg=void 0}try{s.attrs=new TextDecoder("utf-8",{fatal:!0}).decode(s.attrs)}catch(e){}}else s=o.MsgPack.decode(e.payload,this._msgOptions);if(s){if(void 0!==s.attrs)try{var a=JSON.parse(s.attrs);if(a&&void 0!==a.excludedUids&&Array.isArray(a.excludedUids)&&a.excludedUids.includes(this.uid.toString()))return}catch(e){}"function"==typeof this[e.method]&&this[e.method].call(this,s)}}}},{key:"_serviceTLVPush",value:function(e){var t=e._tlvPayload;if(t&&void 0!==t.extra)try{var r=JSON.parse(t.extra);if(r&&void 0!==r.excludedUids&&Array.isArray(r.excludedUids)&&r.excludedUids.includes(this.uid.toString()))return}catch(e){}this.emit(e.method,t)}},{key:"destroy",value:function(){this._map={},this._expireTimerID&&(clearInterval(this._expireTimerID),this._expireTimerID=0)}},{key:"kickout",value:function(e){this.emit(o.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new o.Int64(e.rid)),this.emit(o.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvMessage,e)):this.emit(o.SERVER_PUSH.recvCmd,e):this.emit(o.SERVER_PUSH.recvFile,e):this.emit(o.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new o.Int64(e.gid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvGroupFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvGroupMessage,e)):this.emit(o.SERVER_PUSH.recvGroupCmd,e):this.emit(o.SERVER_PUSH.recvGroupFile,e):this.emit(o.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new o.Int64(e.rid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvRoomFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvRoomMessage,e)):this.emit(o.SERVER_PUSH.recvRoomCmd,e):this.emit(o.SERVER_PUSH.recvRoomFile,e):this.emit(o.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(o.SERVER_PUSH.recvBroadcastCmd,e):this.emit(o.SERVER_PUSH.recvBroadcastFile,e):this.emit(o.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(o.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var i=[];i.push(e),i.push(t),i.push(r),null!=n&&i.push(n);var s=i.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=o.MID_TTL+Date.now(),!0}function u(){var e=this;this._expireTimerID=setInterval((function(){for(var t in e._map)e._map[t]>Date.now()||c.call(e,t)}),o.MID_TTL+1e3)}function c(e){var t=this;setTimeout((function(){delete t._map[e]}),0)}e.exports=s},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},i=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(19),s=r(20),a=r(3),u=r(0),c=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=t||{};if("string"!=typeof r.endpoint||!/^wss?:\/\//i.test(r.endpoint))throw new Error("tlv-v1 requires an explicit ws:// or wss:// endpoint URL");this._endpoint=r.endpoint,this._webSocketFactory=r.webSocketFactory||f,this._legacyMsgPack=r.legacyMsgPack||u.MsgPack,this._legacyMsgOptions=r.legacyMsgOptions,this._requestMetadata=r.requestMetadata,this._connectionTimeout=r.connectionTimeout||3e4,this._requestTimeout=r.requestTimeout||2e4,this._heartbeatIdleMs=r.heartbeatIdleMs||3e4,this._heartbeatTimeoutMs=r.heartbeatTimeoutMs||1e4,this._dedupTtlMs=Math.max(r.pushDedupTtlMs||3e4,2e4),this._listeners={},this._pending=new Map,this._receivedMessages=new Map,this._nextSequence=1,this._socket=null,this._connectionGeneration=0,this._state="idle",this._authenticated=!1,this._connectionTimer=0,this._heartbeatTimer=0,this._heartbeatPending=!1,this._lastActivity=0,this._incomingQueue=Promise.resolve(),this._protocolClosing=!1,this._destroyed=!1,this.processor=null}return i(e,[{key:"on",value:function(e,t){return"function"!=typeof t||(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this}},{key:"off",value:function(e,t){var r=this._listeners[e];return r?(this._listeners[e]=r.filter((function(e){return e!==t})),this):this}},{key:"emit",value:function(e){var t=this._listeners[e]||[],r=Array.prototype.slice.call(arguments,1),n=this;t.slice().forEach((function(e){e.apply(n,r)}))}},{key:"connect",value:function(){if(!this._destroyed&&"connecting"!==this._state&&"open"!==this._state&&"closing"!==this._state){var e=this._connectionGeneration+1;this._connectionGeneration=e,this._nextSequence=1,this._receivedMessages.clear(),this._incomingQueue=Promise.resolve(),this._state="connecting",this._protocolClosing=!1;var t=void 0;try{t=this._webSocketFactory(this._endpoint)}catch(e){return this._state="closed",this.emit("error",h("cannot create WebSocket: "+e.message)),void this.emit("close")}if(!t||"function"!=typeof t.send||"function"!=typeof t.close)return this._state="closed",this.emit("error",h("webSocketFactory returned an invalid socket")),void this.emit("close");this._socket=t;try{t.binaryType="arraybuffer"}catch(e){}t.onopen=this._onOpen.bind(this,t,e),t.onmessage=this._onMessage.bind(this,t,e),t.onerror=this._onError.bind(this,t,e),t.onclose=this._onClose.bind(this,t,e),this._connectionTimer=setTimeout(this._onConnectionTimeout.bind(this,t,e),this._connectionTimeout)}}},{key:"close",value:function(){this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1,"open"!==this._state&&"connecting"!==this._state||(this._state="closing");var e=this._socket;if(e)try{e.close()}catch(e){this._finalizeClose()}else this._finalizeClose()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0,this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1;var e=this._socket;if(e)try{e.close()}catch(e){}this._finalizeClose(),this._listeners={},this._receivedMessages.clear()}}},{key:"markAuthenticated",value:function(){this._destroyed||"open"!==this._state||(this._authenticated=!0,this._lastActivity=Date.now(),this._startHeartbeat())}},{key:"sendQuest",value:function(e,t,r){try{var n=this._decodeLegacyPayload(e&&e.payload),i=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(i.uri,i.payload,r,{onError:function(e){t&&t(p(e))},onSuccess:function(e){t&&t({_tlvPayload:d(e),mtype:2,ss:0})}})}catch(e){t&&t(p(e))}}},{key:"_decodeLegacyPayload",value:function(e){if(null==e)return{legacyEncoded:!1,payload:{}};if(a.isPlainMap(e))return{legacyEncoded:!1,payload:e};try{var t=this._legacyMsgPack.decode(e,this._legacyMsgOptions);if(!a.isPlainMap(t))throw new Error("legacy request payload is not a map");return{legacyEncoded:!0,payload:t}}catch(e){throw new s.TLVContractError(200034,"cannot decode local request payload: "+e.message)}}},{key:"_onOpen",value:function(e,t){e!==this._socket||t!==this._connectionGeneration||"connecting"!==this._state||this._destroyed||(this._clearConnectionTimeout(),this._state="open",this._lastActivity=Date.now(),this.emit("connect"))}},{key:"_onMessage",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){var i=r&&("object"===(void 0===r?"undefined":n(r))||"function"==typeof r)&&"data"in r?r.data:r;this._incomingQueue=this._incomingQueue.then((function(){return function(e){if("string"==typeof e)return Promise.reject(new Error("WebSocket text messages are forbidden by TLV v1"));var t=a.getByteView(e);if(t)return Promise.resolve(t);if(e&&"function"==typeof e.arrayBuffer){var r=void 0;try{r=e.arrayBuffer()}catch(e){return Promise.reject(e)}return Promise.resolve(r).then((function(e){var t=a.getByteView(e);if(!t)throw new Error("WebSocket Blob did not resolve to binary data");return t}))}return Promise.reject(new Error("WebSocket message is not binary data"))}(i)})).then(this._handleIncomingBytes.bind(this,e,t)).catch(this._handleIncomingFailure.bind(this,e,t))}}},{key:"_onError",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed){var n=r&&r.message?r.message:"WebSocket transport error";this.emit("error",h(n))}}},{key:"_onClose",value:function(e,t){e===this._socket&&t===this._connectionGeneration&&this._finalizeClose()}},{key:"_onConnectionTimeout",value:function(e,t){if(this._connectionTimer=0,e===this._socket&&t===this._connectionGeneration&&"connecting"===this._state&&!this._destroyed){var r=h("WebSocket connection timed out after "+this._connectionTimeout+" ms");try{this.emit("error",r)}finally{if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed&&"closed"!==this._state){this._state="closing";try{e.close()}catch(e){}e===this._socket&&t===this._connectionGeneration&&"closed"!==this._state&&this._finalizeClose()}}}}},{key:"_clearConnectionTimeout",value:function(){this._connectionTimer&&(clearTimeout(this._connectionTimer),this._connectionTimer=0)}},{key:"_handleIncomingBytes",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){this._lastActivity=Date.now();var n=o.decodeFrame(r);"2"!==n.mt?"1"!==n.mt?this._handleOneWayPush(n):this._handleReliablePush(n):this._handleAnswer(n)}}},{key:"_handleIncomingFailure",value:function(e,t,r){e!==this._socket||t!==this._connectionGeneration||this._destroyed||this._protocolFailure(r)}},{key:"_handleAnswer",value:function(e){if("control.ack"===e.uri)throw new Error("Gate must not send control.ack to a Client");var t=this._pending.get(e.sequence);if(t){if("control.error"===e.uri)return s.validateControlError(e.payload),void this._completePending(e.sequence,!1,{reason:e.payload.reason,status:Number(e.payload.status)});if(e.uri!==t.uri)throw new Error("Answer URI does not match pending request URI");s.validateResponse(e.uri,e.payload),this._completePending(e.sequence,!0,e.payload)}}},{key:"_handleReliablePush",value:function(e){if(!s.isReliablePush(e.uri))throw new Error('Gate sent an unsupported mt="1" Quest URI: '+e.uri);s.validatePush(e.uri,e.payload);var t=String(e.payload.message_ref),r=this._isDuplicateMessage(t);if(this._sendFrame(e.sequence,"2","control.ack",{}),!r){var n={method:e.uri,payload:d(e.payload)};this._rememberMessage(t),this._dispatchPush(n)}}},{key:"_handleOneWayPush",value:function(e){if(!s.isOneWayPush(e.uri))throw new Error('Gate sent an unsupported mt="0" URI: '+e.uri);s.validatePush(e.uri,e.payload);var t={method:e.uri,payload:d(e.payload)};"event.kicked"===e.uri&&(this._authenticated=!1,this._stopHeartbeat()),this._dispatchPush(t)}},{key:"_dispatchPush",value:function(e){if(this.processor&&"function"==typeof this.processor.service){var t=a.getByteView(e.payload.payload);this.processor.service({_tlvBinaryPayload:!!t,_tlvPayload:e.payload,flag:1,method:e.method})}}},{key:"_request",value:function(e,t,r,n){if(!this._destroyed&&"open"===this._state&&this._socket)if(this._authenticated||"auth.login"===e||"control.ping"===e)if(this._authenticated&&"auth.login"===e)n.onError({status:200023,reason:"auth.login cannot be sent twice on one connection"});else{var i=this._allocateSequence(),o="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,i),o),uri:e};this._pending.set(i,s);try{this._sendFrame(i,"1",e,t)}catch(e){this._pending.delete(i),clearTimeout(s.timer),n.onError(l(e))}}else n.onError({status:200022,reason:"authentication is required before "+e});else n.onError(h("invalid WebSocket connection"))}},{key:"_onRequestTimeout",value:function(e){var t=this._pending.get(e);t&&(this._pending.delete(e),t.handlers.onError({status:200999,reason:"request timeout"}))}},{key:"_completePending",value:function(e,t,r){var n=this._pending.get(e);n&&(this._pending.delete(e),clearTimeout(n.timer),t?n.handlers.onSuccess(r):n.handlers.onError(r))}},{key:"_allocateSequence",value:function(){for(var e=0;e<o.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===o.MAX_SEQUENCE?1:t+1,!this._pending.has(t))return t}throw new Error("all TLV request sequences are pending")}},{key:"_sendFrame",value:function(e,t,r,n){if(this._destroyed||"open"!==this._state||!this._socket)throw h("invalid WebSocket connection");var i=o.encodeFrame(e,t,r,n),s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);this._socket.send(s),this._lastActivity=Date.now()}},{key:"_startHeartbeat",value:function(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(this._heartbeatTick.bind(this),1e3)}},{key:"_stopHeartbeat",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=0),this._heartbeatPending=!1}},{key:"_heartbeatTick",value:function(){this._authenticated&&!this._heartbeatPending&&"open"===this._state&&(Date.now()-this._lastActivity<this._heartbeatIdleMs||(this._heartbeatPending=!0,this._request("control.ping",{},this._heartbeatTimeoutMs,{onError:this._onHeartbeatError.bind(this),onSuccess:this._onHeartbeatAnswer.bind(this)})))}},{key:"_onHeartbeatAnswer",value:function(e){this._heartbeatPending=!1,a.isPlainMap(e)||this._protocolFailure(new Error("control.ping Answer body must be a map"))}},{key:"_onHeartbeatError",value:function(e){this._heartbeatPending=!1,this._protocolFailure(new Error("control.ping failed: "+l(e).reason))}},{key:"_isDuplicateMessage",value:function(e){this._expireReceivedMessages();var t=this._receivedMessages.get(e);return void 0!==t&&t>Date.now()}},{key:"_rememberMessage",value:function(e){this._receivedMessages.set(e,Date.now()+this._dedupTtlMs)}},{key:"_expireReceivedMessages",value:function(){var e=Date.now();this._receivedMessages.forEach((function(t,r){t<=e&&this._receivedMessages.delete(r)}),this)}},{key:"_protocolFailure",value:function(e){if(!this._protocolClosing&&"closed"!==this._state){this._protocolClosing=!0;var t=l(e);this.emit("error",h("TLV protocol error: "+t.reason));var r=this._socket;if(r){this._state="closing";try{r.close(1002,"TLV protocol error")}catch(e){this._finalizeClose()}}else this._finalizeClose()}}},{key:"_finalizeClose",value:function(){if("closed"!==this._state){this._state="closed",this._clearConnectionTimeout(),this._socket=null,this._authenticated=!1,this._stopHeartbeat();var e=Array.from(this._pending.values());this._pending.clear(),e.forEach((function(e){clearTimeout(e.timer),e.handlers.onError(h("WebSocket connection closed"))})),this.emit("close")}}}]),e}();function f(e){var t="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof globalThis?globalThis.WebSocket:void 0;if("function"!=typeof t)throw new Error("WebSocket is unavailable; provide options.webSocketFactory");return new t(e)}function l(e){return e&&"number"==typeof e.status?{reason:"string"==typeof e.reason?e.reason:e.message||String(e.status),status:e.status}:{reason:e&&e.message?e.message:String(e||"unknown error"),status:200999}}function h(e){return{reason:e,status:200999}}function p(e){var t=l(e);return{_tlvPayload:{reason:t.reason,status:t.status},mtype:2,ss:1}}function d(e){if(e instanceof a.Int64Value)return new u.Int64(e.toString());if(Array.isArray(e))return e.map(d);if(a.isPlainMap(e)){var t={};return Object.keys(e).forEach((function(r){t[r]=d(e[r])})),t}return e}e.exports=c},function(e,t,r){"use strict";var n=r(3),i=new Uint8Array([2,0,109,116,1,0]),o=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(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="TLVCodecError",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}();function s(e){if("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e<1||e>2147483647)throw new o("sequence must be an integer in 1..2147483647")}function a(e,t,r){var n=r>>>0;e[t]=255&n,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function u(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]>>>0}e.exports={FLAGS:4,MAGIC:204,MAX_FRAME_LENGTH:67239936,MAX_PAYLOAD_LENGTH:67108864,MAX_SEQUENCE:2147483647,METADATA_LENGTH:7,TLVCodecError:o,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new o("TLV frame length is outside the allowed limit");if(t.length<27)throw new o("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new o("invalid TLV v1 header");var r=u(t,4);if(s(r),7!==function(e,t){return e[t]+256*e[t+1]}(t,8))throw new o("TLV v1 metadata length must be exactly 7");for(var a=0;a<i.length;a+=1)if(t[10+a]!==i[a])throw new o("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new o("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new o("message queue length does not match the frame boundary");var l=21,h=t[l];if(l+=1,0===h||l+h+1+4>t.length)throw new o("invalid URI length in message queue");var p=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new o("TLV v1 passThrough must be empty");var d=u(t,l+=1);if(l+=4,0===d||d>67108864||l+d!==t.length)throw new o("invalid MsgPack payload length or trailing bytes");var g=t.subarray(l,l+d),y=void 0;try{y=n.decodeMap(g,{allowIntegerMapKeyAtPath:"room.last_messages"===p?["last_by_room"]:null})}catch(e){if(e instanceof o)throw e;throw new o("invalid MsgPack payload: "+e.message)}return{mt:f,payload:y,payloadBytes:new Uint8Array(g),sequence:r,uri:p}},encodeFrame:function(e,t,r,u){s(e),function(e){if("0"!==e&&"1"!==e&&"2"!==e)throw new o('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new o("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new o("URI UTF-8 length must be in 1..255");return t}(r),f=n.encodeMap(void 0===u?{}:u);if(0===f.length||f.length>67108864)throw new o("MsgPack payload length is outside the TLV v1 limit");var l=1+c.length+1+4+f.length,h=21+l;if(h>67239936)throw new o("TLV frame exceeds the maximum frame length");var p=new Uint8Array(h);p[0]=204,p[1]=1,p[2]=4,p[3]=0,a(p,4,e),function(e,t,r){e[t]=255&r,e[t+1]=r>>>8&255}(p,8,7),p.set(i,10),p[16]=t.charCodeAt(0),a(p,17,l);var d=21;return p[d]=c.length,d+=1,p.set(c,d),p[d+=c.length]=0,a(p,d+=1,f.length),d+=4,p.set(f,d),p}}},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};var i=r(3),o=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=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,r));return n.name="TLVContractError",n.status=e,n}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}();function s(e,t,r,n){var i=n||{};return{defaults:i.defaults||{},pass:i.pass||[],request:t||{},required:i.required||[],response:r||{},uri:e}}var a={cursor:0,end_ms:0,limit:20,reverse:!1,start_ms:0},u={end_ms:0,limit:20,reverse:!1,start_ms:0},c={end_ms:0,start_ms:0},f={begin:"start_ms",desc:"reverse",end:"end_ms",lastid:"cursor",mtypes:"kinds",num:"limit"},l={begin:"start_ms",desc:"reverse",end:"end_ms",mid:"anchor",mtypes:"kinds",num:"limit"},h={begin:"start_ms",end:"end_ms",mtypes:"kinds"},p={begin:"first_ms",end:"last_ms",lastid:"next",msgs:"items",num:"size"},d={auth:s("auth.login",{attrs:"props",authv:"auth_ver",lang:"locale",pid:"project",token:"credential",ts:"auth_sec",uid:"user",version:"client_ver"},{ok:"accepted"},{required:["project","user","credential","client_ver"]}),bye:s("connection.close"),getservertime:s("system.time",null,{mts:"server_ms"}),addattrs:s("connection.set_props",{attrs:"props"},null,{required:["props"]}),getattrs:s("connection.get_props",null,{attrs:"props"}),adddebuglog:s("system.debug",{attrs:"context",msg:"entry"},null,{required:["entry","context"]}),getonlineusers:s("presence.online",{uids:"users"},{uids:"online_users"},{required:["users"]}),setuserinfo:s("user.set_profile",{oinfo:"public_data",pinfo:"private_data"}),getuserinfo:s("user.get_profile",null,{oinfo:"public_data",pinfo:"private_data"}),getuseropeninfo:s("user.get_public",{uids:"users"},{info:"profiles"},{required:["users"]}),setlang:s("user.set_locale",{lang:"locale"},{ok:"updated"},{required:["locale"]}),dataget:s("storage.get",{key:"slot"},{val:"value"},{required:["slot"]}),dataset:s("storage.set",{key:"slot",val:"value"},null,{required:["slot","value"]}),datadel:s("storage.delete",{key:"slot"},null,{required:["slot"]}),addblacks:s("blacklist.add",{blacks:"blocked_users"},null,{required:["blocked_users"]}),delblacks:s("blacklist.remove",{blacks:"blocked_users"},null,{required:["blocked_users"]}),getblacks:s("blacklist.list",null,{uids:"blocked_users"}),addgroupmembers:s("group.add",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),delgroupmembers:s("group.remove",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),getgroupmembers:s("group.members",{gid:"group_ref",online:"with_online"},{onlines:"active_members",uids:"members"},{required:["group_ref"]}),getgroupcount:s("group.count",{gid:"group_ref",online:"with_online"},{cn:"total",online:"active_total"},{required:["group_ref"]}),getusergroups:s("group.joined",null,{gids:"group_refs"}),setgroupinfo:s("group.set_profile",{gid:"group_ref",oinfo:"public_data",pinfo:"private_data"},null,{required:["group_ref"]}),getgroupinfo:s("group.get_profile",{gid:"group_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["group_ref"]}),getgroupopeninfo:s("group.get_public",{gid:"group_ref"},{oinfo:"public_data"},{required:["group_ref"]}),getgroupsopeninfo:s("group.get_public_batch",{gids:"group_refs"},{info:"profiles"},{required:["group_refs"]}),enterroom:s("room.join",{rid:"room_ref"},null,{required:["room_ref"]}),leaveroom:s("room.leave",{rid:"room_ref"},null,{required:["room_ref"]}),enterrooms:s("room.join_batch",{rids:"room_refs"},null,{required:["room_refs"]}),getuserrooms:s("room.joined",null,{rooms:"room_refs"}),getroommembers:s("room.members",{rid:"room_ref"},{uids:"members"},{required:["room_ref"]}),getroomcount:s("room.counts",{rids:"room_refs"},{cn:"totals"},{required:["room_refs"]}),setroominfo:s("room.set_profile",{icon:"avatar",name:"label",oinfo:"public_data",pinfo:"private_data",rid:"room_ref"},null,{required:["room_ref"]}),getroominfo:s("room.get_profile",{rid:"room_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["room_ref"]}),getroomopeninfo:s("room.get_public",{rid:"room_ref"},{oinfo:"public_data"},{required:["room_ref"]}),getroomsopeninfo:s("room.get_public_batch",{rids:"room_refs"},{info:"profiles"},{required:["room_refs"]}),getuserroomsandlastmsg:s("room.last_messages",{mtypes:"kinds"},{rooms:"last_by_room"}),sendmsg:s("message.send",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",to:"recipient"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["recipient","message_ref","kind","payload","extra"]}),sendmsgs:s("message.send_batch",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",tos:"recipients"},{mid:"message_ref",mtime:"time_ms"},{required:["recipients","message_ref","kind","payload","extra"]}),sendgroupmsg:s("message.send_group",{attrs:"extra",gid:"group_ref",mid:"message_ref",msg:"payload",mtype:"kind"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["group_ref","message_ref","kind","payload","extra"]}),sendroommsg:s("message.send_room",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",rid:"room_ref"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["room_ref","message_ref","kind","payload","extra"]}),tcheck:s("moderation.check",{region:"zone",text:"payload"},{language:"detected_locale",result:"decision",text:"filtered",wlist:"matches"},{pass:["checkParams","strategyId"],required:["payload"]}),translate:s("translation.run",{dst:"to_locale",profanity:"filter_mode",src:"from_locale",text:"input",type:"format"},{dtext:"output",dst:"to_locale",source:"detected_locale",sourceText:"original",src:"from_locale",stext:"input",target:"resolved_locale",targetText:"translated"},{defaults:{filter_mode:"off",format:"chat"},required:["input","to_locale","format","filter_mode"]}),getp2pmsg:s("history.direct",Object.assign({ouid:"peer"},f),p,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},f),p,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},f),p,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",f,p,{defaults:a,required:["reverse","limit","start_ms","end_ms","cursor"]}),getp2pmsgbymessageid:s("history.direct_anchor",Object.assign({ouid:"peer"},l),p,{defaults:u,required:["peer","anchor","reverse","limit","start_ms","end_ms"]}),getgroupmsgbymessageid:s("history.group_anchor",Object.assign({gid:"group_ref"},l),p,{defaults:u,required:["group_ref","anchor","reverse","limit","start_ms","end_ms"]}),getroommsgbymessageid:s("history.room_anchor",Object.assign({rid:"room_ref"},l),p,{defaults:u,required:["room_ref","anchor","reverse","limit","start_ms","end_ms"]}),getbroadcastmsgbymessageid:s("history.broadcast_anchor",l,p,{defaults:u,required:["anchor","reverse","limit","start_ms","end_ms"]}),getp2pmsgcount:s("history.direct_count",Object.assign({ouid:"peer"},h),{count:"total"},{defaults:c,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:c,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:c,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:c,required:["start_ms","end_ms"]}),getmsg:s("message.get",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},{attrs:"extra",from:"sender",id:"sequence",mid:"message_ref",msg:"payload",mtime:"time_ms",mtype:"kind"},{required:["sender","message_ref","target_ref","channel"]}),delmsg:s("message.revoke",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},null,{required:["sender","message_ref","target_ref","channel"]}),getunread:s("unread.summary",{clear:"mark_read",gettime:"with_logout"},{group:"group_refs",logouttime:"logout_sec",p2p:"peers"},{defaults:{mark_read:!1},required:["mark_read"]}),getsession:s("session.list",null,{group:"group_refs",p2p:"peers"}),cleanunread:s("unread.clear"),setsessionread:s("session.read",{category:"channel",read_seq:"through",xid:"target_ref"},null,{required:["channel","target_ref","through"]}),getp2punread:s("unread.direct",{mtime:"since_ms",mtypes:"kinds",uids:"peers"},{ltime:"times",p2p:"counts"},{required:["peers"]}),getgroupunread:s("unread.group",{gids:"group_refs",mtime:"since_ms",mtypes:"kinds"},{group:"counts",ltime:"times"},{required:["group_refs"]}),removesession:s("session.remove",{oneway:"local_only",to:"peer"},null,{defaults:{local_only:!1},required:["peer","local_only"]}),getp2pconversationlist:s("conversation.direct",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getp2punreadconversationlist:s("conversation.direct_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getgroupconversationlist:s("conversation.group",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getgroupunreadconversationlist:s("conversation.group_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getunreadconversationlist:s("conversation.unread",{clear:"mark_read",mtime:"since_ms",mtypes:"kinds"},{groupConversations:"group_refs",groupMsgs:"group_last",groupUnreads:"group_badges",p2pConversations:"peers",p2pMsgs:"peer_last",p2pUnreads:"peer_badges"},{defaults:{mark_read:!1},required:["mark_read"]})},g=new Set(["acheck","adddevice","addfriends","addoption","addprojectban","adminCommand","broadcastfile","closeRTCRoom","delfriends","filetoken","getfriends","getoption","getRTCRoomList","getRTCRoomMemberCount","getRTCRoomMembers","icheck","inviteUserIntoRTCRoom","isfriend","isfriends","isprojectban","kickoutFromRTCRoom","profanity","pullIntoRTCRoom","removedevice","removeoption","removeprojectban","sendfile","sendfiles","sendgroupfile","sendroomfile","setRTCRoomMicStatus","speech2text","speechtranslation","uploadfile","vcheck"]),y={"event.broadcast":!0,"event.direct":!0,"event.group":!0,"event.room":!0},m={"event.kicked":!0,"event.room_removed":!0},_="9223372036854775807";function v(e,t,r){return Object.assign({required:!!t,type:e},r||{})}function b(e,t){return v("integer",e,Object.assign({min:"-9223372036854775808",max:_},t||{}))}function w(e,t){return v("integer",e,Object.assign({min:"-2147483648",max:"2147483647"},t||{}))}function E(e,t){return b(e,Object.assign({min:"1"},t||{}))}function k(e,t){return b(e,Object.assign({min:"0"},t||{}))}function R(e,t){return w(e,Object.assign({min:"0"},t||{}))}function P(e,t){return v("string",e,t)}function C(e){return v("boolean",e)}function O(e,t,r){return v("array",e,Object.assign({element:t},r||{}))}function T(e,t,r,n){return v("map",e,Object.assign({key:t,value:r},n||{}))}function A(e){return Object.assign({sent_ms:b(!1),trace:P(!1)},e||{})}function S(e,t){return{allowEmpty:!(!t||!t.allowEmpty),fields:e||{}}}var M=b(!1),I=w(!1),U=R(!1),B=b(!1),N=k(!1),x=E(!1),D=P(!1),F=v("string_or_bin",!1),L=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function Y(e,t){return O(e,I,t)}function V(e){return T(e,"string",D)}function H(e){return T(e,"positive_decimal_int64",D)}function G(e){return T(e,"positive_decimal_int64",U)}function W(e){return T(e,"positive_decimal_int64",N)}function z(e){return b(e,{max:"255",min:"0"})}var K,J={extra:P(!0,{maxBytes:65535}),kind:(K=!0,b(K,{messageKind:!0})),message_ref:k(!0),payload:v("string_or_bin",!0,{maxBytes:65535})},Q={cursor:b(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},X={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},Z={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},$={"auth.login":A({auth_sec:k(!1),auth_ver:w(!1,{enum:["2"]}),client_ver:P(!0,{nonEmpty:!0}),credential:P(!0,{nonEmpty:!0}),locale:P(!1),project:b(!0,{max:"4294967295",min:"1"}),props:V(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:V(!0)}),"connection.get_props":A(),"system.debug":A({context:P(!0),entry:P(!0,{nonEmpty:!0})}),"presence.online":A({users:j(!0,{minItems:1})}),"user.set_profile":A({private_data:P(!1),public_data:P(!1)}),"user.get_profile":A(),"user.get_public":A({users:j(!0,{minItems:1})}),"user.set_locale":A({locale:P(!0)}),"storage.get":A({slot:P(!0)}),"storage.set":A({slot:P(!0),value:P(!0)}),"storage.delete":A({slot:P(!0)}),"blacklist.add":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.remove":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.list":A(),"group.add":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.remove":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.members":A({group_ref:E(!0),with_online:C(!1)}),"group.count":A({group_ref:E(!0),with_online:C(!1)}),"group.joined":A(),"group.set_profile":A({group_ref:E(!0),private_data:P(!1),public_data:P(!1)}),"group.get_profile":A({group_ref:E(!0)}),"group.get_public":A({group_ref:E(!0)}),"group.get_public_batch":A({group_refs:j(!0,{minItems:1})}),"room.join":A({room_ref:E(!0)}),"room.leave":A({room_ref:E(!0)}),"room.join_batch":A({room_refs:j(!0,{maxItems:100,minItems:1})}),"room.joined":A(),"room.members":A({room_ref:E(!0)}),"room.counts":A({room_refs:j(!0,{minItems:1})}),"room.set_profile":A({avatar:P(!1),label:P(!1),private_data:P(!1),public_data:P(!1),room_ref:E(!0)}),"room.get_profile":A({room_ref:E(!0)}),"room.get_public":A({room_ref:E(!0)}),"room.get_public_batch":A({room_refs:j(!0,{minItems:1})}),"room.last_messages":A({kinds:q(!1)}),"message.send":A(Object.assign({recipient:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_batch":A(Object.assign({recipients:j(!0,{maxItems:100,minItems:1})},J)),"message.send_group":A(Object.assign({group_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_room":A(Object.assign({room_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"moderation.check":A({checkParams:P(!1),payload:P(!0,{nonEmpty:!0}),strategyId:P(!1),zone:P(!1)}),"translation.run":A({filter_mode:P(!0,{enum:["off","stop","censor"]}),format:P(!0,{nonEmpty:!0}),from_locale:P(!1),input:P(!0,{nonEmpty:!0}),to_locale:P(!0)}),"history.direct":A(Object.assign({peer:E(!0)},Q)),"history.group":A(Object.assign({group_ref:E(!0)},Q)),"history.room":A(Object.assign({room_ref:E(!0)},Q)),"history.broadcast":A(Q),"history.direct_anchor":A(Object.assign({peer:E(!0)},X)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},X)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_anchor":A(X),"history.direct_count":A(Object.assign({peer:E(!0)},Z)),"history.group_count":A(Object.assign({group_ref:E(!0)},Z)),"history.room_count":A(Object.assign({room_ref:E(!0)},Z)),"history.broadcast_count":A(Z),"message.get":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"message.revoke":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"unread.summary":A({mark_read:C(!0),with_logout:C(!1)}),"session.list":A(),"unread.clear":A(),"session.read":A({channel:w(!0,{enum:["1","2","3","4","5"]}),target_ref:k(!0),through:E(!0)}),"unread.direct":A({kinds:q(!1),peers:j(!0,{minItems:1}),since_ms:k(!1)}),"unread.group":A({group_refs:j(!0,{minItems:1}),kinds:q(!1),since_ms:k(!1)}),"session.remove":A({local_only:C(!0),peer:E(!0)}),"conversation.direct":A({kinds:q(!1),since_ms:k(!1)}),"conversation.direct_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.unread":A({kinds:q(!1),mark_read:C(!0),since_ms:k(!1)})},ee={first_ms:k(!0),items:O(!0,L),last_ms:k(!0),next:b(!0),size:R(!0)},te={message_ref:b(!0),time_ms:b(!0)},re={extra:P(!0),kind:z(!0),message_ref:b(!0),payload:v("string_or_bin",!0),sender:E(!0),sequence:b(!0),time_ms:b(!0)},ne={"auth.login":S({accepted:C(!0),telemetry_on:C(!1)}),"connection.close":S(),"system.time":S({server_ms:b(!0)}),"connection.set_props":S(),"connection.get_props":S({props:V(!0)}),"system.debug":S(),"presence.online":S({online_users:j(!0)}),"user.set_profile":S(),"user.get_profile":S({private_data:P(!0),public_data:P(!0)}),"user.get_public":S({profiles:H(!0)}),"user.set_locale":S({updated:C(!0)}),"storage.get":S({value:P(!0)}),"storage.set":S(),"storage.delete":S(),"blacklist.add":S(),"blacklist.remove":S(),"blacklist.list":S({blocked_users:j(!0)}),"group.add":S(),"group.remove":S(),"group.members":S({active_members:j(!1),members:j(!0)}),"group.count":S({active_total:R(!1),total:R(!0)}),"group.joined":S({group_refs:j(!0)}),"group.set_profile":S(),"group.get_profile":S({private_data:P(!0),public_data:P(!0)}),"group.get_public":S({public_data:P(!0)}),"group.get_public_batch":S({profiles:H(!0)}),"room.join":S(),"room.leave":S(),"room.join_batch":S(),"room.joined":S({room_refs:j(!0)}),"room.members":S({members:j(!0)}),"room.counts":S({totals:G(!0)}),"room.set_profile":S(),"room.get_profile":S({private_data:P(!0),public_data:P(!0)}),"room.get_public":S({public_data:P(!0)}),"room.get_public_batch":S({profiles:H(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",L)}(!0)}),"message.send":S(te),"message.send_batch":S(te),"message.send_group":S(te),"message.send_room":S(te),"moderation.check":S({decision:w(!0),detected_locale:P(!0),filtered:P(!0),matches:function(e,t){return O(e,D,t)}(!1)}),"translation.run":S({detected_locale:P(!0),from_locale:P(!0),input:P(!0),original:P(!0),output:P(!0),resolved_locale:P(!0),to_locale:P(!0),translated:P(!0)}),"history.direct":S(ee),"history.group":S(ee),"history.room":S(ee),"history.broadcast":S(ee),"history.direct_anchor":S(ee),"history.group_anchor":S(ee),"history.room_anchor":S(ee),"history.broadcast_anchor":S(ee),"history.direct_count":S({total:R(!0)}),"history.group_count":S({total:R(!0)}),"history.room_count":S({total:R(!0)}),"history.broadcast_count":S({total:R(!0)}),"message.get":S(re,{allowEmpty:!0}),"message.revoke":S(),"unread.summary":S({group_refs:j(!0),logout_sec:k(!1),peers:j(!0)}),"session.list":S({group_refs:j(!0),peers:j(!0)}),"unread.clear":S(),"session.read":S(),"unread.direct":S({counts:G(!0),times:W(!0)}),"unread.group":S({counts:G(!0),times:W(!0)}),"session.remove":S(),"conversation.direct":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.direct_unread":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.group":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.group_unread":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.unread":S({group_badges:Y(!0),group_last:O(!0,L),group_refs:j(!0),peer_badges:Y(!0),peer_last:O(!0,L),peers:j(!0)}),"control.ping":S({ts:b(!1)})},ie={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},oe={extra:P(!0,{maxBytes:65535}),kind:z(!0),message_ref:b(!0),payload:v("push_payload",!0),sender:E(!0),time_ms:b(!0)},se={"event.direct":Object.assign({recipient:E(!0)},oe),"event.group":Object.assign({group_ref:E(!0)},oe),"event.room":Object.assign({room_ref:E(!0)},oe),"event.broadcast":oe,"event.kicked":{},"event.room_removed":{room_ref:E(!0)}};function ae(e){return d[e]||null}function ue(e){var t=String(e);if(!/^-?[0-9]+$/.test(t))return null;var r="-"===t.charAt(0),n=(r?t.slice(1):t).replace(/^0+/,"")||"0";return r&&"0"!==n?"-"+n:n}function ce(e){return"number"==typeof e?function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(e)?ue(e):null:"bigint"==typeof e||e instanceof i.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function fe(e,t){var r=ue(e),n=ue(t);if(null===r||null===n)throw new Error("integer comparison requires decimal integers");if(r===n)return 0;var i="-"===r.charAt(0),o="-"===n.charAt(0);if(i!==o)return i?-1:1;var s=i?r.slice(1):r,a=o?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,i?-u:u}function le(e){for(var t=0,r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319){var i=e.charCodeAt(r+1);if(i<56320||i>57343)throw new o(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new o(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new o(200034,e+" "+t)}function pe(e,t,r){if(null==e&&he(r,"must not be nil"),"integer"!==t.type)if("boolean"!==t.type){if("string"===t.type)return"string"!=typeof e&&he(r,"must be a UTF-8 string"),t.nonEmpty&&0===e.length&&he(r,"must not be empty"),t.enum&&-1===t.enum.indexOf(e)&&he(r,"is not an allowed value"),void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));if("string_or_bin"===t.type){if("string"==typeof e)return void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));var n=i.getByteView(e);return n||he(r,"must be a string or MsgPack bin value"),void(void 0!==t.maxBytes&&n.byteLength>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" bytes"))}if("array"!==t.type){if("map"===t.type)return i.isPlainMap(e)||he(r,"must be a map"),void Object.keys(e).forEach((function(n){!function(e,t,r){if("string"!==t)if("positive_decimal_int64"!==t)he(r,"uses an unsupported map-key contract");else{var n=ue(e);(null===n||"-"===n.charAt(0)||"0"===n||fe(n,_)>0)&&he(r,"must be a positive decimal int64 map key")}}(n,t.key,r+"."+n),pe(e[n],t.value,r+"."+n)}));if("tuple8"!==t.type)if("push_payload"!==t.type)he(r,"uses an unsupported value contract");else{if("string"==typeof e||i.getByteView(e))return;de("Chat payload",e,ie)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),pe(e[0],B,t+"[0]"),pe(e[1],B,t+"[1]"),pe(e[2],M,t+"[2]"),pe(e[3],B,t+"[3]"),pe(e[4],v("boolean",!1),t+"[4]"),pe(e[5],F,t+"[5]"),pe(e[6],D,t+"[6]"),pe(e[7],B,t+"[7]")}(e,r)}else if(Array.isArray(e)||he(r,"must be an array"),void 0!==t.minItems&&e.length<t.minItems&&he(r,"must not be empty"),void 0!==t.maxItems&&e.length>t.maxItems&&he(r,"contains too many items"),e.forEach((function(e,n){pe(e,t.element,r+"["+n+"]")})),void 0!==t.uniqueInt64Max){var o={};e.forEach((function(e){o[ce(e)]=!0})),Object.keys(o).length>t.uniqueInt64Max&&he(r,"contains too many distinct int64 items")}}else"boolean"!=typeof e&&he(r,"must be boolean");else!function(e,t,r){var n=ce(e);(null===n||fe(n,"-9223372036854775808")<0||fe(n,_)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&fe(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&fe(n,t.max)>0&&he(r,"is above the allowed range"),t.enum&&-1===t.enum.indexOf(n)&&he(r,"is not an allowed value"),t.messageKind&&!(fe(n,"1")>=0&&fe(n,"39")<=0||fe(n,"51")>=0&&fe(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function de(e,t,r){i.isPlainMap(t)||he(e,"body must be a map"),Object.keys(t).forEach((function(t){Object.prototype.hasOwnProperty.call(r,t)||he(e+"."+t,"is not defined by this contract")})),Object.keys(r).forEach((function(n){var i=r[n];Object.prototype.hasOwnProperty.call(t,n)?pe(t[n],i,e+"."+n):i.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,i=1;i<r.length;i+=1)t[r[i]].length!==n&&he(e+" Answer",r.join(", ")+" must have matching lengths")}function ye(e){return g.has(e)||"string"==typeof e&&0===e.indexOf("imclient_")}e.exports={RELIABLE_PUSHES:y,REQUEST_SCHEMAS:$,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:d,TLVContractError:o,getRoute:ae,getRouteByUri:function(e){for(var t=Object.keys(d),r=0;r<t.length;r+=1){var n=d[t[r]];if(n.uri===e)return{method:t[r],route:n}}return null},isOneWayPush:function(e){return Object.prototype.hasOwnProperty.call(m,e)},isReliablePush:function(e){return Object.prototype.hasOwnProperty.call(y,e)},isReservedWire:ye,toWireRequest:function(e,t,r,n){var s=ae(e);if(!s){if(ye(e))throw new o(200020,e+" is reserved and unavailable on the TLV Client port");throw new o(20004,"unknown or unsupported TLV Client wire: "+e)}if(!i.isPlainMap(t))throw new o(200034,e+" request body must be a map");var a={};return Object.keys(t).forEach((function(e){var r=void 0;if("trace_id"!==e&&"send_ts"!==e){if("trace"===e||"sent_ms"===e)r=e;else if(Object.prototype.hasOwnProperty.call(s.request,e))r=s.request[e];else{if(-1===s.pass.indexOf(e))throw new o(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new o(200034,s.uri+" received duplicate field mapping for "+r);n&&n.omitLegacyNil&&(void 0===t[e]||null===t[e])&&function(e,t){if("trace"===t||"sent_ms"===t)return!0;if(Object.prototype.hasOwnProperty.call(e.defaults,t))return!0;var r=$[e.uri];return!(!r||!r[t]||r[t].required)}(s,r)||(a[r]=t[e])}})),Object.keys(s.defaults).forEach((function(e){Object.prototype.hasOwnProperty.call(a,e)||(a[e]=s.defaults[e])})),function(e,t,r){if(!t)return;var n="function"==typeof t?t():t;if(!n)return;if(!i.isPlainMap(n))throw new o(200034,r+" request metadata must be a map");["trace","sent_ms"].forEach((function(t){if(void 0!==n[t]){if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t])throw new o(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=$[e.uri];if(!r)throw new o(200034,"missing request schema for "+e.uri);if(de(e.uri+" request",t,r),"auth.login"===e.uri){var n=Object.prototype.hasOwnProperty.call(t,"auth_sec"),i=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==i)throw new o(200034,"auth.login requires auth_sec and auth_ver together");if(i&&"2"!==ce(t.auth_ver))throw new o(200034,"auth.login auth_ver must be 2")}}(s,a),{payload:a,uri:s.uri}},validateControlError:function(e){de("control.error Answer",e,{reason:P(!0),status:w(!0)})},validatePush:function(e,t){var r=se[e];if(!r)throw new o(200034,"unsupported Push URI: "+e);de(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new o(200034,"unsupported Answer URI: "+e);r.allowEmpty&&i.isPlainMap(t)&&0===Object.keys(t).length||(de(e+" Answer",t,r.fields),function(e,t){var r=void 0;if("conversation.direct"===e||"conversation.direct_unread"===e)r=["peers","badges","last_items"];else if("conversation.group"===e||"conversation.group_unread"===e)r=["group_refs","badges","last_items"];else if("conversation.unread"===e)return ge(e,t,["group_refs","group_badges","group_last"]),void ge(e,t,["peers","peer_badges","peer_last"]);r&&ge(e,t,r)}(e,t))}}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function i(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(o){if(!n[o]&&"_"!==o.charAt(0)){var s=t[o];if("function"==typeof s){var a="login"===o?2:s.length-1;a<0||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===o){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),i(e,o,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+o+"()"));for(;t.length<a;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),i(e,o,t,n)}))}})}}})),Object.freeze(r)}}]);
|
|
27
|
+
*/!function(){"use strict";function t(e){if(e)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=l;else if(a){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}var r="input is invalid type",e="object"==typeof window,i=e?window:{};i.JS_MD5_NO_WINDOW&&(e=!1);var s=!e&&"object"==typeof self,h=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;h?i=global:s&&(i=self);var f=!i.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,o=__webpack_require__(15),a=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),u=[128,32768,8388608,-2147483648],y=[0,8,16,24],c=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[],l;if(a){var A=new ArrayBuffer(68);l=new Uint8Array(A),d=new Uint32Array(A)}!i.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!a||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){return function(r){return new t(!0).update(r)[e]()}},v=function(){var e=b("hex");h&&(e=w(e)),e.create=function(){return new t},e.update=function(t){return e.create().update(t)};for(var r=0;r<c.length;++r){var n=c[r];e[n]=b(n)}return e},w=function(t){var e=eval("require('crypto')"),i=eval("require('buffer').Buffer"),s=function(n){if("string"==typeof n)return e.createHash("md5").update(n,"utf8").digest("hex");if(null==n)throw r;return n.constructor===ArrayBuffer&&(n=new Uint8Array(n)),Array.isArray(n)||ArrayBuffer.isView(n)||n.constructor===i?e.createHash("md5").update(new i(n)).digest("hex"):t(n)};return s};t.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if("string"!==n){if("object"!==n)throw r;if(null===e)throw r;if(a&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||a&&ArrayBuffer.isView(e)))throw r;t=!0}for(var i,o,s=0,u=e.length,c=this.blocks,f=this.buffer8;s<u;){if(this.hashed&&(this.hashed=!1,c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),t)if(a)for(o=this.start;s<u&&o<64;++s)f[o++]=e[s];else for(o=this.start;s<u&&o<64;++s)c[o>>2]|=e[s]<<y[3&o++];else if(a)for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?f[o++]=i:i<2048?(f[o++]=192|i>>6,f[o++]=128|63&i):i<55296||i>=57344?(f[o++]=224|i>>12,f[o++]=128|i>>6&63,f[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),f[o++]=240|i>>18,f[o++]=128|i>>12&63,f[o++]=128|i>>6&63,f[o++]=128|63&i);else for(o=this.start;s<u&&o<64;++s)(i=e.charCodeAt(s))<128?c[o>>2]|=i<<y[3&o++]:i<2048?(c[o>>2]|=(192|i>>6)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):i<55296||i>=57344?(c[o>>2]|=(224|i>>12)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]):(i=65536+((1023&i)<<10|1023&e.charCodeAt(++s)),c[o>>2]|=(240|i>>18)<<y[3&o++],c[o>>2]|=(128|i>>12&63)<<y[3&o++],c[o>>2]|=(128|i>>6&63)<<y[3&o++],c[o>>2]|=(128|63&i)<<y[3&o++]);this.lastByteIndex=o,this.bytes+=o-this.start,o>=64?(this.start=o-64,this.hash(),this.hashed=!0):this.start=o}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=u[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},t.prototype.hash=function(){var e,t,r,n,i,o,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879<<0)^(r=((r=(-271733879^(n=((n=(-1732584194^2004318071&e)+s[1]-117830708)<<12|n>>>20)+e<<0)&(-271733879^e))+s[2]-1126478375)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1316259209)<<22|t>>>10)+r<<0:(e=this.h0,t=this.h1,r=this.h2,t=((t+=((e=((e+=((n=this.h3)^t&(r^n))+s[0]-680876936)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[1]-389564586)<<12|n>>>20)+e<<0)&(e^t))+s[2]+606105819)<<17|r>>>15)+n<<0)&(n^e))+s[3]-1044525330)<<22|t>>>10)+r<<0),t=((t+=((e=((e+=(n^t&(r^n))+s[4]-176418897)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[5]+1200080426)<<12|n>>>20)+e<<0)&(e^t))+s[6]-1473231341)<<17|r>>>15)+n<<0)&(n^e))+s[7]-45705983)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[8]+1770035416)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[9]-1958414417)<<12|n>>>20)+e<<0)&(e^t))+s[10]-42063)<<17|r>>>15)+n<<0)&(n^e))+s[11]-1990404162)<<22|t>>>10)+r<<0,t=((t+=((e=((e+=(n^t&(r^n))+s[12]+1804603682)<<7|e>>>25)+t<<0)^(r=((r+=(t^(n=((n+=(r^e&(t^r))+s[13]-40341101)<<12|n>>>20)+e<<0)&(e^t))+s[14]-1502002290)<<17|r>>>15)+n<<0)&(n^e))+s[15]+1236535329)<<22|t>>>10)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[1]-165796510)<<5|e>>>27)+t<<0)^t))+s[6]-1069501632)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[11]+643717713)<<14|r>>>18)+n<<0)^n))+s[0]-373897302)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[5]-701558691)<<5|e>>>27)+t<<0)^t))+s[10]+38016083)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[15]-660478335)<<14|r>>>18)+n<<0)^n))+s[4]-405537848)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[9]+568446438)<<5|e>>>27)+t<<0)^t))+s[14]-1019803690)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[3]-187363961)<<14|r>>>18)+n<<0)^n))+s[8]+1163531501)<<20|t>>>12)+r<<0,t=((t+=((n=((n+=(t^r&((e=((e+=(r^n&(t^r))+s[13]-1444681467)<<5|e>>>27)+t<<0)^t))+s[2]-51403784)<<9|n>>>23)+e<<0)^e&((r=((r+=(e^t&(n^e))+s[7]+1735328473)<<14|r>>>18)+n<<0)^n))+s[12]-1926607734)<<20|t>>>12)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[5]-378558)<<4|e>>>28)+t<<0))+s[8]-2022574463)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[11]+1839030562)<<16|r>>>16)+n<<0))+s[14]-35309556)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[1]-1530992060)<<4|e>>>28)+t<<0))+s[4]+1272893353)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[7]-155497632)<<16|r>>>16)+n<<0))+s[10]-1094730640)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[13]+681279174)<<4|e>>>28)+t<<0))+s[0]-358537222)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[3]-722521979)<<16|r>>>16)+n<<0))+s[6]+76029189)<<23|t>>>9)+r<<0,t=((t+=((o=(n=((n+=((i=t^r)^(e=((e+=(i^n)+s[9]-640364487)<<4|e>>>28)+t<<0))+s[12]-421815835)<<11|n>>>21)+e<<0)^e)^(r=((r+=(o^t)+s[15]+530742520)<<16|r>>>16)+n<<0))+s[2]-995338651)<<23|t>>>9)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[0]-198630844)<<6|e>>>26)+t<<0)|~r))+s[7]+1126891415)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[14]-1416354905)<<15|r>>>17)+n<<0)|~e))+s[5]-57434055)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[12]+1700485571)<<6|e>>>26)+t<<0)|~r))+s[3]-1894986606)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[10]-1051523)<<15|r>>>17)+n<<0)|~e))+s[1]-2054922799)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[8]+1873313359)<<6|e>>>26)+t<<0)|~r))+s[15]-30611744)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[6]-1560198380)<<15|r>>>17)+n<<0)|~e))+s[13]+1309151649)<<21|t>>>11)+r<<0,t=((t+=((n=((n+=(t^((e=((e+=(r^(t|~n))+s[4]-145523070)<<6|e>>>26)+t<<0)|~r))+s[11]-1120210379)<<10|n>>>22)+e<<0)^((r=((r+=(e^(n|~t))+s[2]+718787259)<<15|r>>>17)+n<<0)|~e))+s[9]-343485551)<<21|t>>>11)+r<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=r-1732584194<<0,this.h3=n+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+r<<0,this.h3=this.h3+n<<0)},t.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,i=this.h3;return n[e>>4&15]+n[15&e]+n[e>>12&15]+n[e>>8&15]+n[e>>20&15]+n[e>>16&15]+n[e>>28&15]+n[e>>24&15]+n[t>>4&15]+n[15&t]+n[t>>12&15]+n[t>>8&15]+n[t>>20&15]+n[t>>16&15]+n[t>>28&15]+n[t>>24&15]+n[r>>4&15]+n[15&r]+n[r>>12&15]+n[r>>8&15]+n[r>>20&15]+n[r>>16&15]+n[r>>28&15]+n[r>>24&15]+n[i>>4&15]+n[15&i]+n[i>>12&15]+n[i>>8&15]+n[i>>20&15]+n[i>>16&15]+n[i>>28&15]+n[i>>24&15]},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3;return[255&e,e>>8&255,e>>16&255,e>>24&255,255&t,t>>8&255,t>>16&255,t>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255]},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},t.prototype.buffer=t.prototype.arrayBuffer,t.prototype.base64=function(){for(var e,t,r,n="",i=this.array(),o=0;o<15;)e=i[o++],t=i[o++],r=i[o++],n+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|r>>>6)]+p[63&r];return e=i[o],n+(p[e>>>2]+p[e<<4&63]+"==")};var _=v();f?module.exports=_:(i.md5=_,o&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return _}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(14),__webpack_require__(2))},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new d(e,t)),1!==c.length||f||a(p)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,r){(function(e){!function(t){function r(e,r,g){function _(e,t,r,n){return this instanceof _?function(e,t,r,n,i){if(h&&p&&(t instanceof p&&(t=new h(t)),n instanceof p&&(n=new h(n))),t||r||n||c){if(!s(t,r))i=r,n=t,r=0,t=new(c||Array)(8);e.buffer=t,e.offset=r|=0,f!==typeof n&&("string"==typeof n?function(e,t,r,n){var i=0,o=r.length,s=0,a=0;"-"===r[0]&&i++;for(var u=i;i<o;){var c=parseInt(r[i++],n);if(!(c>=0))break;a=a*n+c,s=s*n+Math.floor(a/y),a%=y}u&&(s=~s,a?a=y-a:s++),b(e,t+E,s),b(e,t+k,a)}(t,r,n,i||10):s(n,i)?a(t,r,n,i):"number"==typeof i?(b(t,r+E,n),b(t,r+k,i)):n>0?T(t,r,n):n<0?A(t,r,n):a(t,r,d,0))}else e.buffer=u(d,0)}(this,e,t,r,n):new _(e,t,r,n)}function v(){var e=this.buffer,t=this.offset,r=w(e,t+E),n=w(e,t+k);return g||(r|=0),r?r*y+n:n}function b(e,t,r){e[t+O]=255&r,r>>=8,e[t+C]=255&r,r>>=8,e[t+P]=255&r,r>>=8,e[t+R]=255&r}function w(e,t){return e[t+R]*m+(e[t+P]<<16)+(e[t+C]<<8)+e[t+O]}var E=r?0:4,k=r?4:0,R=r?0:3,P=r?1:2,C=r?2:1,O=r?3:0,T=r?function(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}:function(e,t,r){for(var n=t+8;t<n;)e[t++]=255&r,r/=256},A=r?function(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}:function(e,t,r){var n=t+8;for(r++;t<n;)e[t++]=255&-r^255,r/=256},S=_.prototype,M="is"+e,I="_"+M;return S.buffer=void 0,S.offset=0,S[I]=!0,S.toNumber=v,S.toString=function(e){var t=this.buffer,r=this.offset,n=w(t,r+E),i=w(t,r+k),o="",s=!g&&2147483648&n;for(s&&(n=~n,i=y-i),e=e||10;;){var a=n%e*y+i;if(n=Math.floor(n/e),i=Math.floor(a/e),o=(a%e).toString(e)+o,!n&&!i)break}return s&&(o="-"+o),o},S.toJSON=v,S.toArray=n,l&&(S.toBuffer=i),h&&(S.toArrayBuffer=o),_[M]=function(e){return!(!e||!e[I])},t[e]=_,_}function n(e){var t=this.buffer,r=this.offset;return c=null,!1!==e&&0===r&&8===t.length&&g(t)?t:u(t,r)}function i(t){var r=this.buffer,n=this.offset;if(c=l,!1!==t&&0===n&&8===r.length&&e.isBuffer(r))return r;var i=new l(8);return a(i,0,r,n),i}function o(e){var t=this.buffer,r=this.offset,n=t.buffer;if(c=h,!1!==e&&0===r&&n instanceof p&&8===n.byteLength)return n;var i=new h(8);return a(i,0,t,r),i.buffer}function s(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function a(e,t,r,n){t|=0,n|=0;for(var i=0;i<8;i++)e[t++]=255&r[n++]}function u(e,t){return Array.prototype.slice.call(e,t,t+8)}var c,f="undefined",l=f!==typeof e&&e,h=f!==typeof Uint8Array&&Uint8Array,p=f!==typeof ArrayBuffer&&ArrayBuffer,d=[0,0,0,0,0,0,0,0],g=Array.isArray||function(e){return!!e&&"[object Array]"==Object.prototype.toString.call(e)},y=4294967296,m=16777216;r("Uint64BE",!0,!0),r("Int64BE",!0,!1),r("Uint64LE",!1,!0),r("Int64LE",!1,!1)}("string"!=typeof t.nodeName?t:this||{})}).call(this,r(5).Buffer)},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 i=r(1).fpnn,o=r(0),s=(r(4),function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i.FPEvent.assign(this),this._map={},this._client=t,this.uid=0,this._expireTimerID=0,this._msgOptions={codec:o.MsgPack.createCodec({int64:!0})},this._binaryOptions={codec:o.MsgPack.createCodec({int64:!0,useraw:!0})},this._binaryMessageMethodList=[o.SERVER_PUSH.recvMessage,o.SERVER_PUSH.recvGroupMessage,o.SERVER_PUSH.recvRoomMessage,o.SERVER_PUSH.recvBroadcastMessage,o.SERVER_PUSH.recvFile,o.SERVER_PUSH.recvGroupFile,o.SERVER_PUSH.recvRoomFile,o.SERVER_PUSH.recvBroadcastFile],u.call(this)}return n(e,[{key:"service",value:function(e,t){if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(r=e.method,n=o.TLV_SERVER_PUSH,r===n.recvMessage||r===n.recvGroupMessage||r===n.recvRoomMessage||r===n.recvBroadcastMessage||r===n.kickOut||r===n.kickOutRoom))this._serviceTLVPush(e);else{var r,n,i=!0;o.SERVER_PUSH.kickOut==e.method&&(i=!1),o.SERVER_PUSH.kickOutRoom==e.method&&(i=!1),i&&t&&(0==e.flag&&t(JSON.stringify({}),!1),1==e.flag&&t(o.MsgPack.encode({},this._msgOptions),!1));var s=null;if(e&&Object.prototype.hasOwnProperty.call(e,"_tlvPayload")&&(s=e._tlvPayload,e._tlvBinaryPayload&&(s.binary=s.msg)),s||0!=e.flag||(s=JSON.parse(e.payload)),!s&&1==e.flag)if(-1!==this._binaryMessageMethodList.indexOf(e.method))if((s=o.MsgPack.decode(e.payload,this._binaryOptions)).mtype==o.CHAT_TYPE.text)s=o.MsgPack.decode(e.payload,this._msgOptions);else{s.binary=s.msg;try{s.msg=new TextDecoder("utf-8",{fatal:!0}).decode(s.msg)}catch(e){s.msg=void 0}try{s.attrs=new TextDecoder("utf-8",{fatal:!0}).decode(s.attrs)}catch(e){}}else s=o.MsgPack.decode(e.payload,this._msgOptions);if(s){if(void 0!==s.attrs)try{var a=JSON.parse(s.attrs);if(a&&void 0!==a.excludedUids&&Array.isArray(a.excludedUids)&&a.excludedUids.includes(this.uid.toString()))return}catch(e){}"function"==typeof this[e.method]&&this[e.method].call(this,s)}}}},{key:"_serviceTLVPush",value:function(e){var t=e._tlvPayload;if(t&&void 0!==t.extra)try{var r=JSON.parse(t.extra);if(r&&void 0!==r.excludedUids&&Array.isArray(r.excludedUids)&&r.excludedUids.includes(this.uid.toString()))return}catch(e){}this.emit(e.method,t)}},{key:"destroy",value:function(){this._map={},this._expireTimerID&&(clearInterval(this._expireTimerID),this._expireTimerID=0)}},{key:"kickout",value:function(e){this.emit(o.SERVER_PUSH.kickOut,e)}},{key:"kickoutroom",value:function(e){e.rid&&(e.rid=new o.Int64(e.rid)),this.emit(o.SERVER_PUSH.kickOutRoom,e)}},{key:"pushmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,1,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvMessage,e)):this.emit(o.SERVER_PUSH.recvCmd,e):this.emit(o.SERVER_PUSH.recvFile,e):this.emit(o.SERVER_PUSH.recvChat,e))}},{key:"pushgroupmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,2,e.mid,e.from,e.gid))||(e.gid&&(e.gid=new o.Int64(e.gid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvGroupFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvGroupMessage,e)):this.emit(o.SERVER_PUSH.recvGroupCmd,e):this.emit(o.SERVER_PUSH.recvGroupFile,e):this.emit(o.SERVER_PUSH.recvGroupChat,e))}},{key:"pushroommsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,3,e.mid,e.from,e.rid))||(e.rid&&(e.rid=new o.Int64(e.rid)),e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvRoomFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvRoomMessage,e)):this.emit(o.SERVER_PUSH.recvRoomCmd,e):this.emit(o.SERVER_PUSH.recvRoomFile,e):this.emit(o.SERVER_PUSH.recvRoomChat,e))}},{key:"pushbroadcastmsg",value:function(e){e.from&&(e.from=new o.Int64(e.from)),e.mid&&(e.mid=new o.Int64(e.mid),!a.call(this,4,e.mid,e.from))||(e.mtime&&(e.mtime=new o.Int64(e.mtime)),e.mtype>=40&&e.mtype<=50?this.emit(o.SERVER_PUSH.recvBroadcastFile,e):e.mtype!=o.CHAT_TYPE.text?e.mtype!=o.CHAT_TYPE.audio?e.mtype!=o.CHAT_TYPE.cmd?(delete e.ftype,this.emit(o.SERVER_PUSH.recvBroadcastMessage,e)):this.emit(o.SERVER_PUSH.recvBroadcastCmd,e):this.emit(o.SERVER_PUSH.recvBroadcastFile,e):this.emit(o.SERVER_PUSH.recvBroadcastChat,e))}},{key:"ping",value:function(e){this._client._lastPingTime=parseInt(Date.now()/1e3),this.emit(o.SERVER_PUSH.recvPing,e)}}]),e}());function a(e,t,r,n){var i=[];i.push(e),i.push(t),i.push(r),null!=n&&i.push(n);var s=i.join("_");if(this._map.hasOwnProperty(s)){if(this._map[s]>Date.now())return!1;delete this._map[s]}return this._map[s]=o.MID_TTL+Date.now(),!0}function u(){var e=this;this._expireTimerID=setInterval((function(){for(var t in e._map)e._map[t]>Date.now()||c.call(e,t)}),o.MID_TTL+1e3)}function c(e){var t=this;setTimeout((function(){delete t._map[e]}),0)}e.exports=s},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},i=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(19),s=r(20),a=r(3),u=r(0),c=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=t||{};if("string"!=typeof r.endpoint||!/^wss?:\/\//i.test(r.endpoint))throw new Error("tlv-v1 requires an explicit ws:// or wss:// endpoint URL");this._endpoint=r.endpoint,this._webSocketFactory=r.webSocketFactory||f,this._legacyMsgPack=r.legacyMsgPack||u.MsgPack,this._legacyMsgOptions=r.legacyMsgOptions,this._requestMetadata=r.requestMetadata,this._connectionTimeout=r.connectionTimeout||3e4,this._requestTimeout=r.requestTimeout||2e4,this._heartbeatIdleMs=r.heartbeatIdleMs||3e4,this._heartbeatTimeoutMs=r.heartbeatTimeoutMs||1e4,this._dedupTtlMs=Math.max(r.pushDedupTtlMs||3e4,2e4),this._listeners={},this._pending=new Map,this._receivedMessages=new Map,this._nextSequence=1,this._socket=null,this._connectionGeneration=0,this._state="idle",this._authenticated=!1,this._connectionTimer=0,this._heartbeatTimer=0,this._heartbeatPending=!1,this._lastActivity=0,this._incomingQueue=Promise.resolve(),this._protocolClosing=!1,this._destroyed=!1,this.processor=null}return i(e,[{key:"on",value:function(e,t){return"function"!=typeof t||(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)),this}},{key:"off",value:function(e,t){var r=this._listeners[e];return r?(this._listeners[e]=r.filter((function(e){return e!==t})),this):this}},{key:"emit",value:function(e){var t=this._listeners[e]||[],r=Array.prototype.slice.call(arguments,1),n=this;t.slice().forEach((function(e){e.apply(n,r)}))}},{key:"connect",value:function(){if(!this._destroyed&&"connecting"!==this._state&&"open"!==this._state&&"closing"!==this._state){var e=this._connectionGeneration+1;this._connectionGeneration=e,this._nextSequence=1,this._receivedMessages.clear(),this._incomingQueue=Promise.resolve(),this._state="connecting",this._protocolClosing=!1;var t=void 0;try{t=this._webSocketFactory(this._endpoint)}catch(e){return this._state="closed",this.emit("error",h("cannot create WebSocket: "+e.message)),void this.emit("close")}if(!t||"function"!=typeof t.send||"function"!=typeof t.close)return this._state="closed",this.emit("error",h("webSocketFactory returned an invalid socket")),void this.emit("close");this._socket=t;try{t.binaryType="arraybuffer"}catch(e){}t.onopen=this._onOpen.bind(this,t,e),t.onmessage=this._onMessage.bind(this,t,e),t.onerror=this._onError.bind(this,t,e),t.onclose=this._onClose.bind(this,t,e),this._connectionTimer=setTimeout(this._onConnectionTimeout.bind(this,t,e),this._connectionTimeout)}}},{key:"close",value:function(){this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1,"open"!==this._state&&"connecting"!==this._state||(this._state="closing");var e=this._socket;if(e)try{e.close()}catch(e){this._finalizeClose()}else this._finalizeClose()}},{key:"destroy",value:function(){if(!this._destroyed){this._destroyed=!0,this._clearConnectionTimeout(),this._stopHeartbeat(),this._authenticated=!1;var e=this._socket;if(e)try{e.close()}catch(e){}this._finalizeClose(),this._listeners={},this._receivedMessages.clear()}}},{key:"markAuthenticated",value:function(){this._destroyed||"open"!==this._state||(this._authenticated=!0,this._lastActivity=Date.now(),this._startHeartbeat())}},{key:"sendQuest",value:function(e,t,r){try{var n=this._decodeLegacyPayload(e&&e.payload),i=s.toWireRequest(e&&e.method,n.payload,this._requestMetadata,{omitLegacyNil:n.legacyEncoded});this._request(i.uri,i.payload,r,{onError:function(e){t&&t(p(e))},onSuccess:function(e){t&&t({_tlvPayload:d(e),mtype:2,ss:0})}})}catch(e){t&&t(p(e))}}},{key:"_decodeLegacyPayload",value:function(e){if(null==e)return{legacyEncoded:!1,payload:{}};if(a.isPlainMap(e))return{legacyEncoded:!1,payload:e};try{var t=this._legacyMsgPack.decode(e,this._legacyMsgOptions);if(!a.isPlainMap(t))throw new Error("legacy request payload is not a map");return{legacyEncoded:!0,payload:t}}catch(e){throw new s.TLVContractError(200034,"cannot decode local request payload: "+e.message)}}},{key:"_onOpen",value:function(e,t){e!==this._socket||t!==this._connectionGeneration||"connecting"!==this._state||this._destroyed||(this._clearConnectionTimeout(),this._state="open",this._lastActivity=Date.now(),this.emit("connect"))}},{key:"_onMessage",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){var i=r&&("object"===(void 0===r?"undefined":n(r))||"function"==typeof r)&&"data"in r?r.data:r;this._incomingQueue=this._incomingQueue.then((function(){return function(e){if("string"==typeof e)return Promise.reject(new Error("WebSocket text messages are forbidden by TLV v1"));var t=a.getByteView(e);if(t)return Promise.resolve(t);if(e&&"function"==typeof e.arrayBuffer){var r=void 0;try{r=e.arrayBuffer()}catch(e){return Promise.reject(e)}return Promise.resolve(r).then((function(e){var t=a.getByteView(e);if(!t)throw new Error("WebSocket Blob did not resolve to binary data");return t}))}return Promise.reject(new Error("WebSocket message is not binary data"))}(i)})).then(this._handleIncomingBytes.bind(this,e,t)).catch(this._handleIncomingFailure.bind(this,e,t))}}},{key:"_onError",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed){var n=r&&r.message?r.message:"WebSocket transport error";this.emit("error",h(n))}}},{key:"_onClose",value:function(e,t){e===this._socket&&t===this._connectionGeneration&&this._finalizeClose()}},{key:"_onConnectionTimeout",value:function(e,t){if(this._connectionTimer=0,e===this._socket&&t===this._connectionGeneration&&"connecting"===this._state&&!this._destroyed){var r=h("WebSocket connection timed out after "+this._connectionTimeout+" ms");try{this.emit("error",r)}finally{if(e===this._socket&&t===this._connectionGeneration&&!this._destroyed&&"closed"!==this._state){this._state="closing";try{e.close()}catch(e){}e===this._socket&&t===this._connectionGeneration&&"closed"!==this._state&&this._finalizeClose()}}}}},{key:"_clearConnectionTimeout",value:function(){this._connectionTimer&&(clearTimeout(this._connectionTimer),this._connectionTimer=0)}},{key:"_handleIncomingBytes",value:function(e,t,r){if(e===this._socket&&t===this._connectionGeneration&&"open"===this._state&&!this._destroyed){this._lastActivity=Date.now();var n=o.decodeFrame(r);"2"!==n.mt?"1"!==n.mt?this._handleOneWayPush(n):this._handleReliablePush(n):this._handleAnswer(n)}}},{key:"_handleIncomingFailure",value:function(e,t,r){e!==this._socket||t!==this._connectionGeneration||this._destroyed||this._protocolFailure(r)}},{key:"_handleAnswer",value:function(e){if("control.ack"===e.uri)throw new Error("Gate must not send control.ack to a Client");var t=this._pending.get(e.sequence);if(t){if("control.error"===e.uri)return s.validateControlError(e.payload),void this._completePending(e.sequence,!1,{reason:e.payload.reason,status:Number(e.payload.status)});if(e.uri!==t.uri)throw new Error("Answer URI does not match pending request URI");s.validateResponse(e.uri,e.payload),this._completePending(e.sequence,!0,e.payload)}}},{key:"_handleReliablePush",value:function(e){if(!s.isReliablePush(e.uri))throw new Error('Gate sent an unsupported mt="1" Quest URI: '+e.uri);s.validatePush(e.uri,e.payload);var t=String(e.payload.message_ref),r=this._isDuplicateMessage(t);if(this._sendFrame(e.sequence,"2","control.ack",{}),!r){var n={method:e.uri,payload:d(e.payload)};this._rememberMessage(t),this._dispatchPush(n)}}},{key:"_handleOneWayPush",value:function(e){if(!s.isOneWayPush(e.uri))throw new Error('Gate sent an unsupported mt="0" URI: '+e.uri);s.validatePush(e.uri,e.payload);var t={method:e.uri,payload:d(e.payload)};"event.kicked"===e.uri&&(this._authenticated=!1,this._stopHeartbeat()),this._dispatchPush(t)}},{key:"_dispatchPush",value:function(e){if(this.processor&&"function"==typeof this.processor.service){var t=a.getByteView(e.payload.payload);this.processor.service({_tlvBinaryPayload:!!t,_tlvPayload:e.payload,flag:1,method:e.method})}}},{key:"_request",value:function(e,t,r,n){if(!this._destroyed&&"open"===this._state&&this._socket)if(this._authenticated||"auth.login"===e||"control.ping"===e)if(this._authenticated&&"auth.login"===e)n.onError({status:200023,reason:"auth.login cannot be sent twice on one connection"});else{var i=this._allocateSequence(),o="number"==typeof r&&r>0?r:this._requestTimeout,s={handlers:n,timer:setTimeout(this._onRequestTimeout.bind(this,i),o),uri:e};this._pending.set(i,s);try{this._sendFrame(i,"1",e,t)}catch(e){this._pending.delete(i),clearTimeout(s.timer),n.onError(l(e))}}else n.onError({status:200022,reason:"authentication is required before "+e});else n.onError(h("invalid WebSocket connection"))}},{key:"_onRequestTimeout",value:function(e){var t=this._pending.get(e);t&&(this._pending.delete(e),t.handlers.onError({status:200999,reason:"request timeout"}))}},{key:"_completePending",value:function(e,t,r){var n=this._pending.get(e);n&&(this._pending.delete(e),clearTimeout(n.timer),t?n.handlers.onSuccess(r):n.handlers.onError(r))}},{key:"_allocateSequence",value:function(){for(var e=0;e<o.MAX_SEQUENCE;e+=1){var t=this._nextSequence;if(this._nextSequence=t===o.MAX_SEQUENCE?1:t+1,!this._pending.has(t))return t}throw new Error("all TLV request sequences are pending")}},{key:"_sendFrame",value:function(e,t,r,n){if(this._destroyed||"open"!==this._state||!this._socket)throw h("invalid WebSocket connection");var i=o.encodeFrame(e,t,r,n),s=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);this._socket.send(s),this._lastActivity=Date.now()}},{key:"_startHeartbeat",value:function(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(this._heartbeatTick.bind(this),1e3)}},{key:"_stopHeartbeat",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=0),this._heartbeatPending=!1}},{key:"_heartbeatTick",value:function(){this._authenticated&&!this._heartbeatPending&&"open"===this._state&&(Date.now()-this._lastActivity<this._heartbeatIdleMs||(this._heartbeatPending=!0,this._request("control.ping",{},this._heartbeatTimeoutMs,{onError:this._onHeartbeatError.bind(this),onSuccess:this._onHeartbeatAnswer.bind(this)})))}},{key:"_onHeartbeatAnswer",value:function(e){this._heartbeatPending=!1,a.isPlainMap(e)||this._protocolFailure(new Error("control.ping Answer body must be a map"))}},{key:"_onHeartbeatError",value:function(e){this._heartbeatPending=!1,this._protocolFailure(new Error("control.ping failed: "+l(e).reason))}},{key:"_isDuplicateMessage",value:function(e){this._expireReceivedMessages();var t=this._receivedMessages.get(e);return void 0!==t&&t>Date.now()}},{key:"_rememberMessage",value:function(e){this._receivedMessages.set(e,Date.now()+this._dedupTtlMs)}},{key:"_expireReceivedMessages",value:function(){var e=Date.now();this._receivedMessages.forEach((function(t,r){t<=e&&this._receivedMessages.delete(r)}),this)}},{key:"_protocolFailure",value:function(e){if(!this._protocolClosing&&"closed"!==this._state){this._protocolClosing=!0;var t=l(e);this.emit("error",h("TLV protocol error: "+t.reason));var r=this._socket;if(r){this._state="closing";try{r.close(1002,"TLV protocol error")}catch(e){this._finalizeClose()}}else this._finalizeClose()}}},{key:"_finalizeClose",value:function(){if("closed"!==this._state){this._state="closed",this._clearConnectionTimeout(),this._socket=null,this._authenticated=!1,this._stopHeartbeat();var e=Array.from(this._pending.values());this._pending.clear(),e.forEach((function(e){clearTimeout(e.timer),e.handlers.onError(h("WebSocket connection closed"))})),this.emit("close")}}}]),e}();function f(e){var t="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof globalThis?globalThis.WebSocket:void 0;if("function"!=typeof t)throw new Error("WebSocket is unavailable; provide options.webSocketFactory");return new t(e)}function l(e){return e&&"number"==typeof e.status?{reason:"string"==typeof e.reason?e.reason:e.message||String(e.status),status:e.status}:{reason:e&&e.message?e.message:String(e||"unknown error"),status:200999}}function h(e){return{reason:e,status:200999}}function p(e){var t=l(e);return{_tlvPayload:{reason:t.reason,status:t.status},mtype:2,ss:1}}function d(e){if(e instanceof a.Int64Value)return new u.Int64(e.toString());if(Array.isArray(e))return e.map(d);if(a.isPlainMap(e)){var t={};return Object.keys(e).forEach((function(r){t[r]=d(e[r])})),t}return e}e.exports=c},function(e,t,r){"use strict";var n=r(3),i=new Uint8Array([2,0,109,116,1,0]),o=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(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="TLVCodecError",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}();function s(e){if("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e<1||e>2147483647)throw new o("sequence must be an integer in 1..2147483647")}function a(e,t,r){var n=r>>>0;e[t]=255&n,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function u(e,t){return e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]>>>0}e.exports={FLAGS:4,MAGIC:204,MAX_FRAME_LENGTH:67239936,MAX_PAYLOAD_LENGTH:67108864,MAX_SEQUENCE:2147483647,METADATA_LENGTH:7,TLVCodecError:o,VERSION:1,decodeFrame:function(e){var t=n.toUint8Array(e);if(0===t.length||t.length>67239936)throw new o("TLV frame length is outside the allowed limit");if(t.length<27)throw new o("TLV frame is too short");if(204!==t[0]||1!==t[1]||4!==t[2]||0!==t[3])throw new o("invalid TLV v1 header");var r=u(t,4);if(s(r),7!==function(e,t){return e[t]+256*e[t+1]}(t,8))throw new o("TLV v1 metadata length must be exactly 7");for(var a=0;a<i.length;a+=1)if(t[10+a]!==i[a])throw new o("TLV v1 metadata must contain only key mt");var c=t[16];if(48!==c&&49!==c&&50!==c)throw new o("TLV v1 metadata mt is invalid");var f=String.fromCharCode(c);if(u(t,17)!==t.length-21)throw new o("message queue length does not match the frame boundary");var l=21,h=t[l];if(l+=1,0===h||l+h+1+4>t.length)throw new o("invalid URI length in message queue");var p=n.utf8Decode(t.subarray(l,l+h));if(0!==t[l+=h])throw new o("TLV v1 passThrough must be empty");var d=u(t,l+=1);if(l+=4,0===d||d>67108864||l+d!==t.length)throw new o("invalid MsgPack payload length or trailing bytes");var g=t.subarray(l,l+d),y=void 0;try{y=n.decodeMap(g,{allowIntegerMapKeyAtPath:"room.last_messages"===p?["last_by_room"]:null})}catch(e){if(e instanceof o)throw e;throw new o("invalid MsgPack payload: "+e.message)}return{mt:f,payload:y,payloadBytes:new Uint8Array(g),sequence:r,uri:p}},encodeFrame:function(e,t,r,u){s(e),function(e){if("0"!==e&&"1"!==e&&"2"!==e)throw new o('metadata mt must be "0", "1", or "2"')}(t);var c=function(e){if("string"!=typeof e||0===e.length)throw new o("URI must be a non-empty UTF-8 string");var t=n.utf8Encode(e);if(0===t.length||t.length>255)throw new o("URI UTF-8 length must be in 1..255");return t}(r),f=n.encodeMap(void 0===u?{}:u);if(0===f.length||f.length>67108864)throw new o("MsgPack payload length is outside the TLV v1 limit");var l=1+c.length+1+4+f.length,h=21+l;if(h>67239936)throw new o("TLV frame exceeds the maximum frame length");var p=new Uint8Array(h);p[0]=204,p[1]=1,p[2]=4,p[3]=0,a(p,4,e),function(e,t,r){e[t]=255&r,e[t+1]=r>>>8&255}(p,8,7),p.set(i,10),p[16]=t.charCodeAt(0),a(p,17,l);var d=21;return p[d]=c.length,d+=1,p.set(c,d),p[d+=c.length]=0,a(p,d+=1,f.length),d+=4,p.set(f,d),p}}},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};var i=r(3),o=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=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,r));return n.name="TLVContractError",n.status=e,n}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}();function s(e,t,r,n){var i=n||{};return{defaults:i.defaults||{},pass:i.pass||[],request:t||{},required:i.required||[],response:r||{},uri:e}}var a={cursor:0,end_ms:0,limit:20,reverse:!1,start_ms:0},u={end_ms:0,limit:20,reverse:!1,start_ms:0},c={end_ms:0,start_ms:0},f={begin:"start_ms",desc:"reverse",end:"end_ms",lastid:"cursor",mtypes:"kinds",num:"limit"},l={begin:"start_ms",desc:"reverse",end:"end_ms",mid:"anchor",mtypes:"kinds",num:"limit"},h={begin:"start_ms",end:"end_ms",mtypes:"kinds"},p={begin:"first_ms",end:"last_ms",lastid:"next",msgs:"items",num:"size"},d={auth:s("auth.login",{attrs:"props",authv:"auth_ver",lang:"locale",pid:"project",token:"credential",ts:"auth_sec",uid:"user",version:"client_ver"},{ok:"accepted"},{required:["project","user","credential","client_ver"]}),bye:s("connection.close"),getservertime:s("system.time",null,{mts:"server_ms"}),addattrs:s("connection.set_props",{attrs:"props"},null,{required:["props"]}),getattrs:s("connection.get_props",null,{attrs:"props"}),adddebuglog:s("system.debug",{attrs:"context",msg:"entry"},null,{required:["entry","context"]}),getonlineusers:s("presence.online",{uids:"users"},{uids:"online_users"},{required:["users"]}),setuserinfo:s("user.set_profile",{oinfo:"public_data",pinfo:"private_data"}),getuserinfo:s("user.get_profile",null,{oinfo:"public_data",pinfo:"private_data"}),getuseropeninfo:s("user.get_public",{uids:"users"},{info:"profiles"},{required:["users"]}),setlang:s("user.set_locale",{lang:"locale"},{ok:"updated"},{required:["locale"]}),dataget:s("storage.get",{key:"slot"},{val:"value"},{required:["slot"]}),dataset:s("storage.set",{key:"slot",val:"value"},null,{required:["slot","value"]}),datadel:s("storage.delete",{key:"slot"},null,{required:["slot"]}),addblacks:s("blacklist.add",{blacks:"blocked_users"},null,{required:["blocked_users"]}),delblacks:s("blacklist.remove",{blacks:"blocked_users"},null,{required:["blocked_users"]}),getblacks:s("blacklist.list",null,{uids:"blocked_users"}),addgroupmembers:s("group.add",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),delgroupmembers:s("group.remove",{gid:"group_ref",uids:"members"},null,{required:["group_ref","members"]}),getgroupmembers:s("group.members",{gid:"group_ref",online:"with_online"},{onlines:"active_members",uids:"members"},{required:["group_ref"]}),getgroupcount:s("group.count",{gid:"group_ref",online:"with_online"},{cn:"total",online:"active_total"},{required:["group_ref"]}),getusergroups:s("group.joined",null,{gids:"group_refs"}),setgroupinfo:s("group.set_profile",{gid:"group_ref",oinfo:"public_data",pinfo:"private_data"},null,{required:["group_ref"]}),getgroupinfo:s("group.get_profile",{gid:"group_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["group_ref"]}),getgroupopeninfo:s("group.get_public",{gid:"group_ref"},{oinfo:"public_data"},{required:["group_ref"]}),getgroupsopeninfo:s("group.get_public_batch",{gids:"group_refs"},{info:"profiles"},{required:["group_refs"]}),enterroom:s("room.join",{rid:"room_ref"},null,{required:["room_ref"]}),leaveroom:s("room.leave",{rid:"room_ref"},null,{required:["room_ref"]}),enterrooms:s("room.join_batch",{rids:"room_refs"},null,{required:["room_refs"]}),getuserrooms:s("room.joined",null,{rooms:"room_refs"}),getroommembers:s("room.members",{rid:"room_ref"},{uids:"members"},{required:["room_ref"]}),getroomcount:s("room.counts",{rids:"room_refs"},{cn:"totals"},{required:["room_refs"]}),setroominfo:s("room.set_profile",{icon:"avatar",name:"label",oinfo:"public_data",pinfo:"private_data",rid:"room_ref"},null,{required:["room_ref"]}),getroominfo:s("room.get_profile",{rid:"room_ref"},{oinfo:"public_data",pinfo:"private_data"},{required:["room_ref"]}),getroomopeninfo:s("room.get_public",{rid:"room_ref"},{oinfo:"public_data"},{required:["room_ref"]}),getroomsopeninfo:s("room.get_public_batch",{rids:"room_refs"},{info:"profiles"},{required:["room_refs"]}),getuserroomsandlastmsg:s("room.last_messages",{mtypes:"kinds"},{rooms:"last_by_room"}),sendmsg:s("message.send",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",to:"recipient"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["recipient","message_ref","kind","payload","extra"]}),sendmsgs:s("message.send_batch",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",tos:"recipients"},{mid:"message_ref",mtime:"time_ms"},{required:["recipients","message_ref","kind","payload","extra"]}),sendgroupmsg:s("message.send_group",{attrs:"extra",gid:"group_ref",mid:"message_ref",msg:"payload",mtype:"kind"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["group_ref","message_ref","kind","payload","extra"]}),sendroommsg:s("message.send_room",{attrs:"extra",mid:"message_ref",msg:"payload",mtype:"kind",rid:"room_ref"},{mid:"message_ref",mtime:"time_ms"},{pass:["checkParams","strategyid"],required:["room_ref","message_ref","kind","payload","extra"]}),tcheck:s("moderation.check",{region:"zone",text:"payload"},{language:"detected_locale",result:"decision",text:"filtered",wlist:"matches"},{pass:["checkParams","strategyId"],required:["payload"]}),translate:s("translation.run",{dst:"to_locale",profanity:"filter_mode",src:"from_locale",text:"input",type:"format"},{dtext:"output",dst:"to_locale",source:"detected_locale",sourceText:"original",src:"from_locale",stext:"input",target:"resolved_locale",targetText:"translated"},{defaults:{filter_mode:"off",format:"chat"},required:["input","to_locale","format","filter_mode"]}),getp2pmsg:s("history.direct",Object.assign({ouid:"peer"},f),p,{defaults:a,required:["peer","reverse","limit","start_ms","end_ms","cursor"]}),getgroupmsg:s("history.group",Object.assign({gid:"group_ref"},f),p,{defaults:a,required:["group_ref","reverse","limit","start_ms","end_ms","cursor"]}),getroommsg:s("history.room",Object.assign({rid:"room_ref"},f),p,{defaults:a,required:["room_ref","reverse","limit","start_ms","end_ms","cursor"]}),getbroadcastmsg:s("history.broadcast",f,p,{defaults:a,required:["reverse","limit","start_ms","end_ms","cursor"]}),getp2pmsgbymessageid:s("history.direct_anchor",Object.assign({ouid:"peer"},l),p,{defaults:u,required:["peer","anchor","reverse","limit","start_ms","end_ms"]}),getgroupmsgbymessageid:s("history.group_anchor",Object.assign({gid:"group_ref"},l),p,{defaults:u,required:["group_ref","anchor","reverse","limit","start_ms","end_ms"]}),getroommsgbymessageid:s("history.room_anchor",Object.assign({rid:"room_ref"},l),p,{defaults:u,required:["room_ref","anchor","reverse","limit","start_ms","end_ms"]}),getbroadcastmsgbymessageid:s("history.broadcast_anchor",l,p,{defaults:u,required:["anchor","reverse","limit","start_ms","end_ms"]}),getp2pmsgcount:s("history.direct_count",Object.assign({ouid:"peer"},h),{count:"total"},{defaults:c,required:["peer","start_ms","end_ms"]}),getgroupmsgcount:s("history.group_count",Object.assign({gid:"group_ref"},h),{count:"total"},{defaults:c,required:["group_ref","start_ms","end_ms"]}),getroommsgcount:s("history.room_count",Object.assign({rid:"room_ref"},h),{count:"total"},{defaults:c,required:["room_ref","start_ms","end_ms"]}),getbroadcastmsgcount:s("history.broadcast_count",h,{count:"total"},{defaults:c,required:["start_ms","end_ms"]}),getmsg:s("message.get",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},{attrs:"extra",from:"sender",id:"sequence",mid:"message_ref",msg:"payload",mtime:"time_ms",mtype:"kind"},{required:["sender","message_ref","target_ref","channel"]}),delmsg:s("message.revoke",{from:"sender",mid:"message_ref",type:"channel",xid:"target_ref"},null,{required:["sender","message_ref","target_ref","channel"]}),getunread:s("unread.summary",{clear:"mark_read",gettime:"with_logout"},{group:"group_refs",logouttime:"logout_sec",p2p:"peers"},{defaults:{mark_read:!1},required:["mark_read"]}),getsession:s("session.list",null,{group:"group_refs",p2p:"peers"}),cleanunread:s("unread.clear"),setsessionread:s("session.read",{category:"channel",read_seq:"through",xid:"target_ref"},null,{required:["channel","target_ref","through"]}),getp2punread:s("unread.direct",{mtime:"since_ms",mtypes:"kinds",uids:"peers"},{ltime:"times",p2p:"counts"},{required:["peers"]}),getgroupunread:s("unread.group",{gids:"group_refs",mtime:"since_ms",mtypes:"kinds"},{group:"counts",ltime:"times"},{required:["group_refs"]}),removesession:s("session.remove",{oneway:"local_only",to:"peer"},null,{defaults:{local_only:!1},required:["peer","local_only"]}),getp2pconversationlist:s("conversation.direct",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getp2punreadconversationlist:s("conversation.direct_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"peers",msgs:"last_items",unreads:"badges"}),getgroupconversationlist:s("conversation.group",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getgroupunreadconversationlist:s("conversation.group_unread",{mtime:"since_ms",mtypes:"kinds"},{conversations:"group_refs",msgs:"last_items",unreads:"badges"}),getunreadconversationlist:s("conversation.unread",{clear:"mark_read",mtime:"since_ms",mtypes:"kinds"},{groupConversations:"group_refs",groupMsgs:"group_last",groupUnreads:"group_badges",p2pConversations:"peers",p2pMsgs:"peer_last",p2pUnreads:"peer_badges"},{defaults:{mark_read:!1},required:["mark_read"]})},g=new Set(["acheck","adddevice","addfriends","addoption","addprojectban","adminCommand","broadcastfile","closeRTCRoom","delfriends","filetoken","getfriends","getoption","getRTCRoomList","getRTCRoomMemberCount","getRTCRoomMembers","icheck","inviteUserIntoRTCRoom","isfriend","isfriends","isprojectban","kickoutFromRTCRoom","profanity","pullIntoRTCRoom","removedevice","removeoption","removeprojectban","sendfile","sendfiles","sendgroupfile","sendroomfile","setRTCRoomMicStatus","speech2text","speechtranslation","uploadfile","vcheck"]),y={"event.broadcast":!0,"event.direct":!0,"event.group":!0,"event.room":!0},m={"event.kicked":!0,"event.room_removed":!0},_="9223372036854775807";function v(e,t,r){return Object.assign({required:!!t,type:e},r||{})}function b(e,t){return v("integer",e,Object.assign({min:"-9223372036854775808",max:_},t||{}))}function w(e,t){return v("integer",e,Object.assign({min:"-2147483648",max:"2147483647"},t||{}))}function E(e,t){return b(e,Object.assign({min:"1"},t||{}))}function k(e,t){return b(e,Object.assign({min:"0"},t||{}))}function R(e,t){return w(e,Object.assign({min:"0"},t||{}))}function P(e,t){return v("string",e,t)}function C(e){return v("boolean",e)}function O(e,t,r){return v("array",e,Object.assign({element:t},r||{}))}function T(e,t,r,n){return v("map",e,Object.assign({key:t,value:r},n||{}))}function A(e){return Object.assign({sent_ms:b(!1),trace:P(!1)},e||{})}function S(e,t){return{allowEmpty:!(!t||!t.allowEmpty),fields:e||{}}}var M=b(!1),I=w(!1),U=R(!1),B=b(!1),N=k(!1),x=E(!1),D=P(!1),F=v("string_or_bin",!1),L=v("tuple8",!1);function j(e,t){return O(e,x,t)}function q(e,t){return O(e,M,t)}function Y(e,t){return O(e,I,t)}function V(e){return T(e,"string",D)}function H(e){return T(e,"positive_decimal_int64",D)}function G(e){return T(e,"positive_decimal_int64",U)}function W(e){return T(e,"positive_decimal_int64",N)}function z(e){return b(e,{max:"255",min:"0"})}var K,J={extra:P(!0,{maxBytes:65535}),kind:(K=!0,b(K,{messageKind:!0})),message_ref:k(!0),payload:v("string_or_bin",!0,{maxBytes:65535})},Q={cursor:b(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},X={anchor:E(!0),end_ms:k(!0),kinds:q(!1),limit:R(!0),reverse:C(!0),start_ms:k(!0)},Z={end_ms:k(!0),kinds:q(!1),start_ms:k(!0)},$={"auth.login":A({auth_sec:k(!1),auth_ver:w(!1,{enum:["2"]}),client_ver:P(!0,{nonEmpty:!0}),credential:P(!0,{nonEmpty:!0}),locale:P(!1),project:b(!0,{max:"4294967295",min:"1"}),props:V(!1),user:E(!0)}),"connection.close":A(),"system.time":A(),"connection.set_props":A({props:V(!0)}),"connection.get_props":A(),"system.debug":A({context:P(!0),entry:P(!0,{nonEmpty:!0})}),"presence.online":A({users:j(!0,{minItems:1})}),"user.set_profile":A({private_data:P(!1),public_data:P(!1)}),"user.get_profile":A(),"user.get_public":A({users:j(!0,{minItems:1})}),"user.set_locale":A({locale:P(!0)}),"storage.get":A({slot:P(!0)}),"storage.set":A({slot:P(!0),value:P(!0)}),"storage.delete":A({slot:P(!0)}),"blacklist.add":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.remove":A({blocked_users:j(!0,{minItems:1,uniqueInt64Max:100})}),"blacklist.list":A(),"group.add":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.remove":A({group_ref:E(!0),members:j(!0,{minItems:1})}),"group.members":A({group_ref:E(!0),with_online:C(!1)}),"group.count":A({group_ref:E(!0),with_online:C(!1)}),"group.joined":A(),"group.set_profile":A({group_ref:E(!0),private_data:P(!1),public_data:P(!1)}),"group.get_profile":A({group_ref:E(!0)}),"group.get_public":A({group_ref:E(!0)}),"group.get_public_batch":A({group_refs:j(!0,{minItems:1})}),"room.join":A({room_ref:E(!0)}),"room.leave":A({room_ref:E(!0)}),"room.join_batch":A({room_refs:j(!0,{maxItems:100,minItems:1})}),"room.joined":A(),"room.members":A({room_ref:E(!0)}),"room.counts":A({room_refs:j(!0,{minItems:1})}),"room.set_profile":A({avatar:P(!1),label:P(!1),private_data:P(!1),public_data:P(!1),room_ref:E(!0)}),"room.get_profile":A({room_ref:E(!0)}),"room.get_public":A({room_ref:E(!0)}),"room.get_public_batch":A({room_refs:j(!0,{minItems:1})}),"room.last_messages":A({kinds:q(!1)}),"message.send":A(Object.assign({recipient:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_batch":A(Object.assign({recipients:j(!0,{maxItems:100,minItems:1})},J)),"message.send_group":A(Object.assign({group_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"message.send_room":A(Object.assign({room_ref:E(!0)},J,{checkParams:P(!1),strategyid:P(!1)})),"moderation.check":A({checkParams:P(!1),payload:P(!0,{nonEmpty:!0}),strategyId:P(!1),zone:P(!1)}),"translation.run":A({filter_mode:P(!0,{enum:["off","stop","censor"]}),format:P(!0,{nonEmpty:!0}),from_locale:P(!1),input:P(!0,{nonEmpty:!0}),to_locale:P(!0)}),"history.direct":A(Object.assign({peer:E(!0)},Q)),"history.group":A(Object.assign({group_ref:E(!0)},Q)),"history.room":A(Object.assign({room_ref:E(!0)},Q)),"history.broadcast":A(Q),"history.direct_anchor":A(Object.assign({peer:E(!0)},X)),"history.group_anchor":A(Object.assign({group_ref:E(!0)},X)),"history.room_anchor":A(Object.assign({room_ref:E(!0)},X)),"history.broadcast_anchor":A(X),"history.direct_count":A(Object.assign({peer:E(!0)},Z)),"history.group_count":A(Object.assign({group_ref:E(!0)},Z)),"history.room_count":A(Object.assign({room_ref:E(!0)},Z)),"history.broadcast_count":A(Z),"message.get":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"message.revoke":A({channel:w(!0,{enum:["1","2","3","4"]}),message_ref:b(!0),sender:E(!0),target_ref:k(!0)}),"unread.summary":A({mark_read:C(!0),with_logout:C(!1)}),"session.list":A(),"unread.clear":A(),"session.read":A({channel:w(!0,{enum:["1","2","3","4","5"]}),target_ref:k(!0),through:E(!0)}),"unread.direct":A({kinds:q(!1),peers:j(!0,{minItems:1}),since_ms:k(!1)}),"unread.group":A({group_refs:j(!0,{minItems:1}),kinds:q(!1),since_ms:k(!1)}),"session.remove":A({local_only:C(!0),peer:E(!0)}),"conversation.direct":A({kinds:q(!1),since_ms:k(!1)}),"conversation.direct_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group":A({kinds:q(!1),since_ms:k(!1)}),"conversation.group_unread":A({kinds:q(!1),since_ms:k(!1)}),"conversation.unread":A({kinds:q(!1),mark_read:C(!0),since_ms:k(!1)})},ee={first_ms:k(!0),items:O(!0,L),last_ms:k(!0),next:b(!0),size:R(!0)},te={message_ref:b(!0),time_ms:b(!0)},re={extra:P(!0),kind:z(!0),message_ref:b(!0),payload:v("string_or_bin",!0),sender:E(!0),sequence:b(!0),time_ms:b(!0)},ne={"auth.login":S({accepted:C(!0),telemetry_on:C(!1)}),"connection.close":S(),"system.time":S({server_ms:b(!0)}),"connection.set_props":S(),"connection.get_props":S({props:V(!0)}),"system.debug":S(),"presence.online":S({online_users:j(!0)}),"user.set_profile":S(),"user.get_profile":S({private_data:P(!0),public_data:P(!0)}),"user.get_public":S({profiles:H(!0)}),"user.set_locale":S({updated:C(!0)}),"storage.get":S({value:P(!0)}),"storage.set":S(),"storage.delete":S(),"blacklist.add":S(),"blacklist.remove":S(),"blacklist.list":S({blocked_users:j(!0)}),"group.add":S(),"group.remove":S(),"group.members":S({active_members:j(!1),members:j(!0)}),"group.count":S({active_total:R(!1),total:R(!0)}),"group.joined":S({group_refs:j(!0)}),"group.set_profile":S(),"group.get_profile":S({private_data:P(!0),public_data:P(!0)}),"group.get_public":S({public_data:P(!0)}),"group.get_public_batch":S({profiles:H(!0)}),"room.join":S(),"room.leave":S(),"room.join_batch":S(),"room.joined":S({room_refs:j(!0)}),"room.members":S({members:j(!0)}),"room.counts":S({totals:G(!0)}),"room.set_profile":S(),"room.get_profile":S({private_data:P(!0),public_data:P(!0)}),"room.get_public":S({public_data:P(!0)}),"room.get_public_batch":S({profiles:H(!0)}),"room.last_messages":S({last_by_room:function(e){return T(e,"positive_decimal_int64",L)}(!0)}),"message.send":S(te),"message.send_batch":S(te),"message.send_group":S(te),"message.send_room":S(te),"moderation.check":S({decision:w(!0),detected_locale:P(!0),filtered:P(!0),matches:function(e,t){return O(e,D,t)}(!1)}),"translation.run":S({detected_locale:P(!0),from_locale:P(!0),input:P(!0),original:P(!0),output:P(!0),resolved_locale:P(!0),to_locale:P(!0),translated:P(!0)}),"history.direct":S(ee),"history.group":S(ee),"history.room":S(ee),"history.broadcast":S(ee),"history.direct_anchor":S(ee),"history.group_anchor":S(ee),"history.room_anchor":S(ee),"history.broadcast_anchor":S(ee),"history.direct_count":S({total:R(!0)}),"history.group_count":S({total:R(!0)}),"history.room_count":S({total:R(!0)}),"history.broadcast_count":S({total:R(!0)}),"message.get":S(re,{allowEmpty:!0}),"message.revoke":S(),"unread.summary":S({group_refs:j(!0),logout_sec:k(!1),peers:j(!0)}),"session.list":S({group_refs:j(!0),peers:j(!0)}),"unread.clear":S(),"session.read":S(),"unread.direct":S({counts:G(!0),times:W(!0)}),"unread.group":S({counts:G(!0),times:W(!0)}),"session.remove":S(),"conversation.direct":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.direct_unread":S({badges:Y(!0),last_items:O(!0,L),peers:j(!0)}),"conversation.group":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.group_unread":S({badges:Y(!0),group_refs:j(!0),last_items:O(!0,L)}),"conversation.unread":S({group_badges:Y(!0),group_last:O(!0,L),group_refs:j(!0),peer_badges:Y(!0),peer_last:O(!0,L),peers:j(!0)}),"control.ping":S({ts:b(!1)})},ie={from_locale:P(!0),original:P(!0),to_locale:P(!0),translated:P(!0)},oe={extra:P(!0,{maxBytes:65535}),kind:z(!0),message_ref:b(!0),payload:v("push_payload",!0),sender:E(!0),time_ms:b(!0)},se={"event.direct":Object.assign({recipient:E(!0)},oe),"event.group":Object.assign({group_ref:E(!0)},oe),"event.room":Object.assign({room_ref:E(!0)},oe),"event.broadcast":oe,"event.kicked":{},"event.room_removed":{room_ref:E(!0)}};function ae(e){return d[e]||null}function ue(e){var t=String(e);if(!/^-?[0-9]+$/.test(t))return null;var r="-"===t.charAt(0),n=(r?t.slice(1):t).replace(/^0+/,"")||"0";return r&&"0"!==n?"-"+n:n}function ce(e){return"number"==typeof e?function(e){if(Number.isSafeInteger)return Number.isSafeInteger(e);return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991}(e)?ue(e):null:"bigint"==typeof e||e instanceof i.Int64Value||e&&"object"===(void 0===e?"undefined":n(e))&&"number"==typeof e.offset&&e.buffer&&"function"==typeof e.toString?ue(e.toString()):null}function fe(e,t){var r=ue(e),n=ue(t);if(null===r||null===n)throw new Error("integer comparison requires decimal integers");if(r===n)return 0;var i="-"===r.charAt(0),o="-"===n.charAt(0);if(i!==o)return i?-1:1;var s=i?r.slice(1):r,a=o?n.slice(1):n,u=void 0;return u=s.length!==a.length?s.length<a.length?-1:1:s<a?-1:1,i?-u:u}function le(e){for(var t=0,r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>=55296&&n<=56319){var i=e.charCodeAt(r+1);if(i<56320||i>57343)throw new o(200034,"string contains an unpaired surrogate");t+=4,r+=1}else{if(n>=56320&&n<=57343)throw new o(200034,"string contains an unpaired surrogate");t+=n<=127?1:n<=2047?2:3}}return t}function he(e,t){throw new o(200034,e+" "+t)}function pe(e,t,r){if(null==e&&he(r,"must not be nil"),"integer"!==t.type)if("boolean"!==t.type){if("string"===t.type)return"string"!=typeof e&&he(r,"must be a UTF-8 string"),t.nonEmpty&&0===e.length&&he(r,"must not be empty"),t.enum&&-1===t.enum.indexOf(e)&&he(r,"is not an allowed value"),void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));if("string_or_bin"===t.type){if("string"==typeof e)return void(void 0!==t.maxBytes&&le(e)>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" UTF-8 bytes"));var n=i.getByteView(e);return n||he(r,"must be a string or MsgPack bin value"),void(void 0!==t.maxBytes&&n.byteLength>t.maxBytes&&he(r,"exceeds "+t.maxBytes+" bytes"))}if("array"!==t.type){if("map"===t.type)return i.isPlainMap(e)||he(r,"must be a map"),void Object.keys(e).forEach((function(n){!function(e,t,r){if("string"!==t)if("positive_decimal_int64"!==t)he(r,"uses an unsupported map-key contract");else{var n=ue(e);(null===n||"-"===n.charAt(0)||"0"===n||fe(n,_)>0)&&he(r,"must be a positive decimal int64 map key")}}(n,t.key,r+"."+n),pe(e[n],t.value,r+"."+n)}));if("tuple8"!==t.type)if("push_payload"!==t.type)he(r,"uses an unsupported value contract");else{if("string"==typeof e||i.getByteView(e))return;de("Chat payload",e,ie)}else!function(e,t){Array.isArray(e)&&8===e.length||he(t,"must be an 8-item message tuple"),pe(e[0],B,t+"[0]"),pe(e[1],B,t+"[1]"),pe(e[2],M,t+"[2]"),pe(e[3],B,t+"[3]"),pe(e[4],v("boolean",!1),t+"[4]"),pe(e[5],F,t+"[5]"),pe(e[6],D,t+"[6]"),pe(e[7],B,t+"[7]")}(e,r)}else if(Array.isArray(e)||he(r,"must be an array"),void 0!==t.minItems&&e.length<t.minItems&&he(r,"must not be empty"),void 0!==t.maxItems&&e.length>t.maxItems&&he(r,"contains too many items"),e.forEach((function(e,n){pe(e,t.element,r+"["+n+"]")})),void 0!==t.uniqueInt64Max){var o={};e.forEach((function(e){o[ce(e)]=!0})),Object.keys(o).length>t.uniqueInt64Max&&he(r,"contains too many distinct int64 items")}}else"boolean"!=typeof e&&he(r,"must be boolean");else!function(e,t,r){var n=ce(e);(null===n||fe(n,"-9223372036854775808")<0||fe(n,_)>0)&&he(r,"must be a signed int64 integer"),void 0!==t.min&&fe(n,t.min)<0&&he(r,"is below the allowed range"),void 0!==t.max&&fe(n,t.max)>0&&he(r,"is above the allowed range"),t.enum&&-1===t.enum.indexOf(n)&&he(r,"is not an allowed value"),t.messageKind&&!(fe(n,"1")>=0&&fe(n,"39")<=0||fe(n,"51")>=0&&fe(n,"127")<=0)&&he(r,"must be in kind ranges [1,39] or [51,127]")}(e,t,r)}function de(e,t,r){i.isPlainMap(t)||he(e,"body must be a map"),Object.keys(t).forEach((function(t){Object.prototype.hasOwnProperty.call(r,t)||he(e+"."+t,"is not defined by this contract")})),Object.keys(r).forEach((function(n){var i=r[n];Object.prototype.hasOwnProperty.call(t,n)?pe(t[n],i,e+"."+n):i.required&&he(e+"."+n,"is required")}))}function ge(e,t,r){for(var n=t[r[0]].length,i=1;i<r.length;i+=1)t[r[i]].length!==n&&he(e+" Answer",r.join(", ")+" must have matching lengths")}function ye(e){return g.has(e)||"string"==typeof e&&0===e.indexOf("imclient_")}e.exports={RELIABLE_PUSHES:y,REQUEST_SCHEMAS:$,RESPONSE_SCHEMAS:ne,RESERVED_WIRES:g,ROUTES:d,TLVContractError:o,getRoute:ae,getRouteByUri:function(e){for(var t=Object.keys(d),r=0;r<t.length;r+=1){var n=d[t[r]];if(n.uri===e)return{method:t[r],route:n}}return null},isOneWayPush:function(e){return Object.prototype.hasOwnProperty.call(m,e)},isReliablePush:function(e){return Object.prototype.hasOwnProperty.call(y,e)},isReservedWire:ye,toWireRequest:function(e,t,r,n){var s=ae(e);if(!s){if(ye(e))throw new o(200020,e+" is reserved and unavailable on the TLV Client port");throw new o(20004,"unknown or unsupported TLV Client wire: "+e)}if(!i.isPlainMap(t))throw new o(200034,e+" request body must be a map");var a={};return Object.keys(t).forEach((function(e){var r=void 0;if("trace_id"!==e&&"send_ts"!==e){if("trace"===e||"sent_ms"===e)r=e;else if(Object.prototype.hasOwnProperty.call(s.request,e))r=s.request[e];else{if(-1===s.pass.indexOf(e))throw new o(200034,s.uri+" does not accept field "+e);r=e}if(Object.prototype.hasOwnProperty.call(a,r))throw new o(200034,s.uri+" received duplicate field mapping for "+r);n&&n.omitLegacyNil&&(void 0===t[e]||null===t[e])&&function(e,t){if("trace"===t||"sent_ms"===t)return!0;if(Object.prototype.hasOwnProperty.call(e.defaults,t))return!0;var r=$[e.uri];return!(!r||!r[t]||r[t].required)}(s,r)||(a[r]=t[e])}})),Object.keys(s.defaults).forEach((function(e){Object.prototype.hasOwnProperty.call(a,e)||(a[e]=s.defaults[e])})),function(e,t,r){if(!t)return;var n="function"==typeof t?t():t;if(!n)return;if(!i.isPlainMap(n))throw new o(200034,r+" request metadata must be a map");["trace","sent_ms"].forEach((function(t){if(void 0!==n[t]){if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t])throw new o(200034,r+" has conflicting "+t+" values");e[t]=n[t]}}))}(a,r,s.uri),function(e,t){var r=$[e.uri];if(!r)throw new o(200034,"missing request schema for "+e.uri);if(de(e.uri+" request",t,r),"auth.login"===e.uri){var n=Object.prototype.hasOwnProperty.call(t,"auth_sec"),i=Object.prototype.hasOwnProperty.call(t,"auth_ver");if(n!==i)throw new o(200034,"auth.login requires auth_sec and auth_ver together");if(i&&"2"!==ce(t.auth_ver))throw new o(200034,"auth.login auth_ver must be 2")}}(s,a),{payload:a,uri:s.uri}},validateControlError:function(e){de("control.error Answer",e,{reason:P(!0),status:w(!0)})},validatePush:function(e,t){var r=se[e];if(!r)throw new o(200034,"unsupported Push URI: "+e);de(e+" Push",t,r)},validateResponse:function(e,t){var r=ne[e];if(!r)throw new o(200034,"unsupported Answer URI: "+e);r.allowEmpty&&i.isPlainMap(t)&&0===Object.keys(t).length||(de(e+" Answer",t,r.fields),function(e,t){var r=void 0;if("conversation.direct"===e||"conversation.direct_unread"===e)r=["peers","badges","last_items"];else if("conversation.group"===e||"conversation.group_unread"===e)r=["group_refs","badges","last_items"];else if("conversation.unread"===e)return ge(e,t,["group_refs","group_badges","group_last"]),void ge(e,t,["peers","peer_badges","peer_last"]);r&&ge(e,t,r)}(e,t))}}},function(e,t,r){"use strict";var n={close:!0,constructor:!0,destroy:!0,emit:!0,off:!0,on:!0,removeEvent:!0,startAutoReconnect:!0};function i(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(o){if(!n[o]&&"_"!==o.charAt(0)){var s=t[o];if("function"==typeof s){var a="login"===o?2:s.length-1;a<0||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,writable:!1,value:function(){var t=Array.prototype.slice.call(arguments);if("login"===o){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),i(e,o,t,s)}))}if(t.length>a)return Promise.reject(new TypeError("Do not pass a callback to promises."+o+"()"));for(;t.length<a;)t.push(void 0);return new Promise((function(r,n){t.push((function(e,t){e?n(e):r(t)})),i(e,o,t,n)}))}})}}})),Object.freeze(r)}},function(e,t,r){"use strict";var n=r(0);var i={"tlv-v1":{},fpnn:{}};function o(e,t,r,n){t.forEach((function(t){i[e][t]={type:r,field:n}}))}var s=n.TLV_SERVER_PUSH;o("tlv-v1",[s.recvMessage],"direct","sender"),o("tlv-v1",[s.recvGroupMessage],"group","group_ref"),o("tlv-v1",[s.recvRoomMessage,s.kickOutRoom],"room","room_ref");var a=n.SERVER_PUSH;o("fpnn",[a.recvMessage,a.recvChat,a.recvAudio,a.recvCmd,a.recvFile],"direct","from"),o("fpnn",[a.recvGroupMessage,a.recvGroupChat,a.recvGroupAudio,a.recvGroupCmd,a.recvGroupFile],"group","gid"),o("fpnn",[a.recvRoomMessage,a.recvRoomChat,a.recvRoomAudio,a.recvRoomCmd,a.recvRoomFile,a.kickOutRoom],"room","rid"),e.exports={normalizeClientOptions:function(e){var t=Object.assign({},e||{});if(void 0===t.protocol&&(t.protocol="tlv-v1"),"tlv-v1"!==t.protocol&&"fpnn"!==t.protocol)throw new Error('SharedWorker protocol must be "tlv-v1" or "fpnn"');if("fpnn"===t.protocol){var r=void 0!==t.ssl_endpoint?t.ssl_endpoint:t.endpoint;if("string"!=typeof r||!r.trim()||/[\s/?#]/.test(r))throw new Error("SharedWorker FPNN requires endpoint or ssl_endpoint as host[:port], without a URL scheme or path")}return t},sharedEndpoint:function(e){if("tlv-v1"===e.protocol)return e.tlvEndpoint||e.tlv_endpoint||e.endpoint||e.ssl_endpoint;if(void 0!==e.ssl_endpoint)return"wss://"+e.ssl_endpoint+"/service/websocket";var t=e.endpoint.split(":");return"ws://"+(2===t.length&&"13325"===t[1]?t[0]+":13321":e.endpoint)+"/service/websocket"},conversationRoute:function(e,t,r){var n=i[e],o=n&&Object.prototype.hasOwnProperty.call(n,t)?n[t]:null;return o?{type:o.type,id:r&&r[o.field]}:null}}}]);
|