UNPKG

275 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("leancloud-realtime",["exports"],t):t((e=e||self).AV=e.AV||{})}(this,(function(e){"use strict";var t="undefined"!=typeof window&&window.process||{};t.env=t.env||{};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return o(null==t&&r.path)}},r.exports),r.exports}function o(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var s=i((function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),a=n(s),u=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});
2/*! *****************************************************************************
3 Copyright (c) Microsoft Corporation.
4
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted.
7
8 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 PERFORMANCE OF THIS SOFTWARE.
15 ***************************************************************************** */
16var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function i(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function o(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var u={getItem:function(e){return wx.getStorageSync(e)},setItem:function(e,t){return wx.setStorageSync(e,t)},removeItem:function(e){return wx.removeStorageSync(e)},clear:function(){return wx.clearStorageSync()}},c=new WeakMap,f=new WeakMap;function l(e){var t=c.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function h(e){null==e.passiveListener?e.event.cancelable&&(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault()):"undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener)}function p(e,t){c.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(var r=Object.keys(t),n=0;n<r.length;++n){var i=r[n];i in this||Object.defineProperty(this,i,d(i))}}function d(e){return{get:function(){return l(this).event[e]},set:function(t){l(this).event[e]=t},configurable:!0,enumerable:!0}}function m(e){return{value:function(){var t=l(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function g(e){if(null==e||e===Object.prototype)return p;var t=f.get(e);return null==t&&(t=function(e,t){var r=Object.keys(t);if(0===r.length)return e;function n(t,r){e.call(this,t,r)}n.prototype=Object.create(e.prototype,{constructor:{value:n,configurable:!0,writable:!0}});for(var i=0;i<r.length;++i){var o=r[i];if(!(o in e.prototype)){var s="function"==typeof Object.getOwnPropertyDescriptor(t,o).value;Object.defineProperty(n.prototype,o,s?m(o):d(o))}}return n}(g(Object.getPrototypeOf(e)),e),f.set(e,t)),t}function y(e){return l(e).immediateStopped}function v(e,t){l(e).passiveListener=t}p.prototype={get type(){return l(this).event.type},get target(){return l(this).eventTarget},get currentTarget(){return l(this).currentTarget},composedPath:function(){var e=l(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return l(this).eventPhase},stopPropagation:function(){var e=l(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation:function(){var e=l(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return Boolean(l(this).event.bubbles)},get cancelable(){return Boolean(l(this).event.cancelable)},preventDefault:function(){h(l(this))},get defaultPrevented(){return l(this).canceled},get composed(){return Boolean(l(this).event.composed)},get timeStamp(){return l(this).timeStamp},get srcElement(){return l(this).eventTarget},get cancelBubble(){return l(this).stopped},set cancelBubble(e){if(e){var t=l(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)}},get returnValue(){return!l(this).canceled},set returnValue(e){e||h(l(this))},initEvent:function(){}},Object.defineProperty(p.prototype,"constructor",{value:p,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.Event&&(Object.setPrototypeOf(p.prototype,window.Event.prototype),f.set(window.Event.prototype,p));var b=new WeakMap;function w(e){return null!==e&&"object"===a(e)}function _(e){var t=b.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function E(e,t){Object.defineProperty(e,"on".concat(t),function(e){return{get:function(){for(var t=_(this).get(e);null!=t;){if(3===t.listenerType)return t.listener;t=t.next}return null},set:function(t){"function"==typeof t||w(t)||(t=null);for(var r=_(this),n=null,i=r.get(e);null!=i;)3===i.listenerType?null!==n?n.next=i.next:null!==i.next?r.set(e,i.next):r.delete(e):n=i,i=i.next;if(null!==t){var o={listener:t,listenerType:3,passive:!1,once:!1,next:null};null===n?r.set(e,o):n.next=o}},configurable:!0,enumerable:!0}}(t))}function T(e){function t(){O.call(this)}t.prototype=Object.create(O.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(var r=0;r<e.length;++r)E(t.prototype,e[r]);return t}function O(){if(!(this instanceof O)){if(1===arguments.length&&Array.isArray(arguments[0]))return T(arguments[0]);if(arguments.length>0){for(var e=new Array(arguments.length),t=0;t<arguments.length;++t)e[t]=arguments[t];return T(e)}throw new TypeError("Cannot call a class as a function")}b.set(this,new Map)}O.prototype={addEventListener:function(e,t,r){if(null!=t){if("function"!=typeof t&&!w(t))throw new TypeError("'listener' should be a function or an object.");var n=_(this),i=w(r),o=(i?Boolean(r.capture):Boolean(r))?1:2,s={listener:t,listenerType:o,passive:i&&Boolean(r.passive),once:i&&Boolean(r.once),next:null},a=n.get(e);if(void 0!==a){for(var u=null;null!=a;){if(a.listener===t&&a.listenerType===o)return;u=a,a=a.next}u.next=s}else n.set(e,s)}},removeEventListener:function(e,t,r){if(null!=t)for(var n=_(this),i=(w(r)?Boolean(r.capture):Boolean(r))?1:2,o=null,s=n.get(e);null!=s;){if(s.listener===t&&s.listenerType===i)return void(null!==o?o.next=s.next:null!==s.next?n.set(e,s.next):n.delete(e));o=s,s=s.next}},dispatchEvent:function(e){if(null==e||"string"!=typeof e.type)throw new TypeError('"event.type" should be a string.');var t=_(this),r=e.type,n=t.get(r);if(null==n)return!0;for(var i=function(e,t){return new(g(Object.getPrototypeOf(t)))(e,t)}(this,e),o=null;null!=n;){if(n.once?null!==o?o.next=n.next:null!==n.next?t.set(r,n.next):t.delete(r):o=n,v(i,n.passive?n.listener:null),"function"==typeof n.listener)try{n.listener.call(this,i)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else 3!==n.listenerType&&"function"==typeof n.listener.handleEvent&&n.listener.handleEvent(i);if(y(i))break;n=n.next}return v(i,null),function(e,t){l(e).eventPhase=t}(i,0),function(e,t){l(e).currentTarget=t}(i,null),!i.defaultPrevented}},Object.defineProperty(O.prototype,"constructor",{value:O,configurable:!0,writable:!0}),"undefined"!=typeof window&&void 0!==window.EventTarget&&Object.setPrototypeOf(O.prototype,window.EventTarget.prototype);var S=function(e){function t(r,n){var i=this;if(!r)throw new TypeError("Failed to construct 'WebSocket': url required");if(n&&(!wx.canIUse||!wx.canIUse("connectSocket.object.protocols")))throw new Error("subprotocol not supported in weapp");(i=e.call(this)||this)._url=r,i._protocol=n,i._readyState=t.CONNECTING;var o=function(e){i._readyState=t.CLOSED,i.dispatchEvent({type:"error",message:e.errMsg})},s=wx.connectSocket({url:r,protocols:void 0===i._protocol||Array.isArray(i._protocol)?i._protocol:[i._protocol],fail:function(e){return setTimeout((function(){return o(e)}),0)}});return i._socketTask=s,s.onOpen((function(e){i._readyState=t.OPEN,i.dispatchEvent({type:"open"})})),s.onError(o),s.onMessage((function(e){var t=e.data;i.dispatchEvent({data:t,type:"message"})})),s.onClose((function(e){i._readyState=t.CLOSED;var r=e.code,n=e.reason;i.dispatchEvent({code:r,reason:n,type:"close"})})),i}return function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),Object.defineProperty(t.prototype,"url",{get:function(){return this._url},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"protocol",{get:function(){return this._protocol},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"readyState",{get:function(){return this._readyState},enumerable:!0,configurable:!0}),t.prototype.close=function(){this.readyState!==t.CLOSED&&(this.readyState===t.CONNECTING&&console.warn("close WebSocket which is connecting might not work"),this._socketTask.close({}))},t.prototype.send=function(e){if(this.readyState!==t.OPEN)throw new Error("INVALID_STATE_ERR");if(!("string"==typeof e||e instanceof ArrayBuffer))throw new TypeError("only String/ArrayBuffer supported");this._socketTask.send({data:e})},t.CONNECTING=0,t.OPEN=1,t.CLOSING=2,t.CLOSED=3,t}(O(["open","error","message","close"]));t.WebSocket=S,t.getAuthInfo=function(e){var t=void 0===e?{}:e,r=t.platform,n=void 0===r?"weixin":r,i=t.preferUnionId,a=void 0!==i&&i,u=t.asMainAccount,c=void 0!==u&&u;return o(this,void 0,void 0,(function(){var e,t;return s(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e,t){wx.login({success:function(r){return r.code?e(r.code):t(new Error(r.errMsg))},fail:function(e){var r=e.errMsg;return t(new Error(r))}})}))];case 1:return e=r.sent(),t={code:e},a&&(t.platform=n,t.main_account=c),[2,{authData:t,platform:n,provider:"lc_weapp"}]}}))}))},t.platformInfo={name:"Weapp"},t.request=function(e,t){var r=void 0===t?{}:t,o=r.method,s=r.data,a=r.headers;return new Promise((function(t,r){return wx.request({url:e,method:o,data:s,header:a,responseType:"text",success:function(e){var r=e.statusCode,o=e.data,s=i(e,["statusCode","data"]);t(n(n({},s),{data:"string"==typeof o?JSON.parse(o):o,status:r,ok:!(r>=400)}))},fail:function(e){r(new Error(e.errMsg))}})}))},t.storage=u,t.upload=function(e,t,r){var o=void 0===r?{}:r,s=o.headers,a=o.data,u=o.onprogress;return t&&t.data&&t.data.uri?new Promise((function(r,o){var c,f=wx.uploadFile({url:e,header:s,filePath:t.data.uri,name:t.field,formData:a,success:function(e){var t=e.statusCode,o=e.data,s=i(e,["statusCode","data"]);r(n(n({},s),{data:"string"==typeof o?JSON.parse(o):o,status:t,ok:!(t>=400)}))},fail:function(e){o(new Error(e.errMsg))}});null===(c=null==f?void 0:f.onProgressUpdate)||void 0===c||c.call(f,(function(e){var t=e.progress,r=e.totalBytesSent,n=e.totalBytesExpectedToSend;return null==u?void 0:u({percent:t,loaded:r,total:n})}))})):Promise.reject(new TypeError("File data must be an object like { uri: localPath }."))}}));n(u);var c=u.WebSocket,f=(u.getAuthInfo,u.platformInfo,u.request),l=(u.storage,u.upload,i((function(e){var t=s.default;e.exports=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,r||"default");if("object"!==t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports})));n(l);var h=i((function(e){var t=s.default;e.exports=function(e){var r=l(e,"string");return"symbol"===t(r)?r:String(r)},e.exports.__esModule=!0,e.exports.default=e.exports}));n(h);var p,d=n(i((function(e){e.exports=function(e,t,r){return(t=h(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports}))),m=i((function(e){
17/**
18 * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
19 * Released under the Apache License, Version 2.0
20 * see: https://github.com/dcodeIO/long.js for details
21 */
22!function(t,r){e&&e.exports?e.exports=r():(t.dcodeIO=t.dcodeIO||{}).Long=r()}(r,(function(){function e(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var r={},n={};function i(e,t){var i,o,a;return t?(a=0<=(e>>>=0)&&e<256)&&(o=n[e])?o:(i=s(e,(0|e)<0?-1:0,!0),a&&(n[e]=i),i):(a=-128<=(e|=0)&&e<128)&&(o=r[e])?o:(i=s(e,e<0?-1:0,!1),a&&(r[e]=i),i)}function o(e,t){if(isNaN(e)||!isFinite(e))return t?m:d;if(t){if(e<0)return m;if(e>=l)return w}else{if(e<=-h)return _;if(e+1>=h)return b}return e<0?o(-e,t).neg():s(e%f|0,e/f|0,t)}function s(t,r,n){return new e(t,r,n)}e.fromInt=i,e.fromNumber=o,e.fromBits=s;var a=Math.pow;function u(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return d;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return u(e.substring(1),t,r).neg();for(var i=o(a(r,8)),s=d,c=0;c<e.length;c+=8){var f=Math.min(8,e.length-c),l=parseInt(e.substring(c,c+f),r);if(f<8){var h=o(a(r,f));s=s.mul(h).add(o(l))}else s=(s=s.mul(i)).add(o(l))}return s.unsigned=t,s}function c(t){return t instanceof e?t:"number"==typeof t?o(t):"string"==typeof t?u(t):s(t.low,t.high,t.unsigned)}e.fromString=u,e.fromValue=c;var f=4294967296,l=f*f,h=l/2,p=i(1<<24),d=i(0);e.ZERO=d;var m=i(0,!0);e.UZERO=m;var g=i(1);e.ONE=g;var y=i(1,!0);e.UONE=y;var v=i(-1);e.NEG_ONE=v;var b=s(-1,2147483647,!1);e.MAX_VALUE=b;var w=s(-1,-1,!0);e.MAX_UNSIGNED_VALUE=w;var _=s(0,-2147483648,!1);e.MIN_VALUE=_;var E=e.prototype;return E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},E.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(_)){var t=o(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=o(a(e,6),this.unsigned),s=this,u="";;){var c=s.div(i),f=(s.sub(c.mul(i)).toInt()>>>0).toString(e);if((s=c).isZero())return f+u;for(;f.length<6;)f="0"+f;u=""+f+u}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},E.isZero=function(){return 0===this.high&&0===this.low},E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return 1==(1&this.low)},E.isEven=function(){return 0==(1&this.low)},E.equals=function(e){return t(e)||(e=c(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},E.eq=E.equals,E.notEquals=function(e){return!this.eq(e)},E.neq=E.notEquals,E.lessThan=function(e){return this.comp(e)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(e){return this.comp(e)<=0},E.lte=E.lessThanOrEqual,E.greaterThan=function(e){return this.comp(e)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(e){return this.comp(e)>=0},E.gte=E.greaterThanOrEqual,E.compare=function(e){if(t(e)||(e=c(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(g)},E.neg=E.negate,E.add=function(e){t(e)||(e=c(e));var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,a=e.high>>>16,u=65535&e.high,f=e.low>>>16,l=0,h=0,p=0,d=0;return p+=(d+=o+(65535&e.low))>>>16,h+=(p+=i+f)>>>16,l+=(h+=n+u)>>>16,l+=r+a,s((p&=65535)<<16|(d&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},E.subtract=function(e){return t(e)||(e=c(e)),this.add(e.neg())},E.sub=E.subtract,E.multiply=function(e){if(this.isZero())return d;if(t(e)||(e=c(e)),e.isZero())return d;if(this.eq(_))return e.isOdd()?_:d;if(e.eq(_))return this.isOdd()?_:d;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(p)&&e.lt(p))return o(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,a=65535&this.low,u=e.high>>>16,f=65535&e.high,l=e.low>>>16,h=65535&e.low,m=0,g=0,y=0,v=0;return y+=(v+=a*h)>>>16,g+=(y+=i*h)>>>16,y&=65535,g+=(y+=a*l)>>>16,m+=(g+=n*h)>>>16,g&=65535,m+=(g+=i*l)>>>16,g&=65535,m+=(g+=a*f)>>>16,m+=r*h+n*l+i*f+a*u,s((y&=65535)<<16|(v&=65535),(m&=65535)<<16|(g&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(e){if(t(e)||(e=c(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:d;var r,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return m;if(e.gt(this.shru(1)))return y;i=m}else{if(this.eq(_))return e.eq(g)||e.eq(v)?_:e.eq(_)?g:(r=this.shr(1).div(e).shl(1)).eq(d)?e.isNegative()?g:v:(n=this.sub(e.mul(r)),i=r.add(n.div(e)));if(e.eq(_))return this.unsigned?m:d;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=d}for(n=this;n.gte(e);){r=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:a(2,s-48),f=o(r),l=f.mul(e);l.isNegative()||l.gt(n);)l=(f=o(r-=u,this.unsigned)).mul(e);f.isZero()&&(f=g),i=i.add(f),n=n.sub(l)}return i},E.div=E.divide,E.modulo=function(e){return t(e)||(e=c(e)),this.sub(this.div(e).mul(e))},E.mod=E.modulo,E.not=function(){return s(~this.low,~this.high,this.unsigned)},E.and=function(e){return t(e)||(e=c(e)),s(this.low&e.low,this.high&e.high,this.unsigned)},E.or=function(e){return t(e)||(e=c(e)),s(this.low|e.low,this.high|e.high,this.unsigned)},E.xor=function(e){return t(e)||(e=c(e)),s(this.low^e.low,this.high^e.high,this.unsigned)},E.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):s(0,this.low<<e-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):s(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var r=this.high;return e<32?s(this.low>>>e|r<<32-e,r>>>e,this.unsigned):s(32===e?r:r>>>e-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},E.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},E.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e}))})),g=i((function(e){
23/**
24 * @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
25 * Backing buffer: ArrayBuffer, Accessor: Uint8Array
26 * Released under the Apache License, Version 2.0
27 * see: https://github.com/dcodeIO/bytebuffer.js for details
28 */
29!function(t,r){e&&e.exports?e.exports=function(){var e;try{e=m}catch(e){}return r(e)}():(t.dcodeIO=t.dcodeIO||{}).ByteBuffer=r(t.dcodeIO.Long)}(r,(function(e){var t=function(e,r,i){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===r&&(r=t.DEFAULT_ENDIAN),void 0===i&&(i=t.DEFAULT_NOASSERT),!i){if((e|=0)<0)throw RangeError("Illegal capacity");r=!!r,i=!!i}this.buffer=0===e?n:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=r,this.noAssert=i};t.VERSION="5.0.1",t.LITTLE_ENDIAN=!0,t.BIG_ENDIAN=!1,t.DEFAULT_CAPACITY=16,t.DEFAULT_ENDIAN=t.BIG_ENDIAN,t.DEFAULT_NOASSERT=!1,t.Long=e||null;var r=t.prototype;r.__isByteBuffer__,Object.defineProperty(r,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var n=new ArrayBuffer(0),i=String.fromCharCode;function o(e){var t=0;return function(){return t<e.length?e.charCodeAt(t++):null}}function s(){var e=[],t=[];return function(){if(0===arguments.length)return t.join("")+i.apply(String,e);e.length+arguments.length>1024&&(t.push(i.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function a(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)}function u(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,m=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*m}t.accessor=function(){return Uint8Array},t.allocate=function(e,r,n){return new t(e,r,n)},t.concat=function(e,r,n,i){"boolean"!=typeof r&&"string"==typeof r||(i=n,n=r,r=void 0);for(var o,s=0,a=0,u=e.length;a<u;++a)t.isByteBuffer(e[a])||(e[a]=t.wrap(e[a],r)),(o=e[a].limit-e[a].offset)>0&&(s+=o);if(0===s)return new t(0,n,i);var c,f=new t(s,n,i);for(a=0;a<u;)(o=(c=e[a++]).limit-c.offset)<=0||(f.view.set(c.view.subarray(c.offset,c.limit),f.offset),f.offset+=o);return f.limit=f.offset,f.offset=0,f},t.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},t.type=function(){return ArrayBuffer},t.wrap=function(e,n,i,o){if("string"!=typeof n&&(o=i,i=n,n=void 0),"string"==typeof e)switch(void 0===n&&(n="utf8"),n){case"base64":return t.fromBase64(e,i);case"hex":return t.fromHex(e,i);case"binary":return t.fromBinary(e,i);case"utf8":return t.fromUTF8(e,i);case"debug":return t.fromDebug(e,i);default:throw Error("Unsupported encoding: "+n)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var s;if(t.isByteBuffer(e))return(s=r.clone.call(e)).markedOffset=-1,s;if(e instanceof Uint8Array)s=new t(0,i,o),e.length>0&&(s.buffer=e.buffer,s.offset=e.byteOffset,s.limit=e.byteOffset+e.byteLength,s.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)s=new t(0,i,o),e.byteLength>0&&(s.buffer=e,s.offset=0,s.limit=e.byteLength,s.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(s=new t(e.length,i,o)).limit=e.length;for(var a=0;a<e.length;++a)s.view[a]=e[a]}return s},r.writeBitSet=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if(!(e instanceof Array))throw TypeError("Illegal BitSet: Not an array");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n,i=t,o=e.length,s=o>>3,a=0;for(t+=this.writeVarint32(o,t);s--;)n=1&!!e[a++]|(1&!!e[a++])<<1|(1&!!e[a++])<<2|(1&!!e[a++])<<3|(1&!!e[a++])<<4|(1&!!e[a++])<<5|(1&!!e[a++])<<6|(1&!!e[a++])<<7,this.writeByte(n,t++);if(a<o){var u=0;for(n=0;a<o;)n|=(1&!!e[a++])<<u++;this.writeByte(n,t++)}return r?(this.offset=t,this):t-i},r.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var r,n=this.readVarint32(e),i=n.value,o=i>>3,s=0,a=[];for(e+=n.length;o--;)r=this.readByte(e++),a[s++]=!!(1&r),a[s++]=!!(2&r),a[s++]=!!(4&r),a[s++]=!!(8&r),a[s++]=!!(16&r),a[s++]=!!(32&r),a[s++]=!!(64&r),a[s++]=!!(128&r);if(s<i){var u=0;for(r=this.readByte(e++);s<i;)a[s++]=!!(r>>u++&1)}return t&&(this.offset=e),a},r.readBytes=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var n=this.slice(t,t+e);return r&&(this.offset+=e),n},r.writeBytes=r.append,r.writeInt8=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeByte=r.writeInt8,r.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=this.view[e];return 128==(128&r)&&(r=-(255-r+1)),t&&(this.offset+=1),r},r.readByte=r.readInt8,r.writeUint8=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeUInt8=r.writeUint8,r.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=this.view[e];return t&&(this.offset+=1),r},r.readUInt8=r.readUint8,r.writeInt16=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},r.writeShort=r.writeInt16,r.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),32768==(32768&r)&&(r=-(65535-r+1)),t&&(this.offset+=2),r},r.readShort=r.readInt16,r.writeUint16=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},r.writeUInt16=r.writeUint16,r.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),t&&(this.offset+=2),r},r.readUInt16=r.readUint16,r.writeInt32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),r&&(this.offset+=4),this},r.writeInt=r.writeInt32,r.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),r|=0,t&&(this.offset+=4),r},r.readInt=r.readInt32,r.writeUint32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),r&&(this.offset+=4),this},r.writeUInt32=r.writeUint32,r.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),t&&(this.offset+=4),r},r.readUInt32=r.readUint32,e&&(r.writeInt64=function(t,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var i=this.buffer.byteLength;r>i&&this.resize((i*=2)>r?i:r),r-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o,r+=4,this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s):(this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s,r+=4,this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o),n&&(this.offset+=8),this},r.writeLong=r.writeInt64,r.readInt64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var n=0,i=0;this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0);var o=new e(n,i,!1);return r&&(this.offset+=8),o},r.readLong=r.readInt64,r.writeUint64=function(t,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var i=this.buffer.byteLength;r>i&&this.resize((i*=2)>r?i:r),r-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o,r+=4,this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s):(this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s,r+=4,this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o),n&&(this.offset+=8),this},r.writeUInt64=r.writeUint64,r.readUint64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var n=0,i=0;this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0);var o=new e(n,i,!0);return r&&(this.offset+=8),o},r.readUInt64=r.readUint64),r.writeFloat32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,u(this.view,e,t,this.littleEndian,23,4),r&&(this.offset+=4),this},r.writeFloat=r.writeFloat32,r.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=a(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),r},r.readFloat=r.readFloat32,r.writeFloat64=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=8,u(this.view,e,t,this.littleEndian,52,8),r&&(this.offset+=8),this},r.writeDouble=r.writeFloat64,r.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var r=a(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),r},r.readDouble=r.readFloat64,t.MAX_VARINT32_BYTES=5,t.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},t.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},t.zigZagDecode32=function(e){return e>>>1^-(1&e)|0},r.writeVarint32=function(e,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var i,o=t.calculateVarint32(e);r+=o;var s=this.buffer.byteLength;for(r>s&&this.resize((s*=2)>r?s:r),r-=o,e>>>=0;e>=128;)i=127&e|128,this.view[r++]=i,e>>>=7;return this.view[r++]=e,n?(this.offset=r,this):o},r.writeVarint32ZigZag=function(e,r){return this.writeVarint32(t.zigZagEncode32(e),r)},r.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r,n=0,i=0;do{if(!this.noAssert&&e>this.limit){var o=Error("Truncated");throw o.truncated=!0,o}r=this.view[e++],n<5&&(i|=(127&r)<<7*n),++n}while(0!=(128&r));return i|=0,t?(this.offset=e,i):{value:i,length:n}},r.readVarint32ZigZag=function(e){var r=this.readVarint32(e);return"object"==typeof r?r.value=t.zigZagDecode32(r.value):r=t.zigZagDecode32(r),r},e&&(t.MAX_VARINT64_BYTES=10,t.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var r=t.toInt()>>>0,n=t.shiftRightUnsigned(28).toInt()>>>0,i=t.shiftRightUnsigned(56).toInt()>>>0;return 0==i?0==n?r<16384?r<128?1:2:r<1<<21?3:4:n<16384?n<128?5:6:n<1<<21?7:8:i<128?9:10},t.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},t.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},r.writeVarint64=function(r,n){var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"==typeof r)r=e.fromNumber(r);else if("string"==typeof r)r=e.fromString(r);else if(!(r&&r instanceof e))throw TypeError("Illegal value: "+r+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}"number"==typeof r?r=e.fromNumber(r,!1):"string"==typeof r?r=e.fromString(r,!1):!1!==r.unsigned&&(r=r.toSigned());var o=t.calculateVarint64(r),s=r.toInt()>>>0,a=r.shiftRightUnsigned(28).toInt()>>>0,u=r.shiftRightUnsigned(56).toInt()>>>0;n+=o;var c=this.buffer.byteLength;switch(n>c&&this.resize((c*=2)>n?c:n),n-=o,o){case 10:this.view[n+9]=u>>>7&1;case 9:this.view[n+8]=9!==o?128|u:127&u;case 8:this.view[n+7]=8!==o?a>>>21|128:a>>>21&127;case 7:this.view[n+6]=7!==o?a>>>14|128:a>>>14&127;case 6:this.view[n+5]=6!==o?a>>>7|128:a>>>7&127;case 5:this.view[n+4]=5!==o?128|a:127&a;case 4:this.view[n+3]=4!==o?s>>>21|128:s>>>21&127;case 3:this.view[n+2]=3!==o?s>>>14|128:s>>>14&127;case 2:this.view[n+1]=2!==o?s>>>7|128:s>>>7&127;case 1:this.view[n]=1!==o?128|s:127&s}return i?(this.offset+=o,this):o},r.writeVarint64ZigZag=function(e,r){return this.writeVarint64(t.zigZagEncode64(e),r)},r.readVarint64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var n=t,i=0,o=0,s=0,a=0;if(i=127&(a=this.view[t++]),128&a&&(i|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(i|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(i|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(o=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(s=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<7,128&a||this.noAssert&&void 0===a))))))))))throw Error("Buffer overrun");var u=e.fromBits(i|o<<28,o>>>4|s<<24,!1);return r?(this.offset=t,u):{value:u,length:t-n}},r.readVarint64ZigZag=function(r){var n=this.readVarint64(r);return n&&n.value instanceof e?n.value=t.zigZagDecode64(n.value):n=t.zigZagDecode64(n),n}),r.writeCString=function(e,t){var r=void 0===t;r&&(t=this.offset);var n,i=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(n=0;n<i;++n)if(0===e.charCodeAt(n))throw RangeError("Illegal str: Contains NULL-characters");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}i=f.calculateUTF16asUTF8(o(e))[1],t+=i+1;var s=this.buffer.byteLength;return t>s&&this.resize((s*=2)>t?s:t),t-=i+1,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,r?(this.offset=t,this):i},r.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r,n=e,i=-1;return f.decodeUTF8toUTF16(function(){if(0===i)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(i=this.view[e++])?null:i}.bind(this),r=s(),!0),t?(this.offset=e,r()):{string:r(),length:e-n}},r.writeIString=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n,i=t;n=f.calculateUTF16asUTF8(o(e),this.noAssert)[1],t+=4+n;var s=this.buffer.byteLength;if(t>s&&this.resize((s*=2)>t?s:t),t-=4+n,this.littleEndian?(this.view[t+3]=n>>>24&255,this.view[t+2]=n>>>16&255,this.view[t+1]=n>>>8&255,this.view[t]=255&n):(this.view[t]=n>>>24&255,this.view[t+1]=n>>>16&255,this.view[t+2]=n>>>8&255,this.view[t+3]=255&n),t+=4,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),t!==i+4+n)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+n));return r?(this.offset=t,this):t-i},r.readIString=function(e){var r=void 0===e;if(r&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var n=e,i=this.readUint32(e),o=this.readUTF8String(i,t.METRICS_BYTES,e+=4);return e+=o.length,r?(this.offset=e,o.string):{string:o.string,length:e-n}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",r.writeUTF8String=function(e,t){var r,n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var i=t;r=f.calculateUTF16asUTF8(o(e))[1],t+=r;var s=this.buffer.byteLength;return t>s&&this.resize((s*=2)>t?s:t),t-=r,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),n?(this.offset=t,this):t-i},r.writeString=r.writeUTF8String,t.calculateUTF8Chars=function(e){return f.calculateUTF16asUTF8(o(e))[0]},t.calculateUTF8Bytes=function(e){return f.calculateUTF16asUTF8(o(e))[1]},t.calculateString=t.calculateUTF8Bytes,r.readUTF8String=function(e,r,n){"number"==typeof r&&(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),void 0===r&&(r=t.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}var o,a=0,u=n;if(r===t.METRICS_CHARS){if(o=s(),f.decodeUTF8(function(){return a<e&&n<this.limit?this.view[n++]:null}.bind(this),(function(e){++a,f.UTF8toUTF16(e,o)})),a!==e)throw RangeError("Illegal range: Truncated data, "+a+" == "+e);return i?(this.offset=n,o()):{string:o(),length:n-u}}if(r===t.METRICS_BYTES){if(!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+"+e+") <= "+this.buffer.byteLength)}var c=n+e;if(f.decodeUTF8toUTF16(function(){return n<c?this.view[n++]:null}.bind(this),o=s(),this.noAssert),n!==c)throw RangeError("Illegal range: Truncated data, "+n+" == "+c);return i?(this.offset=n,o()):{string:o(),length:n-u}}throw TypeError("Unsupported metrics: "+r)},r.readString=r.readUTF8String,r.writeVString=function(e,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var i,s,a=r;i=f.calculateUTF16asUTF8(o(e),this.noAssert)[1],s=t.calculateVarint32(i),r+=s+i;var u=this.buffer.byteLength;if(r>u&&this.resize((u*=2)>r?u:r),r-=s+i,r+=this.writeVarint32(i,r),f.encodeUTF16toUTF8(o(e),function(e){this.view[r++]=e}.bind(this)),r!==a+i+s)throw RangeError("Illegal range: Truncated data, "+r+" == "+(r+i+s));return n?(this.offset=r,this):r-a},r.readVString=function(e){var r=void 0===e;if(r&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n=e,i=this.readVarint32(e),o=this.readUTF8String(i.value,t.METRICS_BYTES,e+=i.length);return e+=o.length,r?(this.offset=e,o.string):{string:o.string,length:e-n}},r.append=function(e,r,n){"number"!=typeof r&&"string"==typeof r||(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,r));var o=e.limit-e.offset;if(o<=0)return this;n+=o;var s=this.buffer.byteLength;return n>s&&this.resize((s*=2)>n?s:n),n-=o,this.view.set(e.view.subarray(e.offset,e.limit),n),e.offset+=o,i&&(this.offset+=o),this},r.appendTo=function(e,t){return e.append(this,t),this},r.assert=function(e){return this.noAssert=!e,this},r.capacity=function(){return this.buffer.byteLength},r.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},r.clone=function(e){var r=new t(0,this.littleEndian,this.noAssert);return e?(r.buffer=new ArrayBuffer(this.buffer.byteLength),r.view=new Uint8Array(r.buffer)):(r.buffer=this.buffer,r.view=this.view),r.offset=this.offset,r.markedOffset=this.markedOffset,r.limit=this.limit,r},r.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var r=t-e;if(0===r)return this.buffer=n,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var i=new ArrayBuffer(r),o=new Uint8Array(i);return o.set(this.view.subarray(e,t)),this.buffer=i,this.view=o,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=r,this},r.copy=function(e,r){if(void 0===e&&(e=this.offset),void 0===r&&(r=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,e<0||e>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+r+" <= "+this.buffer.byteLength)}if(e===r)return new t(0,this.littleEndian,this.noAssert);var n=r-e,i=new t(n,this.littleEndian,this.noAssert);return i.offset=0,i.limit=n,i.markedOffset>=0&&(i.markedOffset-=e),this.copyTo(i,0,e,r),i},r.copyTo=function(e,r,n,i){var o,s;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(r=(s=void 0===r)?e.offset:0|r,n=(o=void 0===n)?this.offset:0|n,i=void 0===i?this.limit:0|i,r<0||r>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+r+" <= "+e.buffer.byteLength);if(n<0||i>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+n+" <= "+this.buffer.byteLength);var a=i-n;return 0===a?e:(e.ensureCapacity(r+a),e.view.set(this.view.subarray(n,i),r),o&&(this.offset+=a),s&&(e.offset+=a),this)},r.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},r.fill=function(e,t,r){var n=void 0===t;if(n&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===r&&(r=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(t>=r)return this;for(;t<r;)this.view[t++]=e;return n&&(this.offset=t),this},r.flip=function(){return this.limit=this.offset,this.offset=0,this},r.mark=function(e){if(e=void 0===e?this.offset:e,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},r.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},r.LE=function(e){return this.littleEndian=void 0===e||!!e,this},r.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},r.prepend=function(e,r,n){"number"!=typeof r&&"string"==typeof r||(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,r));var o=e.limit-e.offset;if(o<=0)return this;var s=o-n;if(s>0){var a=new ArrayBuffer(this.buffer.byteLength+s),u=new Uint8Array(a);u.set(this.view.subarray(n,this.buffer.byteLength),o),this.buffer=a,this.view=u,this.offset+=s,this.markedOffset>=0&&(this.markedOffset+=s),this.limit+=s,n+=s}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),n-o),e.offset=e.limit,i&&(this.offset-=o),this},r.prependTo=function(e,t){return e.prepend(this,t),this},r.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},r.remaining=function(){return this.limit-this.offset},r.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},r.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength<e){var t=new ArrayBuffer(e),r=new Uint8Array(t);r.set(this.view),this.buffer=t,this.view=r}return this},r.reverse=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},r.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},r.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r=this.clone();return r.offset=e,r.limit=t,r},r.toBuffer=function(e){var t=this.offset,r=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal limit: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(!e&&0===t&&r===this.buffer.byteLength)return this.buffer;if(t===r)return n;var i=new ArrayBuffer(r-t);return new Uint8Array(i).set(new Uint8Array(this.buffer).subarray(t,r),0),i},r.toArrayBuffer=r.toBuffer,r.toString=function(e,t,r){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(r=t=e="utf8"),e){case"utf8":return this.toUTF8(t,r);case"base64":return this.toBase64(t,r);case"hex":return this.toHex(t,r);case"binary":return this.toBinary(t,r);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var c=function(){for(var e={},t=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],r=[],n=0,i=t.length;n<i;++n)r[t[n]]=n;return e.encode=function(e,r){for(var n,i;null!==(n=e());)r(t[n>>2&63]),i=(3&n)<<4,null!==(n=e())?(r(t[63&((i|=n>>4&15)|n>>4&15)]),i=(15&n)<<2,null!==(n=e())?(r(t[63&(i|n>>6&3)]),r(t[63&n])):(r(t[63&i]),r(61))):(r(t[63&i]),r(61),r(61))},e.decode=function(e,t){var n,i,o;function s(e){throw Error("Illegal character code: "+e)}for(;null!==(n=e());)if(void 0===(i=r[n])&&s(n),null!==(n=e())&&(void 0===(o=r[n])&&s(n),t(i<<2>>>0|(48&o)>>4),null!==(n=e()))){if(void 0===(i=r[n])){if(61===n)break;s(n)}if(t((15&o)<<4>>>0|(60&i)>>2),null!==(n=e())){if(void 0===(o=r[n])){if(61===n)break;s(n)}t((3&i)<<6>>>0|o)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();r.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var r;return c.encode(function(){return e<t?this.view[e++]:null}.bind(this),r=s()),r()},t.fromBase64=function(e,r){if("string"!=typeof e)throw TypeError("str");var n=new t(e.length/4*3,r),i=0;return c.decode(o(e),(function(e){n.view[i++]=e})),n.limit=i,n},t.btoa=function(e){return t.fromBinary(e).toBase64()},t.atob=function(e){return t.fromBase64(e).toBinary()},r.toBinary=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var r=[],n=[];e<t;)r.push(this.view[e++]),r.length>=1024&&(n.push(String.fromCharCode.apply(String,r)),r=[]);return n.join("")+String.fromCharCode.apply(String,r)},t.fromBinary=function(e,r){if("string"!=typeof e)throw TypeError("str");for(var n,i=0,o=e.length,s=new t(o,r);i<o;){if((n=e.charCodeAt(i))>255)throw RangeError("illegal char code: "+n);s.view[i++]=n}return s.limit=o,s},r.toDebug=function(e){for(var t,r=-1,n=this.buffer.byteLength,i="",o="",s="";r<n;){if(-1!==r&&(i+=(t=this.view[r])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(o+=t>32&&t<127?String.fromCharCode(t):".")),++r,e&&r>0&&r%16==0&&r!==n){for(;i.length<51;)i+=" ";s+=i+o+"\n",i=o=""}r===this.offset&&r===this.limit?i+=r===this.markedOffset?"!":"|":r===this.offset?i+=r===this.markedOffset?"[":"<":r===this.limit?i+=r===this.markedOffset?"]":">":i+=r===this.markedOffset?"'":e||0!==r&&r!==n?" ":""}if(e&&" "!==i){for(;i.length<51;)i+=" ";s+=i+o+"\n"}return e?s:i},t.fromDebug=function(e,r,n){for(var i,o,s=e.length,a=new t((s+1)/3|0,r,n),u=0,c=0,f=!1,l=!1,h=!1,p=!1,d=!1;u<s;){switch(i=e.charAt(u++)){case"!":if(!n){if(l||h||p){d=!0;break}l=h=p=!0}a.offset=a.markedOffset=a.limit=c,f=!1;break;case"|":if(!n){if(l||p){d=!0;break}l=p=!0}a.offset=a.limit=c,f=!1;break;case"[":if(!n){if(l||h){d=!0;break}l=h=!0}a.offset=a.markedOffset=c,f=!1;break;case"<":if(!n){if(l){d=!0;break}l=!0}a.offset=c,f=!1;break;case"]":if(!n){if(p||h){d=!0;break}p=h=!0}a.limit=a.markedOffset=c,f=!1;break;case">":if(!n){if(p){d=!0;break}p=!0}a.limit=c,f=!1;break;case"'":if(!n){if(h){d=!0;break}h=!0}a.markedOffset=c,f=!1;break;case" ":f=!1;break;default:if(!n&&f){d=!0;break}if(o=parseInt(i+e.charAt(u++),16),!n&&(isNaN(o)||o<0||o>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[c++]=o,f=!0}if(d)throw TypeError("Illegal str: Invalid symbol at "+u)}if(!n){if(!l||!p)throw TypeError("Illegal str: Missing offset or limit");if(c<a.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+c+" < "+s)}return a},r.toHex=function(e,t){if(e=void 0===e?this.offset:e,t=void 0===t?this.limit:t,!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var r,n=new Array(t-e);e<t;)(r=this.view[e++])<16?n.push("0",r.toString(16)):n.push(r.toString(16));return n.join("")},t.fromHex=function(e,r,n){if(!n){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if(e.length%2!=0)throw TypeError("Illegal str: Length not a multiple of 2")}for(var i,o=e.length,s=new t(o/2|0,r),a=0,u=0;a<o;a+=2){if(i=parseInt(e.substring(a,a+2),16),!n&&(!isFinite(i)||i<0||i>255))throw TypeError("Illegal str: Contains non-hex characters");s.view[u++]=i}return s.limit=u,s};var f=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<128?t(127&r):r<2048?(t(r>>6&31|192),t(63&r|128)):r<65536?(t(r>>12&15|224),t(r>>6&63|128),t(63&r|128)):(t(r>>18&7|240),t(r>>12&63|128),t(r>>6&63|128),t(63&r|128)),r=null},decodeUTF8:function(e,t){for(var r,n,i,o,s=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(r=e());)if(0==(128&r))t(r);else if(192==(224&r))null===(n=e())&&s([r,n]),t((31&r)<<6|63&n);else if(224==(240&r))(null===(n=e())||null===(i=e()))&&s([r,n,i]),t((15&r)<<12|(63&n)<<6|63&i);else{if(240!=(248&r))throw RangeError("Illegal starting byte: "+r);(null===(n=e())||null===(i=e())||null===(o=e()))&&s([r,n,i,o]),t((7&r)<<18|(63&n)<<12|(63&i)<<6|63&o)}},UTF16toUTF8:function(e,t){for(var r,n=null;null!==(r=null!==n?n:e());)r>=55296&&r<=57343&&null!==(n=e())&&n>=56320&&n<=57343?(t(1024*(r-55296)+n-56320+65536),n=null):t(r);null!==n&&t(n)},UTF8toUTF16:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<=65535?t(r):(t(55296+((r-=65536)>>10)),t(r%1024+56320)),r=null},encodeUTF16toUTF8:function(t,r){e.UTF16toUTF8(t,(function(t){e.encodeUTF8(t,r)}))},decodeUTF8toUTF16:function(t,r){e.decodeUTF8(t,(function(t){e.UTF8toUTF16(t,r)}))},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,r=0;null!==(t=e());)r+=t<128?1:t<2048?2:t<65536?3:4;return r},calculateUTF16asUTF8:function(t){var r=0,n=0;return e.UTF16toUTF8(t,(function(e){++r,n+=e<128?1:e<2048?2:e<65536?3:4})),[r,n]}};return e}();return r.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r;try{f.decodeUTF8toUTF16(function(){return e<t?this.view[e++]:null}.bind(this),r=s())}catch(r){if(e!==t)throw RangeError("Illegal range: Truncated data, "+e+" != "+t)}return r()},t.fromUTF8=function(e,r,n){if(!n&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var i=new t(f.calculateUTF16asUTF8(o(e),!0)[1],r,n),s=0;return f.encodeUTF16toUTF8(o(e),(function(e){i.view[s++]=e})),i.limit=s,i},t}))})),y=(p=Object.freeze({__proto__:null,default:{}}))&&p.default||p,v=i((function(e){
30/**
31 * @license protobuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
32 * Released under the Apache License, Version 2.0
33 * see: https://github.com/dcodeIO/protobuf.js for details
34 */
35!function(t,r){e&&e.exports?e.exports=r(g,!0):(t.dcodeIO=t.dcodeIO||{}).ProtoBuf=r(t.dcodeIO.ByteBuffer)}(r,(function(e,r){var n,i={};return i.ByteBuffer=e,i.Long=e.Long||null,i.VERSION="5.0.3",i.WIRE_TYPES={},i.WIRE_TYPES.VARINT=0,i.WIRE_TYPES.BITS64=1,i.WIRE_TYPES.LDELIM=2,i.WIRE_TYPES.STARTGROUP=3,i.WIRE_TYPES.ENDGROUP=4,i.WIRE_TYPES.BITS32=5,i.PACKABLE_WIRE_TYPES=[i.WIRE_TYPES.VARINT,i.WIRE_TYPES.BITS64,i.WIRE_TYPES.BITS32],i.TYPES={int32:{name:"int32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},uint64:{name:"uint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.UZERO:void 0},sint64:{name:"sint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},bool:{name:"bool",wireType:i.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:i.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:i.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.ZERO:void 0},float:{name:"float",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:i.WIRE_TYPES.STARTGROUP,defaultValue:null}},i.MAP_KEY_TYPES=[i.TYPES.int32,i.TYPES.sint32,i.TYPES.sfixed32,i.TYPES.uint32,i.TYPES.fixed32,i.TYPES.int64,i.TYPES.sint64,i.TYPES.sfixed64,i.TYPES.uint64,i.TYPES.fixed64,i.TYPES.bool,i.TYPES.string,i.TYPES.bytes],i.ID_MIN=1,i.ID_MAX=536870911,i.convertFieldsToCamelCase=!1,i.populateAccessors=!0,i.populateDefaults=!0,i.Util=((n={}).IS_NODE=!("object"!=typeof t||t+""!="[object process]"||t.browser),n.XHR=function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,r=0;r<e.length;r++){try{t=e[r]()}catch(e){continue}break}if(!t)throw Error("XMLHttpRequest is not supported");return t},n.fetch=function(e,t){if(t&&"function"!=typeof t&&(t=null),n.IS_NODE){var r=y;if(t)r.readFile(e,(function(e,r){t(e?null:""+r)}));else try{return r.readFileSync(e)}catch(e){return null}}else{var i=n.XHR();if(i.open("GET",e,!!t),i.setRequestHeader("Accept","text/plain"),"function"==typeof i.overrideMimeType&&i.overrideMimeType("text/plain"),!t)return i.send(null),200==i.status||0==i.status&&"string"==typeof i.responseText?i.responseText:null;if(i.onreadystatechange=function(){4==i.readyState&&(200==i.status||0==i.status&&"string"==typeof i.responseText?t(i.responseText):t(null))},4==i.readyState)return;i.send(null)}},n.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,(function(e,t){return t.toUpperCase()}))},n),i.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,FQTYPEREF:/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.Reflect=function(t){var r={},n=function(e,t,r){this.builder=e,this.parent=t,this.name=r,this.className},i=n.prototype;i.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},i.toString=function(e){return(e?this.className+" ":"")+this.fqn()},i.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},r.T=n;var o=function(e,t,r,i,o){n.call(this,e,t,r),this.className="Namespace",this.children=[],this.options=i||{},this.syntax=o||"proto2"},s=o.prototype=Object.create(n.prototype);s.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],r=0,n=this.children.length;r<n;++r)this.children[r]instanceof e&&t.push(this.children[r]);return t},s.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof f.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof f.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},s.getChild=function(e){for(var t="number"==typeof e?"id":"name",r=0,n=this.children.length;r<n;++r)if(this.children[r][t]===e)return this.children[r];return null},s.resolve=function(e,t){var n,i="string"==typeof e?e.split("."):e,o=this,s=0;if(""===i[s]){for(;null!==o.parent;)o=o.parent;s++}do{do{if(!(o instanceof r.Namespace)){o=null;break}if(!(n=o.getChild(i[s]))||!(n instanceof r.T)||t&&!(n instanceof r.Namespace)){o=null;break}o=n,s++}while(s<i.length);if(null!=o)break;if(null!==this.parent)return this.parent.resolve(e,t)}while(null!=o);return o},s.qn=function(e){var t=[],n=e;do{t.unshift(n.name),n=n.parent}while(null!==n);for(var i=1;i<=t.length;i++){var o=t.slice(t.length-i);if(e===this.resolve(o,e instanceof r.Namespace))return o.join(".")}return e.fqn()},s.build=function(){for(var e,t={},r=this.children,n=0,i=r.length;n<i;++n)(e=r[n])instanceof o&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},s.buildOpt=function(){for(var e={},t=Object.keys(this.options),r=0,n=t.length;r<n;++r){var i=t[r],o=this.options[t[r]];e[i]=o}return e},s.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},r.Namespace=o;var a=function(e,r,n,i,o){if(this.type=e,this.resolvedType=r,this.isMapKey=n,this.syntax=i,this.name=o,n&&t.MAP_KEY_TYPES.indexOf(e)<0)throw Error("Invalid map key type: "+e.name)},u=a.prototype;function c(e,r){if(e&&"number"==typeof e.low&&"number"==typeof e.high&&"boolean"==typeof e.unsigned&&e.low==e.low&&e.high==e.high)return new t.Long(e.low,e.high,void 0===r?e.unsigned:r);if("string"==typeof e)return t.Long.fromString(e,r||!1,10);if("number"==typeof e)return t.Long.fromNumber(e,r||!1);throw Error("not convertible to Long")}a.defaultFieldValue=function(r){if("string"==typeof r&&(r=t.TYPES[r]),void 0===r.defaultValue)throw Error("default value for type "+r.name+" is not supported");return r==t.TYPES.bytes?new e(0):r.defaultValue},u.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},u.verifyValue=function(r){var n=this;function i(e,t){throw Error("Illegal value for "+n.toString(!0)+" of type "+n.type.name+": "+e+" ("+t+")")}switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:return("number"!=typeof r||r==r&&r%1!=0)&&i(typeof r,"not an integer"),r>4294967295?0|r:r;case t.TYPES.uint32:case t.TYPES.fixed32:return("number"!=typeof r||r==r&&r%1!=0)&&i(typeof r,"not an integer"),r<0?r>>>0:r;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:if(t.Long)try{return c(r,!1)}catch(e){i(typeof r,e.message)}else i(typeof r,"requires Long.js");case t.TYPES.uint64:case t.TYPES.fixed64:if(t.Long)try{return c(r,!0)}catch(e){i(typeof r,e.message)}else i(typeof r,"requires Long.js");case t.TYPES.bool:return"boolean"!=typeof r&&i(typeof r,"not a boolean"),r;case t.TYPES.float:case t.TYPES.double:return"number"!=typeof r&&i(typeof r,"not a number"),r;case t.TYPES.string:return"string"==typeof r||r&&r instanceof String||i(typeof r,"not a string"),""+r;case t.TYPES.bytes:return e.isByteBuffer(r)?r:e.wrap(r,"base64");case t.TYPES.enum:var o=this.resolvedType.getChildren(t.Reflect.Enum.Value);for(a=0;a<o.length;a++){if(o[a].name==r)return o[a].id;if(o[a].id==r)return o[a].id}if("proto3"===this.syntax)return("number"!=typeof r||r==r&&r%1!=0)&&i(typeof r,"not an integer"),(r>4294967295||r<0)&&i(typeof r,"not in range for uint32"),r;i(r,"not a valid enum value");case t.TYPES.group:case t.TYPES.message:if(r&&"object"==typeof r||i(typeof r,"object expected"),r instanceof this.resolvedType.clazz)return r;if(r instanceof t.Builder.Message){var s={};for(var a in r)r.hasOwnProperty(a)&&(s[a]=r[a]);r=s}return new this.resolvedType.clazz(r)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+r+" (undefined type "+this.type+")")},u.calculateLength=function(r,n){if(null===n)return 0;var i;switch(this.type){case t.TYPES.int32:return n<0?e.calculateVarint64(n):e.calculateVarint32(n);case t.TYPES.uint32:return e.calculateVarint32(n);case t.TYPES.sint32:return e.calculateVarint32(e.zigZagEncode32(n));case t.TYPES.fixed32:case t.TYPES.sfixed32:case t.TYPES.float:return 4;case t.TYPES.int64:case t.TYPES.uint64:return e.calculateVarint64(n);case t.TYPES.sint64:return e.calculateVarint64(e.zigZagEncode64(n));case t.TYPES.fixed64:case t.TYPES.sfixed64:return 8;case t.TYPES.bool:return 1;case t.TYPES.enum:return e.calculateVarint32(n);case t.TYPES.double:return 8;case t.TYPES.string:return i=e.calculateUTF8Bytes(n),e.calculateVarint32(i)+i;case t.TYPES.bytes:if(n.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+n.remaining()+" bytes remaining");return e.calculateVarint32(n.remaining())+n.remaining();case t.TYPES.message:return i=this.resolvedType.calculate(n),e.calculateVarint32(i)+i;case t.TYPES.group:return(i=this.resolvedType.calculate(n))+e.calculateVarint32(r<<3|t.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+n+" (unknown type)")},u.encodeValue=function(r,n,i){if(null===n)return i;switch(this.type){case t.TYPES.int32:n<0?i.writeVarint64(n):i.writeVarint32(n);break;case t.TYPES.uint32:i.writeVarint32(n);break;case t.TYPES.sint32:i.writeVarint32ZigZag(n);break;case t.TYPES.fixed32:i.writeUint32(n);break;case t.TYPES.sfixed32:i.writeInt32(n);break;case t.TYPES.int64:case t.TYPES.uint64:i.writeVarint64(n);break;case t.TYPES.sint64:i.writeVarint64ZigZag(n);break;case t.TYPES.fixed64:i.writeUint64(n);break;case t.TYPES.sfixed64:i.writeInt64(n);break;case t.TYPES.bool:"string"==typeof n?i.writeVarint32("false"===n.toLowerCase()?0:!!n):i.writeVarint32(n?1:0);break;case t.TYPES.enum:i.writeVarint32(n);break;case t.TYPES.float:i.writeFloat32(n);break;case t.TYPES.double:i.writeFloat64(n);break;case t.TYPES.string:i.writeVString(n);break;case t.TYPES.bytes:if(n.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+n.remaining()+" bytes remaining");var o=n.offset;i.writeVarint32(n.remaining()),i.append(n),n.offset=o;break;case t.TYPES.message:var s=(new e).LE();this.resolvedType.encode(n,s),i.writeVarint32(s.offset),i.append(s.flip());break;case t.TYPES.group:this.resolvedType.encode(n,i),i.writeVarint32(r<<3|t.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+n+" (unknown type)")}return i},u.decode=function(e,r,n){if(r!=this.type.wireType)throw Error("Unexpected wire type for element");var i,o;switch(this.type){case t.TYPES.int32:return 0|e.readVarint32();case t.TYPES.uint32:return e.readVarint32()>>>0;case t.TYPES.sint32:return 0|e.readVarint32ZigZag();case t.TYPES.fixed32:return e.readUint32()>>>0;case t.TYPES.sfixed32:return 0|e.readInt32();case t.TYPES.int64:return e.readVarint64();case t.TYPES.uint64:return e.readVarint64().toUnsigned();case t.TYPES.sint64:return e.readVarint64ZigZag();case t.TYPES.fixed64:return e.readUint64();case t.TYPES.sfixed64:return e.readInt64();case t.TYPES.bool:return!!e.readVarint32();case t.TYPES.enum:return e.readVarint32();case t.TYPES.float:return e.readFloat();case t.TYPES.double:return e.readDouble();case t.TYPES.string:return e.readVString();case t.TYPES.bytes:if(o=e.readVarint32(),e.remaining()<o)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+o+" required but got only "+e.remaining());return(i=e.clone()).limit=i.offset+o,e.offset+=o,i;case t.TYPES.message:return o=e.readVarint32(),this.resolvedType.decode(e,o);case t.TYPES.group:return this.resolvedType.decode(e,-1,n)}throw Error("[INTERNAL] Illegal decode type")},u.valueFromString=function(r){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:case t.TYPES.uint32:case t.TYPES.fixed32:return this.verifyValue(parseInt(r));case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:case t.TYPES.uint64:case t.TYPES.fixed64:return this.verifyValue(r);case t.TYPES.bool:return"true"===r;case t.TYPES.string:return this.verifyValue(r);case t.TYPES.bytes:return e.fromBinary(r)}},u.valueToString=function(e){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===t.TYPES.bytes?e.toString("binary"):e.toString()},r.Element=a;var f=function(e,t,r,n,i,s){o.call(this,e,t,r,n,s),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!i,this._fields=null,this._fieldsById=null,this._fieldsByName=null},l=f.prototype=Object.create(o.prototype);function h(e,r){var n=r.readVarint32(),i=7&n,o=n>>>3;switch(i){case t.WIRE_TYPES.VARINT:do{n=r.readUint8()}while(128==(128&n));break;case t.WIRE_TYPES.BITS64:r.offset+=8;break;case t.WIRE_TYPES.LDELIM:n=r.readVarint32(),r.offset+=n;break;case t.WIRE_TYPES.STARTGROUP:h(o,r);break;case t.WIRE_TYPES.ENDGROUP:if(o===e)return!1;throw Error("Illegal GROUPEND after unknown group: "+o+" ("+e+" expected)");case t.WIRE_TYPES.BITS32:r.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+e+": "+i)}return!0}l.build=function(r){if(this.clazz&&!r)return this.clazz;var n=function(t,r){var n=r.getChildren(t.Reflect.Message.Field),i=r.getChildren(t.Reflect.Message.OneOf),o=function(s,a){t.Builder.Message.call(this);for(var u=0,c=i.length;u<c;++u)this[i[u].name]=null;for(u=0,c=n.length;u<c;++u){var f=n[u];this[f.name]=f.repeated?[]:f.map?new t.Map(f):null,!f.required&&"proto3"!==r.syntax||null===f.defaultValue||(this[f.name]=f.defaultValue)}var l;if(arguments.length>0)if(1!==arguments.length||null===s||"object"!=typeof s||!("function"!=typeof s.encode||s instanceof o)||Array.isArray(s)||s instanceof t.Map||e.isByteBuffer(s)||s instanceof ArrayBuffer||t.Long&&s instanceof t.Long)for(u=0,c=arguments.length;u<c;++u)void 0!==(l=arguments[u])&&this.$set(n[u].name,l);else this.$set(s)},s=o.prototype=Object.create(t.Builder.Message.prototype);s.add=function(e,n,i){var o=r._fieldsByName[e];if(!i){if(!o)throw Error(this+"#"+e+" is undefined");if(!(o instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+o.toString(!0));if(!o.repeated)throw Error(this+"#"+e+" is not a repeated field");n=o.verifyValue(n,!0)}return null===this[e]&&(this[e]=[]),this[e].push(n),this},s.$add=s.add,s.set=function(e,n,i){if(e&&"object"==typeof e){for(var o in i=n,e)e.hasOwnProperty(o)&&void 0!==(n=e[o])&&void 0===r._oneofsByName[o]&&this.$set(o,n,i);return this}var s=r._fieldsByName[e];if(i)this[e]=n;else{if(!s)throw Error(this+"#"+e+" is not a field: undefined");if(!(s instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+s.toString(!0));this[s.name]=n=s.verifyValue(n)}if(s&&s.oneof){var a=this[s.oneof.name];null!==n?(null!==a&&a!==s.name&&(this[a]=null),this[s.oneof.name]=s.name):a===e&&(this[s.oneof.name]=null)}return this},s.$set=s.set,s.get=function(e,n){if(n)return this[e];var i=r._fieldsByName[e];if(!(i&&i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: undefined");if(!(i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+i.toString(!0));return this[i.name]},s.$get=s.get;for(var a=0;a<n.length;a++){var u=n[a];u instanceof t.Reflect.Message.ExtensionField||r.builder.options.populateAccessors&&function(e){var t=e.originalName.replace(/(_[a-zA-Z])/g,(function(e){return e.toUpperCase().replace("_","")}));t=t.substring(0,1).toUpperCase()+t.substring(1);var n=e.originalName.replace(/([A-Z])/g,(function(e){return"_"+e})),i=function(t,r){return this[e.name]=r?t:e.verifyValue(t),this},o=function(){return this[e.name]};null===r.getChild("set"+t)&&(s["set"+t]=i),null===r.getChild("set_"+n)&&(s["set_"+n]=i),null===r.getChild("get"+t)&&(s["get"+t]=o),null===r.getChild("get_"+n)&&(s["get_"+n]=o)}(u)}function c(r,n,i,o){if(null===r||"object"!=typeof r){if(o&&o instanceof t.Reflect.Enum){var s=t.Reflect.Enum.getName(o.object,r);if(null!==s)return s}return r}if(e.isByteBuffer(r))return n?r.toBase64():r.toBuffer();if(t.Long.isLong(r))return i?r.toString():t.Long.fromValue(r);var a;if(Array.isArray(r))return a=[],r.forEach((function(e,t){a[t]=c(e,n,i,o)})),a;if(a={},r instanceof t.Map){for(var u=r.entries(),f=u.next();!f.done;f=u.next())a[r.keyElem.valueToString(f.value[0])]=c(f.value[1],n,i,r.valueElem.resolvedType);return a}var l=r.$type,h=void 0;for(var p in r)r.hasOwnProperty(p)&&(l&&(h=l.getChild(p))?a[p]=c(r[p],n,i,h.resolvedType):a[p]=c(r[p],n,i));return a}return s.encode=function(t,n){"boolean"==typeof t&&(n=t,t=void 0);var i=!1;t||(t=new e,i=!0);var o=t.littleEndian;try{return r.encode(this,t.LE(),n),(i?t.flip():t).LE(o)}catch(e){throw t.LE(o),e}},o.encode=function(e,t,r){return new o(e).encode(t,r)},s.calculate=function(){return r.calculate(this)},s.encodeDelimited=function(t,n){var i=!1;t||(t=new e,i=!0);var o=(new e).LE();return r.encode(this,o,n).flip(),t.writeVarint32(o.remaining()),t.append(o),i?t.flip():t},s.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},s.toArrayBuffer=s.encodeAB,s.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},s.toBuffer=s.encodeNB,s.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},s.toBase64=s.encode64,s.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},s.toHex=s.encodeHex,s.toRaw=function(e,t){return c(this,!!e,!!t,this.$type)},s.encodeJSON=function(){return JSON.stringify(c(this,!0,!0,this.$type))},o.decode=function(t,n,i){"string"==typeof n&&(i=n,n=-1),"string"==typeof t?t=e.wrap(t,i||"base64"):e.isByteBuffer(t)||(t=e.wrap(t));var o=t.littleEndian;try{var s=r.decode(t.LE(),n);return t.LE(o),s}catch(e){throw t.LE(o),e}},o.decodeDelimited=function(t,n){if("string"==typeof t?t=e.wrap(t,n||"base64"):e.isByteBuffer(t)||(t=e.wrap(t)),t.remaining()<1)return null;var i=t.offset,o=t.readVarint32();if(t.remaining()<o)return t.offset=i,null;try{var s=r.decode(t.slice(t.offset,t.offset+o).LE());return t.offset+=o,s}catch(e){throw t.offset+=o,e}},o.decode64=function(e){return o.decode(e,"base64")},o.decodeHex=function(e){return o.decode(e,"hex")},o.decodeJSON=function(e){return new o(JSON.parse(e))},s.toString=function(){return r.toString()},Object.defineProperty&&(Object.defineProperty(o,"$options",{value:r.buildOpt()}),Object.defineProperty(s,"$options",{value:o.$options}),Object.defineProperty(o,"$type",{value:r}),Object.defineProperty(s,"$type",{value:r})),o}(t,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var i,o=0,s=this.children.length;o<s;o++)if((i=this.children[o])instanceof g||i instanceof f||i instanceof b){if(n.hasOwnProperty(i.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+i.toString(!0)+" cannot override static property '"+i.name+"'");n[i.name]=i.build()}else if(i instanceof f.Field)i.build(),this._fields.push(i),this._fieldsById[i.id]=i,this._fieldsByName[i.name]=i;else if(i instanceof f.OneOf)this._oneofsByName[i.name]=i;else if(!(i instanceof f.OneOf||i instanceof v))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[o].toString(!0));return this.clazz=n},l.encode=function(e,t,r){for(var n,i,o=null,s=0,a=this._fields.length;s<a;++s)i=e[(n=this._fields[s]).name],n.required&&null===i?null===o&&(o=n):n.encode(r?i:n.verifyValue(i),t,e);if(null!==o){var u=Error("Missing at least one required field for "+this.toString(!0)+": "+o);throw u.encoded=t,u}return t},l.calculate=function(e){for(var t,r,n=0,i=0,o=this._fields.length;i<o;++i){if(r=e[(t=this._fields[i]).name],t.required&&null===r)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);n+=t.calculate(r,e)}return n},l.decode=function(e,r,n){"number"!=typeof r&&(r=-1);for(var i,o,s,a,u=e.offset,c=new this.clazz;e.offset<u+r||-1===r&&e.remaining()>0;){if(s=(i=e.readVarint32())>>>3,(o=7&i)===t.WIRE_TYPES.ENDGROUP){if(s!==n)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+s+" ("+(n?n+" expected":"not a group")+")");break}if(a=this._fieldsById[s]){if(a.repeated&&!a.options.packed)c[a.name].push(a.decode(o,e));else if(a.map){var f=a.decode(o,e);c[a.name].set(f[0],f[1])}else if(c[a.name]=a.decode(o,e),a.oneof){var l=c[a.oneof.name];null!==l&&l!==a.name&&(c[l]=null),c[a.oneof.name]=a.name}}else switch(o){case t.WIRE_TYPES.VARINT:e.readVarint32();break;case t.WIRE_TYPES.BITS32:e.offset+=4;break;case t.WIRE_TYPES.BITS64:e.offset+=8;break;case t.WIRE_TYPES.LDELIM:var p=e.readVarint32();e.offset+=p;break;case t.WIRE_TYPES.STARTGROUP:for(;h(s,e););break;default:throw Error("Illegal wire type for unknown field "+s+" in "+this.toString(!0)+"#decode: "+o)}}for(var d=0,m=this._fields.length;d<m;++d)if(null===c[(a=this._fields[d]).name])if("proto3"===this.syntax)c[a.name]=a.defaultValue;else{if(a.required){var g=Error("Missing at least one required field for "+this.toString(!0)+": "+a.name);throw g.decoded=c,g}t.populateDefaults&&null!==a.defaultValue&&(c[a.name]=a.defaultValue)}return c},r.Message=f;var p=function(e,r,i,o,s,a,u,c,l,h){n.call(this,e,r,a),this.className="Message.Field",this.required="required"===i,this.repeated="repeated"===i,this.map="map"===i,this.keyType=o||null,this.type=s,this.resolvedType=null,this.id=u,this.options=c||{},this.defaultValue=null,this.oneof=l||null,this.syntax=h||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof f.ExtensionField||(this.name=t.Util.toCamelCase(this.name))},d=p.prototype=Object.create(n.prototype);d.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax,this.name)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=a.defaultFieldValue(this.type)},d.verifyValue=function(e,r){r=r||!1;var n,i=this;function o(e,t){throw Error("Illegal value for "+i.toString(!0)+" of type "+i.type.name+": "+e+" ("+t+")")}if(null===e)return this.required&&o(typeof e,"required"),"proto3"===this.syntax&&this.type!==t.TYPES.message&&o(typeof e,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!r){Array.isArray(e)||(e=[e]);var s=[];for(n=0;n<e.length;n++)s.push(this.element.verifyValue(e[n]));return s}return this.map&&!r?e instanceof t.Map?e:(e instanceof Object||o(typeof e,"expected ProtoBuf.Map or raw object for map field"),new t.Map(this,e)):(!this.repeated&&Array.isArray(e)&&o(typeof e,"no array expected"),this.element.verifyValue(e))},d.hasWirePresence=function(e,r){if("proto3"!==this.syntax)return null!==e;if(this.oneof&&r[this.oneof.name]===this.name)return!0;switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:case t.TYPES.uint32:case t.TYPES.fixed32:return 0!==e;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:case t.TYPES.uint64:case t.TYPES.fixed64:return 0!==e.low||0!==e.high;case t.TYPES.bool:return e;case t.TYPES.float:case t.TYPES.double:return 0!==e;case t.TYPES.string:return e.length>0;case t.TYPES.bytes:return e.remaining()>0;case t.TYPES.enum:return 0!==e;case t.TYPES.message:return null!==e;default:return!0}},d.encode=function(r,n,i){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===r||this.repeated&&0==r.length)return n;try{var o;if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){n.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),n.ensureCapacity(n.offset+=1);var s=n.offset;for(o=0;o<r.length;o++)this.element.encodeValue(this.id,r[o],n);var a=n.offset-s,u=e.calculateVarint32(a);if(u>1){var c=n.slice(s,n.offset);s+=u-1,n.offset=s,n.append(c)}n.writeVarint32(a,s-u)}else for(o=0;o<r.length;o++)n.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,r[o],n);else this.map?r.forEach((function(r,i,o){var s=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,i)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,r);n.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),n.writeVarint32(s),n.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,i,n),n.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,r,n)}),this):this.hasWirePresence(r,i)&&(n.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,r,n))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+r+" ("+e+")")}return n},d.calculate=function(r,n){if(r=this.verifyValue(r),null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===r||this.repeated&&0==r.length)return 0;var i=0;try{var o,s;if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(i+=e.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),s=0,o=0;o<r.length;o++)s+=this.element.calculateLength(this.id,r[o]);i+=e.calculateVarint32(s),i+=s}else for(o=0;o<r.length;o++)i+=e.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,r[o]);else this.map?r.forEach((function(r,n,o){var s=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,n)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,r);i+=e.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),i+=e.calculateVarint32(s),i+=s}),this):this.hasWirePresence(r,n)&&(i+=e.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,r))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+r+" ("+e+")")}return i},d.decode=function(e,r,n){var i,o;if(!(!this.map&&e==this.type.wireType||!n&&this.repeated&&this.options.packed&&e==t.WIRE_TYPES.LDELIM||this.map&&e==t.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+e+" ("+this.type.wireType+" expected)");if(e==t.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!n){o=r.readVarint32(),o=r.offset+o;for(var s=[];r.offset<o;)s.push(this.decode(this.type.wireType,r,!0));return s}if(this.map){var u=a.defaultFieldValue(this.keyType);if(i=a.defaultFieldValue(this.type),o=r.readVarint32(),r.remaining()<o)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+o+" required but got only "+r.remaining());var c=r.clone();for(c.limit=c.offset+o,r.offset+=o;c.remaining()>0;){var f=c.readVarint32();e=7&f;var l=f>>>3;if(1===l)u=this.keyElement.decode(c,e,l);else{if(2!==l)throw Error("Unexpected tag in map field key/value submessage");i=this.element.decode(c,e,l)}}return[u,i]}return this.element.decode(r,e,this.id)},r.Message.Field=p;var m=function(e,t,r,n,i,o,s){p.call(this,e,t,r,null,n,i,o,s),this.extension};m.prototype=Object.create(p.prototype),r.Message.ExtensionField=m;r.Message.OneOf=function(e,t,r){n.call(this,e,t,r),this.fields=[]};var g=function(e,t,r,n,i){o.call(this,e,t,r,n,i),this.className="Enum",this.object=null};g.getName=function(e,t){for(var r,n=Object.keys(e),i=0;i<n.length;++i)if(e[r=n[i]]===t)return r;return null},(g.prototype=Object.create(o.prototype)).build=function(e){if(this.object&&!e)return this.object;for(var r=new t.Builder.Enum,n=this.getChildren(g.Value),i=0,o=n.length;i<o;++i)r[n[i].name]=n[i].id;return Object.defineProperty&&Object.defineProperty(r,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=r},r.Enum=g;var y=function(e,t,r,i){n.call(this,e,t,r),this.className="Enum.Value",this.id=i};y.prototype=Object.create(n.prototype),r.Enum.Value=y;var v=function(e,t,r,i){n.call(this,e,t,r),this.field=i};v.prototype=Object.create(n.prototype),r.Extension=v;var b=function(e,t,r,n){o.call(this,e,t,r,n),this.className="Service",this.clazz=null};(b.prototype=Object.create(o.prototype)).build=function(r){return this.clazz&&!r?this.clazz:this.clazz=function(t,r){for(var n=function(e){t.Builder.Service.call(this),this.rpcImpl=e||function(e,t,r){setTimeout(r.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},i=n.prototype=Object.create(t.Builder.Service.prototype),o=r.getChildren(t.Reflect.Service.RPCMethod),s=0;s<o.length;s++)!function(t){i[t.name]=function(n,i){try{try{n=t.resolvedRequestType.clazz.decode(e.wrap(n))}catch(e){if(!(e instanceof TypeError))throw e}if(null===n||"object"!=typeof n)throw Error("Illegal arguments");n instanceof t.resolvedRequestType.clazz||(n=new t.resolvedRequestType.clazz(n)),this.rpcImpl(t.fqn(),n,(function(e,n){if(e)i(e);else{null===n&&(n="");try{n=t.resolvedResponseType.clazz.decode(n)}catch(e){}n&&n instanceof t.resolvedResponseType.clazz?i(null,n):i(Error("Illegal response type received in service method "+r.name+"#"+t.name))}}))}catch(e){setTimeout(i.bind(this,e),0)}},n[t.name]=function(e,r,i){new n(e)[t.name](r,i)},Object.defineProperty&&(Object.defineProperty(n[t.name],"$options",{value:t.buildOpt()}),Object.defineProperty(i[t.name],"$options",{value:n[t.name].$options}))}(o[s]);return Object.defineProperty&&(Object.defineProperty(n,"$options",{value:r.buildOpt()}),Object.defineProperty(i,"$options",{value:n.$options}),Object.defineProperty(n,"$type",{value:r}),Object.defineProperty(i,"$type",{value:r})),n}(t,this)},r.Service=b;var w=function(e,t,r,i){n.call(this,e,t,r),this.className="Service.Method",this.options=i||{}};(w.prototype=Object.create(n.prototype)).buildOpt=s.buildOpt,r.Service.Method=w;var _=function(e,t,r,n,i,o,s,a){w.call(this,e,t,r,a),this.className="Service.RPCMethod",this.requestName=n,this.responseName=i,this.requestStream=o,this.responseStream=s,this.resolvedRequestType=null,this.resolvedResponseType=null};return _.prototype=Object.create(w.prototype),r.Service.RPCMethod=_,r}(i),i.Builder=function(e,t,r){var n=function(e){this.ns=new r.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},i=n.prototype;return n.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},n.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},n.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},n.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},n.isExtend=function(e){return"string"==typeof e.ref},i.reset=function(){return this.ptr=this.ns,this},i.define=function(e){if("string"!=typeof e||!t.TYPEREF.test(e))throw Error("illegal namespace: "+e);return e.split(".").forEach((function(e){var t=this.ptr.getChild(e);null===t&&this.ptr.addChild(t=new r.Namespace(this,this.ptr,e)),this.ptr=t}),this),this},i.create=function(t){if(!t)return this;if(Array.isArray(t)){if(0===t.length)return this;t=t.slice()}else t=[t];for(var i=[t];i.length>0;){if(t=i.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var o=t.shift();if(n.isMessage(o)){var s=new r.Message(this,this.ptr,o.name,o.options,o.isGroup,o.syntax),a={};o.oneofs&&Object.keys(o.oneofs).forEach((function(e){s.addChild(a[e]=new r.Message.OneOf(this,s,e))}),this),o.fields&&o.fields.forEach((function(e){if(null!==s.getChild(0|e.id))throw Error("duplicate or invalid field id in "+s.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+s.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+s.name+"#"+e.name+": "+e.oneof);e=new r.Message.Field(this,s,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,o.syntax),t&&t.fields.push(e),s.addChild(e)}),this);var u=[];if(o.enums&&o.enums.forEach((function(e){u.push(e)})),o.messages&&o.messages.forEach((function(e){u.push(e)})),o.services&&o.services.forEach((function(e){u.push(e)})),o.extensions&&("number"==typeof o.extensions[0]?s.extensions=[o.extensions]:s.extensions=o.extensions),this.ptr.addChild(s),u.length>0){i.push(t),t=u,u=null,this.ptr=s,s=null;continue}u=null}else if(n.isEnum(o))s=new r.Enum(this,this.ptr,o.name,o.options,o.syntax),o.values.forEach((function(e){s.addChild(new r.Enum.Value(this,s,e.name,e.id))}),this),this.ptr.addChild(s);else if(n.isService(o))s=new r.Service(this,this.ptr,o.name,o.options),Object.keys(o.rpc).forEach((function(e){var t=o.rpc[e];s.addChild(new r.Service.RPCMethod(this,s,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))}),this),this.ptr.addChild(s);else{if(!n.isExtend(o))throw Error("not a valid definition: "+JSON.stringify(o));if(s=this.ptr.resolve(o.ref,!0))o.fields.forEach((function(t){if(null!==s.getChild(0|t.id))throw Error("duplicate extended field id in "+s.name+": "+t.id);if(s.extensions){var n=!1;if(s.extensions.forEach((function(e){t.id>=e[0]&&t.id<=e[1]&&(n=!0)})),!n)throw Error("illegal extended field id in "+s.name+": "+t.id+" (not within valid ranges)")}var i=t.name;this.options.convertFieldsToCamelCase&&(i=e.Util.toCamelCase(i));var o=new r.Message.ExtensionField(this,s,t.rule,t.type,this.ptr.fqn()+"."+i,t.id,t.options),a=new r.Extension(this,this.ptr,t.name,o);o.extension=a,this.ptr.addChild(a),s.addChild(o)}),this);else if(!/\.?google\.protobuf\./.test(o.ref))throw Error("extended message "+o.ref+" is not defined")}o=null,s=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},i.import=function(t,r){var n="/";if("string"==typeof r){if(e.Util.IS_NODE&&(r=y.resolve(r)),!0===this.files[r])return this.reset();this.files[r]=!0}else if("object"==typeof r){var i,o=r.root;if(e.Util.IS_NODE&&(o=y.resolve(o)),(o.indexOf("\\")>=0||r.file.indexOf("\\")>=0)&&(n="\\"),i=e.Util.IS_NODE?y.join(o,r.file):o+n+r.file,!0===this.files[i])return this.reset();this.files[i]=!0}if(t.imports&&t.imports.length>0){var s,a=!1;"object"==typeof r?(this.importRoot=r.root,a=!0,s=this.importRoot,r=r.file,(s.indexOf("\\")>=0||r.indexOf("\\")>=0)&&(n="\\")):"string"==typeof r?this.importRoot?s=this.importRoot:r.indexOf("/")>=0?""===(s=r.replace(/\/[^\/]*$/,""))&&(s="/"):r.indexOf("\\")>=0?(s=r.replace(/\\[^\\]*$/,""),n="\\"):s=".":s=null;for(var u=0;u<t.imports.length;u++)if("string"==typeof t.imports[u]){if(!s)throw Error("cannot determine import root");var c=t.imports[u];if("google/protobuf/descriptor.proto"===c)continue;if(c=e.Util.IS_NODE?y.join(s,c):s+n+c,!0===this.files[c])continue;/\.proto$/i.test(c)&&!e.DotProto&&(c=c.replace(/\.proto$/,".json"));var f=e.Util.fetch(c);if(null===f)throw Error("failed to import '"+c+"' in '"+r+"': file not found");/\.json$/i.test(c)?this.import(JSON.parse(f+""),c):this.import(e.DotProto.Parser.parse(f),c)}else r?/\.(\w+)$/.test(r)?this.import(t.imports[u],r.replace(/^(.+)\.(\w+)$/,(function(e,t,r){return t+"_import"+u+"."+r}))):this.import(t.imports[u],r+"_import"+u):this.import(t.imports[u]);a&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&function e(t){t.messages&&t.messages.forEach((function(r){r.syntax=t.syntax,e(r)})),t.enums&&t.enums.forEach((function(e){e.syntax=t.syntax}))}(t);var l=this.ptr;return t.options&&Object.keys(t.options).forEach((function(e){l.options[e]=t.options[e]})),t.messages&&(this.create(t.messages),this.ptr=l),t.enums&&(this.create(t.enums),this.ptr=l),t.services&&(this.create(t.services),this.ptr=l),t.extends&&this.create(t.extends),this.reset()},i.resolveAll=function(){var n;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof r.Namespace)this.ptr.children.forEach((function(e){this.ptr=e,this.resolveAll()}),this);else if(this.ptr instanceof r.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=e.TYPES[this.ptr.type];else{if(!t.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(n=(this.ptr instanceof r.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0)))throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(this.ptr.resolvedType=n,n instanceof r.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==n.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(n instanceof r.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=n.isGroup?e.TYPES.group:e.TYPES.message}}if(this.ptr.map){if(!t.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=e.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==e.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof e.Reflect.Service.Method){if(!(this.ptr instanceof e.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((n=this.ptr.parent.resolve(this.ptr.requestName,!0))&&n instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=n,!((n=this.ptr.parent.resolve(this.ptr.responseName,!0))&&n instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=n}else if(!(this.ptr instanceof e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension||this.ptr instanceof e.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},i.build=function(e){if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),null===this.result&&(this.result=this.ns.build()),!e)return this.result;for(var t="string"==typeof e?e.split("."):e,r=this.result,n=0;n<t.length;n++){if(!r[t[n]]){r=null;break}r=r[t[n]]}return r},i.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},i.toString=function(){return"Builder"},n.Message=function(){},n.Enum=function(){},n.Service=function(){},n}(i,i.Lang,i.Reflect),i.Map=function(e,t){var r=function(e,r){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new t.Element(e.keyType,null,!0,e.syntax),this.valueElem=new t.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),r)for(var n=Object.keys(r),i=0;i<n.length;i++){var o=this.keyElem.valueFromString(n[i]),s=this.valueElem.verifyValue(r[n[i]]);this.map[this.keyElem.valueToString(o)]={key:o,value:s}}},n=r.prototype;function i(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return n.clear=function(){this.map={}},n.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),r=t in this.map;return delete this.map[t],r},n.entries=function(){for(var e,t=[],r=Object.keys(this.map),n=0;n<r.length;n++)t.push([(e=this.map[r[n]]).key,e.value]);return i(t)},n.keys=function(){for(var e=[],t=Object.keys(this.map),r=0;r<t.length;r++)e.push(this.map[t[r]].key);return i(e)},n.values=function(){for(var e=[],t=Object.keys(this.map),r=0;r<t.length;r++)e.push(this.map[t[r]].value);return i(e)},n.forEach=function(e,t){for(var r,n=Object.keys(this.map),i=0;i<n.length;i++)e.call(t,(r=this.map[n[i]]).value,r.key,this)},n.set=function(e,t){var r=this.keyElem.verifyValue(e),n=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(r)]={key:r,value:n},this},n.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},n.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},r}(0,i.Reflect),i.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=i.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=i.populateAccessors),new i.Builder(e)},i.loadJson=function(e,t,r){return("string"==typeof t||t&&"string"==typeof t.file&&"string"==typeof t.root)&&(r=t,t=null),t&&"object"==typeof t||(t=i.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),t.import(e,r),t.resolveAll(),t},i.loadJsonFile=function(e,t,r){if(t&&"object"==typeof t?(r=t,t=null):t&&"function"==typeof t||(t=null),t)return i.Util.fetch("string"==typeof e?e:e.root+"/"+e.file,(function(n){if(null!==n)try{t(null,i.loadJson(JSON.parse(n),r,e))}catch(e){t(e)}else t(Error("Failed to fetch file"))}));var n=i.Util.fetch("object"==typeof e?e.root+"/"+e.file:e);return null===n?null:i.loadJson(JSON.parse(n),r,e)},i}))})).newBuilder({}).import({package:"push_server.messages2",syntax:"proto2",options:{objc_class_prefix:"AVIM"},messages:[{name:"JsonObjectMessage",syntax:"proto2",fields:[{rule:"required",type:"string",name:"data",id:1}]},{name:"UnreadTuple",syntax:"proto2",fields:[{rule:"required",type:"string",name:"cid",id:1},{rule:"required",type:"int32",name:"unread",id:2},{rule:"optional",type:"string",name:"mid",id:3},{rule:"optional",type:"int64",name:"timestamp",id:4},{rule:"optional",type:"string",name:"from",id:5},{rule:"optional",type:"string",name:"data",id:6},{rule:"optional",type:"int64",name:"patchTimestamp",id:7},{rule:"optional",type:"bool",name:"mentioned",id:8},{rule:"optional",type:"bytes",name:"binaryMsg",id:9},{rule:"optional",type:"int32",name:"convType",id:10}]},{name:"LogItem",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"from",id:1},{rule:"optional",type:"string",name:"data",id:2},{rule:"optional",type:"int64",name:"timestamp",id:3},{rule:"optional",type:"string",name:"msgId",id:4},{rule:"optional",type:"int64",name:"ackAt",id:5},{rule:"optional",type:"int64",name:"readAt",id:6},{rule:"optional",type:"int64",name:"patchTimestamp",id:7},{rule:"optional",type:"bool",name:"mentionAll",id:8},{rule:"repeated",type:"string",name:"mentionPids",id:9},{rule:"optional",type:"bool",name:"bin",id:10},{rule:"optional",type:"int32",name:"convType",id:11}]},{name:"ConvMemberInfo",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"pid",id:1},{rule:"optional",type:"string",name:"role",id:2},{rule:"optional",type:"string",name:"infoId",id:3}]},{name:"DataCommand",syntax:"proto2",fields:[{rule:"repeated",type:"string",name:"ids",id:1},{rule:"repeated",type:"JsonObjectMessage",name:"msg",id:2},{rule:"optional",type:"bool",name:"offline",id:3}]},{name:"SessionCommand",syntax:"proto2",fields:[{rule:"optional",type:"int64",name:"t",id:1},{rule:"optional",type:"string",name:"n",id:2},{rule:"optional",type:"string",name:"s",id:3},{rule:"optional",type:"string",name:"ua",id:4},{rule:"optional",type:"bool",name:"r",id:5},{rule:"optional",type:"string",name:"tag",id:6},{rule:"optional",type:"string",name:"deviceId",id:7},{rule:"repeated",type:"string",name:"sessionPeerIds",id:8},{rule:"repeated",type:"string",name:"onlineSessionPeerIds",id:9},{rule:"optional",type:"string",name:"st",id:10},{rule:"optional",type:"int32",name:"stTtl",id:11},{rule:"optional",type:"int32",name:"code",id:12},{rule:"optional",type:"string",name:"reason",id:13},{rule:"optional",type:"string",name:"deviceToken",id:14},{rule:"optional",type:"bool",name:"sp",id:15},{rule:"optional",type:"string",name:"detail",id:16},{rule:"optional",type:"int64",name:"lastUnreadNotifTime",id:17},{rule:"optional",type:"int64",name:"lastPatchTime",id:18},{rule:"optional",type:"int64",name:"configBitmap",id:19}]},{name:"ErrorCommand",syntax:"proto2",fields:[{rule:"required",type:"int32",name:"code",id:1},{rule:"required",type:"string",name:"reason",id:2},{rule:"optional",type:"int32",name:"appCode",id:3},{rule:"optional",type:"string",name:"detail",id:4},{rule:"repeated",type:"string",name:"pids",id:5},{rule:"optional",type:"string",name:"appMsg",id:6}]},{name:"DirectCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"msg",id:1},{rule:"optional",type:"string",name:"uid",id:2},{rule:"optional",type:"string",name:"fromPeerId",id:3},{rule:"optional",type:"int64",name:"timestamp",id:4},{rule:"optional",type:"bool",name:"offline",id:5},{rule:"optional",type:"bool",name:"hasMore",id:6},{rule:"repeated",type:"string",name:"toPeerIds",id:7},{rule:"optional",type:"bool",name:"r",id:10},{rule:"optional",type:"string",name:"cid",id:11},{rule:"optional",type:"string",name:"id",id:12},{rule:"optional",type:"bool",name:"transient",id:13},{rule:"optional",type:"string",name:"dt",id:14},{rule:"optional",type:"string",name:"roomId",id:15},{rule:"optional",type:"string",name:"pushData",id:16},{rule:"optional",type:"bool",name:"will",id:17},{rule:"optional",type:"int64",name:"patchTimestamp",id:18},{rule:"optional",type:"bytes",name:"binaryMsg",id:19},{rule:"repeated",type:"string",name:"mentionPids",id:20},{rule:"optional",type:"bool",name:"mentionAll",id:21},{rule:"optional",type:"int32",name:"convType",id:22}]},{name:"AckCommand",syntax:"proto2",fields:[{rule:"optional",type:"int32",name:"code",id:1},{rule:"optional",type:"string",name:"reason",id:2},{rule:"optional",type:"string",name:"mid",id:3},{rule:"optional",type:"string",name:"cid",id:4},{rule:"optional",type:"int64",name:"t",id:5},{rule:"optional",type:"string",name:"uid",id:6},{rule:"optional",type:"int64",name:"fromts",id:7},{rule:"optional",type:"int64",name:"tots",id:8},{rule:"optional",type:"string",name:"type",id:9},{rule:"repeated",type:"string",name:"ids",id:10},{rule:"optional",type:"int32",name:"appCode",id:11},{rule:"optional",type:"string",name:"appMsg",id:12}]},{name:"UnreadCommand",syntax:"proto2",fields:[{rule:"repeated",type:"UnreadTuple",name:"convs",id:1},{rule:"optional",type:"int64",name:"notifTime",id:2}]},{name:"ConvCommand",syntax:"proto2",fields:[{rule:"repeated",type:"string",name:"m",id:1},{rule:"optional",type:"bool",name:"transient",id:2},{rule:"optional",type:"bool",name:"unique",id:3},{rule:"optional",type:"string",name:"cid",id:4},{rule:"optional",type:"string",name:"cdate",id:5},{rule:"optional",type:"string",name:"initBy",id:6},{rule:"optional",type:"string",name:"sort",id:7},{rule:"optional",type:"int32",name:"limit",id:8},{rule:"optional",type:"int32",name:"skip",id:9},{rule:"optional",type:"int32",name:"flag",id:10},{rule:"optional",type:"int32",name:"count",id:11},{rule:"optional",type:"string",name:"udate",id:12},{rule:"optional",type:"int64",name:"t",id:13},{rule:"optional",type:"string",name:"n",id:14},{rule:"optional",type:"string",name:"s",id:15},{rule:"optional",type:"bool",name:"statusSub",id:16},{rule:"optional",type:"bool",name:"statusPub",id:17},{rule:"optional",type:"int32",name:"statusTTL",id:18},{rule:"optional",type:"string",name:"uniqueId",id:19},{rule:"optional",type:"string",name:"targetClientId",id:20},{rule:"optional",type:"int64",name:"maxReadTimestamp",id:21},{rule:"optional",type:"int64",name:"maxAckTimestamp",id:22},{rule:"optional",type:"bool",name:"queryAllMembers",id:23},{rule:"repeated",type:"MaxReadTuple",name:"maxReadTuples",id:24},{rule:"repeated",type:"string",name:"cids",id:25},{rule:"optional",type:"ConvMemberInfo",name:"info",id:26},{rule:"optional",type:"bool",name:"tempConv",id:27},{rule:"optional",type:"int32",name:"tempConvTTL",id:28},{rule:"repeated",type:"string",name:"tempConvIds",id:29},{rule:"repeated",type:"string",name:"allowedPids",id:30},{rule:"repeated",type:"ErrorCommand",name:"failedPids",id:31},{rule:"optional",type:"string",name:"next",id:40},{rule:"optional",type:"JsonObjectMessage",name:"results",id:100},{rule:"optional",type:"JsonObjectMessage",name:"where",id:101},{rule:"optional",type:"JsonObjectMessage",name:"attr",id:103},{rule:"optional",type:"JsonObjectMessage",name:"attrModified",id:104}]},{name:"RoomCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"roomId",id:1},{rule:"optional",type:"string",name:"s",id:2},{rule:"optional",type:"int64",name:"t",id:3},{rule:"optional",type:"string",name:"n",id:4},{rule:"optional",type:"bool",name:"transient",id:5},{rule:"repeated",type:"string",name:"roomPeerIds",id:6},{rule:"optional",type:"string",name:"byPeerId",id:7}]},{name:"LogsCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"optional",type:"int32",name:"l",id:2},{rule:"optional",type:"int32",name:"limit",id:3},{rule:"optional",type:"int64",name:"t",id:4},{rule:"optional",type:"int64",name:"tt",id:5},{rule:"optional",type:"string",name:"tmid",id:6},{rule:"optional",type:"string",name:"mid",id:7},{rule:"optional",type:"string",name:"checksum",id:8},{rule:"optional",type:"bool",name:"stored",id:9},{rule:"optional",type:"QueryDirection",name:"direction",id:10,options:{default:"OLD"}},{rule:"optional",type:"bool",name:"tIncluded",id:11},{rule:"optional",type:"bool",name:"ttIncluded",id:12},{rule:"optional",type:"int32",name:"lctype",id:13},{rule:"repeated",type:"LogItem",name:"logs",id:105}],enums:[{name:"QueryDirection",syntax:"proto2",values:[{name:"OLD",id:1},{name:"NEW",id:2}]}]},{name:"RcpCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"id",id:1},{rule:"optional",type:"string",name:"cid",id:2},{rule:"optional",type:"int64",name:"t",id:3},{rule:"optional",type:"bool",name:"read",id:4},{rule:"optional",type:"string",name:"from",id:5}]},{name:"ReadTuple",syntax:"proto2",fields:[{rule:"required",type:"string",name:"cid",id:1},{rule:"optional",type:"int64",name:"timestamp",id:2},{rule:"optional",type:"string",name:"mid",id:3}]},{name:"MaxReadTuple",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"pid",id:1},{rule:"optional",type:"int64",name:"maxAckTimestamp",id:2},{rule:"optional",type:"int64",name:"maxReadTimestamp",id:3}]},{name:"ReadCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"repeated",type:"string",name:"cids",id:2},{rule:"repeated",type:"ReadTuple",name:"convs",id:3}]},{name:"PresenceCommand",syntax:"proto2",fields:[{rule:"optional",type:"StatusType",name:"status",id:1},{rule:"repeated",type:"string",name:"sessionPeerIds",id:2},{rule:"optional",type:"string",name:"cid",id:3}]},{name:"ReportCommand",syntax:"proto2",fields:[{rule:"optional",type:"bool",name:"initiative",id:1},{rule:"optional",type:"string",name:"type",id:2},{rule:"optional",type:"string",name:"data",id:3}]},{name:"PatchItem",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"optional",type:"string",name:"mid",id:2},{rule:"optional",type:"int64",name:"timestamp",id:3},{rule:"optional",type:"bool",name:"recall",id:4},{rule:"optional",type:"string",name:"data",id:5},{rule:"optional",type:"int64",name:"patchTimestamp",id:6},{rule:"optional",type:"string",name:"from",id:7},{rule:"optional",type:"bytes",name:"binaryMsg",id:8},{rule:"optional",type:"bool",name:"mentionAll",id:9},{rule:"repeated",type:"string",name:"mentionPids",id:10},{rule:"optional",type:"int64",name:"patchCode",id:11},{rule:"optional",type:"string",name:"patchReason",id:12}]},{name:"PatchCommand",syntax:"proto2",fields:[{rule:"repeated",type:"PatchItem",name:"patches",id:1},{rule:"optional",type:"int64",name:"lastPatchTime",id:2}]},{name:"PubsubCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"repeated",type:"string",name:"cids",id:2},{rule:"optional",type:"string",name:"topic",id:3},{rule:"optional",type:"string",name:"subtopic",id:4},{rule:"repeated",type:"string",name:"topics",id:5},{rule:"repeated",type:"string",name:"subtopics",id:6},{rule:"optional",type:"JsonObjectMessage",name:"results",id:7}]},{name:"BlacklistCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"srcCid",id:1},{rule:"repeated",type:"string",name:"toPids",id:2},{rule:"optional",type:"string",name:"srcPid",id:3},{rule:"repeated",type:"string",name:"toCids",id:4},{rule:"optional",type:"int32",name:"limit",id:5},{rule:"optional",type:"string",name:"next",id:6},{rule:"repeated",type:"string",name:"blockedPids",id:8},{rule:"repeated",type:"string",name:"blockedCids",id:9},{rule:"repeated",type:"string",name:"allowedPids",id:10},{rule:"repeated",type:"ErrorCommand",name:"failedPids",id:11},{rule:"optional",type:"int64",name:"t",id:12},{rule:"optional",type:"string",name:"n",id:13},{rule:"optional",type:"string",name:"s",id:14}]},{name:"GenericCommand",syntax:"proto2",fields:[{rule:"optional",type:"CommandType",name:"cmd",id:1},{rule:"optional",type:"OpType",name:"op",id:2},{rule:"optional",type:"string",name:"appId",id:3},{rule:"optional",type:"string",name:"peerId",id:4},{rule:"optional",type:"int32",name:"i",id:5},{rule:"optional",type:"string",name:"installationId",id:6},{rule:"optional",type:"int32",name:"priority",id:7},{rule:"optional",type:"int32",name:"service",id:8},{rule:"optional",type:"int64",name:"serverTs",id:9},{rule:"optional",type:"int64",name:"clientTs",id:10},{rule:"optional",type:"int32",name:"notificationType",id:11},{rule:"optional",type:"DataCommand",name:"dataMessage",id:101},{rule:"optional",type:"SessionCommand",name:"sessionMessage",id:102},{rule:"optional",type:"ErrorCommand",name:"errorMessage",id:103},{rule:"optional",type:"DirectCommand",name:"directMessage",id:104},{rule:"optional",type:"AckCommand",name:"ackMessage",id:105},{rule:"optional",type:"UnreadCommand",name:"unreadMessage",id:106},{rule:"optional",type:"ReadCommand",name:"readMessage",id:107},{rule:"optional",type:"RcpCommand",name:"rcpMessage",id:108},{rule:"optional",type:"LogsCommand",name:"logsMessage",id:109},{rule:"optional",type:"ConvCommand",name:"convMessage",id:110},{rule:"optional",type:"RoomCommand",name:"roomMessage",id:111},{rule:"optional",type:"PresenceCommand",name:"presenceMessage",id:112},{rule:"optional",type:"ReportCommand",name:"reportMessage",id:113},{rule:"optional",type:"PatchCommand",name:"patchMessage",id:114},{rule:"optional",type:"PubsubCommand",name:"pubsubMessage",id:115},{rule:"optional",type:"BlacklistCommand",name:"blacklistMessage",id:116}]}],enums:[{name:"CommandType",syntax:"proto2",values:[{name:"session",id:0},{name:"conv",id:1},{name:"direct",id:2},{name:"ack",id:3},{name:"rcp",id:4},{name:"unread",id:5},{name:"logs",id:6},{name:"error",id:7},{name:"login",id:8},{name:"data",id:9},{name:"room",id:10},{name:"read",id:11},{name:"presence",id:12},{name:"report",id:13},{name:"echo",id:14},{name:"loggedin",id:15},{name:"logout",id:16},{name:"loggedout",id:17},{name:"patch",id:18},{name:"pubsub",id:19},{name:"blacklist",id:20},{name:"goaway",id:21}]},{name:"OpType",syntax:"proto2",values:[{name:"open",id:1},{name:"add",id:2},{name:"remove",id:3},{name:"close",id:4},{name:"opened",id:5},{name:"closed",id:6},{name:"query",id:7},{name:"query_result",id:8},{name:"conflict",id:9},{name:"added",id:10},{name:"removed",id:11},{name:"refresh",id:12},{name:"refreshed",id:13},{name:"start",id:30},{name:"started",id:31},{name:"joined",id:32},{name:"members_joined",id:33},{name:"left",id:39},{name:"members_left",id:40},{name:"results",id:42},{name:"count",id:43},{name:"result",id:44},{name:"update",id:45},{name:"updated",id:46},{name:"mute",id:47},{name:"unmute",id:48},{name:"status",id:49},{name:"members",id:50},{name:"max_read",id:51},{name:"is_member",id:52},{name:"member_info_update",id:53},{name:"member_info_updated",id:54},{name:"member_info_changed",id:55},{name:"join",id:80},{name:"invite",id:81},{name:"leave",id:82},{name:"kick",id:83},{name:"reject",id:84},{name:"invited",id:85},{name:"kicked",id:86},{name:"upload",id:100},{name:"uploaded",id:101},{name:"subscribe",id:120},{name:"subscribed",id:121},{name:"unsubscribe",id:122},{name:"unsubscribed",id:123},{name:"is_subscribed",id:124},{name:"modify",id:150},{name:"modified",id:151},{name:"block",id:170},{name:"unblock",id:171},{name:"blocked",id:172},{name:"unblocked",id:173},{name:"members_blocked",id:174},{name:"members_unblocked",id:175},{name:"check_block",id:176},{name:"check_result",id:177},{name:"add_shutup",id:180},{name:"remove_shutup",id:181},{name:"query_shutup",id:182},{name:"shutup_added",id:183},{name:"shutup_removed",id:184},{name:"shutup_result",id:185},{name:"shutuped",id:186},{name:"unshutuped",id:187},{name:"members_shutuped",id:188},{name:"members_unshutuped",id:189},{name:"check_shutup",id:190}]},{name:"StatusType",syntax:"proto2",values:[{name:"on",id:1},{name:"off",id:2}]}],isNamespace:!0}).build().push_server.messages2,b=v.JsonObjectMessage,w=v.UnreadTuple,_=v.LogItem,E=v.DataCommand,T=v.SessionCommand,O=v.ErrorCommand,S=v.DirectCommand,A=v.AckCommand,I=v.UnreadCommand,x=v.ConvCommand,C=v.RoomCommand,M=v.LogsCommand,P=v.RcpCommand,k=v.ReadTuple,j=v.MaxReadTuple,R=v.ReadCommand,N=v.PresenceCommand,L=v.ReportCommand,D=v.GenericCommand,F=v.BlacklistCommand,U=v.PatchCommand,B=v.PatchItem,V=v.ConvMemberInfo,Y=v.CommandType,q=v.OpType,z=v.StatusType,W=Object.freeze({__proto__:null,JsonObjectMessage:b,UnreadTuple:w,LogItem:_,DataCommand:E,SessionCommand:T,ErrorCommand:O,DirectCommand:S,AckCommand:A,UnreadCommand:I,ConvCommand:x,RoomCommand:C,LogsCommand:M,RcpCommand:P,ReadTuple:k,MaxReadTuple:j,ReadCommand:R,PresenceCommand:N,ReportCommand:L,GenericCommand:D,BlacklistCommand:F,PatchCommand:U,PatchItem:B,ConvMemberInfo:V,CommandType:Y,OpType:q,StatusType:z}),G=i((function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,o,s){var a=r?r+e:e;if(!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,n),!0;case 4:return f.fn.call(f.context,t,n,i),!0;case 5:return f.fn.call(f.context,t,n,i,o),!0;case 6:return f.fn.call(f.context,t,n,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;c<p;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,n);break;case 4:f[c].fn.call(f[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},a.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,c=[],f=a.length;u<f;u++)(a[u].fn!==t||i&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a})),$=n(i((function(e){function t(e,t,r,n,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,i)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(i,o){var s=e.apply(r,n);function a(e){t(s,i,o,a,u,"next",e)}function u(e){t(s,i,o,a,u,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}))),J=i((function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports}));n(J);var Z=i((function(e){e.exports=function(e){if(Array.isArray(e))return J(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));n(Z);var X=i((function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));n(X);var Q=i((function(e){e.exports=function(e,t){if(e){if("string"==typeof e)return J(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?J(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}));n(Q);var H=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));n(H);var K=n(i((function(e){e.exports=function(e){return Z(e)||X(e)||Q(e)||H()},e.exports.__esModule=!0,e.exports.default=e.exports}))),ee=i((function(e){e.exports=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i},e.exports.__esModule=!0,e.exports.default=e.exports}));n(ee);var te=n(i((function(e){e.exports=function(e,t){if(null==e)return{};var r,n,i=ee(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i},e.exports.__esModule=!0,e.exports.default=e.exports}))),re=n(i((function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}))),ne=i((function(e){function t(r,n){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));n(ne);var ie=n(i((function(e){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ne(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports}))),oe=i((function(e){var t=s.default;function r(){e.exports=r=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var n={},i=Object.prototype,o=i.hasOwnProperty,s=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var i=t&&t.prototype instanceof m?t:m,o=Object.create(i.prototype),a=new x(n||[]);return s(o,"_invoke",{value:O(e,r,a)}),o}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}n.wrap=h;var d={};function m(){}function g(){}function y(){}var v={};l(v,u,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(C([])));w&&w!==i&&o.call(w,u)&&(v=w);var _=y.prototype=m.prototype=Object.create(v);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,r){var n;s(this,"_invoke",{value:function(i,s){function a(){return new r((function(n,a){!function n(i,s,a,u){var c=p(e[i],e,s);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==t(l)&&o.call(l,"__await")?r.resolve(l.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):r.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}(i,s,n,a)}))}return n=n?n.then(a,a):a()}})}function O(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return M()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=S(s,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function S(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=p(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function C(e){if(e){var t=e[u];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(o.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:M}}function M(){return{value:void 0,done:!0}}return g.prototype=y,s(_,"constructor",{value:y,configurable:!0}),s(y,"constructor",{value:g,configurable:!0}),g.displayName=l(y,f,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,l(e,f,"GeneratorFunction")),e.prototype=Object.create(_),e},n.awrap=function(e){return{__await:e}},E(T.prototype),l(T.prototype,c,(function(){return this})),n.AsyncIterator=T,n.async=function(e,t,r,i,o){void 0===o&&(o=Promise);var s=new T(h(e,t,r,i),o);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(_),l(_,f,"Generator"),l(_,u,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},n.values=C,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!e)for(var t in this)"t"===t.charAt(0)&&o.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],s=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=o.call(i,"catchLoc"),u=o.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}));n(oe);var se=oe(),ae=se;try{regeneratorRuntime=se}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=se:Function("r","regeneratorRuntime = r")(se)}var ue=1e3,ce=6e4,fe=60*ce,le=24*fe,he=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*le;case"hours":case"hour":case"hrs":case"hr":case"h":return r*fe;case"minutes":case"minute":case"mins":case"min":case"m":return r*ce;case"seconds":case"second":case"secs":case"sec":case"s":return r*ue;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(t>=le)return pe(e,t,le,"day");if(t>=fe)return pe(e,t,fe,"hour");if(t>=ce)return pe(e,t,ce,"minute");if(t>=ue)return pe(e,t,ue,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=le)return Math.round(e/le)+"d";if(t>=fe)return Math.round(e/fe)+"h";if(t>=ce)return Math.round(e/ce)+"m";if(t>=ue)return Math.round(e/ue)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function pe(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var de=function(e){function t(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var o;function s(){if(s.enabled){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=s,a=Number(new Date),u=a-(o||a);i.diff=u,i.prev=o,i.curr=a,o=a,t[0]=r.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var c=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,n){if("%%"===e)return e;c++;var o=r.formatters[n];if("function"==typeof o){var s=t[c];e=o.call(i,s),t.splice(c,1),c--}return e})),r.formatArgs.call(i,t);var f=i.log||r.log;f.apply(i,t)}}return s.namespace=e,s.enabled=r.enabled(e),s.useColors=r.useColors(),s.color=t(e),s.destroy=n,s.extend=i,"function"==typeof r.init&&r.init(s),r.instances.push(s),s}function n(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){return r(this.namespace+(void 0===t?":":t)+e)}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){r.enable("")},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(t=0;t<i;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var o=r.instances[t];o.enabled=r.enabled(o.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=he,Object.keys(e).forEach((function(t){r[t]=e[t]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=t,r.enable(r.load()),r},me=i((function(e,r){function n(e){return(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})(e)}r.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":n(console))&&console.log&&(e=console).log.apply(e,arguments)},r.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){var e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==t&&"env"in t&&(e=t.env.DEBUG);return e},r.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=de(r),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}));me.log,me.formatArgs,me.save,me.load,me.useColors,me.storage,me.colors;var ge=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t},ye=Math.floor,ve=Math.random;var be=function(e,t){return e+ye(ve()*(t-e+1))};var we=function(e,t){var r=-1,n=e.length,i=n-1;for(t=void 0===t?n:t;++r<t;){var o=be(r,i),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e};var _e=function(e){return we(ge(e))};var Ee=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i};var Te=function(e,t){return Ee(t,(function(t){return e[t]}))};var Oe=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n},Se="object"==typeof r&&r&&r.Object===Object&&r,Ae="object"==typeof self&&self&&self.Object===Object&&self,Ie=Se||Ae||Function("return this")(),xe=Ie.Symbol,Ce=Object.prototype,Me=Ce.hasOwnProperty,Pe=Ce.toString,ke=xe?xe.toStringTag:void 0;var je=function(e){var t=Me.call(e,ke),r=e[ke];try{e[ke]=void 0;var n=!0}catch(e){}var i=Pe.call(e);return n&&(t?e[ke]=r:delete e[ke]),i},Re=Object.prototype.toString;var Ne=function(e){return Re.call(e)},Le=xe?xe.toStringTag:void 0;var De=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Le&&Le in Object(e)?je(e):Ne(e)};var Fe=function(e){return null!=e&&"object"==typeof e};var Ue=function(e){return Fe(e)&&"[object Arguments]"==De(e)},Be=Object.prototype,Ve=Be.hasOwnProperty,Ye=Be.propertyIsEnumerable,qe=Ue(function(){return arguments}())?Ue:function(e){return Fe(e)&&Ve.call(e,"callee")&&!Ye.call(e,"callee")},ze=Array.isArray;var We=function(){return!1},Ge=i((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?Ie.Buffer:void 0,o=(i?i.isBuffer:void 0)||We;e.exports=o})),$e=/^(?:0|[1-9]\d*)$/;var Je=function(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&$e.test(e))&&e>-1&&e%1==0&&e<t};var Ze=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Xe={};Xe["[object Float32Array]"]=Xe["[object Float64Array]"]=Xe["[object Int8Array]"]=Xe["[object Int16Array]"]=Xe["[object Int32Array]"]=Xe["[object Uint8Array]"]=Xe["[object Uint8ClampedArray]"]=Xe["[object Uint16Array]"]=Xe["[object Uint32Array]"]=!0,Xe["[object Arguments]"]=Xe["[object Array]"]=Xe["[object ArrayBuffer]"]=Xe["[object Boolean]"]=Xe["[object DataView]"]=Xe["[object Date]"]=Xe["[object Error]"]=Xe["[object Function]"]=Xe["[object Map]"]=Xe["[object Number]"]=Xe["[object Object]"]=Xe["[object RegExp]"]=Xe["[object Set]"]=Xe["[object String]"]=Xe["[object WeakMap]"]=!1;var Qe=function(e){return Fe(e)&&Ze(e.length)&&!!Xe[De(e)]};var He=function(e){return function(t){return e(t)}},Ke=i((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&Se.process,o=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})),et=Ke&&Ke.isTypedArray,tt=et?He(et):Qe,rt=Object.prototype.hasOwnProperty;var nt=function(e,t){var r=ze(e),n=!r&&qe(e),i=!r&&!n&&Ge(e),o=!r&&!n&&!i&&tt(e),s=r||n||i||o,a=s?Oe(e.length,String):[],u=a.length;for(var c in e)!t&&!rt.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Je(c,u))||a.push(c);return a},it=Object.prototype;var ot=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||it)};var st=function(e,t){return function(r){return e(t(r))}},at=st(Object.keys,Object),ut=Object.prototype.hasOwnProperty;var ct=function(e){if(!ot(e))return at(e);var t=[];for(var r in Object(e))ut.call(e,r)&&"constructor"!=r&&t.push(r);return t};var ft=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var lt=function(e){if(!ft(e))return!1;var t=De(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var ht=function(e){return null!=e&&Ze(e.length)&&!lt(e)};var pt=function(e){return ht(e)?nt(e):ct(e)};var dt=function(e){return null==e?[]:Te(e,pt(e))};var mt=function(e){return we(dt(e))};var gt=function(e){return(ze(e)?_e:mt)(e)},yt=i((function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}));n(yt);var vt=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));n(vt);var bt=n(i((function(e){e.exports=function(e){return yt(e)||X(e)||Q(e)||vt()},e.exports.__esModule=!0,e.exports.default=e.exports}))),wt=n(i((function(e){function t(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,h(n.key),n)}}e.exports=function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}))),_t=n(i((function(e){e.exports=function(e,t,r,n,i){var o={};return Object.keys(n).forEach((function(e){o[e]=n[e]})),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=r.slice().reverse().reduce((function(r,n){return n(e,t,r)||r}),o),i&&void 0!==o.initializer&&(o.value=o.initializer?o.initializer.call(i):void 0,o.initializer=void 0),void 0===o.initializer&&(Object.defineProperty(e,t,o),o=null),o},e.exports.__esModule=!0,e.exports.default=e.exports}))),Et=i((function(e,t){var r;r={VERSION:"2.4.0",Result:{SUCCEEDED:1,NOTRANSITION:2,CANCELLED:3,PENDING:4},Error:{INVALID_TRANSITION:100,PENDING_TRANSITION:200,INVALID_CALLBACK:300},WILDCARD:"*",ASYNC:"async",create:function(e,t){var n="string"==typeof e.initial?{state:e.initial}:e.initial,i=e.terminal||e.final,o=t||e.target||{},s=e.events||[],a=e.callbacks||{},u={},c={},f=function(e){var t=Array.isArray(e.from)?e.from:e.from?[e.from]:[r.WILDCARD];u[e.name]=u[e.name]||{};for(var n=0;n<t.length;n++)c[t[n]]=c[t[n]]||[],c[t[n]].push(e.name),u[e.name][t[n]]=e.to||t[n];e.to&&(c[e.to]=c[e.to]||[])};n&&(n.event=n.event||"startup",f({name:n.event,from:"none",to:n.state}));for(var l=0;l<s.length;l++)f(s[l]);for(var h in u)u.hasOwnProperty(h)&&(o[h]=r.buildEvent(h,u[h]));for(var h in a)a.hasOwnProperty(h)&&(o[h]=a[h]);return o.current="none",o.is=function(e){return Array.isArray(e)?e.indexOf(this.current)>=0:this.current===e},o.can=function(e){return!this.transition&&void 0!==u[e]&&(u[e].hasOwnProperty(this.current)||u[e].hasOwnProperty(r.WILDCARD))},o.cannot=function(e){return!this.can(e)},o.transitions=function(){return(c[this.current]||[]).concat(c[r.WILDCARD]||[])},o.isFinished=function(){return this.is(i)},o.error=e.error||function(e,t,r,n,i,o,s){throw s||o},o.states=function(){return Object.keys(c).sort()},n&&!n.defer&&o[n.event](),o},doCallback:function(e,t,n,i,o,s){if(t)try{return t.apply(e,[n,i,o].concat(s))}catch(t){return e.error(n,i,o,s,r.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",t)}},beforeAnyEvent:function(e,t,n,i,o){return r.doCallback(e,e.onbeforeevent,t,n,i,o)},afterAnyEvent:function(e,t,n,i,o){return r.doCallback(e,e.onafterevent||e.onevent,t,n,i,o)},leaveAnyState:function(e,t,n,i,o){return r.doCallback(e,e.onleavestate,t,n,i,o)},enterAnyState:function(e,t,n,i,o){return r.doCallback(e,e.onenterstate||e.onstate,t,n,i,o)},changeState:function(e,t,n,i,o){return r.doCallback(e,e.onchangestate,t,n,i,o)},beforeThisEvent:function(e,t,n,i,o){return r.doCallback(e,e["onbefore"+t],t,n,i,o)},afterThisEvent:function(e,t,n,i,o){return r.doCallback(e,e["onafter"+t]||e["on"+t],t,n,i,o)},leaveThisState:function(e,t,n,i,o){return r.doCallback(e,e["onleave"+n],t,n,i,o)},enterThisState:function(e,t,n,i,o){return r.doCallback(e,e["onenter"+i]||e["on"+i],t,n,i,o)},beforeEvent:function(e,t,n,i,o){if(!1===r.beforeThisEvent(e,t,n,i,o)||!1===r.beforeAnyEvent(e,t,n,i,o))return!1},afterEvent:function(e,t,n,i,o){r.afterThisEvent(e,t,n,i,o),r.afterAnyEvent(e,t,n,i,o)},leaveState:function(e,t,n,i,o){var s=r.leaveThisState(e,t,n,i,o),a=r.leaveAnyState(e,t,n,i,o);return!1!==s&&!1!==a&&(r.ASYNC===s||r.ASYNC===a?r.ASYNC:void 0)},enterState:function(e,t,n,i,o){r.enterThisState(e,t,n,i,o),r.enterAnyState(e,t,n,i,o)},buildEvent:function(e,t){return function(){var n=this.current,i=t[n]||(t[r.WILDCARD]!=r.WILDCARD?t[r.WILDCARD]:n)||n,o=Array.prototype.slice.call(arguments);if(this.transition)return this.error(e,n,i,o,r.Error.PENDING_TRANSITION,"event "+e+" inappropriate because previous transition did not complete");if(this.cannot(e))return this.error(e,n,i,o,r.Error.INVALID_TRANSITION,"event "+e+" inappropriate in current state "+this.current);if(!1===r.beforeEvent(this,e,n,i,o))return r.Result.CANCELLED;if(n===i)return r.afterEvent(this,e,n,i,o),r.Result.NOTRANSITION;var s=this;this.transition=function(){return s.transition=null,s.current=i,r.enterState(s,e,n,i,o),r.changeState(s,e,n,i,o),r.afterEvent(s,e,n,i,o),r.Result.SUCCEEDED},this.transition.cancel=function(){s.transition=null,r.afterEvent(s,e,n,i,o)};var a=r.leaveState(this,e,n,i,o);return!1===a?(this.transition=null,r.Result.CANCELLED):r.ASYNC===a?r.Result.PENDING:this.transition?this.transition():void 0}}},e.exports&&(t=e.exports=r),t.StateMachine=r})),Tt=(Et.StateMachine,{}),Ot=function(e){var t=Tt[e];if(void 0===t)throw new Error("".concat(e," adapter is not configured"));return t},St=function(e){Object.assign(Tt,e)},At=st(Object.getPrototypeOf,Object),It=Function.prototype,xt=Object.prototype,Ct=It.toString,Mt=xt.hasOwnProperty,Pt=Ct.call(Object);var kt=function(e){if(!Fe(e)||"[object Object]"!=De(e))return!1;var t=At(e);if(null===t)return!0;var r=Mt.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Ct.call(r)==Pt},jt="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},Rt=Symbol("expired"),Nt=me("LC:Expirable"),Lt=function(){function e(e,t){this.originalValue=e,"number"==typeof t&&(this.expiredAt=Date.now()+t)}return wt(e,[{key:"value",get:function(){var e=this.expiredAt&&this.expiredAt<=Date.now();return e&&Nt("expired: ".concat(this.originalValue)),e?Rt:this.originalValue}}]),e}();Lt.EXPIRED=Rt;var Dt=me("LC:Cache"),Ft=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"anonymous";this.name=e,this._map={}}var t=e.prototype;return t.get=function(e){var t=this._map[e];if(t){var r=t.value;if(r!==Lt.EXPIRED)return Dt("[%s] hit: %s",this.name,e),r;delete this._map[e]}return Dt("[".concat(this.name,"] missed: ").concat(e)),null},t.set=function(e,t,r){Dt("[%s] set: %s %d",this.name,e,r),this._map[e]=new Lt(t,r)},e}();function Ut(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Bt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ut(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ut(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Vt,Yt={enable:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"LC*";return me.enable(e)},disable:me.disable},qt=function(e){return function(t){return e(t),t}},zt=function(e){return[function(t){return e(),t},function(t){throw e(),t}]},Wt=function(e){return e?"string"==typeof e||"number"==typeof e?new Date(e):"Date"===e.__type&&e.iso?new Date(e.iso):"function"==typeof e.toNumber?new Date(e.toNumber()):e:e},Gt=function(e){return e&&e.getTime?e.getTime():void 0},$t=function e(t){return t?"Date"===t.__type&&t.iso?new Date(t.iso):Array.isArray(t)?t.map(e):kt(t)?Object.keys(t).reduce((function(r,n){return Bt(Bt({},r),{},d({},n,e(t[n])))}),{}):t:t},Jt=function e(t){return t instanceof Date?{__type:"Date",iso:t.toJSON()}:Array.isArray(t)?t.map(e):kt(t)?Object.keys(t).reduce((function(r,n){return Bt(Bt({},r),{},d({},n,e(t[n])))}),{}):t},Zt=function(e,t){return Object.keys(t).reduce((function(r,n){var i=e[n]||n;return Object.assign(r,d({},i,t[n]))}),{})},Xt=jt.navigator&&jt.navigator.userAgent&&-1!==jt.navigator.userAgent.indexOf("MSIE 10."),Qt=function e(t,r){return t[r]||(t.__proto__?e(t.__proto__,r):void 0)},Ht=function(e,t){return Array.from(new Set([].concat(K(e),K(t))))},Kt=function(e,t){return Array.from((r=new Set(t),new Set(e.filter((function(e){return!r.has(e)})))));var r},er=new WeakMap,tr=function(e){return er.has(e)||er.set(e,{}),er.get(e)},rr=function e(t,r){if(!kt(t))return t;var n=Bt({},t);return Object.keys(n).forEach((function(t){var i=n[t];i===r?delete n[t]:n[t]=e(i,r)})),n},nr=function(e){return t=JSON.parse(JSON.stringify(e)),rr(t,null);var t},ir=function(e){return Array.isArray(e)?e:null==e?[]:[e]},or=function(e,t,r){var n=t.split("."),i=n.pop(),o=e;return n.forEach((function(e){void 0===o[e]&&(o[e]={}),o=o[e]})),o[i]=r,e},sr="object"===("undefined"==typeof wx?"undefined":a(wx))&&"function"==typeof wx.connectSocket,ar=function(e){return function(t,r,n){var i=n.value;if(i.length)throw new Error("throttled function should not accept any arguments");return Bt(Bt({},n),{},{value:function(){var t=this,n=tr(this).throttleMeta;n||(n={},tr(this).throttleMeta=n);var o=n[r];o||(o={},n[r]=o);var s=o,a=s.previouseTimestamp,u=void 0===a?0:a,c=s.timeout,f=Date.now(),l=e-(f-u);l<=0?(n[r].previouseTimestamp=f,i.apply(this)):c||(o.timeout=setTimeout((function(){o.previouseTimestamp=Date.now(),delete o.timeout,i.apply(t)}),l))}})}},ur=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;var r=new Uint8Array(e),n=new Uint8Array(t);return!r.some((function(e,t){return e!==n[t]}))};function cr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function fr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?cr(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var lr=me("LC:WebSocketPlus"),hr="disconnect",pr="reconnect",dr="retry",mr="schedule",gr="offline",yr="online",vr=function(e){return Math.min(1e3*Math.pow(2,e),3e5)},br=function(e,t,r){return fr(fr({},r),{},{value:function(){var e;this.checkConnectionAvailability(t);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(e=r.value).call.apply(e,[this].concat(i))}})},wr=(_t((Vt=function(e){function t(t,r){var n;return(n=e.call(this)||this).init(),n._protocol=r,Promise.resolve("function"==typeof t?t():t).then(ir).then((function(e){return n._urls=e,n._open()})).then((function(){n.__postponeTimeoutTimer=n._postponeTimeoutTimer.bind(re(n)),jt.addEventListener&&(n.__pause=function(){n.can("pause")&&n.pause()},n.__resume=function(){n.can("resume")&&n.resume()},jt.addEventListener("offline",n.__pause),jt.addEventListener("online",n.__resume)),n.open()})).catch(n.throw.bind(re(n))),n}ie(t,e);var r=t.prototype;return r._open=function(){var e=this;return this._createWs(this._urls,this._protocol).then((function(t){var r=bt(e._urls),n=r[0],i=r.slice(1);return e._urls=[].concat(K(i),[n]),t}))},r._createWs=function(e,t){var r=this;return function e(t){var r=new Promise(t[0]);return 1===t.length?r:r.catch((function(){return e(t.slice(1))}))}(e.map((function(e){return function(n,i){lr("connect [".concat(e,"] ").concat(t));var o=Ot("WebSocket"),s=t?new o(e,t):new o(e);s.binaryType=r.binaryType||"arraybuffer",s.onopen=function(){return n(s)},s.onclose=function(t){return t instanceof Error?i(t):i(new Error("Failed to connect [".concat(e,"]")))},s.onerror=s.onclose}}))).then((function(e){return r._ws=e,r._ws.onclose=r._handleClose.bind(r),r._ws.onmessage=r._handleMessage.bind(r),e}))},r._destroyWs=function(){var e=this._ws;e&&(e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null,this._ws=null,e.close())},r.onbeforeevent=function(e,t,r){for(var n=arguments.length,i=new Array(n>3?n-3:0),o=3;o<n;o++)i[o-3]=arguments[o];lr("".concat(e,": ").concat(t," -> ").concat(r," %o"),i)},r.onopen=function(){this.emit("open")},r.onconnected=function(){this._startConnectionKeeper()},r.onleaveconnected=function(e,t,r){this._stopConnectionKeeper(),this._destroyWs(),"offline"!==r&&"disconnected"!==r||this.emit(hr)},r.onpause=function(){this.emit(gr)},r.onbeforeresume=function(){this.emit(yr)},r.onreconnect=function(){this.emit(pr)},r.ondisconnected=function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=t===gr?0:vr.call(null,i);lr("schedule attempt=".concat(i," delay=").concat(o)),this.emit(mr,i,o),this.__scheduledRetry&&clearTimeout(this.__scheduledRetry),this.__scheduledRetry=setTimeout((function(){n.is("disconnected")&&n.retry(i)}),o)},r.onretry=function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.emit(dr,i),this._open().then((function(){return n.can("reconnect")&&n.reconnect()}),(function(){return n.can("fail")&&n.fail(i+1)}))},r.onerror=function(e,t,r,n){this.emit("error",n)},r.onclose=function(){jt.removeEventListener&&(this.__pause&&jt.removeEventListener("offline",this.__pause),this.__resume&&jt.removeEventListener("online",this.__resume))},r.checkConnectionAvailability=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"API";if(!this.is("connected")){var t=this.current;throw console.warn("".concat(e," should not be called when the connection is ").concat(t)),(this.is("disconnected")||this.is("reconnecting"))&&console.warn("disconnect and reconnect event should be handled to avoid such calls."),new Error("Connection unavailable")}},r._ping=function(){lr("ping");try{this.ping()}catch(e){console.warn("websocket ping error: ".concat(e.message))}},r.ping=function(){this._ws.ping?this._ws.ping():console.warn("The WebSocket implement does not support sending ping frame.\n Override ping method to use application defined ping/pong mechanism.")},r._postponeTimeoutTimer=function(){var e=this;lr("_postponeTimeoutTimer"),this._clearTimeoutTimers(),this._timeoutTimer=setTimeout((function(){lr("timeout"),e.disconnect()}),38e4)},r._clearTimeoutTimers=function(){this._timeoutTimer&&clearTimeout(this._timeoutTimer)},r._startConnectionKeeper=function(){lr("start connection keeper"),this._heartbeatTimer=setInterval(this._ping.bind(this),18e4);var e=this._ws.addListener||this._ws.addEventListener;e?(e.call(this._ws,"message",this.__postponeTimeoutTimer),e.call(this._ws,"pong",this.__postponeTimeoutTimer),this._postponeTimeoutTimer()):lr("connection keeper disabled due to the lack of #addEventListener.")},r._stopConnectionKeeper=function(){lr("stop connection keeper");var e=this._ws.removeListener||this._ws.removeEventListener;e&&(e.call(this._ws,"message",this.__postponeTimeoutTimer),e.call(this._ws,"pong",this.__postponeTimeoutTimer),this._clearTimeoutTimers()),this._heartbeatTimer&&clearInterval(this._heartbeatTimer)},r._handleClose=function(e){lr("ws closed [".concat(e.code,"] ").concat(e.reason)),this.isFinished()||this.handleClose(e)},r.handleClose=function(){this.disconnect()},r.send=function(e){lr("send",e),this._ws.send(e)},r._handleMessage=function(e){lr("message",e.data),this.handleMessage(e.data)},r.handleMessage=function(e){this.emit("message",e)},wt(t,[{key:"urls",get:function(){return this._urls},set:function(e){this._urls=ir(e)}}]),t}(G)).prototype,"_ping",[br],Object.getOwnPropertyDescriptor(Vt.prototype,"_ping"),Vt.prototype),_t(Vt.prototype,"send",[br],Object.getOwnPropertyDescriptor(Vt.prototype,"send"),Vt.prototype),Vt);Et.create({target:wr.prototype,initial:{state:"initialized",event:"init",defer:!0},terminal:"closed",events:[{name:"open",from:"initialized",to:"connected"},{name:"disconnect",from:"connected",to:"disconnected"},{name:"retry",from:"disconnected",to:"reconnecting"},{name:"fail",from:"reconnecting",to:"disconnected"},{name:"reconnect",from:"reconnecting",to:"connected"},{name:"pause",from:["connected","disconnected","reconnecting"],to:"offline"},{},{name:"resume",from:"offline",to:"disconnected"},{name:"close",from:["connected","disconnected","reconnecting","offline"],to:"closed"},{name:"throw",from:"*",to:"error"}]});var _r=Object.freeze({1e3:{name:"CLOSE_NORMAL"},1006:{name:"CLOSE_ABNORMAL"},4100:{name:"APP_NOT_AVAILABLE",message:"App not exists or realtime message service is disabled."},4102:{name:"SIGNATURE_FAILED",message:"Login signature mismatch."},4103:{name:"INVALID_LOGIN",message:"Malformed clientId."},4105:{name:"SESSION_REQUIRED",message:"Message sent before session opened."},4107:{name:"READ_TIMEOUT"},4108:{name:"LOGIN_TIMEOUT"},4109:{name:"FRAME_TOO_LONG"},4110:{name:"INVALID_ORIGIN",message:"Access denied by domain whitelist."},4111:{name:"SESSION_CONFLICT"},4112:{name:"SESSION_TOKEN_EXPIRED"},4113:{name:"APP_QUOTA_EXCEEDED",message:"The daily active users limit exceeded."},4116:{name:"MESSAGE_SENT_QUOTA_EXCEEDED",message:"Command sent too fast."},4200:{name:"INTERNAL_ERROR",message:"Internal error, please contact LeanCloud for support."},4301:{name:"CONVERSATION_API_FAILED",message:"Upstream Conversatoin API failed, see error.detail for details."},4302:{name:"CONVERSATION_SIGNATURE_FAILED",message:"Conversation action signature mismatch."},4303:{name:"CONVERSATION_NOT_FOUND"},4304:{name:"CONVERSATION_FULL"},4305:{name:"CONVERSATION_REJECTED_BY_APP",message:"Conversation action rejected by hook."},4306:{name:"CONVERSATION_UPDATE_FAILED"},4307:{name:"CONVERSATION_READ_ONLY"},4308:{name:"CONVERSATION_NOT_ALLOWED"},4309:{name:"CONVERSATION_UPDATE_REJECTED",message:"Conversation update rejected because the client is not a member."},4310:{name:"CONVERSATION_QUERY_FAILED",message:"Conversation query failed because it is too expansive."},4311:{name:"CONVERSATION_LOG_FAILED"},4312:{name:"CONVERSATION_LOG_REJECTED",message:"Message query rejected because the client is not a member of the conversation."},4313:{name:"SYSTEM_CONVERSATION_REQUIRED"},4314:{name:"NORMAL_CONVERSATION_REQUIRED"},4315:{name:"CONVERSATION_BLACKLISTED",message:"Blacklisted in the conversation."},4316:{name:"TRANSIENT_CONVERSATION_REQUIRED"},4317:{name:"CONVERSATION_MEMBERSHIP_REQUIRED"},4318:{name:"CONVERSATION_API_QUOTA_EXCEEDED",message:"LeanCloud API quota exceeded. You may upgrade your plan."},4323:{name:"TEMPORARY_CONVERSATION_EXPIRED",message:"Temporary conversation expired or does not exist."},4401:{name:"INVALID_MESSAGING_TARGET",message:"Conversation does not exist or client is not a member."},4402:{name:"MESSAGE_REJECTED_BY_APP",message:"Message rejected by hook."},4403:{name:"MESSAGE_OWNERSHIP_REQUIRED"},4404:{name:"MESSAGE_NOT_FOUND"},4405:{name:"MESSAGE_UPDATE_REJECTED_BY_APP",message:"Message update rejected by hook."},4406:{name:"MESSAGE_EDIT_DISABLED"},4407:{name:"MESSAGE_RECALL_DISABLED"},5130:{name:"OWNER_PROMOTION_NOT_ALLOWED",message:"Updating a member's role to owner is not allowed."}}),Er=Object.freeze(Object.keys(_r).reduce((function(e,t){return Object.assign(e,d({},_r[t].name,Number(t)))}),{})),Tr=function(e){var t=e.code,r=e.reason,n=e.appCode,i=e.detail,o=e.error,s=r||i||o,a=r;!s&&_r[t]&&(a=_r[t].name,s=_r[t].message||a),s||(s="Unknow Error: ".concat(t));var u=new Error(s);return Object.assign(u,{code:t,appCode:n,detail:i,name:a})},Or=me("LC:Connection"),Sr=Symbol("expire"),Ar=function(e){return!(e.cmd===Y.direct||e.cmd===Y.session&&e.op===q.open||e.cmd===Y.conv&&(e.op===q.start||e.op===q.update||e.op===q.members))},Ir=function(e){function t(t,r){var n,i=r.format,o=r.version;Or("initializing Connection");var s="lc.".concat(i,".").concat(o);return(n=e.call(this,t,s)||this)._protocolFormat=i,n._commands={},n._serialId=0,n}ie(t,e);var r=t.prototype;return r.send=function(){var t=$(ae.mark((function t(r){var n,i,o,s,a,u,c=this,f=arguments;return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=!(f.length>1&&void 0!==f[1])||f[1])){t.next=11;break}if(!Ar(r)){t.next=8;break}if(i=r.toArrayBuffer(),!(s=dt(this._commands).find((function(e){var t=e.buffer,n=e.command;return n.cmd===r.cmd&&n.op===r.op&&ur(t,i)})))){t.next=8;break}return console.warn("Duplicated command [cmd:".concat(r.cmd," op:").concat(r.op,"] is throttled.")),t.abrupt("return",s.promise);case 8:this._serialId+=1,o=this._serialId,r.i=o;case 11:if(Or.enabled&&Or("↑ %O sent",nr(r)),"proto2base64"===this._protocolFormat?a=r.toBase64():r.toArrayBuffer&&(a=r.toArrayBuffer()),a){t.next=15;break}throw new TypeError("".concat(r," is not a GenericCommand"));case 15:if(e.prototype.send.call(this,a),n){t.next=18;break}return t.abrupt("return",void 0);case 18:return u=new Promise((function(e,t){c._commands[o]={command:r,buffer:i,resolve:e,reject:t,timeout:setTimeout((function(){c._commands[o]&&(Or.enabled&&Or("✗ %O timeout",nr(r)),t(Tr({error:"Command Timeout [cmd:".concat(r.cmd," op:").concat(r.op,"]"),name:"COMMAND_TIMEOUT"})),delete c._commands[o])}),2e4)}})),this._commands[o].promise=u,t.abrupt("return",u);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.handleMessage=function(e){var t;try{t=D.decode(e),Or.enabled&&Or("↓ %O received",nr(t))}catch(t){return void console.warn("Decode message failed:",t.message,e)}var r=t.i;if(r)this._commands[r]?(clearTimeout(this._commands[r].timeout),t.cmd===Y.error?this._commands[r].reject(Tr(t.errorMessage)):this._commands[r].resolve(t),delete this._commands[r]):console.warn("Unexpected command received with serialId [".concat(r,"],\n which have timed out or never been requested."));else switch(t.cmd){case Y.error:return void this.emit("error",Tr(t.errorMessage));case Y.goaway:return void this.emit(Sr);default:this.emit("message",t)}},r.ping=function(){return this.send(new D({cmd:Y.echo})).catch((function(e){return Or("ping failed:",e)}))},t}(wr),xr=i((function(e){var t;e.exports.timeout=function(e,r){var n,i=new t;return Promise.race([e,new Promise((function(e,t){n=setTimeout((function(){t(i)}),r)}))]).then((function(e){return clearTimeout(n),e}),(function(e){throw clearTimeout(n),e}))};(t=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),t.prototype.name="TimeoutError"})),Cr=xr.timeout,Mr=(xr.TimeoutError,me("LC:request")),Pr=function(e){var t=e.method,r=void 0===t?"GET":t,n=e.url,i=e.query,o=e.headers,s=e.data,a=e.timeout,u=n;if(i){var c=Object.keys(i).map((function(e){var t=i[e];if(void 0!==t){var r=kt(t)?JSON.stringify(t):t;return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))}})).filter((function(e){return e})).join("&");u="".concat(u,"?").concat(c)}Mr("Req: %O %O %O",r,u,{headers:o,data:s});var f=Ot("request")(u,{method:r,headers:o,data:s}).then((function(e){if(!1===e.ok){var t=Tr(e.data);throw t.response=e,t}return Mr("Res: %O %O %O",u,e.status,e.data),e.data})).catch((function(e){throw e.response&&Mr("Error: %O %O %O",u,e.response.status,e.response.data),e}));return a?Cr(f,a):f},kr=function(e,t){e&&e.forEach((function(e){try{e(t)}catch(t){throw e._pluginName&&(t.message+="[".concat(e._pluginName,"]")),t}}))},jr=function(e){return function(t){return ir(e).reduce((function(e,t){return e.then(function(e){return function(t){var r=t.constructor;return Promise.resolve(t).then(e).then(qt((function(n){return null==n?console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns ").concat(n," while a ").concat(t.constructor.name," expected.")):n instanceof r?0:console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns a ").concat(n.constructor.name," while a ").concat(t.constructor.name," expected."))})))}}(t)).catch((function(e){throw t._pluginName&&(e.message+="[".concat(t._pluginName,"]")),e}))}),Promise.resolve(t))}},Rr=function(e,t){return ir(e).reduce((function(e,r){return e.then((function(e){return!1!==e&&r.apply(void 0,K(t))})).catch((function(e){throw r._pluginName&&(e.message+="[".concat(r._pluginName,"]")),e}))}),Promise.resolve(!0))},Nr=["plugins"];function Lr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Dr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Lr(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lr(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}for(var Fr=me("LC:Realtime"),Ur=new Ft("push-router"),Br={},Vr=function(e){function r(n){var i,o=n.plugins,s=te(n,Nr);Fr("initializing Realtime %s %O","5.0.0-rc.8",s),i=e.call(this)||this;var a=s.appId;if("string"!=typeof a)throw new TypeError("appId [".concat(a,"] is not a string"));if(Br[a])throw new Error("App [".concat(a,"] is already initialized."));if(Br[a]=!0,"string"!=typeof s.appKey)throw new TypeError("appKey [".concat(s.appKey,"] is not a string"));if(function(e){return"-MdYXbMMI"!==e.slice(-9)}(a)&&!s.server)throw new TypeError("server option is required for apps from CN region");i._options=Dr({appId:void 0,appKey:void 0,noBinary:!1,ssl:!0,RTMServerName:void 0!==t?t.env.RTM_SERVER_NAME:void 0},s),i._cache=new Ft("endpoints");var u=tr(re(i));u.clients=new Set,u.pendingClients=new Set;var c=[].concat(K(ir(r.__preRegisteredPlugins)),K(ir(o)));return Fr("Using plugins %o",c.map((function(e){return e.name}))),i._plugins=c.reduce((function(e,t){return Object.keys(t).forEach((function(r){({}).hasOwnProperty.call(t,r)&&"name"!==r&&(t.name&&ir(t[r]).forEach((function(e){e._pluginName=t.name})),e[r]=ir(e[r]).concat(t[r]))})),e}),{}),kr(i._plugins.onRealtimeCreate,re(i)),i}ie(r,e);var n=r.prototype;return n._request=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d,m;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.method,n=t.url,i=t.version,o=void 0===i?"1.1":i,s=t.path,a=t.query,u=t.headers,c=t.data,f=n){e.next=9;break}return l=this._options,h=l.appId,p=l.server,e.next=6,this.constructor._getServerUrls({appId:h,server:p});case 6:d=e.sent,m=d.api,f="".concat(m,"/").concat(o).concat(s);case 9:return e.abrupt("return",Pr({url:f,method:r,query:a,headers:Dr({"X-LC-Id":this._options.appId,"X-LC-Key":this._options.appKey},u),data:c}));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._open=function(){var e=this;if(this._openPromise)return this._openPromise;var t="protobuf2";this._options.noBinary&&(t="proto2base64");var r={format:t,version:3};return this._openPromise=new Promise((function(t,n){Fr("No connection established, create a new one.");var i=new Ir((function(){return e._getRTMServers(e._options)}),r);i.on("open",(function(){return t(i)})).on("error",(function(t){delete e._openPromise,n(t)})).on(Sr,$(ae.mark((function t(){return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Fr("Connection expired. Refresh endpoints."),e._cache.set("endpoints",null,0),t.next=4,e._getRTMServers(e._options);case 4:i.urls=t.sent,i.disconnect();case 6:case"end":return t.stop()}}),t)})))).on("message",e._dispatchCommand.bind(e)),[hr,pr,dr,mr,gr,yr].forEach((function(t){return i.on(t,(function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];Fr("".concat(t," event emitted. %o"),n),e.emit.apply(e,[t].concat(n)),t!==pr&&tr(e).clients.forEach((function(e){e.emit.apply(e,[t].concat(n))}))}))})),i.handleClose=function(e){[Er.APP_NOT_AVAILABLE,Er.INVALID_LOGIN,Er.INVALID_ORIGIN].some((function(t){return t===e.code}))?this.throw(Tr(e)):this.disconnect()},tr(e).connection=i})),this._openPromise},n._getRTMServers=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.RTMServers){e.next=2;break}return e.abrupt("return",gt(ir(t.RTMServers)));case 2:if(!(n=this._cache.get("endpoints"))){e.next=7;break}r=n,e.next=14;break;case 7:return e.next=9,this.constructor._fetchRTMServers(t);case 9:if(r=e.sent,o=(i=r).server,s=i.secondary,a=i.ttl,"string"==typeof o||"string"==typeof s||"number"==typeof a){e.next=13;break}throw new Error("malformed RTM route response: ".concat(JSON.stringify(r)));case 13:this._cache.set("endpoints",r,1e3*r.ttl);case 14:return Fr("endpoint info: %O",r),e.abrupt("return",[r.server,r.secondary]);case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._getServerUrls=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.appId,n=t.server,Fr("fetch server urls"),!n){e.next=6;break}if("string"==typeof n){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",{RTMRouter:n,api:n});case 6:if(!(i=Ur.get(r))){e.next=9;break}return e.abrupt("return",i);case 9:return"https://",e.abrupt("return",Pr({url:"https://app-router.com/2/route",query:{appId:r},timeout:2e4}).then(qt(Fr)).then((function(e){var t=e.rtm_router_server,n=e.api_server,i=e.ttl,o=void 0===i?3600:i;if(!t)throw new Error("rtm router not exists");var s={RTMRouter:"".concat("https://").concat(t),api:"".concat("https://").concat(n)};return Ur.set(r,s,1e3*o),s})).catch((function(){var e=r.slice(0,8).toLowerCase();return{RTMRouter:"".concat("https://").concat(e,".rtm.").concat("lncldglobal.com"),api:"".concat("https://").concat(e,".api.").concat("lncldglobal.com")}})));case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r._fetchRTMServers=function(e){var t=e.appId,r=e.ssl,n=e.server,i=e.RTMServerName;return Fr("fetch endpoint info"),this._getServerUrls({appId:t,server:n}).then(qt(Fr)).then((function(e){var n=e.RTMRouter;return Pr({url:"".concat(n,"/v1/route"),query:{appId:t,secure:r,features:sr?"wechat":void 0,server:i,_t:Date.now()},timeout:2e4}).then(qt(Fr))}))},n._close=function(){this._openPromise&&this._openPromise.then((function(e){return e.close()})),delete this._openPromise},n.retry=function(){var e=tr(this).connection;if(!e)throw new Error("no connection established");if(e.cannot("retry"))throw new Error("retrying not allowed when not disconnected. the connection is now ".concat(e.current));return e.retry()},n.pause=function(){var e=tr(this).connection;e&&e.can("pause")&&e.pause()},n.resume=function(){var e=tr(this).connection;e&&e.can("resume")&&e.resume()},n._registerPending=function(e){tr(this).pendingClients.add(e)},n._deregisterPending=function(e){tr(this).pendingClients.delete(e)},n._register=function(e){tr(this).clients.add(e)},n._deregister=function(e){var t=tr(this);t.clients.delete(e),t.clients.size+t.pendingClients.size===0&&this._close()},n._dispatchCommand=function(e){return Rr(this._plugins.beforeCommandDispatch,[e,this]).then((function(t){return!!t&&Fr("[WARN] Unexpected message received: %O",nr(e))}))},r}(G),Yr=Promise,qr=i((function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var r=new Uint8Array(16);e.exports=function(){return t(r),r}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}})),zr=[],Wr=0;Wr<256;++Wr)zr[Wr]=(Wr+256).toString(16).substr(1);var Gr=function(e,t){var r=t||0,n=zr;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")};var $r=function(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||qr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[n+o]=i[o];return t||Gr(i)},Jr=i((function(e){e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,s,a=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(a.push(n.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}));n(Jr);var Zr=n(i((function(e){e.exports=function(e,t){return yt(e)||Jr(e,t)||Q(e,t)||vt()},e.exports.__esModule=!0,e.exports.default=e.exports}))),Xr=i((function(e,t){!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n<e.length;n++)r[e.charCodeAt(n)]=n;t.encode=function(t){var r,n=new Uint8Array(t),i=n.length,o="";for(r=0;r<i;r+=3)o+=e[n[r]>>2],o+=e[(3&n[r])<<4|n[r+1]>>4],o+=e[(15&n[r+1])<<2|n[r+2]>>6],o+=e[63&n[r+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=function(e){var t,n,i,o,s,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t<u;t+=4)n=r[e.charCodeAt(t)],i=r[e.charCodeAt(t+1)],o=r[e.charCodeAt(t+2)],s=r[e.charCodeAt(t+3)],l[c++]=n<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return f}}()})),Qr=Xr.encode,Hr=Xr.decode;var Kr=function(){this.__data__=[],this.size=0};var en=function(e,t){return e===t||e!=e&&t!=t};var tn=function(e,t){for(var r=e.length;r--;)if(en(e[r][0],t))return r;return-1},rn=Array.prototype.splice;var nn=function(e){var t=this.__data__,r=tn(t,e);return!(r<0)&&(r==t.length-1?t.pop():rn.call(t,r,1),--this.size,!0)};var on=function(e){var t=this.__data__,r=tn(t,e);return r<0?void 0:t[r][1]};var sn=function(e){return tn(this.__data__,e)>-1};var an=function(e,t){var r=this.__data__,n=tn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function un(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}un.prototype.clear=Kr,un.prototype.delete=nn,un.prototype.get=on,un.prototype.has=sn,un.prototype.set=an;var cn=un;var fn=function(){this.__data__=new cn,this.size=0};var ln=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r};var hn=function(e){return this.__data__.get(e)};var pn,dn=function(e){return this.__data__.has(e)},mn=Ie["__core-js_shared__"],gn=(pn=/[^.]+$/.exec(mn&&mn.keys&&mn.keys.IE_PROTO||""))?"Symbol(src)_1."+pn:"";var yn=function(e){return!!gn&&gn in e},vn=Function.prototype.toString;var bn=function(e){if(null!=e){try{return vn.call(e)}catch(e){}try{return e+""}catch(e){}}return""},wn=/^\[object .+?Constructor\]$/,_n=Function.prototype,En=Object.prototype,Tn=_n.toString,On=En.hasOwnProperty,Sn=RegExp("^"+Tn.call(On).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var An=function(e){return!(!ft(e)||yn(e))&&(lt(e)?Sn:wn).test(bn(e))};var In=function(e,t){return null==e?void 0:e[t]};var xn=function(e,t){var r=In(e,t);return An(r)?r:void 0},Cn=xn(Ie,"Map"),Mn=xn(Object,"create");var Pn=function(){this.__data__=Mn?Mn(null):{},this.size=0};var kn=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},jn=Object.prototype.hasOwnProperty;var Rn=function(e){var t=this.__data__;if(Mn){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return jn.call(t,e)?t[e]:void 0},Nn=Object.prototype.hasOwnProperty;var Ln=function(e){var t=this.__data__;return Mn?void 0!==t[e]:Nn.call(t,e)};var Dn=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Mn&&void 0===t?"__lodash_hash_undefined__":t,this};function Fn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Fn.prototype.clear=Pn,Fn.prototype.delete=kn,Fn.prototype.get=Rn,Fn.prototype.has=Ln,Fn.prototype.set=Dn;var Un=Fn;var Bn=function(){this.size=0,this.__data__={hash:new Un,map:new(Cn||cn),string:new Un}};var Vn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Yn=function(e,t){var r=e.__data__;return Vn(t)?r["string"==typeof t?"string":"hash"]:r.map};var qn=function(e){var t=Yn(this,e).delete(e);return this.size-=t?1:0,t};var zn=function(e){return Yn(this,e).get(e)};var Wn=function(e){return Yn(this,e).has(e)};var Gn=function(e,t){var r=Yn(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function $n(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}$n.prototype.clear=Bn,$n.prototype.delete=qn,$n.prototype.get=zn,$n.prototype.has=Wn,$n.prototype.set=Gn;var Jn=$n;var Zn=function(e,t){var r=this.__data__;if(r instanceof cn){var n=r.__data__;if(!Cn||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Jn(n)}return r.set(e,t),this.size=r.size,this};function Xn(e){var t=this.__data__=new cn(e);this.size=t.size}Xn.prototype.clear=fn,Xn.prototype.delete=ln,Xn.prototype.get=hn,Xn.prototype.has=dn,Xn.prototype.set=Zn;var Qn=Xn;var Hn=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};var Kn=function(e){return this.__data__.has(e)};function ei(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Jn;++t<r;)this.add(e[t])}ei.prototype.add=ei.prototype.push=Hn,ei.prototype.has=Kn;var ti=ei;var ri=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1};var ni=function(e,t){return e.has(t)};var ii=function(e,t,r,n,i,o){var s=1&r,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e),f=o.get(t);if(c&&f)return c==t&&f==e;var l=-1,h=!0,p=2&r?new ti:void 0;for(o.set(e,t),o.set(t,e);++l<a;){var d=e[l],m=t[l];if(n)var g=s?n(m,d,l,t,e,o):n(d,m,l,e,t,o);if(void 0!==g){if(g)continue;h=!1;break}if(p){if(!ri(t,(function(e,t){if(!ni(p,t)&&(d===e||i(d,e,r,n,o)))return p.push(t)}))){h=!1;break}}else if(d!==m&&!i(d,m,r,n,o)){h=!1;break}}return o.delete(e),o.delete(t),h},oi=Ie.Uint8Array;var si=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r};var ai=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r},ui=xe?xe.prototype:void 0,ci=ui?ui.valueOf:void 0;var fi=function(e,t,r,n,i,o,s){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new oi(e),new oi(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return en(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=si;case"[object Set]":var u=1&n;if(a||(a=ai),e.size!=t.size&&!u)return!1;var c=s.get(e);if(c)return c==t;n|=2,s.set(e,t);var f=ii(a(e),a(t),n,i,o,s);return s.delete(e),f;case"[object Symbol]":if(ci)return ci.call(e)==ci.call(t)}return!1};var li=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e};var hi=function(e,t,r){var n=t(e);return ze(e)?n:li(n,r(e))};var pi=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var s=e[r];t(s,r,e)&&(o[i++]=s)}return o};var di=function(){return[]},mi=Object.prototype.propertyIsEnumerable,gi=Object.getOwnPropertySymbols,yi=gi?function(e){return null==e?[]:(e=Object(e),pi(gi(e),(function(t){return mi.call(e,t)})))}:di;var vi=function(e){return hi(e,pt,yi)},bi=Object.prototype.hasOwnProperty;var wi=function(e,t,r,n,i,o){var s=1&r,a=vi(e),u=a.length;if(u!=vi(t).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in t:bi.call(t,f)))return!1}var l=o.get(e),h=o.get(t);if(l&&h)return l==t&&h==e;var p=!0;o.set(e,t),o.set(t,e);for(var d=s;++c<u;){var m=e[f=a[c]],g=t[f];if(n)var y=s?n(g,m,f,t,e,o):n(m,g,f,e,t,o);if(!(void 0===y?m===g||i(m,g,r,n,o):y)){p=!1;break}d||(d="constructor"==f)}if(p&&!d){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(p=!1)}return o.delete(e),o.delete(t),p},_i=xn(Ie,"DataView"),Ei=xn(Ie,"Promise"),Ti=xn(Ie,"Set"),Oi=xn(Ie,"WeakMap"),Si=bn(_i),Ai=bn(Cn),Ii=bn(Ei),xi=bn(Ti),Ci=bn(Oi),Mi=De;(_i&&"[object DataView]"!=Mi(new _i(new ArrayBuffer(1)))||Cn&&"[object Map]"!=Mi(new Cn)||Ei&&"[object Promise]"!=Mi(Ei.resolve())||Ti&&"[object Set]"!=Mi(new Ti)||Oi&&"[object WeakMap]"!=Mi(new Oi))&&(Mi=function(e){var t=De(e),r="[object Object]"==t?e.constructor:void 0,n=r?bn(r):"";if(n)switch(n){case Si:return"[object DataView]";case Ai:return"[object Map]";case Ii:return"[object Promise]";case xi:return"[object Set]";case Ci:return"[object WeakMap]"}return t});var Pi=Mi,ki=Object.prototype.hasOwnProperty;var ji=function(e,t,r,n,i,o){var s=ze(e),a=ze(t),u=s?"[object Array]":Pi(e),c=a?"[object Array]":Pi(t),f="[object Object]"==(u="[object Arguments]"==u?"[object Object]":u),l="[object Object]"==(c="[object Arguments]"==c?"[object Object]":c),h=u==c;if(h&&Ge(e)){if(!Ge(t))return!1;s=!0,f=!1}if(h&&!f)return o||(o=new Qn),s||tt(e)?ii(e,t,r,n,i,o):fi(e,t,u,r,n,i,o);if(!(1&r)){var p=f&&ki.call(e,"__wrapped__"),d=l&&ki.call(t,"__wrapped__");if(p||d){var m=p?e.value():e,g=d?t.value():t;return o||(o=new Qn),i(m,g,r,n,o)}}return!!h&&(o||(o=new Qn),wi(e,t,r,n,i,o))};var Ri=function e(t,r,n,i,o){return t===r||(null==t||null==r||!Fe(t)&&!Fe(r)?t!=t&&r!=r:ji(t,r,n,i,e,o))};var Ni=function(e,t,r,n){var i=r.length,o=i,s=!n;if(null==e)return!o;for(e=Object(e);i--;){var a=r[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){var u=(a=r[i])[0],c=e[u],f=a[1];if(s&&a[2]){if(void 0===c&&!(u in e))return!1}else{var l=new Qn;if(n)var h=n(c,f,u,e,t,l);if(!(void 0===h?Ri(f,c,3,n,l):h))return!1}}return!0};var Li=function(e){return e==e&&!ft(e)};var Di=function(e){for(var t=pt(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Li(i)]}return t};var Fi=function(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}};var Ui=function(e){var t=Di(e);return 1==t.length&&t[0][2]?Fi(t[0][0],t[0][1]):function(r){return r===e||Ni(r,e,t)}};var Bi=function(e){return"symbol"==typeof e||Fe(e)&&"[object Symbol]"==De(e)},Vi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Yi=/^\w*$/;var qi=function(e,t){if(ze(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Bi(e))||(Yi.test(e)||!Vi.test(e)||null!=t&&e in Object(t))};function zi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(zi.Cache||Jn),r}zi.Cache=Jn;var Wi=zi;var Gi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$i=/\\(\\)?/g,Ji=function(e){var t=Wi(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Gi,(function(e,r,n,i){t.push(n?i.replace($i,"$1"):r||e)})),t})),Zi=xe?xe.prototype:void 0,Xi=Zi?Zi.toString:void 0;var Qi=function e(t){if("string"==typeof t)return t;if(ze(t))return Ee(t,e)+"";if(Bi(t))return Xi?Xi.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r};var Hi=function(e){return null==e?"":Qi(e)};var Ki=function(e,t){return ze(e)?e:qi(e,t)?[e]:Ji(Hi(e))};var eo=function(e){if("string"==typeof e||Bi(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var to=function(e,t){for(var r=0,n=(t=Ki(t,e)).length;null!=e&&r<n;)e=e[eo(t[r++])];return r&&r==n?e:void 0};var ro=function(e,t,r){var n=null==e?void 0:to(e,t);return void 0===n?r:n};var no=function(e,t){return null!=e&&t in Object(e)};var io=function(e,t,r){for(var n=-1,i=(t=Ki(t,e)).length,o=!1;++n<i;){var s=eo(t[n]);if(!(o=null!=e&&r(e,s)))break;e=e[s]}return o||++n!=i?o:!!(i=null==e?0:e.length)&&Ze(i)&&Je(s,i)&&(ze(e)||qe(e))};var oo=function(e,t){return null!=e&&io(e,t,no)};var so=function(e,t){return qi(e)&&Li(t)?Fi(eo(e),t):function(r){var n=ro(r,e);return void 0===n&&n===t?oo(r,e):Ri(t,n,3)}};var ao=function(e){return e};var uo=function(e){return function(t){return null==t?void 0:t[e]}};var co=function(e){return function(t){return to(t,e)}};var fo=function(e){return qi(e)?uo(eo(e)):co(e)};var lo=function(e){return"function"==typeof e?e:null==e?ao:"object"==typeof e?ze(e)?so(e[0],e[1]):Ui(e):fo(e)};var ho=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var po=function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n<i;)o[n]=e[n+t];return o};var mo=function(e,t){return t.length<2?e:to(e,po(t,0,-1))};var go=function(e,t){return t=Ki(t,e),null==(e=mo(e,t))||delete e[eo(ho(t))]},yo=Array.prototype.splice;var vo=function(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;Je(i)?yo.call(e,i,1):go(e,i)}}return e};var bo=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],o=e.length;for(t=lo(t);++n<o;){var s=e[n];t(s,n,e)&&(r.push(s),i.push(n))}return vo(e,i),r},wo=Object.prototype.hasOwnProperty;var _o=function(e){if(null==e)return!0;if(ht(e)&&(ze(e)||"string"==typeof e||"function"==typeof e.splice||Ge(e)||tt(e)||qe(e)))return!e.length;var t=Pi(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(ot(e))return!ct(e).length;for(var r in e)if(wo.call(e,r))return!1;return!0};var Eo=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e},To=function(){try{var e=xn(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var Oo=function(e,t,r){"__proto__"==t&&To?To(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r},So=Object.prototype.hasOwnProperty;var Ao=function(e,t,r){var n=e[t];So.call(e,t)&&en(n,r)&&(void 0!==r||t in e)||Oo(e,t,r)};var Io=function(e,t,r,n){var i=!r;r||(r={});for(var o=-1,s=t.length;++o<s;){var a=t[o],u=n?n(r[a],e[a],a,r,e):void 0;void 0===u&&(u=e[a]),i?Oo(r,a,u):Ao(r,a,u)}return r};var xo=function(e,t){return e&&Io(t,pt(t),e)};var Co=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t},Mo=Object.prototype.hasOwnProperty;var Po=function(e){if(!ft(e))return Co(e);var t=ot(e),r=[];for(var n in e)("constructor"!=n||!t&&Mo.call(e,n))&&r.push(n);return r};var ko=function(e){return ht(e)?nt(e,!0):Po(e)};var jo=function(e,t){return e&&Io(t,ko(t),e)},Ro=i((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r?Ie.Buffer:void 0,o=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=o?o(r):new e.constructor(r);return e.copy(n),n}}));var No=function(e,t){return Io(e,yi(e),t)},Lo=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)li(t,yi(e)),e=At(e);return t}:di;var Do=function(e,t){return Io(e,Lo(e),t)};var Fo=function(e){return hi(e,ko,Lo)},Uo=Object.prototype.hasOwnProperty;var Bo=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Uo.call(e,"index")&&(r.index=e.index,r.input=e.input),r};var Vo=function(e){var t=new e.constructor(e.byteLength);return new oi(t).set(new oi(e)),t};var Yo=function(e,t){var r=t?Vo(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)},qo=/\w*$/;var zo=function(e){var t=new e.constructor(e.source,qo.exec(e));return t.lastIndex=e.lastIndex,t},Wo=xe?xe.prototype:void 0,Go=Wo?Wo.valueOf:void 0;var $o=function(e){return Go?Object(Go.call(e)):{}};var Jo=function(e,t){var r=t?Vo(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)};var Zo=function(e,t,r){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return Vo(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return Yo(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Jo(e,r);case"[object Map]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return zo(e);case"[object Set]":return new n;case"[object Symbol]":return $o(e)}},Xo=Object.create,Qo=function(){function e(){}return function(t){if(!ft(t))return{};if(Xo)return Xo(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();var Ho=function(e){return"function"!=typeof e.constructor||ot(e)?{}:Qo(At(e))};var Ko=function(e){return Fe(e)&&"[object Map]"==Pi(e)},es=Ke&&Ke.isMap,ts=es?He(es):Ko;var rs=function(e){return Fe(e)&&"[object Set]"==Pi(e)},ns=Ke&&Ke.isSet,is=ns?He(ns):rs,os={};os["[object Arguments]"]=os["[object Array]"]=os["[object ArrayBuffer]"]=os["[object DataView]"]=os["[object Boolean]"]=os["[object Date]"]=os["[object Float32Array]"]=os["[object Float64Array]"]=os["[object Int8Array]"]=os["[object Int16Array]"]=os["[object Int32Array]"]=os["[object Map]"]=os["[object Number]"]=os["[object Object]"]=os["[object RegExp]"]=os["[object Set]"]=os["[object String]"]=os["[object Symbol]"]=os["[object Uint8Array]"]=os["[object Uint8ClampedArray]"]=os["[object Uint16Array]"]=os["[object Uint32Array]"]=!0,os["[object Error]"]=os["[object Function]"]=os["[object WeakMap]"]=!1;var ss=function e(t,r,n,i,o,s){var a,u=1&r,c=2&r,f=4&r;if(n&&(a=o?n(t,i,o,s):n(t)),void 0!==a)return a;if(!ft(t))return t;var l=ze(t);if(l){if(a=Bo(t),!u)return ge(t,a)}else{var h=Pi(t),p="[object Function]"==h||"[object GeneratorFunction]"==h;if(Ge(t))return Ro(t,u);if("[object Object]"==h||"[object Arguments]"==h||p&&!o){if(a=c||p?{}:Ho(t),!u)return c?Do(t,jo(a,t)):No(t,xo(a,t))}else{if(!os[h])return o?t:{};a=Zo(t,h,u)}}s||(s=new Qn);var d=s.get(t);if(d)return d;s.set(t,a),is(t)?t.forEach((function(i){a.add(e(i,r,n,i,t,s))})):ts(t)&&t.forEach((function(i,o){a.set(o,e(i,r,n,o,t,s))}));var m=l?void 0:(f?c?Fo:vi:c?ko:pt)(t);return Eo(m||t,(function(i,o){m&&(i=t[o=i]),Ao(a,o,e(i,r,n,o,t,s))})),a};var as=function(e){return ss(e,5)};var us=function(e){return function(t,r,n){var i=Object(t);if(!ht(t)){var o=lo(r);t=pt(t),r=function(e){return o(i[e],e,i)}}var s=e(t,r,n);return s>-1?i[o?t[s]:s]:void 0}};var cs=function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o<i;)if(t(e[o],o,e))return o;return-1},fs=/\s/;var ls=function(e){for(var t=e.length;t--&&fs.test(e.charAt(t)););return t},hs=/^\s+/;var ps=function(e){return e?e.slice(0,ls(e)+1).replace(hs,""):e},ds=/^[-+]0x[0-9a-f]+$/i,ms=/^0b[01]+$/i,gs=/^0o[0-7]+$/i,ys=parseInt;var vs=function(e){if("number"==typeof e)return e;if(Bi(e))return NaN;if(ft(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ft(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ps(e);var r=ms.test(e);return r||gs.test(e)?ys(e.slice(2),r?2:8):ds.test(e)?NaN:+e};var bs=function(e){return e?(e=vs(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var ws=function(e){var t=bs(e),r=t%1;return t==t?r?t-r:t:0},_s=Math.max;var Es,Ts=us((function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:ws(r);return i<0&&(i=_s(n+i,0)),cs(e,lo(t),i)})),Os=Object.freeze({__proto__:null,UNREAD_MESSAGES_COUNT_UPDATE:"unreadmessagescountupdate",CLOSE:"close",CONFLICT:"conflict",CONVERSATION_INFO_UPDATED:"conversationinfoupdated",UNHANDLED_MESSAGE:"unhandledmessage",INVITED:"invited",KICKED:"kicked",MEMBERS_JOINED:"membersjoined",MEMBERS_LEFT:"membersleft",MEMBER_INFO_UPDATED:"memberinfoupdated",BLOCKED:"blocked",UNBLOCKED:"unblocked",MEMBERS_BLOCKED:"membersblocked",MEMBERS_UNBLOCKED:"membersunblocked",MUTED:"muted",UNMUTED:"unmuted",MEMBERS_MUTED:"membersmuted",MEMBERS_UNMUTED:"membersunmuted",MESSAGE:"message",MESSAGE_RECALL:"messagerecall",MESSAGE_UPDATE:"messageupdate",LAST_DELIVERED_AT_UPDATE:"lastdeliveredatupdate",LAST_READ_AT_UPDATE:"lastreadatupdate",INFO_UPDATED:"infoupdated"});function Ss(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function As(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ss(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ss(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Is={NONE:Symbol("none"),SENDING:Symbol("sending"),SENT:Symbol("sent"),DELIVERED:Symbol("delivered"),FAILED:Symbol("failed")};Object.freeze(Is);var xs,Cs=(d(Es={},Is.NONE,!0),d(Es,Is.SENDING,!0),d(Es,Is.SENT,!0),d(Es,Is.DELIVERED,!0),d(Es,Is.READ,!0),d(Es,Is.FAILED,!0),Es),Ms=function(){function e(e){Object.assign(this,{content:e},{id:$r(),cid:null,timestamp:new Date,from:void 0,mentionList:[],mentionedAll:!1,_mentioned:!1}),this._setStatus(Is.NONE)}var t=e.prototype;return t.getPayload=function(){return this.content},t._toJSON=function(){return{id:this.id,cid:this.cid,from:this.from,timestamp:this.timestamp,deliveredAt:this.deliveredAt,updatedAt:this.updatedAt,mentionList:this.mentionList,mentionedAll:this.mentionedAll,mentioned:this.mentioned}},t.toJSON=function(){return As(As({},this._toJSON()),{},{data:this.content})},t.toFullJSON=function(){var e=this.content,t=this.id,r=this.cid,n=this.from,i=this.timestamp,o=this.deliveredAt,s=this._updatedAt,a=this.mentionList,u=this.mentionedAll;return{data:e,id:t,cid:r,from:n,timestamp:Gt(i),deliveredAt:Gt(o),updatedAt:Gt(s),mentionList:a,mentionedAll:u}},t._setStatus=function(e){if(!Cs[e])throw new Error("Invalid message status");this._status=e},t._updateMentioned=function(e){this._mentioned=this.from!==e&&(this.mentionedAll||this.mentionList.indexOf(e)>-1)},t.getMentionList=function(){return this.mentionList},t.setMentionList=function(e){return this.mentionList=ir(e),this},t.mentionAll=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.mentionedAll=Boolean(e),this},e.validate=function(){return!0},e.parse=function(e,t){return t||new this(e)},wt(e,[{key:"status",get:function(){return this._status}},{key:"timestamp",get:function(){return this._timestamp},set:function(e){this._timestamp=Wt(e)}},{key:"deliveredAt",get:function(){return this._deliveredAt},set:function(e){this._deliveredAt=Wt(e)}},{key:"updatedAt",get:function(){return this._updatedAt||this.timestamp},set:function(e){this._updatedAt=Wt(e)}},{key:"mentioned",get:function(){return this._mentioned}}]),e}(),Ps=function(e){if("number"!=typeof e)throw new TypeError("".concat(e," is not a Number"));return function(t){t.TYPE=e,t.validate=function(t){return t._lctype===e},t.prototype._getType=function(){return{_lctype:e}}}},ks=function(e){if("string"!=typeof e){if(!Array.isArray(e))throw new TypeError("".concat(e," is not an Array"));if(e.some((function(e){return"string"!=typeof e})))throw new TypeError("fields contains non-string typed member")}return function(t){var r=Xt?Qt(t,"_customFields"):t._customFields;r=Array.isArray(r)?r:[],t._customFields=r.concat(e)}},js=function(e){Xt&&(e.parse=Qt(e,"parse"))};function Rs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ns(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Rs(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rs(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ls,Ds=ks(["_lctext","_lcattrs"])(xs=function(e){function t(){return e.apply(this,arguments)||this}ie(t,e);var r=t.prototype;return r.setText=function(e){return this._lctext=e,this},r.getText=function(){return this._lctext},r.setAttributes=function(e){return this._lcattrs=e,this},r.getAttributes=function(){return this._lcattrs},r._getCustomFields=function(){var e=this;return(Array.isArray(this.constructor._customFields)?this.constructor._customFields:[]).reduce((function(t,r){return"string"!=typeof r||(t[r]=e[r]),t}),{})},r._getType=function(){throw new Error("not implemented")},r.getPayload=function(){return rr(Ns(Ns({_lctext:this.getText(),_lcattrs:this.getAttributes()},this._getCustomFields()),this._getType()))},r.toJSON=function(){var t=this.type,r=this.text,n=this.attributes,i=this.summary;return Ns(Ns({},e.prototype._toJSON.call(this)),{},{type:t,text:r,attributes:n,summary:i})},r.toFullJSON=function(){return Ns(Ns({},e.prototype.toFullJSON.call(this)),{},{data:this.getPayload()})},t.parse=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new this;r.content=t;var n=Xt?Qt(r.constructor,"_customFields"):r.constructor._customFields,i=Array.isArray(n)?n:[];return i=i.reduce((function(e,r){return"string"!=typeof r||(e[r]=t[r]),e}),{}),Object.assign(r,i),e.parse.call(this,t,r)},wt(t,[{key:"type",get:function(){return this.constructor.TYPE}},{key:"text",get:function(){return this.getText()},set:function(e){return this.setText(e)}},{key:"attributes",get:function(){return this.getAttributes()},set:function(e){return this.setAttributes(e)}},{key:"summary",get:function(){return this.text}}]),t}(Ms))||xs,Fs=Ps(-127)(Ls=js(Ls=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),wt(t,[{key:"summary",get:function(){return"[该消息已撤回]"}}]),t}(Ds))||Ls)||Ls,Us=["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"];function Bs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Vs(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Bs(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Bs(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ys=me("LC:Conversation"),qs=function(e){var t,r,n=e.getPayload();return n instanceof ArrayBuffer?r=n:t="string"!=typeof n?JSON.stringify(n):n,{msg:t,binaryMsg:r}},zs=M.QueryDirection,Ws=zs.NEW,Gs={NEW_TO_OLD:zs.OLD,OLD_TO_NEW:Ws};Object.freeze(Gs);var $s=function(e){function t(t,r){var n,i=t.id,o=t.lastMessageAt,s=t.lastMessage,a=t.lastDeliveredAt,u=t.lastReadAt,c=t.unreadMessagesCount,f=void 0===c?0:c,l=t.members,h=void 0===l?[]:l,p=t.mentioned,d=void 0!==p&&p,m=te(t,Us);return n=e.call(this)||this,Object.assign(re(n),Vs({id:i,lastMessageAt:o,lastMessage:s,members:h},m)),n.members=Array.from(new Set(n.members)),Object.assign(tr(re(n)),{messagesWaitingForReceipt:{},lastDeliveredAt:a,lastReadAt:u,unreadMessagesCount:f,mentioned:d}),n._client=r,Ys.enabled&&dt(Os).forEach((function(e){return n.on(e,(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return n._debug("".concat(e," event emitted. %o"),r)}))})),kr(n._client._plugins.onConversationCreate,re(n)),n}ie(t,e);var r=t.prototype;return r._setUnreadMessagesMentioned=function(e){tr(this).unreadMessagesMentioned=Boolean(e)},r._setLastDeliveredAt=function(e){var t=Wt(e);t<tr(this).lastDeliveredAt||(tr(this).lastDeliveredAt=t,this.emit("lastdeliveredatupdate"))},r._setLastReadAt=function(e){var t=Wt(e);t<tr(this).lastReadAt||(tr(this).lastReadAt=t,this.emit("lastreadatupdate"))},r.toFullJSON=function(){var e=this.id,t=this.members,r=this.lastMessageAt,n=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount;return{id:e,members:t,lastMessageAt:Gt(r),lastDeliveredAt:Gt(n),lastReadAt:Gt(i),lastMessage:o?o.toFullJSON():void 0,unreadMessagesCount:s}},r.toJSON=function(){var e=this.id,t=this.members,r=this.lastMessageAt,n=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount,a=this.unreadMessagesMentioned;return{id:e,members:t,lastMessageAt:r,lastDeliveredAt:n,lastReadAt:i,lastMessage:o?o.toJSON():void 0,unreadMessagesCount:s,unreadMessagesMentioned:a}},r._debug=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];Ys.apply(void 0,t.concat(["[".concat(this.id,"]")]))},r._send=function(e){var t;null===e.cmd&&(e.cmd="conv"),"conv"===e.cmd&&null===e.convMessage&&(e.convMessage=new x),e.convMessage&&null===e.convMessage.cid&&(e.convMessage.cid=this.id);for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return(t=this._client)._send.apply(t,[e].concat(n))},r.send=function(){var e=$(ae.mark((function e(t,r){var n,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug(t,"send"),t instanceof Ms){e.next=3;break}throw new TypeError("".concat(t," is not a Message"));case 3:return n=Vs(Vs(Vs({},t.constructor.sendOptions),"function"==typeof t.constructor.getSendOptions?t.constructor.getSendOptions(t):{}),r),i=n.transient,o=n.receipt,s=n.priority,a=n.pushData,u=n.will,o&&(this.transient?console.warn("receipt option is ignored as the conversation is transient."):i?console.warn("receipt option is ignored as the message is sent transiently."):this.members.length>2&&console.warn("receipt option is recommended to be used in one-on-one conversation.")),s&&!this.transient&&console.warn("priority option is ignored as the conversation is not transient."),Object.assign(t,{cid:this.id,from:this._client.id}),t._setStatus(Is.SENDING),c=qs(t),f=c.msg,l=c.binaryMsg,h=new D({cmd:"direct",directMessage:new S({msg:f,binaryMsg:l,cid:this.id,r:o,transient:i,dt:t.id,pushData:JSON.stringify(a),will:u,mentionPids:t.mentionList,mentionAll:t.mentionedAll}),priority:s}),e.prev=10,e.next=13,this._send(h);case 13:if(p=e.sent,d=p.ackMessage,m=d.uid,g=d.t,y=d.code,v=d.reason,b=d.appCode,null===y){e.next=17;break}throw Tr({code:y,reason:v,appCode:b});case 17:return Object.assign(t,{id:m,timestamp:g}),i||(this.lastMessage=t,this.lastMessageAt=t.timestamp),t._setStatus(Is.SENT),o&&(tr(this).messagesWaitingForReceipt[t.id]=t),e.abrupt("return",t);case 24:throw e.prev=24,e.t0=e.catch(10),t._setStatus(Is.FAILED),e.t0;case 28:case"end":return e.stop()}}),e,this,[[10,24]])})));return function(t,r){return e.apply(this,arguments)}}(),r._update=function(){var e=$(ae.mark((function e(t,r,n){var i,o,s,a,u,c,f,l;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("patch %O %O %O",t,r,n),!(t instanceof Ms)){e.next=8;break}if(t.from===this._client.id){e.next=4;break}throw new Error("Updating message from others is not allowed");case 4:if(t.status===Is.SENT||t.status===Is.DELIVERED){e.next=6;break}throw new Error("Message is not sent");case 6:e.next=10;break;case 8:if(t.id&&t.timestamp){e.next=10;break}throw new TypeError("".concat(t," is not a Message"));case 10:return n||(s=qs(r),i=s.msg,o=s.binaryMsg),e.next=13,this._send(new D({cmd:Y.patch,op:q.modify,patchMessage:new U({patches:[new B({cid:this.id,mid:t.id,timestamp:Number(t.timestamp),recall:n,data:i,binaryMsg:o,mentionPids:r.mentionList,mentionAll:r.mentionedAll})],lastPatchTime:this._client._lastPatchTime})}));case 13:return a=t.id,u=t.cid,c=t.timestamp,f=t.from,l=t._status,Object.assign(r,{id:a,cid:u,timestamp:c,from:f,_status:l}),this.lastMessage&&this.lastMessage.id===r.id&&(this.lastMessage=r),e.abrupt("return",r);case 17:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.count=function(){var e=$(ae.mark((function e(){var t;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("count"),e.next=3,this._send(new D({op:"count"}));case 3:return t=e.sent,e.abrupt("return",t.convMessage.count);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r._addMembers=function(){},r._removeMembers=function(){},r.update=function(){var e=$(ae.mark((function e(t,r){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r instanceof Ms){e.next=2;break}throw new TypeError("".concat(r," is not a Message"));case 2:return e.abrupt("return",this._update(t,r,!1));case 3:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.recall=function(){var e=$(ae.mark((function e(t){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._update(t,new Fs,!0));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.queryMessages=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,m,g,y=this,v=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=v.length>0&&void 0!==v[0]?v[0]:{},this._debug("query messages %O",t),r=t.beforeTime,n=t.beforeMessageId,i=t.afterTime,o=t.afterMessageId,s=t.limit,a=t.direction,u=t.type,c=t.startTime,f=t.startMessageId,l=t.startClosed,h=t.endTime,p=t.endMessageId,d=t.endClosed,!(n||r||o||i)){e.next=6;break}return console.warn("DEPRECATION: queryMessages options beforeTime, beforeMessageId, afterTime and afterMessageId are deprecated in favor of startTime, startMessageId, endTime and endMessageId."),e.abrupt("return",this.queryMessages({startTime:r,startMessageId:n,endTime:i,endMessageId:o,limit:s}));case 6:if(!f||c){e.next=8;break}throw new Error("query option startMessageId must be used with option startTime");case 8:if(!p||h){e.next=10;break}throw new Error("query option endMessageId must be used with option endTime");case 10:return(m={t:c,mid:f,tIncluded:l,tt:h,tmid:p,ttIncluded:d,l:s,lctype:u}).t instanceof Date&&(m.t=m.t.getTime()),m.tt instanceof Date&&(m.tt=m.tt.getTime()),void 0!==a?m.direction=a:m.tt>m.t&&(m.direction=Gs.OLD_TO_NEW),e.next=16,this._send(new D({cmd:"logs",logsMessage:new M(Object.assign(m,{cid:this.id}))}));case 16:return g=e.sent,e.abrupt("return",Promise.all(g.logsMessage.logs.map(function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.msgId,n=t.timestamp,i=t.patchTimestamp,o=t.from,s=t.ackAt,a=t.readAt,u=t.data,c=t.mentionAll,f=t.mentionPids,l=t.bin,h={data:u,bin:l,id:r,cid:y.id,timestamp:n,from:o,deliveredAt:s,updatedAt:i,mentionList:f,mentionedAll:c},e.next=4,y._client.parseMessage(h);case 4:return p=e.sent,d=Is.SENT,2===y.members.length&&(s&&(d=Is.DELIVERED),s&&y._setLastDeliveredAt(s),a&&y._setLastReadAt(a)),p._setStatus(d),e.abrupt("return",p);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 18:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.createMessagesIterator=function(){var e,t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.beforeTime,i=r.beforeMessageId,o=r.limit;return{next:function(){return(e=void 0===e?t.queryMessages({limit:o,startTime:n,startMessageId:i}):e.then((function(e){return 0===e.length||e.length<o?[]:t.queryMessages({startTime:e[0].timestamp,startMessageId:e[0].id,limit:o})}))).then((function(e){return{value:Array.from(e),done:0===e.length||e.length<o}}))}}},r.read=function(){var e=$(ae.mark((function e(){var t;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.unreadMessagesCount=0,this._setUnreadMessagesMentioned(!1),!this.transient){e.next=4;break}return e.abrupt("return",this);case 4:return t=this._client,tr(t).readConversationsBuffer||(tr(t).readConversationsBuffer=new Set),tr(t).readConversationsBuffer.add(this),t._doSendRead(),e.abrupt("return",this);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r._handleReceipt=function(e){var t=e.messageId,r=e.timestamp;e.read?this._setLastReadAt(r):this._setLastDeliveredAt(r);var n=tr(this).messagesWaitingForReceipt,i=n[t];i&&(i._setStatus(Is.DELIVERED),i.deliveredAt=r,delete n[t])},r.fetchReceiptTimestamps=function(){var e=$(ae.mark((function e(){var t,r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.transient&&!this.system){e.next=2;break}return e.abrupt("return",this);case 2:return e.next=4,this._send(new D({op:"max_read"}));case 4:return t=e.sent,r=t.convMessage,n=r.maxReadTimestamp,i=r.maxAckTimestamp,this._setLastDeliveredAt(i),this._setLastReadAt(n),e.abrupt("return",this);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r._fetchAllReceiptTimestamps=function(){if(this.transient||this.system)return this;var e=new x({queryAllMembers:!0});return this._send(new D({op:"max_read",convMessage:e})).then((function(e){return e.convMessage.maxReadTuples.filter((function(e){return e.maxAckTimestamp||e.maxReadTimestamp})).map((function(e){var t=e.pid,r=e.maxAckTimestamp,n=e.maxReadTimestamp;return{pid:t,lastDeliveredAt:Wt(r),lastReadAt:Wt(n)}}))}))},wt(t,[{key:"unreadMessagesMentioned",get:function(){return tr(this).unreadMessagesMentioned}},{key:"unreadMessagesCount",get:function(){return tr(this).unreadMessagesCount},set:function(e){e!==this.unreadMessagesCount&&(tr(this).unreadMessagesCount=e,this._client.emit("unreadmessagescountupdate",[this]))}},{key:"lastMessageAt",get:function(){return this._lastMessageAt},set:function(e){var t=Wt(e);t<=this._lastMessageAt||(this._lastMessageAt=t)}},{key:"lastDeliveredAt",get:function(){return 2!==this.members.length?null:tr(this).lastDeliveredAt}},{key:"lastReadAt",get:function(){return 2!==this.members.length?null:tr(this).lastReadAt}}]),t}(G),Js=me("LC:SignatureFactoryRunner");function Zs(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.signature,r=e.timestamp,n=e.nonce;if("string"!=typeof t||"number"!=typeof r||"string"!=typeof n)throw new Error("malformed signature");return{signature:t,timestamp:r,nonce:n}}var Xs=function(e,t){return Promise.resolve().then((function(){return Js("call signatureFactory with %O",t),e.apply(void 0,K(t))})).then(qt((function(e){return Js("sign result %O",e)})),(function(e){throw e.message="sign error: ".concat(e.message),Js(e),e})).then(Zs)},Qs=["pids"],Hs=["creator","createdAt","updatedAt","transient","system","muted","mutedMembers"];function Ks(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ea(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ks(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ks(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ta=function(e){return{successfulClientIds:e.allowedPids,failures:e.failedPids.map((function(e){var t=e.pids,r=te(e,Qs);return Object.assign(Tr(r),{clientIds:t})}))}},ra=function(e){function t(t,r,n){var i,o=r.creator,s=r.createdAt,a=r.updatedAt,u=r.transient,c=void 0!==u&&u,f=r.system,l=void 0!==f&&f,h=r.muted,p=void 0!==h&&h,d=r.mutedMembers,m=void 0===d?[]:d,g=te(r,Hs);return(i=e.call(this,ea(ea({},t),{},{creator:o,createdAt:s,updatedAt:a,mutedMembers:m,transient:c,system:l,muted:p,_attributes:g}),n)||this)._reset(),i}ie(t,e);var r=t.prototype;return r.get=function(e){return ro(tr(this).currentAttributes,e)},r.set=function(e,t){this._debug("set [".concat(e,"]: ").concat(t));var r=tr(this).pendingAttributes,n=Object.keys(r),i=new RegExp("^".concat(e)),o=n.filter(i.test.bind(i));if(o.forEach((function(e){delete r[e]})),o.length)r[e]=t;else{var s=Ts(n,(function(t){return 0===e.indexOf(t)}));s?or(r[s],e.slice(s.length+1),t):r[e]=t}return this._buildCurrentAttributes(),this},r._buildCurrentAttributes=function(){var e=tr(this).pendingAttributes;tr(this).currentAttributes=Object.keys(e).reduce((function(t,r){return or(t,r,e[r])}),as(this._attributes))},r._updateServerAttributes=function(e){var t=this;Object.keys(e).forEach((function(r){return or(t._attributes,r,e[r])})),this._buildCurrentAttributes()},r._reset=function(){Object.assign(tr(this),{pendingAttributes:{},currentAttributes:this._attributes})},r.save=function(){var e=$(ae.mark((function e(){var t,r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("save"),t=tr(this).pendingAttributes,!_o(t)){e.next=5;break}return this._debug("nothing touched, resolve with self"),e.abrupt("return",this);case 5:return this._debug("attr: %O",t),r=new x({attr:new b({data:JSON.stringify(Jt(t))})}),e.next=9,this._send(new D({op:"update",convMessage:r}));case 9:return n=e.sent,this.updatedAt=n.convMessage.udate,this._attributes=tr(this).currentAttributes,tr(this).pendingAttributes={},e.abrupt("return",this);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.fetch=function(){var e=$(ae.mark((function e(){var t;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._client.getQuery().equalTo("objectId",this.id),e.next=3,t.find();case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.mute=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute"),e.next=3,this._send(new D({op:"mute"}));case 3:return this.transient||(this.muted=!0,this.mutedMembers=Ht(this.mutedMembers,[this._client.id])),e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.unmute=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute"),e.next=3,this._send(new D({op:"unmute"}));case 3:return this.transient||(this.muted=!1,this.mutedMembers=Kt(this.mutedMembers,[this._client.id])),e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r._appendConversationSignature=function(){var e=$(ae.mark((function e(t,r,n){var i,o;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._client.options.conversationSignatureFactory){e.next=6;break}return i=[this.id,this._client.id,n.sort(),r],e.next=4,Xs(this._client.options.conversationSignatureFactory,i);case 4:o=e.sent,Object.assign(t.convMessage,Zt({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r._appendBlacklistSignature=function(){var e=$(ae.mark((function e(t,r,n){var i,o;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._client.options.blacklistSignatureFactory){e.next=6;break}return i=[this.id,this._client.id,n.sort(),r],e.next=4,Xs(this._client.options.blacklistSignatureFactory,i);case 4:o=e.sent,Object.assign(t.blacklistMessage,Zt({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.add=function(){var e=$(ae.mark((function e(t){var r,n,i,o;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("add",t),"string"==typeof t&&(t=[t]),r=new D({op:"add",convMessage:new x({m:t})}),e.next=5,this._appendConversationSignature(r,"invite",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.convMessage,o=n.convMessage.allowedPids,this._addMembers(o),e.abrupt("return",ta(i));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.remove=function(){var e=$(ae.mark((function e(t){var r,n,i,o;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("remove",t),"string"==typeof t&&(t=[t]),r=new D({op:"remove",convMessage:new x({m:t})}),e.next=5,this._appendConversationSignature(r,"kick",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.convMessage,o=n.convMessage.allowedPids,this._removeMembers(o),e.abrupt("return",ta(i));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.join=function(){var e=$(ae.mark((function e(){var t=this;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("join"),e.abrupt("return",this.add(this._client.id).then((function(e){var r=e.failures;if(r[0])throw r[0];return t})));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.quit=function(){var e=$(ae.mark((function e(){var t=this;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("quit"),e.abrupt("return",this.remove(this._client.id).then((function(e){var r=e.failures;if(r[0])throw r[0];return t})));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.muteMembers=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute",t),t=ir(t),r=new D({op:q.add_shutup,convMessage:new x({m:t})}),e.next=5,this._send(r);case 5:return n=e.sent,i=n.convMessage,e.abrupt("return",ta(i));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unmuteMembers=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute",t),t=ir(t),r=new D({op:q.remove_shutup,convMessage:new x({m:t})}),e.next=5,this._send(r);case 5:return n=e.sent,i=n.convMessage,e.abrupt("return",ta(i));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.queryMutedMembers=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s,a,u,c=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.limit,n=t.next,this._debug("query muted: limit %O, next: %O",r,n),i=new D({op:q.query_shutup,convMessage:new x({limit:r,next:n})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.convMessage,a=s.m,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.blockMembers=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("block",t),t=ir(t),r=new D({cmd:"blacklist",op:q.block,blacklistMessage:new F({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(r,"conversation-block-clients",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.blacklistMessage,e.abrupt("return",ta(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unblockMembers=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unblock",t),t=ir(t),r=new D({cmd:"blacklist",op:q.unblock,blacklistMessage:new F({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(r,"conversation-unblock-clients",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.blacklistMessage,e.abrupt("return",ta(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.queryBlockedMembers=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s,a,u,c=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.limit,n=t.next,this._debug("query blocked: limit %O, next: %O",r,n),i=new D({cmd:"blacklist",op:q.query,blacklistMessage:new F({srcCid:this.id,limit:r,next:n})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.blacklistMessage,a=s.blockedPids,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.toFullJSON=function(){var t=this.creator,r=this.system,n=this.transient,i=this.createdAt,o=this.updatedAt,s=this._attributes;return ea(ea({},e.prototype.toFullJSON.call(this)),{},{creator:t,system:r,transient:n,createdAt:Gt(i),updatedAt:Gt(o)},s)},r.toJSON=function(){var t=this.creator,r=this.system,n=this.transient,i=this.muted,o=this.mutedMembers,s=this.createdAt,a=this.updatedAt,u=this._attributes;return ea(ea({},e.prototype.toJSON.call(this)),{},{creator:t,system:r,transient:n,muted:i,mutedMembers:o,createdAt:s,updatedAt:a},u)},wt(t,[{key:"createdAt",get:function(){return this._createdAt},set:function(e){this._createdAt=Wt(e)}},{key:"updatedAt",get:function(){return this._updatedAt},set:function(e){this._updatedAt=Wt(e)}},{key:"name",get:function(){return this.get("name")},set:function(e){this.set("name",e)}}]),t}($s),na={OWNER:"Owner",MANAGER:"Manager",MEMBER:"Member"};Object.freeze(na);var ia=function(){function e(e){var t=e.conversation,r=e.memberId,n=e.role;if(!t)throw new Error("conversation requried");if(!r)throw new Error("memberId requried");Object.assign(tr(this),{conversation:t,memberId:r,role:n})}return e.prototype.toJSON=function(){return{conversationId:this.conversationId,memberId:this.memberId,role:this.role,isOwner:this.isOwner}},wt(e,[{key:"conversationId",get:function(){return tr(this).conversation.id}},{key:"memberId",get:function(){return tr(this).memberId}},{key:"role",get:function(){return this.isOwner?na.OWNER:tr(this).role}},{key:"isOwner",get:function(){return this.memberId===tr(this).conversation.creator}}]),e}(),oa=function(e){function t(){return e.apply(this,arguments)||this}ie(t,e);var r=t.prototype;return r._addMembers=function(t){var r=this;e.prototype._addMembers.call(this,t),this.members=Ht(this.members,t);var n=tr(this).memberInfoMap;n&&t.forEach((function(e){n[e]=n[e]||new ia({conversation:r,memberId:e,role:na.MEMBER})}))},r._removeMembers=function(t){e.prototype._removeMembers.call(this,t),this.members=Kt(this.members,t);var r=tr(this).memberInfoMap;r&&t.forEach((function(e){delete r[e]}))},r._fetchAllMemberInfo=function(){var e=$(ae.mark((function e(){var t,r,n,i=this;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._client._requestWithSessionToken({method:"GET",path:"/classes/_ConversationMemberInfo",query:{where:{cid:this.id}}});case 2:return t=e.sent,r=t.results.map((function(e){return new ia({conversation:i,memberId:e.clientId,role:e.role})})),n={},r.forEach((function(e){n[e.memberId]=e})),this.members.forEach((function(e){n[e]=n[e]||new ia({conversation:i,memberId:e,role:na.MEMBER})})),tr(this).memberInfoMap=n,e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getAllMemberInfo=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{},r=t.noCache,n=void 0!==r&&r,i=tr(this),(o=i.memberInfoMap)&&!n){e.next=6;break}return e.next=5,this._fetchAllMemberInfo();case 5:o=e.sent;case 6:return e.abrupt("return",this.members.map((function(e){return o[e]})));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getMemberInfo=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1!==this.members.indexOf(t)){e.next=2;break}throw new Error("".concat(t," is not the mumber of conversation[").concat(this.id,"]"));case 2:if(r=tr(this),(n=r.memberInfoMap)&&n[t]){e.next=6;break}return e.next=6,this.getAllMemberInfo();case 6:return e.abrupt("return",tr(this).memberInfoMap[t]);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.updateMemberRole=function(){var e=$(ae.mark((function e(t,r){var n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("update member role"),r!==na.OWNER){e.next=3;break}throw Tr({code:Er.OWNER_PROMOTION_NOT_ALLOWED});case 3:return e.next=5,this._send(new D({op:q.member_info_update,convMessage:new x({targetClientId:t,info:new V({pid:t,role:r})})}));case 5:return n=tr(this),(i=n.memberInfos)&&i[t]&&(tr(i[t]).role=r),e.abrupt("return",this);case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(ra),sa=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(ra),aa=function(e){function t(){return e.apply(this,arguments)||this}ie(t,e);var r=t.prototype;return r.subscribe=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.join());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.unsubscribe=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.quit());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(ra);function ua(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ca(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ua(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ua(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var fa,la,ha,pa=function(e){return e.code===Er.CONVERSATION_NOT_FOUND?Tr({code:Er.TEMPORARY_CONVERSATION_EXPIRED}):e},da=function(e){function t(t,r,n){var i=r.expiredAt;return e.call(this,ca(ca({},t),{},{expiredAt:i}),n)||this}ie(t,e);var r=t.prototype;return r._send=function(){var t=$(ae.mark((function t(){var r,n,i,o,s=arguments;return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.expired){t.next=2;break}throw Tr({code:Er.TEMPORARY_CONVERSATION_EXPIRED});case 2:for(t.prev=2,n=s.length,i=new Array(n),o=0;o<n;o++)i[o]=s[o];return t.next=6,(r=e.prototype._send).call.apply(r,[this].concat(i));case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(2),pa(t.t0);case 12:case"end":return t.stop()}}),t,this,[[2,9]])})));return function(){return t.apply(this,arguments)}}(),r.send=function(){var t=$(ae.mark((function t(){var r,n,i,o,s=arguments;return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(t.prev=0,n=s.length,i=new Array(n),o=0;o<n;o++)i[o]=s[o];return t.next=4,(r=e.prototype.send).call.apply(r,[this].concat(i));case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),pa(t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(){return t.apply(this,arguments)}}(),r.toFullJSON=function(){var t=this.expiredAt;return ca(ca({},e.prototype.toFullJSON.call(this)),{},{expiredAt:Gt(t)})},r.toJSON=function(){var t=this.expiredAt,r=this.expired;return ca(ca({},e.prototype.toJSON.call(this)),{},{expiredAt:t,expired:r})},wt(t,[{key:"expiredAt",get:function(){return this._expiredAt},set:function(e){this._expiredAt=Wt(e)}},{key:"expired",get:function(){return this.expiredAt<new Date}}]),t}($s),ma=me("LC:ConversationQuery"),ga=function(){function e(e){this._client=e,this._where={},this._extraOptions={}}e._encode=function(e){return e instanceof Date?{__type:"Date",iso:e.toJSON()}:e instanceof RegExp?e.source:e},e._quote=function(e){return"\\Q".concat(e.replace("\\E","\\E\\\\E\\Q"),"\\E")},e._calculateFlag=function(e){return["withLastMessagesRefreshed","compact"].reduce((function(t,r){return(t<<1)+Boolean(e[r])}),0)},e.and=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];if(r.length<2)throw new Error("The queries must contain at least two elements");if(!r.every((function(t){return t instanceof e})))throw new Error("The element of queries must be an instance of ConversationQuery");var i=new e(r[0]._client);return i._where.$and=r.map((function(e){return e._where})),i},e.or=function(){var t=e.and.apply(e,arguments);return t._where.$or=t._where.$and,delete t._where.$and,t};var t=e.prototype;return t._addCondition=function(e,t,r){return this._where[e]||(this._where[e]={}),this._where[e][t]=this.constructor._encode(r),this},t.toJSON=function(){var e={where:this._where,flag:this.constructor._calculateFlag(this._extraOptions)};return void 0!==this._skip&&(e.skip=this._skip),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._order&&(e.sort=this._order),ma(e),e},t.containsMembers=function(e){return this.containsAll("m",e)},t.withMembers=function(e,t){var r=new Set(e);return t&&r.add(this._client.id),this.sizeEqualTo("m",r.size),this.containsMembers(Array.from(r))},t.equalTo=function(e,t){return this._where[e]=this.constructor._encode(t),this},t.lessThan=function(e,t){return this._addCondition(e,"$lt",t)},t.lessThanOrEqualTo=function(e,t){return this._addCondition(e,"$lte",t)},t.greaterThan=function(e,t){return this._addCondition(e,"$gt",t)},t.greaterThanOrEqualTo=function(e,t){return this._addCondition(e,"$gte",t)},t.notEqualTo=function(e,t){return this._addCondition(e,"$ne",t)},t.exists=function(e){return this._addCondition(e,"$exists",!0)},t.doesNotExist=function(e){return this._addCondition(e,"$exists",!1)},t.containedIn=function(e,t){return this._addCondition(e,"$in",t)},t.notContainsIn=function(e,t){return this._addCondition(e,"$nin",t)},t.containsAll=function(e,t){return this._addCondition(e,"$all",t)},t.contains=function(t,r){return this._addCondition(t,"$regex",e._quote(r))},t.startsWith=function(t,r){return this._addCondition(t,"$regex","^".concat(e._quote(r)))},t.endsWith=function(t,r){return this._addCondition(t,"$regex","".concat(e._quote(r),"$"))},t.matches=function(e,t){this._addCondition(e,"$regex",t);var r="";return t.ignoreCase&&(r+="i"),t.multiline&&(r+="m"),r&&r.length&&this._addCondition(e,"$options",r),this},t.sizeEqualTo=function(e,t){return this._addCondition(e,"$size",t)},t.limit=function(e){return this._limit=e,this},t.skip=function(e){return this._skip=e,this},t.ascending=function(e){return this._order=e,this},t.addAscending=function(e){return this._order?this._order+=",".concat(e):this._order=e,this},t.descending=function(e){return this._order="-".concat(e),this},t.addDescending=function(e){return this._order?this._order+=",-".concat(e):this._order="-".concat(e),this},t.withLastMessagesRefreshed=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.withLastMessagesRefreshed=e,this},t.compact=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.compact=e,this},t.find=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._client._executeQuery(this));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.first=function(){var e=$(ae.mark((function e(){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.limit(1).find();case 2:return e.abrupt("return",e.sent[0]);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),ya=me("LC:SessionManager"),va=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refresh,r=e.onBeforeGetSessionToken;this.refresh=t,this._onBeforeGetSessionToken=r,this.setSessionToken(null,0)}var t=e.prototype;return t.setSessionToken=function(e,t){ya("set session token",e,t);var r=new Lt(e,1e3*t);return this._sessionToken=r,delete this._pendingSessionTokenPromise,r},t.setSessionTokenAsync=function(){var e=$(ae.mark((function e(t){var r,n=this;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sessionToken,this._pendingSessionTokenPromise=t.catch((function(e){throw n._sessionToken=r,e})),e.t0=this.setSessionToken,e.t1=this,e.t2=K,e.next=7,this._pendingSessionTokenPromise;case 7:return e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.abrupt("return",e.t0.apply.call(e.t0,e.t1,e.t4));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getSessionToken=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s,a,u,c=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.autoRefresh,n=void 0===r||r,ya("get session token"),this._onBeforeGetSessionToken&&this._onBeforeGetSessionToken(this),e.t0=this._sessionToken,e.t0){e.next=8;break}return e.next=7,this._pendingSessionTokenPromise;case 7:e.t0=e.sent;case 8:if(i=e.t0,o=i.value,s=i.originalValue,o!==Lt.EXPIRED||!n||!this.refresh){e.next=19;break}return ya("refresh expired session token"),e.next=15,this.setSessionTokenAsync(this.refresh(this,s));case 15:return a=e.sent,u=a.value,ya("session token",u),e.abrupt("return",u);case 19:return ya("session token",o),e.abrupt("return",o);case 21:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.revoke=function(){this._sessionToken&&(this._sessionToken.expiredAt=-1)},e}(),ba=["cmd","op","serverTs","notificationType"],wa=["headers","query"],_a=["data","bin"],Ea=["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"],Ta=["members","name","transient","unique","_tempConv","_tempConvTTL"],Oa=["ttl"];function Sa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Aa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sa(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ia,xa=me("LC:IMClient"),Ca=function(e){return/^_tmp:/.test(e)},Ma=(fa=ar(1e3),la=ar(1e3),_t((ha=function(e){function t(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Client id [".concat(t,"] is not a String"));if(r=e.call(this)||this,Object.assign(re(r),{id:t,options:n},i),!r._messageParser)throw new Error("IMClient must be initialized with a MessageParser");return r._conversationCache=new Ft("client:".concat(r.id)),r._ackMessageBuffer={},tr(re(r)).lastPatchTime=Date.now(),tr(re(r)).lastNotificationTime=void 0,tr(re(r))._eventemitter=new G,xa.enabled&&dt(Os).forEach((function(e){return r.on(e,(function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r._debug("".concat(e," event emitted. %o"),n)}))})),kr(r._plugins.onIMClientCreate,re(r)),r}ie(t,e);var r=t.prototype;return r._debug=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];xa.apply(void 0,t.concat(["[".concat(this.id,"]")]))},r._dispatchCommand=function(){var e=$(ae.mark((function e(t){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._debug(nr(t),"received"),t.serverTs&&1===t.notificationType&&(tr(this).lastNotificationTime=Gt(Wt(t.serverTs))),e.t0=t.cmd,e.next=e.t0===Y.conv?5:e.t0===Y.direct?6:e.t0===Y.session?7:e.t0===Y.unread?8:e.t0===Y.rcp?9:e.t0===Y.patch?10:11;break;case 5:return e.abrupt("return",this._dispatchConvMessage(t));case 6:return e.abrupt("return",this._dispatchDirectMessage(t));case 7:return e.abrupt("return",this._dispatchSessionMessage(t));case 8:return e.abrupt("return",this._dispatchUnreadMessage(t));case 9:return e.abrupt("return",this._dispatchRcpMessage(t));case 10:return e.abrupt("return",this._dispatchPatchMessage(t));case 11:return e.abrupt("return",this.emit("unhandledmessage",t));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._dispatchSessionMessage=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.sessionMessage,n=r.code,i=r.reason,e.t0=t.op,e.next=e.t0===q.closed?4:8;break;case 4:if(tr(this)._eventemitter.emit("close"),n!==Er.SESSION_CONFLICT){e.next=7;break}return e.abrupt("return",this.emit("conflict",{reason:i}));case 7:return e.abrupt("return",this.emit("close",{code:n,reason:i}));case 8:throw this.emit("unhandledmessage",t),new Error("Unrecognized session command");case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._dispatchUnreadMessage=function(e){var t=this,r=e.unreadMessage,n=r.convs,i=r.notifTime;return tr(this).lastUnreadNotifTime=i,this.getConversations(n.map((function(e){return e.cid}))).then((function(){return Promise.all(n.map((function(e){var r,n=e.cid,i=e.unread,o=e.mid,s=e.timestamp,a=e.from,u=e.data,c=e.binaryMsg,f=e.patchTimestamp,l=e.mentioned,h=t._conversationCache.get(n);return h?(s&&(r=Wt(s),h.lastMessageAt=r),(o?t._messageParser.parse(c||u).then((function(e){var t={id:o,cid:n,timestamp:r,updatedAt:f,from:a};Object.assign(e,t),h.lastMessage=e})):Promise.resolve()).then((function(){return h._setUnreadMessagesMentioned(l),i===tr(h).unreadMessagesCount?null:(tr(h).unreadMessagesCount=i,h)}))):null}))).then((function(e){return e.filter((function(e){return e}))}))})).then((function(e){e.length&&t.emit("unreadmessagescountupdate",e)}))},r._dispatchRcpMessage=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.rcpMessage,n=t.rcpMessage.read,i=r.cid,o=r.id,s=Wt(r.t),a=this._conversationCache.get(i)){e.next=7;break}return e.abrupt("return");case 7:a._handleReceipt({messageId:o,timestamp:s,read:n});case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._dispatchPatchMessage=function(e){var t=this,r=e.patchMessage.patches;return this.getConversations(r.map((function(e){return e.cid}))).then((function(){return Promise.all(r.map((function(e){var r=e.cid,n=e.mid,i=e.timestamp,o=e.recall,s=e.data,a=e.patchTimestamp,u=e.from,c=e.binaryMsg,f=e.mentionAll,l=e.mentionPids,h=e.patchCode,p=e.patchReason,d=t._conversationCache.get(r);return d?t._messageParser.parse(c||s).then((function(e){var s,c=Gt(Wt(a)),m={id:n,cid:r,timestamp:i,updatedAt:c,from:u,mentionList:l,mentionedAll:f};Object.assign(e,m),e._setStatus(Is.SENT),e._updateMentioned(t.id),tr(t).lastPatchTime<c&&(tr(t).lastPatchTime=c),d.lastMessage&&d.lastMessage.id===n&&(d.lastMessage=e),h&&(s={code:h.toNumber(),detail:p}),o?(t.emit("messagerecall",e,d,s),d.emit("messagerecall",e,s)):(t.emit("messageupdate",e,d,s),d.emit("messageupdate",e,s))})):null})))}))},r._dispatchConvMessage=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,E,T,O,S,A,I;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.convMessage,n=t.convMessage,i=n.initBy,o=n.m,s=n.info,a=n.attr,e.next=3,this.getConversation(r.cid);case 3:u=e.sent,e.t0=t.op,e.next=e.t0===q.joined?7:e.t0===q.left?12:e.t0===q.members_joined?17:e.t0===q.members_left?22:e.t0===q.members_blocked?27:e.t0===q.members_unblocked?31:e.t0===q.blocked?35:e.t0===q.unblocked?39:e.t0===q.members_shutuped?43:e.t0===q.members_unshutuped?47:e.t0===q.shutuped?51:e.t0===q.unshutuped?55:e.t0===q.member_info_changed?59:e.t0===q.updated?71:77;break;case 7:return u._addMembers([this.id]),c={invitedBy:i},this.emit("invited",c,u),u.emit("invited",c),e.abrupt("return");case 12:return u._removeMembers([this.id]),f={kickedBy:i},this.emit("kicked",f,u),u.emit("kicked",f),e.abrupt("return");case 17:return u._addMembers(o),l={invitedBy:i,members:o},this.emit("membersjoined",l,u),u.emit("membersjoined",l),e.abrupt("return");case 22:return u._removeMembers(o),h={kickedBy:i,members:o},this.emit("membersleft",h,u),u.emit("membersleft",h),e.abrupt("return");case 27:return p={blockedBy:i,members:o},this.emit("membersblocked",p,u),u.emit("membersblocked",p),e.abrupt("return");case 31:return d={unblockedBy:i,members:o},this.emit("membersunblocked",d,u),u.emit("membersunblocked",d),e.abrupt("return");case 35:return m={blockedBy:i},this.emit("blocked",m,u),u.emit("blocked",m),e.abrupt("return");case 39:return g={unblockedBy:i},this.emit("unblocked",g,u),u.emit("unblocked",g),e.abrupt("return");case 43:return y={mutedBy:i,members:o},this.emit("membersmuted",y,u),u.emit("membersmuted",y),e.abrupt("return");case 47:return v={unmutedBy:i,members:o},this.emit("membersunmuted",v,u),u.emit("membersunmuted",v),e.abrupt("return");case 51:return b={mutedBy:i},this.emit("muted",b,u),u.emit("muted",b),e.abrupt("return");case 55:return w={unmutedBy:i},this.emit("unmuted",w,u),u.emit("unmuted",w),e.abrupt("return");case 59:if(_=s.pid,E=s.role,T=tr(u),T.memberInfoMap||E){e.next=63;break}return e.abrupt("return");case 63:return e.next=65,u.getMemberInfo(_);case 65:return O=e.sent,tr(O).role=E,S={member:_,memberInfo:O,updatedBy:i},this.emit("memberinfoupdated",S,u),u.emit("memberinfoupdated",S),e.abrupt("return");case 71:return A=$t(JSON.parse(a.data)),u._updateServerAttributes(A),I={attributes:A,updatedBy:i},this.emit("conversationinfoupdated",I,u),u.emit("infoupdated",I),e.abrupt("return");case 77:throw this.emit("unhandledmessage",t),new Error("Unrecognized conversation command");case 79:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._dispatchDirectMessage=function(e){var t=this,r=e.directMessage,n=e.directMessage,i=n.id,o=n.cid,s=n.fromPeerId,a=n.timestamp,u=n.transient,c=n.patchTimestamp,f=n.mentionPids,l=n.mentionAll,h=n.binaryMsg,p=n.msg,d=h?h.toArrayBuffer():p;return Promise.all([this.getConversation(r.cid),this._messageParser.parse(d)]).then((function(e){var r=Zr(e,2),n=r[0],h=r[1];if(n){var p={id:i,cid:o,timestamp:a,updatedAt:c,from:s,mentionList:f,mentionedAll:l};return Object.assign(h,p),h._updateMentioned(t.id),h._setStatus(Is.SENT),h.from!==t.id&&(u||n.transient||t._sendAck(h)),t._dispatchParsedMessage(h,n)}}))},r._dispatchParsedMessage=function(e,t){var r=this;return Rr(this._plugins.beforeMessageDispatch,[e,t]).then((function(n){!1!==n&&(t.lastMessage=e,t.lastMessageAt=e.timestamp,e.from!==r.id&&(t.unreadMessagesCount+=1,e.mentioned&&t._setUnreadMessagesMentioned(!0)),r.emit("message",e,t),t.emit("message",e))}))},r._sendAck=function(e){this._debug("send ack for %O",e);var t=e.cid;if(!t)throw new Error("missing cid");return this._ackMessageBuffer[t]||(this._ackMessageBuffer[t]=[]),this._ackMessageBuffer[t].push(e),this._doSendAck()},r._doSendAck=function(){var e=this;this._connection.is("connected")&&(this._debug("do send ack %O",this._ackMessageBuffer),Promise.all(Object.keys(this._ackMessageBuffer).map((function(t){var r=e._ackMessageBuffer[t],n=r.map((function(e){return e.timestamp})),i=new D({cmd:"ack",ackMessage:new A({cid:t,fromts:Math.min.apply(null,n),tots:Math.max.apply(null,n)})});return delete e._ackMessageBuffer[t],e._send(i,!1).catch((function(n){e._debug("send ack failed: %O",n),e._ackMessageBuffer[t]=r}))}))))},r._omitPeerId=function(e){tr(this).peerIdOmittable=e},r._send=function(e){var t,r=e;!tr(this).peerIdOmittable&&this.id&&(r.peerId=this.id);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return(t=this._connection).send.apply(t,[r].concat(i))},r._open=function(){var e=$(ae.mark((function e(t,r,n){var i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,E=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=E.length>3&&void 0!==E[3]&&E[3],this._debug("open session"),o=tr(this),s=o.lastUnreadNotifTime,a=o.lastPatchTime,u=o.lastNotificationTime,c=new D({cmd:"session",op:"open",appId:t,peerId:this.id,sessionMessage:new T({ua:"js/".concat("5.0.0-rc.8"),r:i,lastUnreadNotifTime:s,lastPatchTime:a,configBitmap:187})}),i){e.next=13;break}if(Object.assign(c.sessionMessage,nr({tag:r,deviceId:n})),!this.options.signatureFactory){e.next=11;break}return e.next=9,Xs(this.options.signatureFactory,[this._identity]);case 9:f=e.sent,Object.assign(c.sessionMessage,Zt({signature:"s",timestamp:"t",nonce:"n"},f));case 11:e.next=17;break;case 13:return e.next=15,this._sessionManager.getSessionToken({autoRefresh:!1});case 15:(l=e.sent)&&l!==Lt.EXPIRED&&Object.assign(c.sessionMessage,{st:l});case 17:return e.prev=17,e.next=20,this._send(c);case 20:h=e.sent,e.next=32;break;case 23:if(e.prev=23,e.t0=e.catch(17),e.t0.code!==Er.SESSION_TOKEN_EXPIRED){e.next=31;break}if(this._sessionManager){e.next=28;break}throw new Error("Unexpected session expiration");case 28:return xa("Session token expired, reopening"),this._sessionManager.revoke(),e.abrupt("return",this._open(t,r,n,i));case 31:throw e.t0;case 32:if(d=(p=h).peerId,m=p.sessionMessage,g=p.sessionMessage,y=g.st,v=g.stTtl,b=g.code,w=p.serverTs,!b){e.next=35;break}throw Tr(m);case 35:return d?(this.id=d,this._identity||(this._identity=d),y&&(this._sessionManager=this._sessionManager||this._createSessionManager(),this._sessionManager.setSessionToken(y,v)),_=Gt(Wt(w)),w&&(tr(this).lastPatchTime=_),u?this._syncNotifications(u).catch((function(e){return console.warn("Syncing notifications failed:",e)})):tr(this).lastNotificationTime=_):console.warn("Unexpected session opened without peerId."),e.abrupt("return",void 0);case 37:case"end":return e.stop()}}),e,this,[[17,23]])})));return function(t,r,n){return e.apply(this,arguments)}}(),r._syncNotifications=function(){var e=$(ae.mark((function e(t){var r,n,i=this;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchNotifications(t);case 2:if(r=e.sent,n=r.hasMore,r.notifications.forEach((function(e){var t=e.cmd,r=e.op,n=e.serverTs,o=e.notificationType,s=te(e,ba);i._dispatchCommand(d({cmd:Y[t],op:q[r],serverTs:n,notificationType:o},"".concat(t,"Message"),s))})),!n){e.next=8;break}return e.abrupt("return",this._syncNotifications(tr(this).lastNotificationTime));case 8:return e.abrupt("return",void 0);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._fetchNotifications=function(){var e=$(ae.mark((function e(t){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._requestWithSessionToken({method:"GET",path:"/rtm/notifications",query:{start_ts:t,notification_type:"permanent"}}));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._createSessionManager=function(){var e=this;return xa("create SessionManager"),new va({onBeforeGetSessionToken:this._connection.checkConnectionAvailability.bind(this._connection),refresh:function(t,r){return t.setSessionTokenAsync(Promise.resolve(new D({cmd:"session",op:"refresh",sessionMessage:new T({ua:"js/".concat("5.0.0-rc.8"),st:r})})).then(function(){var t=$(ae.mark((function t(r){var n;return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.options.signatureFactory){t.next=5;break}return t.next=3,Xs(e.options.signatureFactory,[e._identity]);case 3:n=t.sent,Object.assign(r.sessionMessage,Zt({signature:"s",timestamp:"t",nonce:"n"},n));case 5:return t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).then(e._send.bind(e)).then((function(e){var t=e.sessionMessage;return[t.st,t.stTtl]})))}})},r._requestWithSessionToken=function(){var e=$(ae.mark((function e(t){var r,n,i,o;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.headers,n=t.query,i=te(t,wa),e.next=3,this._sessionManager.getSessionToken();case 3:return o=e.sent,e.abrupt("return",this._request(Aa({headers:Aa({"X-LC-IM-Session-Token":o},r),query:Aa({client_id:this.id},n)},i)));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.close=function(){var e=$(ae.mark((function e(){var t,r;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("close session"),(t=tr(this)._eventemitter).emit("beforeclose"),!this._connection.is("connected")){e.next=7;break}return r=new D({cmd:"session",op:"close"}),e.next=7,this._send(r);case 7:t.emit("close"),this.emit("close",{code:0});case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.ping=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("ping"),t instanceof Array){e.next=3;break}throw new TypeError("clientIds ".concat(t," is not an Array"));case 3:if(t.length){e.next=5;break}return e.abrupt("return",Promise.resolve([]));case 5:return r=new D({cmd:"session",op:"query",sessionMessage:new T({sessionPeerIds:t})}),e.next=8,this._send(r);case 8:return n=e.sent,e.abrupt("return",n.sessionMessage.onlineSessionPeerIds);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getConversation=function(){var e=$(ae.mark((function e(t){var r,n,i=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],"string"==typeof t){e.next=3;break}throw new TypeError("".concat(t," is not a String"));case 3:if(r){e.next=7;break}if(!(n=this._conversationCache.get(t))){e.next=7;break}return e.abrupt("return",n);case 7:if(!Ca(t)){e.next=14;break}return e.next=10,this._getTemporaryConversations([t]);case 10:if(e.t0=e.sent[0],e.t0){e.next=13;break}e.t0=null;case 13:return e.abrupt("return",e.t0);case 14:return e.abrupt("return",this.getQuery().equalTo("objectId",t).find().then((function(e){return e[0]||null})));case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getConversations=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a=this,u=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>1&&void 0!==u[1]&&u[1],!(n=r?t:t.filter((function(e){return null===a._conversationCache.get(e)}))).length){e.next=9;break}return i=bo(n,Ca),o=[],n.length&&o.push(this.getQuery().containedIn("objectId",n).limit(999).find()),i.length&&(s=i.map(this._getTemporaryConversations.bind(this)),o.push.apply(o,K(s))),e.next=9,Promise.all(o);case 9:return e.abrupt("return",t.map((function(e){return a._conversationCache.get(e)})));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._getTemporaryConversations=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new D({cmd:"conv",op:"query",convMessage:new x({tempConvIds:t})}),e.next=3,this._send(r);case 3:return n=e.sent,e.abrupt("return",this._handleQueryResults(n));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getQuery=function(){return new ga(this)},r.getChatRoomQuery=function(){return this.getQuery().equalTo("tr",!0)},r.getServiceConversationQuery=function(){return this.getQuery().equalTo("sys",!0)},r._executeQuery=function(){var e=$(ae.mark((function e(t){var r,n,i;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.toJSON()).where=new b({data:JSON.stringify(Jt(r.where))}),n=new D({cmd:"conv",op:"query",convMessage:new x(r)}),e.next=5,this._send(n);case 5:return i=e.sent,e.abrupt("return",this._handleQueryResults(i));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._handleQueryResults=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,r=$t(JSON.parse(t.convMessage.results.data)),e.next=8;break;case 4:throw e.prev=4,e.t0=e.catch(0),n=JSON.stringify(nr(t)),new Error("Parse query result failed: ".concat(e.t0.message,". Command: ").concat(n));case 8:return e.next=10,Promise.all(r.map(this._parseConversationFromRawData.bind(this)));case 10:return r=e.sent,e.abrupt("return",r.map(this._upsertConversationToCache.bind(this)));case 12:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(t){return e.apply(this,arguments)}}(),r._upsertConversationToCache=function(e){var t=this._conversationCache.get(e.id);return t?(this._debug("update cached conversation"),["creator","createdAt","updatedAt","lastMessageAt","lastMessage","mutedMembers","members","_attributes","transient","muted"].forEach((function(r){var n=e[r];void 0!==n&&(t[r]=n)})),t._reset&&t._reset()):(t=e,this._debug("no match, set cache"),this._conversationCache.set(e.id,e)),t},r.parseMessage=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=t.bin,i=void 0!==n&&n,o=te(t,_a),s=i?Hr(r):r,e.next=4,this._messageParser.parse(s);case 4:return a=e.sent,Object.assign(a,o),a._updateMentioned(this.id),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.parseConversation=function(){var e=$(ae.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.id,n=t.lastMessageAt,i=t.lastMessage,o=t.lastDeliveredAt,s=t.lastReadAt,a=t.unreadMessagesCount,u=t.members,c=t.mentioned,f=te(t,Ea),l={id:r,lastMessageAt:n,lastMessage:i,lastDeliveredAt:o,lastReadAt:s,unreadMessagesCount:a,members:u,mentioned:c},!i){e.next=7;break}return e.next=5,this.parseMessage(i);case 5:l.lastMessage=e.sent,l.lastMessage._setStatus(Is.SENT);case 7:if(h=f.transient,p=f.system,d=f.expiredAt,!h){e.next=10;break}return e.abrupt("return",new sa(l,f,this));case 10:if(!p){e.next=12;break}return e.abrupt("return",new aa(l,f,this));case 12:if(!d&&!Ca(r)){e.next=14;break}return e.abrupt("return",new da(l,{expiredAt:d},this));case 14:return e.abrupt("return",new oa(l,f,this));case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._parseConversationFromRawData=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=Zt({objectId:"id",lm:"lastMessageAt",m:"members",tr:"transient",sys:"system",c:"creator",mu:"mutedMembers"},t)).msg&&(r.lastMessage={data:r.msg,bin:r.bin,from:r.msg_from,id:r.msg_mid,timestamp:r.msg_timestamp,updatedAt:r.patch_timestamp},delete r.lastMessageFrom,delete r.lastMessageId,delete r.lastMessageTimestamp,delete r.lastMessagePatchTimestamp),(n=r.ttl)&&(r.expiredAt=Date.now()+1e3*n),e.abrupt("return",this.parseConversation(r));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.createConversation=function(){var e=$(ae.mark((function e(){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,w,_,E,T=arguments;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=T.length>0&&void 0!==T[0]?T[0]:{},r=t.members,n=t.name,i=t.transient,o=t.unique,s=void 0===o||o,a=t._tempConv,u=t._tempConvTTL,c=te(t,Ta),i||Array.isArray(r)){e.next=3;break}throw new TypeError("conversation members ".concat(r," is not an array"));case 3:if((f=new Set(r)).add(this.id),f=Array.from(f).sort(),l=c||{},!n){e.next=11;break}if("string"==typeof n){e.next=10;break}throw new TypeError("conversation name ".concat(n," is not a string"));case 10:l.name=n;case 11:if(l=new b({data:JSON.stringify(Jt(l))}),h=new D({cmd:"conv",op:"start",convMessage:new x({m:f,attr:l,transient:i,unique:s,tempConv:a,tempConvTTL:u})}),!this.options.conversationSignatureFactory){e.next=20;break}return p=[null,this._identity,f,"create"],e.next=18,Xs(this.options.conversationSignatureFactory,p);case 18:d=e.sent,Object.assign(h.convMessage,Zt({signature:"s",timestamp:"t",nonce:"n"},d));case 20:return e.next=22,this._send(h);case 22:return m=e.sent,g=m.convMessage,y=g.cid,v=g.cdate,w=g.tempConvTTL,_=Aa({name:n,transient:i,unique:s,id:y,createdAt:v,updatedAt:v,lastMessageAt:null,creator:this.id,members:i?[]:f},c),w&&(_.expiredAt=Date.now()+1e3*w),e.next=31,this.parseConversation(_);case 31:return E=e.sent,e.abrupt("return",this._upsertConversationToCache(E));case 33:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.createChatRoom=function(){var e=$(ae.mark((function e(t){return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.createConversation(Aa(Aa({},t),{},{transient:!0,members:null,unique:!1,_tempConv:!1})));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.createTemporaryConversation=function(){var e=$(ae.mark((function e(t){var r,n;return ae.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ttl,n=te(t,Oa),e.abrupt("return",this.createConversation(Aa(Aa({},n),{},{_tempConv:!0,_tempConvTTL:r})));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._doSendRead=function(){var e=this;if(this._connection.is("connected")){var t=tr(this).readConversationsBuffer,r=Array.from(t);if(r.length){var n=r.map((function(e){if(!(e instanceof $s))throw new TypeError("".concat(e," is not a Conversation"));return e.id}));this._debug("mark [".concat(n,"] as read")),t.clear(),this._sendReadCommand(r).catch((function(n){e._debug("send read failed: %O",n),r.forEach(t.add.bind(t))}))}}},r._sendReadCommand=function(e){var t=this;return this._send(new D({cmd:"read",readMessage:new R({convs:e.map((function(e){return new k({cid:e.id,mid:e.lastMessage&&e.lastMessage.from!==t.id?e.lastMessage.id:void 0,timestamp:(e.lastMessageAt||new Date).getTime()})}))})}),!1)},t}(G)).prototype,"_doSendAck",[fa],Object.getOwnPropertyDescriptor(ha.prototype,"_doSendAck"),ha.prototype),_t(ha.prototype,"_doSendRead",[la],Object.getOwnPropertyDescriptor(ha.prototype,"_doSendRead"),ha.prototype),ha),Pa=Object.freeze({__proto__:null,RECONNECT_ERROR:"reconnecterror",DISCONNECT:hr,RECONNECT:pr,RETRY:dr,SCHEDULE:mr,OFFLINE:gr,ONLINE:yr});function ka(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ja(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ka(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ka(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Ra,Na,La=js(Ia=function(e){function t(t){if(!(t instanceof ArrayBuffer))throw new TypeError("".concat(t," is not an ArrayBuffer"));return e.call(this,t)||this}ie(t,e),t.validate=function(e){return e instanceof ArrayBuffer};var r=t.prototype;return r.toJSON=function(){return ja(ja({},e.prototype._toJSON.call(this)),{},{data:Qr(this.content)})},r.toFullJSON=function(){return ja(ja({},e.prototype.toFullJSON.call(this)),{},{bin:!0,data:Qr(this.content)})},wt(t,[{key:"buffer",get:function(){return this.content},set:function(e){this.content=e}}]),t}(Ms))||Ia,Da=Ps(-1)(Ra=js(Ra=function(e){function t(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if("string"!=typeof r)throw new TypeError("".concat(r," is not a string"));return(t=e.call(this)||this).setText(r),t}return ie(t,e),t}(Ds))||Ra)||Ra;function Fa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ua(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Fa(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fa(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ba(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Va(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Va(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Va(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Ya=me("LC:MessageParser"),qa=(_t((Na=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._plugins=e,this._messageClasses=[],this.register(e.messageClasses)}var t=e.prototype;return t.register=function(e){var t=this;ir(e).map((function(e){return t._register(e)}))},t._register=function(e){if(!(e&&e.parse&&e.prototype&&e.prototype.getPayload))throw new TypeError("Invalid messageClass");this._messageClasses.unshift(e)},t.parse=function(e){Ya("parsing message: %O",e);var t,r=Ba(this._messageClasses);try{for(r.s();!(t=r.n()).done;){var n=t.value,i=kt(e)?Ua({},e):e,o=void 0,s=void 0;try{o=n.validate(i)}catch(e){}if(o){try{s=n.parse(i)}catch(e){console.warn("parsing a valid message content error",{error:e,Klass:n,content:i})}if(void 0!==s)return Ya("parse result: %O",s),s}}}catch(e){r.e(e)}finally{r.f()}throw new Error("No Message Class matched")},e}()).prototype,"parse",[function(e,t,r){var n=r.value;r.value=function(e){var t;if("string"!=typeof e)t=e;else try{t=JSON.parse(e)}catch(r){t=e}return n.call(this,t)}},function(e,t,r){var n=r.value;r.value=function(e){var t=this;return Promise.resolve(e).then(jr(this._plugins.beforeMessageParse)).then((function(e){return n.call(t,e)})).then(jr(this._plugins.afterMessageParse))}}],Object.getOwnPropertyDescriptor(Na.prototype,"parse"),Na.prototype),Na),za=["tag","isReconnect"];function Wa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ga(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Wa(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wa(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var $a=me("LC:IMPlugin"),Ja={HIGH:1,NORMAL:2,LOW:3};Object.freeze(Ja);var Za=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{get:function(){return this.get(e)},set:function(t){this.set(e,t)}};Object.defineProperty(oa.prototype,e,t)},Xa={name:"leancloud-realtime-plugin-im",onRealtimeCreate:function(e){var t=$r();e._IMClients={},e._IMClientsCreationCount=0;var r=new qa(e._plugins);e._messageParser=r;var n=function(){var t=$(ae.mark((function t(r){return ae.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._request({method:"POST",path:"/rtm/sign",data:{session_token:r.getSessionToken()}}));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),i=r.register.bind(r),o=function(){var i=$(ae.mark((function i(o){var s,a,u,c,f,l,h,p,d,m,g=arguments;return ae.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=g.length>1&&void 0!==g[1]?g[1]:{},u=a.tag,c=a.isReconnect,f=te(a,za),l=g.length>2?g[2]:void 0,p={},!o){i.next=19;break}if("string"!=typeof o){i.next=8;break}h=o,i.next=17;break;case 8:if(!o.id||!o.getSessionToken){i.next=16;break}if(h=o.id,o.getSessionToken()){i.next=13;break}throw new Error("User must be authenticated");case 13:p.signatureFactory=n,i.next=17;break;case 16:throw new TypeError("Identity must be a String or an AV.User");case 17:if(void 0===e._IMClients[h]){i.next=19;break}return i.abrupt("return",e._IMClients[h]);case 19:return l&&console.warn("DEPRECATION createIMClient tag param: Use options.tag instead."),d=u||l,m=(s=e._open().then((function(n){var i=new Ma(h,Ga(Ga({},p),f),{_connection:n,_request:e._request.bind(e),_messageParser:r,_plugins:e._plugins,_identity:o});return n.on(pr,(function(){return i._open(e._options.appId,d,t,!0).then((function(){return i.emit(pr)}),(function(e){return i.emit("reconnecterror",e)}))})),tr(i)._eventemitter.on("beforeclose",(function(){delete e._IMClients[i.id],e._firstIMClient===i&&delete e._firstIMClient}),e),tr(i)._eventemitter.on("close",(function(){e._deregister(i)}),e),i._open(e._options.appId,d,t,c).then((function(){return e._IMClients[i.id]=i,e._IMClientsCreationCount+=1,1===e._IMClientsCreationCount?(i._omitPeerId(!0),e._firstIMClient=i):e._IMClientsCreationCount>1&&e._firstIMClient&&e._firstIMClient._omitPeerId(!1),e._register(i),i})).catch((function(t){throw delete e._IMClients[i.id],t}))}))).then.apply(s,K(zt((function(){e._deregisterPending(m)})))).catch((function(t){throw delete e._IMClients[h],t})),o&&(e._IMClients[h]=m),e._registerPending(m),i.abrupt("return",m);case 25:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}();Object.assign(e,{register:i,createIMClient:o})},beforeCommandDispatch:function(e,t){if(!(null===e.service||2===e.service))return!0;var r=e.peerId?t._IMClients[e.peerId]:t._firstIMClient;return r?Promise.resolve(r).then((function(t){return t._dispatchCommand(e)})).catch($a):$a("[WARN] Unexpected message received without any live client match: %O",nr(e)),!1},messageClasses:[Ms,La,Fs,Da]};function Qa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ha(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Qa(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qa(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Vr.defineConversationProperty=Za,Vr.__preRegisteredPlugins=[Xa];var Ka=Ha(Ha({},Pa),Os);St({WebSocket:c,request:f}),e.BinaryMessage=La,e.ChatRoom=sa,e.Conversation=oa,e.ConversationMemberRole=na,e.ConversationQuery=ga,e.ErrorCode=Er,e.Event=Ka,e.EventEmitter=G,e.IE10Compatible=js,e.IMPlugin=Xa,e.Message=Ms,e.MessageParser=qa,e.MessagePriority=Ja,e.MessageQueryDirection=Gs,e.MessageStatus=Is,e.Promise=Yr,e.Protocals=W,e.Protocols=W,e.Realtime=Vr,e.RecalledMessage=Fs,e.ServiceConversation=aa,e.TemporaryConversation=da,e.TextMessage=Da,e.TypedMessage=Ds,e.debug=Yt,e.defineConversationProperty=Za,e.getAdapter=Ot,e.messageField=ks,e.messageType=Ps,e.setAdapters=St,Object.defineProperty(e,"__esModule",{value:!0})}));
36//# sourceMappingURL=im-weapp.min.js.map