UNPKG

278 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 d,u="undefined"!=typeof window&&window.process||{};function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t,n,r,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}function b(a){return function(){var e=this,s=arguments;return new Promise(function(t,n){var r=a.apply(e,s);function i(e){c(r,t,n,i,o,"next",e)}function o(e){c(r,t,n,i,o,"throw",e)}i(void 0)})}}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(e){a(t,e,n[e])})}return t}function f(e,t){e.prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t}function S(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],0<=t.indexOf(n)||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return s(e)||function(e,t){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}(e,t)||h()}function v(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function s(e){if(Array.isArray(e))return e}function l(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function h(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function t(n,r,e,t,i){var o={};return Object.keys(t).forEach(function(e){o[e]=t[e]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=e.slice().reverse().reduce(function(e,t){return t(n,r,e)||e},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(n,r,o),o=null),o}u.env=u.env||{};var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e,t){return e(t={exports:{}},t.exports),t.exports}var p=new(function(){function e(){}var t=e.prototype;return t.getItem=function(e){return wx.getStorageSync(e)},t.setItem=function(e,t){return wx.setStorageSync(e,t)},t.removeItem=function(e){return this.setItem(e,"")},t.clear=function(){return wx.clearStorageSync()},e}()),w=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var A=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,r,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),o=1;o<arguments.length;o++){for(var s in n=Object(arguments[o]))_.call(n,s)&&(i[s]=n[s]);if(w){r=w(n);for(var a=0;a<r.length;a++)E.call(n,r[a])&&(i[r[a]]=n[r[a]])}}return i},I=n(function(e,t){var n=t.createUniqueKey="undefined"!=typeof Symbol?Symbol:function(e){return"[["+e+"_"+Math.random().toFixed(8).slice(2)+"]]"};t.LISTENERS=n("listeners"),t.CAPTURE=1,t.BUBBLE=2,t.ATTRIBUTE=3,t.newNode=function(e,t){return{listener:e,kind:t,next:null}}}),O=(I.createUniqueKey,I.LISTENERS,I.CAPTURE,I.BUBBLE,I.ATTRIBUTE,I.newNode,I.LISTENERS),C=I.ATTRIBUTE,x=I.newNode;var M=function(e,t){function n(){e.call(this)}var r={constructor:{value:n,configurable:!0,writable:!0}};return t.forEach(function(t){r["on"+t]={get:function(){return function(e,t){for(var n=e[O][t];null!=n;){if(n.kind===C)return n.listener;n=n.next}return null}(this,t)},set:function(e){!function(e,t,n){"function"!=typeof n&&"object"!=typeof n&&(n=null);for(var r=null,i=e[O][t];null!=i;)i.kind===C?null==r?e[O][t]=i.next:r.next=i.next:r=i,i=i.next;null!=n&&(null==r?e[O][t]=x(n,C):r.next=x(n,C))}(this,t,e)},configurable:!0,enumerable:!0}}),n.prototype=Object.create(e.prototype,r),n},k=I.createUniqueKey,R=k("stop_immediate_propagation_flag"),P=k("canceled_flag"),N=k("original_event"),L=Object.freeze({stopPropagation:Object.freeze({value:function(){var e=this[N];"function"==typeof e.stopPropagation&&e.stopPropagation()},writable:!0,configurable:!0}),stopImmediatePropagation:Object.freeze({value:function(){this[R]=!0;var e=this[N];"function"==typeof e.stopImmediatePropagation&&e.stopImmediatePropagation()},writable:!0,configurable:!0}),preventDefault:Object.freeze({value:function(){!0===this.cancelable&&(this[P]=!0);var e=this[N];"function"==typeof e.preventDefault&&e.preventDefault()},writable:!0,configurable:!0}),defaultPrevented:Object.freeze({get:function(){return this[P]},enumerable:!0,configurable:!0})}),j={STOP_IMMEDIATE_PROPAGATION_FLAG:R,createEventWrapper:function(e,t){var n="number"==typeof e.timeStamp?e.timeStamp:Date.now(),r={type:{value:e.type,enumerable:!0},target:{value:t,enumerable:!0},currentTarget:{value:t,enumerable:!0},eventPhase:{value:2,enumerable:!0},bubbles:{value:Boolean(e.bubbles),enumerable:!0},cancelable:{value:Boolean(e.cancelable),enumerable:!0},timeStamp:{value:n,enumerable:!0},isTrusted:{value:!1,enumerable:!0}};return r[R]={value:!1,writable:!0},r[P]={value:!1,writable:!0},r[N]={value:e},void 0!==e.detail&&(r.detail={value:e.detail,enumerable:!0}),Object.create(Object.create(e,L),r)}},D=n(function(e){var s=I.LISTENERS,a=I.CAPTURE,u=I.BUBBLE,r=I.ATTRIBUTE,c=I.newNode,i=M,o=j.createEventWrapper,f=j.STOP_IMMEDIATE_PROPAGATION_FLAG,t="undefined"!=typeof window&&void 0!==window.EventTarget,n=e.exports=function e(){if(!(this instanceof e)){if(1===arguments.length&&Array.isArray(arguments[0]))return i(e,arguments[0]);if(0<arguments.length){for(var t=Array(arguments.length),n=0;n<arguments.length;++n)t[n]=arguments[n];return i(e,t)}throw new TypeError("Cannot call a class as a function")}Object.defineProperty(this,s,{value:Object.create(null)})};n.prototype=Object.create((t?window.EventTarget:Object).prototype,{constructor:{value:n,writable:!0,configurable:!0},addEventListener:{value:function(e,t,n){if(null==t)return!1;if("function"!=typeof t&&"object"!=typeof t)throw new TypeError('"listener" is not an object.');var r=n?a:u,i=this[s][e];if(null==i)return this[s][e]=c(t,r),!0;for(var o=null;null!=i;){if(i.listener===t&&i.kind===r)return!1;i=(o=i).next}return o.next=c(t,r),!0},configurable:!0,writable:!0},removeEventListener:{value:function(e,t,n){if(null==t)return!1;for(var r=n?a:u,i=null,o=this[s][e];null!=o;){if(o.listener===t&&o.kind===r)return null==i?this[s][e]=o.next:i.next=o.next,!0;o=(i=o).next}return!1},configurable:!0,writable:!0},dispatchEvent:{value:function(e){var t=this[s][e.type];if(null==t)return!0;for(var n=o(e,this);null!=t&&("function"==typeof t.listener?t.listener.call(this,n):t.kind!==r&&"function"==typeof t.listener.handleEvent&&t.listener.handleEvent(n),!n[f]);)t=t.next;return!n.defaultPrevented},configurable:!0,writable:!0}})}),F=function(){function e(){this._entries=[]}var t=e.prototype;return t.append=function(e,t){if("string"!=typeof e)throw new TypeError("FormData name must be a string");if("string"!=typeof t&&("object"!==m(t)||"string"!=typeof t.uri))throw new TypeError("FormData value must be a string or { uri: tempFilePath }");this._entries.push([e,t])},t.set=function(e,t){var n=this.get(e);n?n[1]=t:this.append(e,t)},t.delete=function(t){this._entries=this._entries.filter(function(e){return e[0]!==t})},t.entries=function(){return this._entries},t.get=function(t){return this._entries.find(function(e){return e[0]===t})},t.getAll=function(t){return this._entries.filter(function(e){return e[0]===t})},t.has=function(t){return this._entries.some(function(e){return e[0]===t})},t.keys=function(){return this._entries.map(function(e){return e[0]})},t.values=function(){return this._entries.map(function(e){return e[1]})},e}();function U(n){this.status=n.statusCode,this.statusText=n.statusCode,n.header&&(this._responseHeaders=Object.keys(n.header).reduce(function(e,t){return e[t.toLowerCase()]=n.header[t],e},{}));var e=n.data;"string"!=typeof e&&(e=JSON.stringify(e)),this.responseText=this.response=e,this.readyState=4,this.dispatchEvent({type:"readystatechange"})}var B=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(D(["abort","error","load","loadstart","progress","timeout","loadend"])),V=function(t){function e(){var e;return(e=t.call(this)||this).readyState=0,e._headers={},e.upload=new B,e}f(e,t);var n=e.prototype;return n.abort=function(){if(!this._request||this._request.abort)return this.status=0,this.readyState=4,this._request.abort();throw new Error("该版本基础库不支持 abort request")},n.getAllResponseHeaders=function(){var t=this;return this._responseHeaders?Object.keys(this._responseHeaders).map(function(e){return"".concat(e,": ").concat(t._responseHeaders[e])}).join("\r\n"):""},n.getResponseHeader=function(e){var t=e.toLowerCase();return this._responseHeaders&&this._responseHeaders[t]?this._responseHeaders[t]:null},n.overrideMimeType=function(){throw new Error("not supported in weapp")},n.open=function(e,t){var n=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];if(0!==this.readyState)throw new Error("request is already opened");if(!n)throw new Error("sync request is not supported");this._method=e,this._url=t,this.readyState=1,this.dispatchEvent({type:"readystatechange"})},n.setRequestHeader=function(e,t){if(1!==this.readyState)throw new Error("request is not opened");this._headers[e.toLowerCase()]=t},n.send=function(e){var r=this;if(1!==this.readyState)throw new Error("request is not opened");if(e instanceof F){var t=e.entries(),n=t.filter(function(e){return"string"!=typeof e[1]});if(0===n.length)throw new Error("Must specify a Blob field in FormData");1<n.length&&console.warn("Only the first Blob will be send in Weapp");var i=t.filter(function(e){return"string"==typeof e[1]}).reduce(function(e,t){return A(e,a({},t[0],t[1]))},{});this._request=wx.uploadFile({url:this._url,name:n[0][0],filePath:n[0][1].uri,formData:i,header:this._headers,success:U.bind(this),fail:function(e){r.status=0,r.readyState=4,r.dispatchEvent({type:"readystatechange"}),r.dispatchEvent({type:"error"})}}),this._request&&this._request.onProgressUpdate&&this._request.onProgressUpdate(function(e){var t=e.totalBytesSent,n=e.totalBytesExpectedToSend;r.upload.dispatchEvent({type:"progress",loaded:t,total:n})})}else this._request=wx.request({url:this._url,data:e||"",method:this._method.toUpperCase(),header:this._headers,success:U.bind(this),fail:function(e){r.status=0,r.readyState=4,r.dispatchEvent({type:"readystatechange"}),r.dispatchEvent({type:"error"})}})},e}(D(["abort","error","load","loadstart","progress","timeout","loadend","readystatechange"]));A(V,{UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4});var Y=V,q=function(i){function e(e,t){var o;if(!e)throw new TypeError("Failed to construct 'WebSocket': url required");if(t&&(!wx.canIUse||!wx.canIUse("connectSocket.object.protocols")))throw new Error("subprotocal not supported in weapp");(o=i.call(this)||this)._url=e,o._protocal=t||"",o._readyState=0;var n=function(e){o._readyState=3,o.dispatchEvent({type:"error",message:e.errMsg})},r=wx.connectSocket({url:e,protocals:o._protocal,fail:function(e){return setTimeout(function(){return n(e)},0)}});return(o._socketTask=r).onOpen(function(e){o._readyState=1,o.dispatchEvent({type:"open"})}),r.onError(n),r.onMessage(function(e){var t=e.data,n=e.origin,r=e.ports,i=e.source;o.dispatchEvent({data:t,origin:n,ports:r,source:i,type:"message"})}),r.onClose(function(e){o._readyState=3;var t=e.code,n=e.reason,r=e.wasClean;o.dispatchEvent({code:t,reason:n,wasClean:r,type:"close"})}),o}f(e,i);var t=e.prototype;return t.close=function(){3!==this.readyState&&(0===this.readyState&&console.warn("close WebSocket which is connecting might not work"),this._socketTask.close())},t.send=function(e){if(1!==this.readyState)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})},o(e,[{key:"url",get:function(){return this._url}},{key:"protocal",get:function(){return this._protocal}},{key:"readyState",get:function(){return this._readyState}}]),e}(D(["open","error","message","close"]));A(q,{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3});var z=q,W=function(n){if(wx.onNetworkStatusChange&&!n.__onlineOfflinePolyfilled){n.__onlineOfflinePolyfilled=!0;var e=new D;n.dispatchEvent||(n.addEventListener=e.addEventListener.bind(e),n.removeEventListener=e.removeEventListener.bind(e),n.dispatchEvent=e.dispatchEvent.bind(e),"function"!=typeof postMessage||n.importScripts||(n.importScripts=function(){throw new Error("mocked")})),wx.getNetworkType({success:function(e){var t=e.networkType;n.onLine="none"!==t,wx.onNetworkStatusChange(function(e){var t=e.isConnected;n.onLine!==t&&(n.onLine=t,n.dispatchEvent({type:t?"online":"offline"}))})}})}},G={},$=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:i||window;if("object"!==m(e))throw new Error("polyfill target is not an Object");var t={localStorage:p,XMLHttpRequest:Y,FormData:F,WebSocket:z,Object:Object,navigator:G};for(var n in t)e[n]||(e[n]=t[n]);W(e),e.navigator.product="ReactNative"};try{$()}catch(e){}try{$(GameGlobal)}catch(e){}try{window=window||{},$(window)}catch(e){}try{localStorage=localStorage||p}catch(e){}try{d=d||Y}catch(e){}try{FormData=FormData||F}catch(e){}try{WebSocket=WebSocket||z}catch(e){}try{navigator=navigator||G}catch(e){}var J=n(function(e){var t,n;t=i,n=function(){function r(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function p(e){return!0===(e&&e.__isLong__)}Object.defineProperty(r.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),r.isLong=p;var o={},s={};function e(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=s[e])?r:(n=m(e,(0|e)<0?-1:0,!0),i&&(s[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=o[e])?r:(n=m(e,e<0?-1:0,!1),i&&(o[e]=n),n)}function d(e,t){if(isNaN(e)||!isFinite(e))return t?u:v;if(t){if(e<0)return u;if(i<=e)return _}else{if(e<=-a)return E;if(a<=e+1)return w}return e<0?d(-e,t).neg():m(e%n|0,e/n|0,t)}function m(e,t,n){return new r(e,t,n)}r.fromInt=e,r.fromNumber=d,r.fromBits=m;var f=Math.pow;function l(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return v;if(t="number"==typeof t?(n=t,!1):!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if(0<(r=e.indexOf("-")))throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,n).neg();for(var i=d(f(n,8)),o=v,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),u=parseInt(e.substring(s,s+a),n);if(a<8){var c=d(f(n,a));o=o.mul(c).add(d(u))}else o=(o=o.mul(i)).add(d(u))}return o.unsigned=t,o}function g(e){return e instanceof r?e:"number"==typeof e?d(e):"string"==typeof e?l(e):m(e.low,e.high,e.unsigned)}r.fromString=l,r.fromValue=g;var n=4294967296,i=n*n,a=i/2,y=e(1<<24),v=e(0);r.ZERO=v;var u=e(0,!0);r.UZERO=u;var c=e(1);r.ONE=c;var h=e(1,!0);r.UONE=h;var b=e(-1);r.NEG_ONE=b;var w=m(-1,2147483647,!1);r.MAX_VALUE=w;var _=m(-1,-1,!0);r.MAX_UNSIGNED_VALUE=_;var E=m(0,-2147483648,!1);r.MIN_VALUE=E;var t=r.prototype;return t.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.toNumber=function(){return this.unsigned?(this.high>>>0)*n+(this.low>>>0):this.high*n+(this.low>>>0)},t.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(E)){var t=d(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=d(f(e,6),this.unsigned),o=this,s="";;){var a=o.div(i),u=(o.sub(a.mul(i)).toInt()>>>0).toString(e);if((o=a).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},t.getHighBits=function(){return this.high},t.getHighBitsUnsigned=function(){return this.high>>>0},t.getLowBits=function(){return this.low},t.getLowBitsUnsigned=function(){return this.low>>>0},t.getNumBitsAbs=function(){if(this.isNegative())return this.eq(E)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;0<t&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},t.isZero=function(){return 0===this.high&&0===this.low},t.isNegative=function(){return!this.unsigned&&this.high<0},t.isPositive=function(){return this.unsigned||0<=this.high},t.isOdd=function(){return 1==(1&this.low)},t.isEven=function(){return 0==(1&this.low)},t.equals=function(e){return p(e)||(e=g(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},t.eq=t.equals,t.notEquals=function(e){return!this.eq(e)},t.neq=t.notEquals,t.lessThan=function(e){return this.comp(e)<0},t.lt=t.lessThan,t.lessThanOrEqual=function(e){return this.comp(e)<=0},t.lte=t.lessThanOrEqual,t.greaterThan=function(e){return 0<this.comp(e)},t.gt=t.greaterThan,t.greaterThanOrEqual=function(e){return 0<=this.comp(e)},t.gte=t.greaterThanOrEqual,t.compare=function(e){if(p(e)||(e=g(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&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},t.comp=t.compare,t.negate=function(){return!this.unsigned&&this.eq(E)?E:this.not().add(c)},t.neg=t.negate,t.add=function(e){p(e)||(e=g(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,u=0,c=0,f=0,l=0;return f+=(l+=i+(65535&e.low))>>>16,c+=(f+=r+a)>>>16,u+=(c+=n+s)>>>16,u+=t+o,m((f&=65535)<<16|(l&=65535),(u&=65535)<<16|(c&=65535),this.unsigned)},t.subtract=function(e){return p(e)||(e=g(e)),this.add(e.neg())},t.sub=t.subtract,t.multiply=function(e){if(this.isZero())return v;if(p(e)||(e=g(e)),e.isZero())return v;if(this.eq(E))return e.isOdd()?E:v;if(e.eq(E))return this.isOdd()?E:v;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(y)&&e.lt(y))return d(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,u=65535&e.low,c=0,f=0,l=0,h=0;return l+=(h+=i*u)>>>16,f+=(l+=r*u)>>>16,l&=65535,f+=(l+=i*a)>>>16,c+=(f+=n*u)>>>16,f&=65535,c+=(f+=r*a)>>>16,f&=65535,c+=(f+=i*s)>>>16,c+=t*u+n*a+r*s+i*o,m((l&=65535)<<16|(h&=65535),(c&=65535)<<16|(f&=65535),this.unsigned)},t.mul=t.multiply,t.divide=function(e){if(p(e)||(e=g(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?u:v;var t,n,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return u;if(e.gt(this.shru(1)))return h;r=u}else{if(this.eq(E))return e.eq(c)||e.eq(b)?E:e.eq(E)?c:(t=this.shr(1).div(e).shl(1)).eq(v)?e.isNegative()?c:b:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));else if(e.eq(E))return this.unsigned?u:v;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();r=v}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var i=Math.ceil(Math.log(t)/Math.LN2),o=i<=48?1:f(2,i-48),s=d(t),a=s.mul(e);a.isNegative()||a.gt(n);)a=(s=d(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=c),r=r.add(s),n=n.sub(a)}return r},t.div=t.divide,t.modulo=function(e){return p(e)||(e=g(e)),this.sub(this.div(e).mul(e))},t.mod=t.modulo,t.not=function(){return m(~this.low,~this.high,this.unsigned)},t.and=function(e){return p(e)||(e=g(e)),m(this.low&e.low,this.high&e.high,this.unsigned)},t.or=function(e){return p(e)||(e=g(e)),m(this.low|e.low,this.high|e.high,this.unsigned)},t.xor=function(e){return p(e)||(e=g(e)),m(this.low^e.low,this.high^e.high,this.unsigned)},t.shiftLeft=function(e){return p(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?m(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):m(0,this.low<<e-32,this.unsigned)},t.shl=t.shiftLeft,t.shiftRight=function(e){return p(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?m(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):m(this.high>>e-32,0<=this.high?0:-1,this.unsigned)},t.shr=t.shiftRight,t.shiftRightUnsigned=function(e){if(p(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?m(this.low>>>e|t<<32-e,t>>>e,this.unsigned):m(32===e?t:t>>>e-32,0,this.unsigned)},t.shru=t.shiftRightUnsigned,t.toSigned=function(){return this.unsigned?m(this.low,this.high,!1):this},t.toUnsigned=function(){return this.unsigned?this:m(this.low,this.high,!0)},t.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},t.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]},t.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]},r},e&&e.exports?e.exports=n():(t.dcodeIO=t.dcodeIO||{}).Long=n()}),H=n(function(e){var t,n;t=i,n=function(u){var d=function(e,t,n){if(void 0===e&&(e=d.DEFAULT_CAPACITY),void 0===t&&(t=d.DEFAULT_ENDIAN),void 0===n&&(n=d.DEFAULT_NOASSERT),!n){if((e|=0)<0)throw RangeError("Illegal capacity");t=!!t,n=!!n}this.buffer=0===e?o:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t,this.noAssert=n};d.VERSION="5.0.1",d.LITTLE_ENDIAN=!0,d.BIG_ENDIAN=!1,d.DEFAULT_CAPACITY=16,d.DEFAULT_ENDIAN=d.BIG_ENDIAN,d.DEFAULT_NOASSERT=!1,d.Long=u||null;var s=d.prototype;s.__isByteBuffer__,Object.defineProperty(s,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var o=new ArrayBuffer(0),n=String.fromCharCode;function a(e){var t=0;return function(){return t<e.length?e.charCodeAt(t++):null}}function c(){var e=[],t=[];return function(){if(0===arguments.length)return t.join("")+n.apply(String,e);1024<e.length+arguments.length&&(t.push(n.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function r(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?i-1:0,h=n?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;0<f;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;0<f;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,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)}function i(e,t,n,r,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=r?0:o-1,d=r?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),2<=(t+=1<=s+l?h/u:h*Math.pow(2,1-l))*u&&(s++,u/=2),f<=s+l?(a=0,s=f):1<=s+l?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));8<=i;e[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;0<c;e[n+p]=255&s,p+=d,s/=256,c-=8);e[n+p-d]|=128*m}d.accessor=function(){return Uint8Array},d.allocate=function(e,t,n){return new d(e,t,n)},d.concat=function(e,t,n,r){"boolean"!=typeof t&&"string"==typeof t||(r=n,n=t,t=void 0);for(var i,o=0,s=0,a=e.length;s<a;++s)d.isByteBuffer(e[s])||(e[s]=d.wrap(e[s],t)),0<(i=e[s].limit-e[s].offset)&&(o+=i);if(0===o)return new d(0,n,r);var u,c=new d(o,n,r);for(s=0;s<a;)(i=(u=e[s++]).limit-u.offset)<=0||(c.view.set(u.view.subarray(u.offset,u.limit),c.offset),c.offset+=i);return c.limit=c.offset,c.offset=0,c},d.isByteBuffer=function(e){return!0===(e&&e.__isByteBuffer__)},d.type=function(){return ArrayBuffer},d.wrap=function(e,t,n,r){if("string"!=typeof t&&(r=n,n=t,t=void 0),"string"==typeof e)switch(void 0===t&&(t="utf8"),t){case"base64":return d.fromBase64(e,n);case"hex":return d.fromHex(e,n);case"binary":return d.fromBinary(e,n);case"utf8":return d.fromUTF8(e,n);case"debug":return d.fromDebug(e,n);default:throw Error("Unsupported encoding: "+t)}if(null===e||"object"!=typeof e)throw TypeError("Illegal buffer");var i;if(d.isByteBuffer(e))return(i=s.clone.call(e)).markedOffset=-1,i;if(e instanceof Uint8Array)i=new d(0,n,r),0<e.length&&(i.buffer=e.buffer,i.offset=e.byteOffset,i.limit=e.byteOffset+e.byteLength,i.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)i=new d(0,n,r),0<e.byteLength&&(i.buffer=e,i.offset=0,i.limit=e.byteLength,i.view=0<e.byteLength?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(i=new d(e.length,n,r)).limit=e.length;for(var o=0;o<e.length;++o)i.view[o]=e[o]}return i},s.writeBitSet=function(e,t){var n=void 0===t;if(n&&(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 r,i=t,o=e.length,s=o>>3,a=0;for(t+=this.writeVarint32(o,t);s--;)r=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(r,t++);if(a<o){var u=0;for(r=0;a<o;)r|=(1&!!e[a++])<<u++;this.writeByte(r,t++)}return n?(this.offset=t,this):t-i},s.readBitSet=function(e){var t=void 0===e;t&&(e=this.offset);var n,r=this.readVarint32(e),i=r.value,o=i>>3,s=0,a=[];for(e+=r.length;o--;)n=this.readByte(e++),a[s++]=!!(1&n),a[s++]=!!(2&n),a[s++]=!!(4&n),a[s++]=!!(8&n),a[s++]=!!(16&n),a[s++]=!!(32&n),a[s++]=!!(64&n),a[s++]=!!(128&n);if(s<i){var u=0;for(n=this.readByte(e++);s<i;)a[s++]=!!(n>>u++&1)}return t&&(this.offset=e),a},s.readBytes=function(e,t){var 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+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var r=this.slice(t,t+e);return n&&(this.offset+=e),r},s.writeBytes=s.append,s.writeInt8=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,n&&(this.offset+=1),this},s.writeByte=s.writeInt8,s.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 n=this.view[e];return 128==(128&n)&&(n=-(255-n+1)),t&&(this.offset+=1),n},s.readByte=s.readInt8,s.writeUint8=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r:t),t-=1,this.view[t]=e,n&&(this.offset+=1),this},s.writeUInt8=s.writeUint8,s.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 n=this.view[e];return t&&(this.offset+=1),n},s.readUInt8=s.readUint8,s.writeInt16=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r: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),n&&(this.offset+=2),this},s.writeShort=s.writeInt16,s.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 n=0;return this.littleEndian?(n=this.view[e],n|=this.view[e+1]<<8):(n=this.view[e]<<8,n|=this.view[e+1]),32768==(32768&n)&&(n=-(65535-n+1)),t&&(this.offset+=2),n},s.readShort=s.readInt16,s.writeUint16=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r: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),n&&(this.offset+=2),this},s.writeUInt16=s.writeUint16,s.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 n=0;return this.littleEndian?(n=this.view[e],n|=this.view[e+1]<<8):(n=this.view[e]<<8,n|=this.view[e+1]),t&&(this.offset+=2),n},s.readUInt16=s.readUint16,s.writeInt32=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r: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),n&&(this.offset+=4),this},s.writeInt=s.writeInt32,s.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 n=0;return this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0):(n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0),n|=0,t&&(this.offset+=4),n},s.readInt=s.readInt32,s.writeUint32=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r: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),n&&(this.offset+=4),this},s.writeUInt32=s.writeUint32,s.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 n=0;return this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0):(n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0),t&&(this.offset+=4),n},s.readUInt32=s.readUint32,u&&(s.writeInt64=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"==typeof e)e=u.fromNumber(e);else if("string"==typeof e)e=u.fromString(e);else if(!(e&&e instanceof u))throw TypeError("Illegal value: "+e+" (not an integer or Long)");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)}"number"==typeof e?e=u.fromNumber(e):"string"==typeof e&&(e=u.fromString(e)),t+=8;var r=this.buffer.byteLength;r<t&&this.resize((r*=2)>t?r:t),t-=8;var i=e.low,o=e.high;return this.littleEndian?(this.view[t+3]=i>>>24&255,this.view[t+2]=i>>>16&255,this.view[t+1]=i>>>8&255,this.view[t]=255&i,t+=4,this.view[t+3]=o>>>24&255,this.view[t+2]=o>>>16&255,this.view[t+1]=o>>>8&255,this.view[t]=255&o):(this.view[t]=o>>>24&255,this.view[t+1]=o>>>16&255,this.view[t+2]=o>>>8&255,this.view[t+3]=255&o,t+=4,this.view[t]=i>>>24&255,this.view[t+1]=i>>>16&255,this.view[t+2]=i>>>8&255,this.view[t+3]=255&i),n&&(this.offset+=8),this},s.writeLong=s.writeInt64,s.readInt64=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 n=0,r=0;this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0,e+=4,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,e+=4,n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0);var i=new u(n,r,!1);return t&&(this.offset+=8),i},s.readLong=s.readInt64,s.writeUint64=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"==typeof e)e=u.fromNumber(e);else if("string"==typeof e)e=u.fromString(e);else if(!(e&&e instanceof u))throw TypeError("Illegal value: "+e+" (not an integer or Long)");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)}"number"==typeof e?e=u.fromNumber(e):"string"==typeof e&&(e=u.fromString(e)),t+=8;var r=this.buffer.byteLength;r<t&&this.resize((r*=2)>t?r:t),t-=8;var i=e.low,o=e.high;return this.littleEndian?(this.view[t+3]=i>>>24&255,this.view[t+2]=i>>>16&255,this.view[t+1]=i>>>8&255,this.view[t]=255&i,t+=4,this.view[t+3]=o>>>24&255,this.view[t+2]=o>>>16&255,this.view[t+1]=o>>>8&255,this.view[t]=255&o):(this.view[t]=o>>>24&255,this.view[t+1]=o>>>16&255,this.view[t+2]=o>>>8&255,this.view[t+3]=255&o,t+=4,this.view[t]=i>>>24&255,this.view[t+1]=i>>>16&255,this.view[t+2]=i>>>8&255,this.view[t+3]=255&i),n&&(this.offset+=8),this},s.writeUInt64=s.writeUint64,s.readUint64=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 n=0,r=0;this.littleEndian?(n=this.view[e+2]<<16,n|=this.view[e+1]<<8,n|=this.view[e],n+=this.view[e+3]<<24>>>0,e+=4,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,e+=4,n=this.view[e+1]<<16,n|=this.view[e+2]<<8,n|=this.view[e+3],n+=this.view[e]<<24>>>0);var i=new u(n,r,!0);return t&&(this.offset+=8),i},s.readUInt64=s.readUint64),s.writeFloat32=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r:t),t-=4,i(this.view,e,t,this.littleEndian,23,4),n&&(this.offset+=4),this},s.writeFloat=s.writeFloat32,s.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 n=r(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),n},s.readFloat=s.readFloat32,s.writeFloat64=function(e,t){var n=void 0===t;if(n&&(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 r=this.buffer.byteLength;return r<t&&this.resize((r*=2)>t?r:t),t-=8,i(this.view,e,t,this.littleEndian,52,8),n&&(this.offset+=8),this},s.writeDouble=s.writeFloat64,s.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 n=r(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),n},s.readDouble=s.readFloat64,d.MAX_VARINT32_BYTES=5,d.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},d.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},d.zigZagDecode32=function(e){return e>>>1^-(1&e)|0},s.writeVarint32=function(e,t){var n=void 0===t;if(n&&(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)}var r,i=d.calculateVarint32(e);t+=i;var o=this.buffer.byteLength;for(o<t&&this.resize((o*=2)>t?o:t),t-=i,e>>>=0;128<=e;)r=127&e|128,this.view[t++]=r,e>>>=7;return this.view[t++]=e,n?(this.offset=t,this):i},s.writeVarint32ZigZag=function(e,t){return this.writeVarint32(d.zigZagEncode32(e),t)},s.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 n,r=0,i=0;do{if(!this.noAssert&&e>this.limit){var o=Error("Truncated");throw o.truncated=!0,o}n=this.view[e++],r<5&&(i|=(127&n)<<7*r),++r}while(0!=(128&n));return i|=0,t?(this.offset=e,i):{value:i,length:r}},s.readVarint32ZigZag=function(e){var t=this.readVarint32(e);return"object"==typeof t?t.value=d.zigZagDecode32(t.value):t=d.zigZagDecode32(t),t},u&&(d.MAX_VARINT64_BYTES=10,d.calculateVarint64=function(e){"number"==typeof e?e=u.fromNumber(e):"string"==typeof e&&(e=u.fromString(e));var t=e.toInt()>>>0,n=e.shiftRightUnsigned(28).toInt()>>>0,r=e.shiftRightUnsigned(56).toInt()>>>0;return 0==r?0==n?t<16384?t<128?1:2:t<1<<21?3:4:n<16384?n<128?5:6:n<1<<21?7:8:r<128?9:10},d.zigZagEncode64=function(e){return"number"==typeof e?e=u.fromNumber(e,!1):"string"==typeof e?e=u.fromString(e,!1):!1!==e.unsigned&&(e=e.toSigned()),e.shiftLeft(1).xor(e.shiftRight(63)).toUnsigned()},d.zigZagDecode64=function(e){return"number"==typeof e?e=u.fromNumber(e,!1):"string"==typeof e?e=u.fromString(e,!1):!1!==e.unsigned&&(e=e.toSigned()),e.shiftRightUnsigned(1).xor(e.and(u.ONE).toSigned().negate()).toSigned()},s.writeVarint64=function(e,t){var n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"==typeof e)e=u.fromNumber(e);else if("string"==typeof e)e=u.fromString(e);else if(!(e&&e instanceof u))throw TypeError("Illegal value: "+e+" (not an integer or Long)");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)}"number"==typeof e?e=u.fromNumber(e,!1):"string"==typeof e?e=u.fromString(e,!1):!1!==e.unsigned&&(e=e.toSigned());var r=d.calculateVarint64(e),i=e.toInt()>>>0,o=e.shiftRightUnsigned(28).toInt()>>>0,s=e.shiftRightUnsigned(56).toInt()>>>0;t+=r;var a=this.buffer.byteLength;switch(a<t&&this.resize((a*=2)>t?a:t),t-=r,r){case 10:this.view[t+9]=s>>>7&1;case 9:this.view[t+8]=9!==r?128|s:127&s;case 8:this.view[t+7]=8!==r?o>>>21|128:o>>>21&127;case 7:this.view[t+6]=7!==r?o>>>14|128:o>>>14&127;case 6:this.view[t+5]=6!==r?o>>>7|128:o>>>7&127;case 5:this.view[t+4]=5!==r?128|o:127&o;case 4:this.view[t+3]=4!==r?i>>>21|128:i>>>21&127;case 3:this.view[t+2]=3!==r?i>>>14|128:i>>>14&127;case 2:this.view[t+1]=2!==r?i>>>7|128:i>>>7&127;case 1:this.view[t]=1!==r?128|i:127&i}return n?(this.offset+=r,this):r},s.writeVarint64ZigZag=function(e,t){return this.writeVarint64(d.zigZagEncode64(e),t)},s.readVarint64=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 n=e,r=0,i=0,o=0,s=0;if(r=127&(s=this.view[e++]),128&s&&(r|=(127&(s=this.view[e++]))<<7,(128&s||this.noAssert&&void 0===s)&&(r|=(127&(s=this.view[e++]))<<14,(128&s||this.noAssert&&void 0===s)&&(r|=(127&(s=this.view[e++]))<<21,(128&s||this.noAssert&&void 0===s)&&(i=127&(s=this.view[e++]),(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[e++]))<<7,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[e++]))<<14,(128&s||this.noAssert&&void 0===s)&&(i|=(127&(s=this.view[e++]))<<21,(128&s||this.noAssert&&void 0===s)&&(o=127&(s=this.view[e++]),(128&s||this.noAssert&&void 0===s)&&(o|=(127&(s=this.view[e++]))<<7,128&s||this.noAssert&&void 0===s))))))))))throw Error("Buffer overrun");var a=u.fromBits(r|i<<28,i>>>4|o<<24,!1);return t?(this.offset=e,a):{value:a,length:e-n}},s.readVarint64ZigZag=function(e){var t=this.readVarint64(e);return t&&t.value instanceof u?t.value=d.zigZagDecode64(t.value):t=d.zigZagDecode64(t),t}),s.writeCString=function(e,t){var n=void 0===t;n&&(t=this.offset);var r,i=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(r=0;r<i;++r)if(0===e.charCodeAt(r))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=h.calculateUTF16asUTF8(a(e))[1],t+=i+1;var o=this.buffer.byteLength;return o<t&&this.resize((o*=2)>t?o:t),t-=i+1,h.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,n?(this.offset=t,this):i},s.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 n,r=e,i=-1;return h.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),n=c(),!0),t?(this.offset=e,n()):{string:n(),length:e-r}},s.writeIString=function(e,t){var n=void 0===t;if(n&&(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 r,i=t;r=h.calculateUTF16asUTF8(a(e),this.noAssert)[1],t+=4+r;var o=this.buffer.byteLength;if(o<t&&this.resize((o*=2)>t?o:t),t-=4+r,this.littleEndian?(this.view[t+3]=r>>>24&255,this.view[t+2]=r>>>16&255,this.view[t+1]=r>>>8&255,this.view[t]=255&r):(this.view[t]=r>>>24&255,this.view[t+1]=r>>>16&255,this.view[t+2]=r>>>8&255,this.view[t+3]=255&r),t+=4,h.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),t!==i+4+r)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+r));return n?(this.offset=t,this):t-i},s.readIString=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 n=e,r=this.readUint32(e),i=this.readUTF8String(r,d.METRICS_BYTES,e+=4);return e+=i.length,t?(this.offset=e,i.string):{string:i.string,length:e-n}},d.METRICS_CHARS="c",d.METRICS_BYTES="b",s.writeUTF8String=function(e,t){var n,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+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var i=t;n=h.calculateUTF16asUTF8(a(e))[1],t+=n;var o=this.buffer.byteLength;return o<t&&this.resize((o*=2)>t?o:t),t-=n,h.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),r?(this.offset=t,this):t-i},s.writeString=s.writeUTF8String,d.calculateUTF8Chars=function(e){return h.calculateUTF16asUTF8(a(e))[0]},d.calculateUTF8Bytes=function(e){return h.calculateUTF16asUTF8(a(e))[1]},d.calculateString=d.calculateUTF8Bytes,s.readUTF8String=function(e,t,n){"number"==typeof t&&(n=t,t=void 0);var r=void 0===n;if(r&&(n=this.offset),void 0===t&&(t=d.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 i,o=0,s=n;if(t===d.METRICS_CHARS){if(i=c(),h.decodeUTF8(function(){return o<e&&n<this.limit?this.view[n++]:null}.bind(this),function(e){++o,h.UTF8toUTF16(e,i)}),o!==e)throw RangeError("Illegal range: Truncated data, "+o+" == "+e);return r?(this.offset=n,i()):{string:i(),length:n-s}}if(t!==d.METRICS_BYTES)throw TypeError("Unsupported metrics: "+t);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 a=n+e;if(h.decodeUTF8toUTF16(function(){return n<a?this.view[n++]:null}.bind(this),i=c(),this.noAssert),n!==a)throw RangeError("Illegal range: Truncated data, "+n+" == "+a);return r?(this.offset=n,i()):{string:i(),length:n-s}},s.readString=s.readUTF8String,s.writeVString=function(e,t){var n=void 0===t;if(n&&(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 r,i,o=t;r=h.calculateUTF16asUTF8(a(e),this.noAssert)[1],i=d.calculateVarint32(r),t+=i+r;var s=this.buffer.byteLength;if(s<t&&this.resize((s*=2)>t?s:t),t-=i+r,t+=this.writeVarint32(r,t),h.encodeUTF16toUTF8(a(e),function(e){this.view[t++]=e}.bind(this)),t!==o+r+i)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+r+i));return n?(this.offset=t,this):t-o},s.readVString=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 n=e,r=this.readVarint32(e),i=this.readUTF8String(r.value,d.METRICS_BYTES,e+=r.length);return e+=i.length,t?(this.offset=e,i.string):{string:i.string,length:e-n}},s.append=function(e,t,n){"number"!=typeof t&&"string"==typeof t||(n=t,t=void 0);var r=void 0===n;if(r&&(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 d||(e=d.wrap(e,t));var i=e.limit-e.offset;if(i<=0)return this;n+=i;var o=this.buffer.byteLength;return o<n&&this.resize((o*=2)>n?o:n),n-=i,this.view.set(e.view.subarray(e.offset,e.limit),n),e.offset+=i,r&&(this.offset+=i),this},s.appendTo=function(e,t){return e.append(this,t),this},s.assert=function(e){return this.noAssert=!e,this},s.capacity=function(){return this.buffer.byteLength},s.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},s.clone=function(e){var t=new d(0,this.littleEndian,this.noAssert);return t.view=e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(t.buffer)):(t.buffer=this.buffer,this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t},s.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||t<e||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var n=t-e;if(0===n)return this.buffer=o,this.view=null,0<=this.markedOffset&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var r=new ArrayBuffer(n),i=new Uint8Array(r);return i.set(this.view.subarray(e,t)),this.buffer=r,this.view=i,0<=this.markedOffset&&(this.markedOffset-=e),this.offset=0,this.limit=n,this},s.copy=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||t<e||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(e===t)return new d(0,this.littleEndian,this.noAssert);var n=t-e,r=new d(n,this.littleEndian,this.noAssert);return r.offset=0,r.limit=n,0<=r.markedOffset&&(r.markedOffset-=e),this.copyTo(r,0,e,t),r},s.copyTo=function(e,t,n,r){var i,o;if(!this.noAssert&&!d.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(t=(o=void 0===t)?e.offset:0|t,n=(i=void 0===n)?this.offset:0|n,r=void 0===r?this.limit:0|r,t<0||t>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+t+" <= "+e.buffer.byteLength);if(n<0||r>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+n+" <= "+this.buffer.byteLength);var s=r-n;return 0===s?e:(e.ensureCapacity(t+s),e.view.set(this.view.subarray(n,r),t),i&&(this.offset+=s),o&&(e.offset+=s),this)},s.ensureCapacity=function(e){var t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this},s.fill=function(e,t,n){var r=void 0===t;if(r&&(t=this.offset),"string"==typeof e&&0<e.length&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===n&&(n=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 n||n%1!=0)throw TypeError("Illegal end: Not an integer");if(n>>>=0,t<0||n<t||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}if(n<=t)return this;for(;t<n;)this.view[t++]=e;return r&&(this.offset=t),this},s.flip=function(){return this.limit=this.offset,this.offset=0,this},s.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},s.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},s.LE=function(e){return this.littleEndian=void 0===e||!!e,this},s.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},s.prepend=function(e,t,n){"number"!=typeof t&&"string"==typeof t||(n=t,t=void 0);var r=void 0===n;if(r&&(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 d||(e=d.wrap(e,t));var i=e.limit-e.offset;if(i<=0)return this;var o=i-n;if(0<o){var s=new ArrayBuffer(this.buffer.byteLength+o),a=new Uint8Array(s);a.set(this.view.subarray(n,this.buffer.byteLength),i),this.buffer=s,this.view=a,this.offset+=o,0<=this.markedOffset&&(this.markedOffset+=o),this.limit+=o,n+=o}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),n-i),e.offset=e.limit,r&&(this.offset-=i),this},s.prependTo=function(e,t){return e.prepend(this,t),this},s.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},s.remaining=function(){return this.limit-this.offset},s.reset=function(){return 0<=this.markedOffset?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},s.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),n=new Uint8Array(t);n.set(this.view),this.buffer=t,this.view=n}return this},s.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||t<e||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},s.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},s.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||t<e||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var n=this.clone();return n.offset=e,n.limit=t,n},s.toBuffer=function(e){var t=this.offset,n=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal limit: Not an integer");if(n>>>=0,t<0||n<t||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}if(!e&&0===t&&n===this.buffer.byteLength)return this.buffer;if(t===n)return o;var r=new ArrayBuffer(n-t);return new Uint8Array(r).set(new Uint8Array(this.buffer).subarray(t,n),0),r},s.toArrayBuffer=s.toBuffer,s.toString=function(e,t,n){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(n=t=e="utf8"),e){case"utf8":return this.toUTF8(t,n);case"base64":return this.toBase64(t,n);case"hex":return this.toHex(t,n);case"binary":return this.toBinary(t,n);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var f=function(){for(var e={},i=[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],s=[],t=0,n=i.length;t<n;++t)s[i[t]]=t;return e.encode=function(e,t){for(var n,r;null!==(n=e());)t(i[n>>2&63]),r=(3&n)<<4,null!==(n=e())?(t(i[63&((r|=n>>4&15)|n>>4&15)]),r=(15&n)<<2,null!==(n=e())?(t(i[63&(r|n>>6&3)]),t(i[63&n])):(t(i[63&r]),t(61))):(t(i[63&r]),t(61),t(61))},e.decode=function(e,t){var n,r,i;function o(e){throw Error("Illegal character code: "+e)}for(;null!==(n=e());)if(void 0===(r=s[n])&&o(n),null!==(n=e())&&(void 0===(i=s[n])&&o(n),t(r<<2>>>0|(48&i)>>4),null!==(n=e()))){if(void 0===(r=s[n])){if(61===n)break;o(n)}if(t((15&i)<<4>>>0|(60&r)>>2),null!==(n=e())){if(void 0===(i=s[n])){if(61===n)break;o(n)}t((3&r)<<6>>>0|i)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();s.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||t<e)throw RangeError("begin, end");var n;return f.encode(function(){return e<t?this.view[e++]:null}.bind(this),n=c()),n()},d.fromBase64=function(e,t){if("string"!=typeof e)throw TypeError("str");var n=new d(e.length/4*3,t),r=0;return f.decode(a(e),function(e){n.view[r++]=e}),n.limit=r,n},d.btoa=function(e){return d.fromBinary(e).toBase64()},d.atob=function(e){return d.fromBase64(e).toBinary()},s.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()||t<e)throw RangeError("begin, end");if(e===t)return"";for(var n=[],r=[];e<t;)n.push(this.view[e++]),1024<=n.length&&(r.push(String.fromCharCode.apply(String,n)),n=[]);return r.join("")+String.fromCharCode.apply(String,n)},d.fromBinary=function(e,t){if("string"!=typeof e)throw TypeError("str");for(var n,r=0,i=e.length,o=new d(i,t);r<i;){if(255<(n=e.charCodeAt(r)))throw RangeError("illegal char code: "+n);o.view[r++]=n}return o.limit=i,o},s.toDebug=function(e){for(var t,n=-1,r=this.buffer.byteLength,i="",o="",s="";n<r;){if(-1!==n&&(i+=(t=this.view[n])<16?"0"+t.toString(16).toUpperCase():t.toString(16).toUpperCase(),e&&(o+=32<t&&t<127?String.fromCharCode(t):".")),++n,e&&0<n&&n%16==0&&n!==r){for(;i.length<51;)i+=" ";s+=i+o+"\n",i=o=""}n===this.offset&&n===this.limit?i+=n===this.markedOffset?"!":"|":n===this.offset?i+=n===this.markedOffset?"[":"<":n===this.limit?i+=n===this.markedOffset?"]":">":i+=n===this.markedOffset?"'":e||0!==n&&n!==r?" ":""}if(e&&" "!==i){for(;i.length<51;)i+=" ";s+=i+o+"\n"}return e?s:i},d.fromDebug=function(e,t,n){for(var r,i,o=e.length,s=new d((o+1)/3|0,t,n),a=0,u=0,c=!1,f=!1,l=!1,h=!1,p=!1;a<o;){switch(r=e.charAt(a++)){case"!":if(!n){if(f||l||h){p=!0;break}f=l=h=!0}s.offset=s.markedOffset=s.limit=u,c=!1;break;case"|":if(!n){if(f||h){p=!0;break}f=h=!0}s.offset=s.limit=u,c=!1;break;case"[":if(!n){if(f||l){p=!0;break}f=l=!0}s.offset=s.markedOffset=u,c=!1;break;case"<":if(!n){if(f){p=!0;break}f=!0}s.offset=u,c=!1;break;case"]":if(!n){if(h||l){p=!0;break}h=l=!0}s.limit=s.markedOffset=u,c=!1;break;case">":if(!n){if(h){p=!0;break}h=!0}s.limit=u,c=!1;break;case"'":if(!n){if(l){p=!0;break}l=!0}s.markedOffset=u,c=!1;break;case" ":c=!1;break;default:if(!n&&c){p=!0;break}if(i=parseInt(r+e.charAt(a++),16),!n&&(isNaN(i)||i<0||255<i))throw TypeError("Illegal str: Not a debug encoded string");s.view[u++]=i,c=!0}if(p)throw TypeError("Illegal str: Invalid symbol at "+a)}if(!n){if(!f||!h)throw TypeError("Illegal str: Missing offset or limit");if(u<s.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+u+" < "+o)}return s},s.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||t<e||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var n,r=new Array(t-e);e<t;)(n=this.view[e++])<16?r.push("0",n.toString(16)):r.push(n.toString(16));return r.join("")},d.fromHex=function(e,t,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 r,i=e.length,o=new d(i/2|0,t),s=0,a=0;s<i;s+=2){if(r=parseInt(e.substring(s,s+2),16),!n&&(!isFinite(r)||r<0||255<r))throw TypeError("Illegal str: Contains non-hex characters");o.view[a++]=r}return o.limit=a,o};var l,h=l={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<128?t(127&n):(n<2048?t(n>>6&31|192):(n<65536?t(n>>12&15|224):(t(n>>18&7|240),t(n>>12&63|128)),t(n>>6&63|128)),t(63&n|128)),n=null},decodeUTF8:function(e,t){for(var n,r,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!==(n=e());)if(0==(128&n))t(n);else if(192==(224&n))null===(r=e())&&s([n,r]),t((31&n)<<6|63&r);else if(224==(240&n))(null===(r=e())||null===(i=e()))&&s([n,r,i]),t((15&n)<<12|(63&r)<<6|63&i);else{if(240!=(248&n))throw RangeError("Illegal starting byte: "+n);(null===(r=e())||null===(i=e())||null===(o=e()))&&s([n,r,i,o]),t((7&n)<<18|(63&r)<<12|(63&i)<<6|63&o)}},UTF16toUTF8:function(e,t){for(var n,r=null;null!==(n=null!==r?r:e());)55296<=n&&n<=57343&&null!==(r=e())&&56320<=r&&r<=57343?(t(1024*(n-55296)+r-56320+65536),r=null):t(n);null!==r&&t(r)},UTF8toUTF16:function(e,t){var n=null;for("number"==typeof e&&(n=e,e=function(){return null});null!==n||null!==(n=e());)n<=65535?t(n):(t(55296+((n-=65536)>>10)),t(n%1024+56320)),n=null},encodeUTF16toUTF8:function(e,t){l.UTF16toUTF8(e,function(e){l.encodeUTF8(e,t)})},decodeUTF8toUTF16:function(e,t){l.decodeUTF8(e,function(e){l.UTF8toUTF16(e,t)})},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,n=0;null!==(t=e());)n+=t<128?1:t<2048?2:t<65536?3:4;return n},calculateUTF16asUTF8:function(e){var t=0,n=0;return l.UTF16toUTF8(e,function(e){++t,n+=e<128?1:e<2048?2:e<65536?3:4}),[t,n]}};return s.toUTF8=function(t,n){if(void 0===t&&(t=this.offset),void 0===n&&(n=this.limit),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal end: Not an integer");if(n>>>=0,t<0||n<t||n>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+n+" <= "+this.buffer.byteLength)}var e;try{h.decodeUTF8toUTF16(function(){return t<n?this.view[t++]:null}.bind(this),e=c())}catch(e){if(t!==n)throw RangeError("Illegal range: Truncated data, "+t+" != "+n)}return e()},d.fromUTF8=function(e,t,n){if(!n&&"string"!=typeof e)throw TypeError("Illegal str: Not a string");var r=new d(h.calculateUTF16asUTF8(a(e),!0)[1],t,n),i=0;return h.encodeUTF16toUTF8(a(e),function(e){r.view[i++]=e}),r.limit=i,r},d},e&&e.exports?e.exports=function(){var e;try{e=J}catch(e){}return n(e)}():(t.dcodeIO=t.dcodeIO||{}).ByteBuffer=n(t.dcodeIO.Long)}),Z={},X=n(function(e){var t,n;t=i,n=function(_,e){var i,l,t,s,a,n,o={};return o.ByteBuffer=_,o.Long=_.Long||null,o.VERSION="5.0.3",o.WIRE_TYPES={},o.WIRE_TYPES.VARINT=0,o.WIRE_TYPES.BITS64=1,o.WIRE_TYPES.LDELIM=2,o.WIRE_TYPES.STARTGROUP=3,o.WIRE_TYPES.ENDGROUP=4,o.WIRE_TYPES.BITS32=5,o.PACKABLE_WIRE_TYPES=[o.WIRE_TYPES.VARINT,o.WIRE_TYPES.BITS64,o.WIRE_TYPES.BITS32],o.TYPES={int32:{name:"int32",wireType:o.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:o.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:o.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:o.WIRE_TYPES.VARINT,defaultValue:o.Long?o.Long.ZERO:void 0},uint64:{name:"uint64",wireType:o.WIRE_TYPES.VARINT,defaultValue:o.Long?o.Long.UZERO:void 0},sint64:{name:"sint64",wireType:o.WIRE_TYPES.VARINT,defaultValue:o.Long?o.Long.ZERO:void 0},bool:{name:"bool",wireType:o.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:o.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:o.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:o.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:o.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:o.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:o.WIRE_TYPES.BITS64,defaultValue:o.Long?o.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:o.WIRE_TYPES.BITS64,defaultValue:o.Long?o.Long.ZERO:void 0},float:{name:"float",wireType:o.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:o.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:o.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:o.WIRE_TYPES.STARTGROUP,defaultValue:null}},o.MAP_KEY_TYPES=[o.TYPES.int32,o.TYPES.sint32,o.TYPES.sfixed32,o.TYPES.uint32,o.TYPES.fixed32,o.TYPES.int64,o.TYPES.sint64,o.TYPES.sfixed64,o.TYPES.uint64,o.TYPES.fixed64,o.TYPES.bool,o.TYPES.string,o.TYPES.bytes],o.ID_MIN=1,o.ID_MAX=536870911,o.convertFieldsToCamelCase=!1,o.populateAccessors=!0,o.populateDefaults=!0,o.Util=((i={}).IS_NODE=!("object"!=typeof u||u+""!="[object process]"||u.browser),i.XHR=function(){for(var e=[function(){return new d},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,n=0;n<e.length;n++){try{t=e[n]()}catch(e){continue}break}if(!t)throw Error("XMLHttpRequest is not supported");return t},i.fetch=function(e,n){if(n&&"function"!=typeof n&&(n=null),i.IS_NODE){var t=Z;if(n)t.readFile(e,function(e,t){n(e?null:""+t)});else try{return t.readFileSync(e)}catch(e){return null}}else{var r=i.XHR();if(r.open("GET",e,!!n),r.setRequestHeader("Accept","text/plain"),"function"==typeof r.overrideMimeType&&r.overrideMimeType("text/plain"),!n)return r.send(null),200==r.status||0==r.status&&"string"==typeof r.responseText?r.responseText:null;if(r.onreadystatechange=function(){4==r.readyState&&(200==r.status||0==r.status&&"string"==typeof r.responseText?n(r.responseText):n(null))},4==r.readyState)return;r.send(null)}},i.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,function(e,t){return t.toUpperCase()})},i),o.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},o.Reflect=function(m){var s={},f=function(e,t,n){this.builder=e,this.parent=t,this.name=n,this.className},e=f.prototype;e.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},e.toString=function(e){return(e?this.className+" ":"")+this.fqn()},e.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},s.T=f;var a=function(e,t,n,r,i){f.call(this,e,t,n),this.className="Namespace",this.children=[],this.options=r||{},this.syntax=i||"proto2"},t=a.prototype=Object.create(f.prototype);t.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],n=0,r=this.children.length;n<r;++n)this.children[n]instanceof e&&t.push(this.children[n]);return t},t.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof h.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof h.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)},t.getChild=function(e){for(var t="number"==typeof e?"id":"name",n=0,r=this.children.length;n<r;++n)if(this.children[n][t]===e)return this.children[n];return null},t.resolve=function(e,t){var n,r="string"==typeof e?e.split("."):e,i=this,o=0;if(""===r[o]){for(;null!==i.parent;)i=i.parent;o++}do{do{if(!(i instanceof s.Namespace)){i=null;break}if(!(n=i.getChild(r[o]))||!(n instanceof s.T)||t&&!(n instanceof s.Namespace)){i=null;break}i=n,o++}while(o<r.length);if(null!=i)break;if(null!==this.parent)return this.parent.resolve(e,t)}while(null!=i);return i},t.qn=function(e){for(var t=[],n=e;t.unshift(n.name),null!==(n=n.parent););for(var r=1;r<=t.length;r++){var i=t.slice(t.length-r);if(e===this.resolve(i,e instanceof s.Namespace))return i.join(".")}return e.fqn()},t.build=function(){for(var e,t={},n=this.children,r=0,i=n.length;r<i;++r)(e=n[r])instanceof a&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},t.buildOpt=function(){for(var e={},t=Object.keys(this.options),n=0,r=t.length;n<r;++n){var i=t[n],o=this.options[t[n]];e[i]=o}return e},t.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},s.Namespace=a;var l=function(e,t,n,r,i){if(this.type=e,this.resolvedType=t,this.isMapKey=n,this.syntax=r,this.name=i,n&&m.MAP_KEY_TYPES.indexOf(e)<0)throw Error("Invalid map key type: "+e.name)},n=l.prototype;function u(e,t){if(e&&"number"==typeof e.low&&"number"==typeof e.high&&"boolean"==typeof e.unsigned&&e.low==e.low&&e.high==e.high)return new m.Long(e.low,e.high,void 0===t?e.unsigned:t);if("string"==typeof e)return m.Long.fromString(e,t||!1,10);if("number"==typeof e)return m.Long.fromNumber(e,t||!1);throw Error("not convertible to Long")}l.defaultFieldValue=function(e){if("string"==typeof e&&(e=m.TYPES[e]),void 0===e.defaultValue)throw Error("default value for type "+e.name+" is not supported");return e==m.TYPES.bytes?new _(0):e.defaultValue},n.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},n.verifyValue=function(t){var n=this;function r(e,t){throw Error("Illegal value for "+n.toString(!0)+" of type "+n.type.name+": "+e+" ("+t+")")}switch(this.type){case m.TYPES.int32:case m.TYPES.sint32:case m.TYPES.sfixed32:return("number"!=typeof t||t==t&&t%1!=0)&&r(typeof t,"not an integer"),4294967295<t?0|t:t;case m.TYPES.uint32:case m.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&r(typeof t,"not an integer"),t<0?t>>>0:t;case m.TYPES.int64:case m.TYPES.sint64:case m.TYPES.sfixed64:if(m.Long)try{return u(t,!1)}catch(e){r(typeof t,e.message)}else r(typeof t,"requires Long.js");case m.TYPES.uint64:case m.TYPES.fixed64:if(m.Long)try{return u(t,!0)}catch(e){r(typeof t,e.message)}else r(typeof t,"requires Long.js");case m.TYPES.bool:return"boolean"!=typeof t&&r(typeof t,"not a boolean"),t;case m.TYPES.float:case m.TYPES.double:return"number"!=typeof t&&r(typeof t,"not a number"),t;case m.TYPES.string:return"string"==typeof t||t&&t instanceof String||r(typeof t,"not a string"),""+t;case m.TYPES.bytes:return _.isByteBuffer(t)?t:_.wrap(t,"base64");case m.TYPES.enum:var e=this.resolvedType.getChildren(m.Reflect.Enum.Value);for(o=0;o<e.length;o++){if(e[o].name==t)return e[o].id;if(e[o].id==t)return e[o].id}if("proto3"===this.syntax)return("number"!=typeof t||t==t&&t%1!=0)&&r(typeof t,"not an integer"),(4294967295<t||t<0)&&r(typeof t,"not in range for uint32"),t;r(t,"not a valid enum value");case m.TYPES.group:case m.TYPES.message:if(t&&"object"==typeof t||r(typeof t,"object expected"),t instanceof this.resolvedType.clazz)return t;if(t instanceof m.Builder.Message){var i={};for(var o in t)t.hasOwnProperty(o)&&(i[o]=t[o]);t=i}return new this.resolvedType.clazz(t)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+t+" (undefined type "+this.type+")")},n.calculateLength=function(e,t){if(null===t)return 0;var n;switch(this.type){case m.TYPES.int32:return t<0?_.calculateVarint64(t):_.calculateVarint32(t);case m.TYPES.uint32:return _.calculateVarint32(t);case m.TYPES.sint32:return _.calculateVarint32(_.zigZagEncode32(t));case m.TYPES.fixed32:case m.TYPES.sfixed32:case m.TYPES.float:return 4;case m.TYPES.int64:case m.TYPES.uint64:return _.calculateVarint64(t);case m.TYPES.sint64:return _.calculateVarint64(_.zigZagEncode64(t));case m.TYPES.fixed64:case m.TYPES.sfixed64:return 8;case m.TYPES.bool:return 1;case m.TYPES.enum:return _.calculateVarint32(t);case m.TYPES.double:return 8;case m.TYPES.string:return n=_.calculateUTF8Bytes(t),_.calculateVarint32(n)+n;case m.TYPES.bytes:if(t.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+t.remaining()+" bytes remaining");return _.calculateVarint32(t.remaining())+t.remaining();case m.TYPES.message:return n=this.resolvedType.calculate(t),_.calculateVarint32(n)+n;case m.TYPES.group:return(n=this.resolvedType.calculate(t))+_.calculateVarint32(e<<3|m.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+t+" (unknown type)")},n.encodeValue=function(e,t,n){if(null===t)return n;switch(this.type){case m.TYPES.int32:t<0?n.writeVarint64(t):n.writeVarint32(t);break;case m.TYPES.uint32:n.writeVarint32(t);break;case m.TYPES.sint32:n.writeVarint32ZigZag(t);break;case m.TYPES.fixed32:n.writeUint32(t);break;case m.TYPES.sfixed32:n.writeInt32(t);break;case m.TYPES.int64:case m.TYPES.uint64:n.writeVarint64(t);break;case m.TYPES.sint64:n.writeVarint64ZigZag(t);break;case m.TYPES.fixed64:n.writeUint64(t);break;case m.TYPES.sfixed64:n.writeInt64(t);break;case m.TYPES.bool:"string"==typeof t?n.writeVarint32("false"===t.toLowerCase()?0:!!t):n.writeVarint32(t?1:0);break;case m.TYPES.enum:n.writeVarint32(t);break;case m.TYPES.float:n.writeFloat32(t);break;case m.TYPES.double:n.writeFloat64(t);break;case m.TYPES.string:n.writeVString(t);break;case m.TYPES.bytes:if(t.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+t.remaining()+" bytes remaining");var r=t.offset;n.writeVarint32(t.remaining()),n.append(t),t.offset=r;break;case m.TYPES.message:var i=(new _).LE();this.resolvedType.encode(t,i),n.writeVarint32(i.offset),n.append(i.flip());break;case m.TYPES.group:this.resolvedType.encode(t,n),n.writeVarint32(e<<3|m.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+t+" (unknown type)")}return n},n.decode=function(e,t,n){if(t!=this.type.wireType)throw Error("Unexpected wire type for element");var r,i;switch(this.type){case m.TYPES.int32:return 0|e.readVarint32();case m.TYPES.uint32:return e.readVarint32()>>>0;case m.TYPES.sint32:return 0|e.readVarint32ZigZag();case m.TYPES.fixed32:return e.readUint32()>>>0;case m.TYPES.sfixed32:return 0|e.readInt32();case m.TYPES.int64:return e.readVarint64();case m.TYPES.uint64:return e.readVarint64().toUnsigned();case m.TYPES.sint64:return e.readVarint64ZigZag();case m.TYPES.fixed64:return e.readUint64();case m.TYPES.sfixed64:return e.readInt64();case m.TYPES.bool:return!!e.readVarint32();case m.TYPES.enum:return e.readVarint32();case m.TYPES.float:return e.readFloat();case m.TYPES.double:return e.readDouble();case m.TYPES.string:return e.readVString();case m.TYPES.bytes:if(i=e.readVarint32(),e.remaining()<i)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+i+" required but got only "+e.remaining());return(r=e.clone()).limit=r.offset+i,e.offset+=i,r;case m.TYPES.message:return i=e.readVarint32(),this.resolvedType.decode(e,i);case m.TYPES.group:return this.resolvedType.decode(e,-1,n)}throw Error("[INTERNAL] Illegal decode type")},n.valueFromString=function(e){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case m.TYPES.int32:case m.TYPES.sint32:case m.TYPES.sfixed32:case m.TYPES.uint32:case m.TYPES.fixed32:return this.verifyValue(parseInt(e));case m.TYPES.int64:case m.TYPES.sint64:case m.TYPES.sfixed64:case m.TYPES.uint64:case m.TYPES.fixed64:return this.verifyValue(e);case m.TYPES.bool:return"true"===e;case m.TYPES.string:return this.verifyValue(e);case m.TYPES.bytes:return _.fromBinary(e)}},n.valueToString=function(e){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===m.TYPES.bytes?e.toString("binary"):e.toString()},s.Element=l;var h=function(e,t,n,r,i,o){a.call(this,e,t,n,r,o),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!i,this._fields=null,this._fieldsById=null,this._fieldsByName=null},r=h.prototype=Object.create(a.prototype);function g(e,t){var n=t.readVarint32(),r=7&n,i=n>>>3;switch(r){case m.WIRE_TYPES.VARINT:for(;128==(128&(n=t.readUint8())););break;case m.WIRE_TYPES.BITS64:t.offset+=8;break;case m.WIRE_TYPES.LDELIM:n=t.readVarint32(),t.offset+=n;break;case m.WIRE_TYPES.STARTGROUP:g(i,t);break;case m.WIRE_TYPES.ENDGROUP:if(i===e)return!1;throw Error("Illegal GROUPEND after unknown group: "+i+" ("+e+" expected)");case m.WIRE_TYPES.BITS32:t.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+e+": "+r)}return!0}r.build=function(e){if(this.clazz&&!e)return this.clazz;var t=function(l,s){var a=s.getChildren(l.Reflect.Message.Field),u=s.getChildren(l.Reflect.Message.OneOf),c=function(e,t){l.Builder.Message.call(this);for(var n=0,r=u.length;n<r;++n)this[u[n].name]=null;for(n=0,r=a.length;n<r;++n){var i=a[n];this[i.name]=i.repeated?[]:i.map?new l.Map(i):null,!i.required&&"proto3"!==s.syntax||null===i.defaultValue||(this[i.name]=i.defaultValue)}var o;if(0<arguments.length)if(1!==arguments.length||null===e||"object"!=typeof e||!("function"!=typeof e.encode||e instanceof c)||Array.isArray(e)||e instanceof l.Map||_.isByteBuffer(e)||e instanceof ArrayBuffer||l.Long&&e instanceof l.Long)for(n=0,r=arguments.length;n<r;++n)void 0!==(o=arguments[n])&&this.$set(a[n].name,o);else this.$set(e)},o=c.prototype=Object.create(l.Builder.Message.prototype);o.add=function(e,t,n){var r=s._fieldsByName[e];if(!n){if(!r)throw Error(this+"#"+e+" is undefined");if(!(r instanceof l.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+r.toString(!0));if(!r.repeated)throw Error(this+"#"+e+" is not a repeated field");t=r.verifyValue(t,!0)}return null===this[e]&&(this[e]=[]),this[e].push(t),this},o.$add=o.add,o.set=function(e,t,n){if(e&&"object"==typeof e){for(var r in n=t,e)e.hasOwnProperty(r)&&void 0!==(t=e[r])&&void 0===s._oneofsByName[r]&&this.$set(r,t,n);return this}var i=s._fieldsByName[e];if(n)this[e]=t;else{if(!i)throw Error(this+"#"+e+" is not a field: undefined");if(!(i instanceof l.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+i.toString(!0));this[i.name]=t=i.verifyValue(t)}if(i&&i.oneof){var o=this[i.oneof.name];null!==t?(null!==o&&o!==i.name&&(this[o]=null),this[i.oneof.name]=i.name):o===e&&(this[i.oneof.name]=null)}return this},o.$set=o.set,o.get=function(e,t){if(t)return this[e];var n=s._fieldsByName[e];if(!(n&&n instanceof l.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: undefined");if(!(n instanceof l.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+n.toString(!0));return this[n.name]},o.$get=o.get;for(var e=0;e<a.length;e++){var t=a[e];t instanceof l.Reflect.Message.ExtensionField||s.builder.options.populateAccessors&&function(n){var e=n.originalName.replace(/(_[a-zA-Z])/g,function(e){return e.toUpperCase().replace("_","")});e=e.substring(0,1).toUpperCase()+e.substring(1);var t=n.originalName.replace(/([A-Z])/g,function(e){return"_"+e}),r=function(e,t){return this[n.name]=t?e:n.verifyValue(e),this},i=function(){return this[n.name]};null===s.getChild("set"+e)&&(o["set"+e]=r),null===s.getChild("set_"+t)&&(o["set_"+t]=r),null===s.getChild("get"+e)&&(o["get"+e]=i),null===s.getChild("get_"+t)&&(o["get_"+t]=i)}(t)}function h(e,n,r,i){if(null===e||"object"!=typeof e){if(i&&i instanceof l.Reflect.Enum){var t=l.Reflect.Enum.getName(i.object,e);if(null!==t)return t}return e}if(_.isByteBuffer(e))return n?e.toBase64():e.toBuffer();if(l.Long.isLong(e))return r?e.toString():l.Long.fromValue(e);var o;if(Array.isArray(e))return o=[],e.forEach(function(e,t){o[t]=h(e,n,r,i)}),o;if(o={},e instanceof l.Map){for(var s=e.entries(),a=s.next();!a.done;a=s.next())o[e.keyElem.valueToString(a.value[0])]=h(a.value[1],n,r,e.valueElem.resolvedType);return o}var u=e.$type,c=void 0;for(var f in e)e.hasOwnProperty(f)&&(u&&(c=u.getChild(f))?o[f]=h(e[f],n,r,c.resolvedType):o[f]=h(e[f],n,r));return o}return o.encode=function(t,e){"boolean"==typeof t&&(e=t,t=void 0);var n=!1;t||(t=new _,n=!0);var r=t.littleEndian;try{return s.encode(this,t.LE(),e),(n?t.flip():t).LE(r)}catch(e){throw t.LE(r),e}},c.encode=function(e,t,n){return new c(e).encode(t,n)},o.calculate=function(){return s.calculate(this)},o.encodeDelimited=function(e,t){var n=!1;e||(e=new _,n=!0);var r=(new _).LE();return s.encode(this,r,t).flip(),e.writeVarint32(r.remaining()),e.append(r),n?e.flip():e},o.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},o.toArrayBuffer=o.encodeAB,o.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},o.toBuffer=o.encodeNB,o.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},o.toBase64=o.encode64,o.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},o.toHex=o.encodeHex,o.toRaw=function(e,t){return h(this,!!e,!!t,this.$type)},o.encodeJSON=function(){return JSON.stringify(h(this,!0,!0,this.$type))},c.decode=function(t,e,n){"string"==typeof e&&(n=e,e=-1),"string"==typeof t?t=_.wrap(t,n||"base64"):_.isByteBuffer(t)||(t=_.wrap(t));var r=t.littleEndian;try{var i=s.decode(t.LE(),e);return t.LE(r),i}catch(e){throw t.LE(r),e}},c.decodeDelimited=function(t,e){if("string"==typeof t?t=_.wrap(t,e||"base64"):_.isByteBuffer(t)||(t=_.wrap(t)),t.remaining()<1)return null;var n=t.offset,r=t.readVarint32();if(t.remaining()<r)return t.offset=n,null;try{var i=s.decode(t.slice(t.offset,t.offset+r).LE());return t.offset+=r,i}catch(e){throw t.offset+=r,e}},c.decode64=function(e){return c.decode(e,"base64")},c.decodeHex=function(e){return c.decode(e,"hex")},c.decodeJSON=function(e){return new c(JSON.parse(e))},o.toString=function(){return s.toString()},Object.defineProperty&&(Object.defineProperty(c,"$options",{value:s.buildOpt()}),Object.defineProperty(o,"$options",{value:c.$options}),Object.defineProperty(c,"$type",{value:s}),Object.defineProperty(o,"$type",{value:s})),c}(m,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var n,r=0,i=this.children.length;r<i;r++)if((n=this.children[r])instanceof p||n instanceof h||n instanceof v){if(t.hasOwnProperty(n.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+n.toString(!0)+" cannot override static property '"+n.name+"'");t[n.name]=n.build()}else if(n instanceof h.Field)n.build(),this._fields.push(n),this._fieldsById[n.id]=n,this._fieldsByName[n.name]=n;else if(n instanceof h.OneOf)this._oneofsByName[n.name]=n;else if(!(n instanceof h.OneOf||n instanceof y))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[r].toString(!0));return this.clazz=t},r.encode=function(e,t,n){for(var r,i,o=null,s=0,a=this._fields.length;s<a;++s)i=e[(r=this._fields[s]).name],r.required&&null===i?null===o&&(o=r):r.encode(n?i:r.verifyValue(i),t,e);if(null===o)return t;var u=Error("Missing at least one required field for "+this.toString(!0)+": "+o);throw u.encoded=t,u},r.calculate=function(e){for(var t,n,r=0,i=0,o=this._fields.length;i<o;++i){if(n=e[(t=this._fields[i]).name],t.required&&null===n)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(n,e)}return r},r.decode=function(e,t,n){"number"!=typeof t&&(t=-1);for(var r,i,o,s,a=e.offset,u=new this.clazz;e.offset<a+t||-1===t&&0<e.remaining();){if(o=(r=e.readVarint32())>>>3,(i=7&r)===m.WIRE_TYPES.ENDGROUP){if(o!==n)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+o+" ("+(n?n+" expected":"not a group")+")");break}if(s=this._fieldsById[o]){if(s.repeated&&!s.options.packed)u[s.name].push(s.decode(i,e));else if(s.map){var c=s.decode(i,e);u[s.name].set(c[0],c[1])}else if(u[s.name]=s.decode(i,e),s.oneof){var f=u[s.oneof.name];null!==f&&f!==s.name&&(u[f]=null),u[s.oneof.name]=s.name}}else switch(i){case m.WIRE_TYPES.VARINT:e.readVarint32();break;case m.WIRE_TYPES.BITS32:e.offset+=4;break;case m.WIRE_TYPES.BITS64:e.offset+=8;break;case m.WIRE_TYPES.LDELIM:var l=e.readVarint32();e.offset+=l;break;case m.WIRE_TYPES.STARTGROUP:for(;g(o,e););break;default:throw Error("Illegal wire type for unknown field "+o+" in "+this.toString(!0)+"#decode: "+i)}}for(var h=0,p=this._fields.length;h<p;++h)if(null===u[(s=this._fields[h]).name])if("proto3"===this.syntax)u[s.name]=s.defaultValue;else{if(s.required){var d=Error("Missing at least one required field for "+this.toString(!0)+": "+s.name);throw d.decoded=u,d}m.populateDefaults&&null!==s.defaultValue&&(u[s.name]=s.defaultValue)}return u},s.Message=h;var c=function(e,t,n,r,i,o,s,a,u,c){f.call(this,e,t,o),this.className="Message.Field",this.required="required"===n,this.repeated="repeated"===n,this.map="map"===n,this.keyType=r||null,this.type=i,this.resolvedType=null,this.id=s,this.options=a||{},this.defaultValue=null,this.oneof=u||null,this.syntax=c||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof h.ExtensionField||(this.name=m.Util.toCamelCase(this.name))},i=c.prototype=Object.create(f.prototype);i.build=function(){this.element=new l(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new l(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=l.defaultFieldValue(this.type)},i.verifyValue=function(e,t){t=t||!1;var n,r=this;function i(e,t){throw Error("Illegal value for "+r.toString(!0)+" of type "+r.type.name+": "+e+" ("+t+")")}if(null===e)return this.required&&i(typeof e,"required"),"proto3"===this.syntax&&this.type!==m.TYPES.message&&i(typeof e,"proto3 field without field presence cannot be null"),null;if(!this.repeated||t)return this.map&&!t?e instanceof m.Map?e:(e instanceof Object||i(typeof e,"expected ProtoBuf.Map or raw object for map field"),new m.Map(this,e)):(!this.repeated&&Array.isArray(e)&&i(typeof e,"no array expected"),this.element.verifyValue(e));Array.isArray(e)||(e=[e]);var o=[];for(n=0;n<e.length;n++)o.push(this.element.verifyValue(e[n]));return o},i.hasWirePresence=function(e,t){if("proto3"!==this.syntax)return null!==e;if(this.oneof&&t[this.oneof.name]===this.name)return!0;switch(this.type){case m.TYPES.int32:case m.TYPES.sint32:case m.TYPES.sfixed32:case m.TYPES.uint32:case m.TYPES.fixed32:return 0!==e;case m.TYPES.int64:case m.TYPES.sint64:case m.TYPES.sfixed64:case m.TYPES.uint64:case m.TYPES.fixed64:return 0!==e.low||0!==e.high;case m.TYPES.bool:return e;case m.TYPES.float:case m.TYPES.double:return 0!==e;case m.TYPES.string:return 0<e.length;case m.TYPES.bytes:return 0<e.remaining();case m.TYPES.enum:return 0!==e;case m.TYPES.message:return null!==e;default:return!0}},i.encode=function(t,i,e){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return i;try{var n;if(this.repeated)if(this.options.packed&&0<=m.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){i.writeVarint32(this.id<<3|m.WIRE_TYPES.LDELIM),i.ensureCapacity(i.offset+=1);var r=i.offset;for(n=0;n<t.length;n++)this.element.encodeValue(this.id,t[n],i);var o=i.offset-r,s=_.calculateVarint32(o);if(1<s){var a=i.slice(r,i.offset);r+=s-1,i.offset=r,i.append(a)}i.writeVarint32(o,r-s)}else for(n=0;n<t.length;n++)i.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t[n],i);else this.map?t.forEach(function(e,t,n){var r=_.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,t)+_.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,e);i.writeVarint32(this.id<<3|m.WIRE_TYPES.LDELIM),i.writeVarint32(r),i.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,t,i),i.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,e,i)},this):this.hasWirePresence(t,e)&&(i.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,t,i))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return i},i.calculate=function(t,e){if(t=this.verifyValue(t),null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===t||this.repeated&&0==t.length)return 0;var i=0;try{var n,r;if(this.repeated)if(this.options.packed&&0<=m.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)){for(i+=_.calculateVarint32(this.id<<3|m.WIRE_TYPES.LDELIM),n=r=0;n<t.length;n++)r+=this.element.calculateLength(this.id,t[n]);i+=_.calculateVarint32(r),i+=r}else for(n=0;n<t.length;n++)i+=_.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,t[n]);else this.map?t.forEach(function(e,t,n){var r=_.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,t)+_.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,e);i+=_.calculateVarint32(this.id<<3|m.WIRE_TYPES.LDELIM),i+=_.calculateVarint32(r),i+=r},this):this.hasWirePresence(t,e)&&(i+=_.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,t))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+t+" ("+e+")")}return i},i.decode=function(e,t,n){var r,i;if(!(!this.map&&e==this.type.wireType||!n&&this.repeated&&this.options.packed&&e==m.WIRE_TYPES.LDELIM||this.map&&e==m.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+e+" ("+this.type.wireType+" expected)");if(e==m.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&0<=m.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)&&!n){i=t.readVarint32(),i=t.offset+i;for(var o=[];t.offset<i;)o.push(this.decode(this.type.wireType,t,!0));return o}if(this.map){var s=l.defaultFieldValue(this.keyType);if(r=l.defaultFieldValue(this.type),i=t.readVarint32(),t.remaining()<i)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+i+" required but got only "+t.remaining());var a=t.clone();for(a.limit=a.offset+i,t.offset+=i;0<a.remaining();){var u=a.readVarint32();e=7&u;var c=u>>>3;if(1===c)s=this.keyElement.decode(a,e,c);else{if(2!==c)throw Error("Unexpected tag in map field key/value submessage");r=this.element.decode(a,e,c)}}return[s,r]}return this.element.decode(t,e,this.id)},s.Message.Field=c;var o=function(e,t,n,r,i,o,s){c.call(this,e,t,n,null,r,i,o,s),this.extension};o.prototype=Object.create(c.prototype),s.Message.ExtensionField=o;s.Message.OneOf=function(e,t,n){f.call(this,e,t,n),this.fields=[]};var p=function(e,t,n,r,i){a.call(this,e,t,n,r,i),this.className="Enum",this.object=null};p.getName=function(e,t){for(var n,r=Object.keys(e),i=0;i<r.length;++i)if(e[n=r[i]]===t)return n;return null},(p.prototype=Object.create(a.prototype)).build=function(e){if(this.object&&!e)return this.object;for(var t=new m.Builder.Enum,n=this.getChildren(p.Value),r=0,i=n.length;r<i;++r)t[n[r].name]=n[r].id;return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=t},s.Enum=p;var d=function(e,t,n,r){f.call(this,e,t,n),this.className="Enum.Value",this.id=r};d.prototype=Object.create(f.prototype),s.Enum.Value=d;var y=function(e,t,n,r){f.call(this,e,t,n),this.field=r};y.prototype=Object.create(f.prototype),s.Extension=y;var v=function(e,t,n,r){a.call(this,e,t,n,r),this.className="Service",this.clazz=null};(v.prototype=Object.create(a.prototype)).build=function(e){return this.clazz&&!e?this.clazz:this.clazz=function(t,i){for(var o=function(e){t.Builder.Service.call(this),this.rpcImpl=e||function(e,t,n){setTimeout(n.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},e=o.prototype=Object.create(t.Builder.Service.prototype),n=i.getChildren(t.Reflect.Service.RPCMethod),r=0;r<n.length;r++)!function(r){e[r.name]=function(e,n){try{try{e=r.resolvedRequestType.clazz.decode(_.wrap(e))}catch(e){if(!(e instanceof TypeError))throw e}if(null===e||"object"!=typeof e)throw Error("Illegal arguments");e instanceof r.resolvedRequestType.clazz||(e=new r.resolvedRequestType.clazz(e)),this.rpcImpl(r.fqn(),e,function(e,t){if(e)n(e);else{null===t&&(t="");try{t=r.resolvedResponseType.clazz.decode(t)}catch(e){}t&&t instanceof r.resolvedResponseType.clazz?n(null,t):n(Error("Illegal response type received in service method "+i.name+"#"+r.name))}})}catch(e){setTimeout(n.bind(this,e),0)}},o[r.name]=function(e,t,n){new o(e)[r.name](t,n)},Object.defineProperty&&(Object.defineProperty(o[r.name],"$options",{value:r.buildOpt()}),Object.defineProperty(e[r.name],"$options",{value:o[r.name].$options}))}(n[r]);return Object.defineProperty&&(Object.defineProperty(o,"$options",{value:i.buildOpt()}),Object.defineProperty(e,"$options",{value:o.$options}),Object.defineProperty(o,"$type",{value:i}),Object.defineProperty(e,"$type",{value:i})),o}(m,this)},s.Service=v;var b=function(e,t,n,r){f.call(this,e,t,n),this.className="Service.Method",this.options=r||{}};(b.prototype=Object.create(f.prototype)).buildOpt=t.buildOpt,s.Service.Method=b;var w=function(e,t,n,r,i,o,s,a){b.call(this,e,t,n,a),this.className="Service.RPCMethod",this.requestName=r,this.responseName=i,this.requestStream=o,this.responseStream=s,this.resolvedRequestType=null,this.resolvedResponseType=null};return w.prototype=Object.create(b.prototype),s.Service.RPCMethod=w,s}(o),o.Builder=(t=(l=o).Lang,s=o.Reflect,n=(a=function(e){this.ns=new s.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}}).prototype,a.isMessage=function(e){return"string"==typeof e.name&&void 0===e.values&&void 0===e.rpc},a.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},a.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},a.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},a.isExtend=function(e){return"string"==typeof e.ref},n.reset=function(){return this.ptr=this.ns,this},n.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 s.Namespace(this,this.ptr,e)),this.ptr=t},this),this},n.create=function(e){if(!e)return this;if(Array.isArray(e)){if(0===e.length)return this;e=e.slice()}else e=[e];for(var t=[e];0<t.length;){if(e=t.pop(),!Array.isArray(e))throw Error("not a valid namespace: "+JSON.stringify(e));for(;0<e.length;){var n=e.shift();if(a.isMessage(n)){var o=new s.Message(this,this.ptr,n.name,n.options,n.isGroup,n.syntax),r={};n.oneofs&&Object.keys(n.oneofs).forEach(function(e){o.addChild(r[e]=new s.Message.OneOf(this,o,e))},this),n.fields&&n.fields.forEach(function(e){if(null!==o.getChild(0|e.id))throw Error("duplicate or invalid field id in "+o.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+o.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=r[e.oneof]))throw Error("illegal oneof in "+o.name+"#"+e.name+": "+e.oneof);e=new s.Message.Field(this,o,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,n.syntax),t&&t.fields.push(e),o.addChild(e)},this);var i=[];if(n.enums&&n.enums.forEach(function(e){i.push(e)}),n.messages&&n.messages.forEach(function(e){i.push(e)}),n.services&&n.services.forEach(function(e){i.push(e)}),n.extensions&&("number"==typeof n.extensions[0]?o.extensions=[n.extensions]:o.extensions=n.extensions),this.ptr.addChild(o),0<i.length){t.push(e),e=i,i=null,this.ptr=o,o=null;continue}i=null}else if(a.isEnum(n))o=new s.Enum(this,this.ptr,n.name,n.options,n.syntax),n.values.forEach(function(e){o.addChild(new s.Enum.Value(this,o,e.name,e.id))},this),this.ptr.addChild(o);else if(a.isService(n))o=new s.Service(this,this.ptr,n.name,n.options),Object.keys(n.rpc).forEach(function(e){var t=n.rpc[e];o.addChild(new s.Service.RPCMethod(this,o,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))},this),this.ptr.addChild(o);else{if(!a.isExtend(n))throw Error("not a valid definition: "+JSON.stringify(n));if(o=this.ptr.resolve(n.ref,!0))n.fields.forEach(function(t){if(null!==o.getChild(0|t.id))throw Error("duplicate extended field id in "+o.name+": "+t.id);if(o.extensions){var n=!1;if(o.extensions.forEach(function(e){t.id>=e[0]&&t.id<=e[1]&&(n=!0)}),!n)throw Error("illegal extended field id in "+o.name+": "+t.id+" (not within valid ranges)")}var e=t.name;this.options.convertFieldsToCamelCase&&(e=l.Util.toCamelCase(e));var r=new s.Message.ExtensionField(this,o,t.rule,t.type,this.ptr.fqn()+"."+e,t.id,t.options),i=new s.Extension(this,this.ptr,t.name,r);r.extension=i,this.ptr.addChild(i),o.addChild(r)},this);else if(!/\.?google\.protobuf\./.test(n.ref))throw Error("extended message "+n.ref+" is not defined")}o=n=null}e=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},n.import=function(t,e){var n="/";if("string"==typeof e){if(l.Util.IS_NODE&&(e=Z.resolve(e)),!0===this.files[e])return this.reset();this.files[e]=!0}else if("object"==typeof e){var r,i=e.root;if(l.Util.IS_NODE&&(i=Z.resolve(i)),(0<=i.indexOf("\\")||0<=e.file.indexOf("\\"))&&(n="\\"),r=l.Util.IS_NODE?Z.join(i,e.file):i+n+e.file,!0===this.files[r])return this.reset();this.files[r]=!0}if(t.imports&&0<t.imports.length){var o,s=!1;"object"==typeof e?(this.importRoot=e.root,s=!0,o=this.importRoot,e=e.file,(0<=o.indexOf("\\")||0<=e.indexOf("\\"))&&(n="\\")):"string"==typeof e?this.importRoot?o=this.importRoot:0<=e.indexOf("/")?""===(o=e.replace(/\/[^\/]*$/,""))&&(o="/"):0<=e.indexOf("\\")?(o=e.replace(/\\[^\\]*$/,""),n="\\"):o=".":o=null;for(var a=0;a<t.imports.length;a++)if("string"==typeof t.imports[a]){if(!o)throw Error("cannot determine import root");var u=t.imports[a];if("google/protobuf/descriptor.proto"===u)continue;if(u=l.Util.IS_NODE?Z.join(o,u):o+n+u,!0===this.files[u])continue;/\.proto$/i.test(u)&&!l.DotProto&&(u=u.replace(/\.proto$/,".json"));var c=l.Util.fetch(u);if(null===c)throw Error("failed to import '"+u+"' in '"+e+"': file not found");/\.json$/i.test(u)?this.import(JSON.parse(c+""),u):this.import(l.DotProto.Parser.parse(c),u)}else e?/\.(\w+)$/.test(e)?this.import(t.imports[a],e.replace(/^(.+)\.(\w+)$/,function(e,t,n){return t+"_import"+a+"."+n})):this.import(t.imports[a],e+"_import"+a):this.import(t.imports[a]);s&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&function t(n){n.messages&&n.messages.forEach(function(e){e.syntax=n.syntax,t(e)}),n.enums&&n.enums.forEach(function(e){e.syntax=n.syntax})}(t);var f=this.ptr;return t.options&&Object.keys(t.options).forEach(function(e){f.options[e]=t.options[e]}),t.messages&&(this.create(t.messages),this.ptr=f),t.enums&&(this.create(t.enums),this.ptr=f),t.services&&(this.create(t.services),this.ptr=f),t.extends&&this.create(t.extends),this.reset()},n.resolveAll=function(){var e;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof s.Namespace)this.ptr.children.forEach(function(e){this.ptr=e,this.resolveAll()},this);else if(this.ptr instanceof s.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=l.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(!(e=(this.ptr instanceof s.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=e)instanceof s.Enum){if(this.ptr.type=l.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==e.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(e instanceof s.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=e.isGroup?l.TYPES.group:l.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=l.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==l.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof l.Reflect.Service.Method){if(!(this.ptr instanceof l.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((e=this.ptr.parent.resolve(this.ptr.requestName,!0))&&e instanceof l.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=e,!((e=this.ptr.parent.resolve(this.ptr.responseName,!0))&&e instanceof l.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=e}else if(!(this.ptr instanceof l.Reflect.Message.OneOf||this.ptr instanceof l.Reflect.Extension||this.ptr instanceof l.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},n.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,n=this.result,r=0;r<t.length;r++){if(!n[t[r]]){n=null;break}n=n[t[r]]}return n},n.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},n.toString=function(){return"Builder"},a.Message=function(){},a.Enum=function(){},a.Service=function(){},a),o.Map=function(e,s){var t=function(e,t){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new s.Element(e.keyType,null,!0,e.syntax),this.valueElem=new s.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),t)for(var n=Object.keys(t),r=0;r<n.length;r++){var i=this.keyElem.valueFromString(n[r]),o=this.valueElem.verifyValue(t[n[r]]);this.map[this.keyElem.valueToString(i)]={key:i,value:o}}},n=t.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)),n=t in this.map;return delete this.map[t],n},n.entries=function(){for(var e,t=[],n=Object.keys(this.map),r=0;r<n.length;r++)t.push([(e=this.map[n[r]]).key,e.value]);return i(t)},n.keys=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].key);return i(e)},n.values=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].value);return i(e)},n.forEach=function(e,t){for(var n,r=Object.keys(this.map),i=0;i<r.length;i++)e.call(t,(n=this.map[r[i]]).value,n.key,this)},n.set=function(e,t){var n=this.keyElem.verifyValue(e),r=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(n)]={key:n,value:r},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},t}(0,o.Reflect),o.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=o.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=o.populateAccessors),new o.Builder(e)},o.loadJson=function(e,t,n){return("string"==typeof t||t&&"string"==typeof t.file&&"string"==typeof t.root)&&(n=t,t=null),t&&"object"==typeof t||(t=o.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),t.import(e,n),t.resolveAll(),t},o.loadJsonFile=function(t,n,r){if(n&&"object"==typeof n?(r=n,n=null):n&&"function"==typeof n||(n=null),n)return o.Util.fetch("string"==typeof t?t:t.root+"/"+t.file,function(e){if(null!==e)try{n(null,o.loadJson(JSON.parse(e),r,t))}catch(e){n(e)}else n(Error("Failed to fetch file"))});var e=o.Util.fetch("object"==typeof t?t.root+"/"+t.file:t);return null===e?null:o.loadJson(JSON.parse(e),r,t)},o},e&&e.exports?e.exports=n(H):(t.dcodeIO=t.dcodeIO||{}).ProtoBuf=n(t.dcodeIO.ByteBuffer)}).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,K=X.JsonObjectMessage,Q=X.UnreadTuple,ee=X.LogItem,te=X.DataCommand,ne=X.SessionCommand,re=X.ErrorCommand,ie=X.DirectCommand,oe=X.AckCommand,se=X.UnreadCommand,ae=X.ConvCommand,ue=X.RoomCommand,ce=X.LogsCommand,fe=X.RcpCommand,le=X.ReadTuple,he=X.MaxReadTuple,pe=X.ReadCommand,de=X.PresenceCommand,me=X.ReportCommand,ge=X.GenericCommand,ye=X.BlacklistCommand,ve=X.PatchCommand,be=X.PatchItem,we=X.ConvMemberInfo,_e=X.CommandType,Ee=X.OpType,Te=X.StatusType,Se=Object.freeze({JsonObjectMessage:K,UnreadTuple:Q,LogItem:ee,DataCommand:te,SessionCommand:ne,ErrorCommand:re,DirectCommand:ie,AckCommand:oe,UnreadCommand:se,ConvCommand:ae,RoomCommand:ue,LogsCommand:ce,RcpCommand:fe,ReadTuple:le,MaxReadTuple:he,ReadCommand:pe,PresenceCommand:de,ReportCommand:me,GenericCommand:ge,BlacklistCommand:ye,PatchCommand:ve,PatchItem:be,ConvMemberInfo:we,CommandType:_e,OpType:Ee,StatusType:Te}),Ae=n(function(e){var r=Object.prototype.hasOwnProperty,p="~";function n(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new a(n,r||e,i),s=p?p+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],o]:e._events[s].push(o):(e._events[s]=o,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function t(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(p=!1)),t.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(p?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},t.prototype.listeners=function(e){var t=p?p+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,o=new Array(i);r<i;r++)o[r]=n[r].fn;return o},t.prototype.listenerCount=function(e){var t=p?p+e:e,n=this._events[t];return n?n.fn?1:n.length:0},t.prototype.emit=function(e,t,n,r,i,o){var s=p?p+e:e;if(!this._events[s])return!1;var a,u,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,o),!0}for(u=1,a=new Array(f-1);u<f;u++)a[u-1]=arguments[u];c.fn.apply(c.context,a)}else{var l,h=c.length;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,r);break;default:if(!a)for(l=1,a=new Array(f-1);l<f;l++)a[l-1]=arguments[l];c[u].fn.apply(c[u].context,a)}}return!0},t.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},t.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},t.prototype.removeListener=function(e,t,n,r){var i=p?p+e:e;if(!this._events[i])return this;if(!t)return c(this,i),this;var o=this._events[i];if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||c(this,i);else{for(var s=0,a=[],u=o.length;s<u;s++)(o[s].fn!==t||r&&!o[s].once||n&&o[s].context!==n)&&a.push(o[s]);a.length?this._events[i]=1===a.length?a[0]:a:c(this,i)}return this},t.prototype.removeAllListeners=function(e){var t;return e?(t=p?p+e:e,this._events[t]&&c(this,t)):(this._events=new n,this._eventsCount=0),this},t.prototype.off=t.prototype.removeListener,t.prototype.addListener=t.prototype.on,t.prefixed=p,t.EventEmitter=t,e.exports=t}),Ie=n(function(k){!function(e){var u,t=Object.prototype,c=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag",s=e.regeneratorRuntime;if(s)k.exports=s;else{(s=e.regeneratorRuntime=k.exports).wrap=v;var l="suspendedStart",h="suspendedYield",p="executing",d="completed",m={},a={};a[i]=function(){return this};var f=Object.getPrototypeOf,g=f&&f(f(x([])));g&&g!==t&&c.call(g,i)&&(a=g);var y=E.prototype=w.prototype=Object.create(a);_.prototype=y.constructor=E,E.constructor=_,E[o]=_.displayName="GeneratorFunction",s.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===_||"GeneratorFunction"===(t.displayName||t.name))},s.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(y),e},s.awrap=function(e){return{__await:e}},T(S.prototype),S.prototype[r]=function(){return this},s.AsyncIterator=S,s.async=function(e,t,n,r){var i=new S(v(e,t,n,r));return s.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},T(y),y[o]="Generator",y[i]=function(){return this},y.toString=function(){return"[object Generator]"},s.keys=function(n){var r=[];for(var e in n)r.push(e);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},s.values=x,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&c.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=u)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return o.type="throw",o.arg=n,r.next=e,t&&(r.method="next",r.arg=u),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var i=this.tryEntries[t],o=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var s=c.call(i,"catchLoc"),a=c.call(i,"finallyLoc");if(s&&a){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&c.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},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),m},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;O(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:x(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=u),m}}}function v(e,t,n,r){var o,s,a,u,i=t&&t.prototype instanceof w?t:w,c=Object.create(i.prototype),f=new C(r||[]);return c._invoke=(o=e,s=n,a=f,u=l,function(e,t){if(u===p)throw new Error("Generator is already running");if(u===d){if("throw"===e)throw t;return M()}for(a.method=e,a.arg=t;;){var n=a.delegate;if(n){var r=A(n,a);if(r){if(r===m)continue;return r}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if(u===l)throw u=d,a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);u=p;var i=b(o,s,a);if("normal"===i.type){if(u=a.done?d:h,i.arg===m)continue;return{value:i.arg,done:a.done}}"throw"===i.type&&(u=d,a.method="throw",a.arg=i.arg)}}),c}function b(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function w(){}function _(){}function E(){}function T(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function S(u){var t;this._invoke=function(n,r){function e(){return new Promise(function(e,t){!function t(e,n,r,i){var o=b(u[e],u,n);if("throw"!==o.type){var s=o.arg,a=s.value;return a&&"object"==typeof a&&c.call(a,"__await")?Promise.resolve(a.__await).then(function(e){t("next",e,r,i)},function(e){t("throw",e,r,i)}):Promise.resolve(a).then(function(e){s.value=e,r(s)},function(e){return t("throw",e,r,i)})}i(o.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}}function A(e,t){var n=e.iterator[t.method];if(n===u){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=u,A(e,t),"throw"===t.method))return m;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var r=b(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,m;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=u),t.delegate=null,m):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function I(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function x(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,r=function e(){for(;++n<t.length;)if(c.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=u,e.done=!0,e};return r.next=r}}return{next:M}}function M(){return{value:u,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())}),Oe=function(){return this||"object"==typeof self&&self}()||Function("return this")(),Ce=Oe.regeneratorRuntime&&0<=Object.getOwnPropertyNames(Oe).indexOf("regeneratorRuntime"),xe=Ce&&Oe.regeneratorRuntime;Oe.regeneratorRuntime=void 0;var Me=Ie;if(Ce)Oe.regeneratorRuntime=xe;else try{delete Oe.regeneratorRuntime}catch(e){Oe.regeneratorRuntime=void 0}var ke=Me,Re=36e5,Pe=864e5,Ne=function(e,t){t=t||{};var n=typeof e;if("string"===n&&0<e.length)return function(e){if(100<(e=String(e)).length)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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*Pe;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Re;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*n;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(Pe<=t)return Le(e,t,Pe,"day");if(Re<=t)return Le(e,t,Re,"hour");if(6e4<=t)return Le(e,t,6e4,"minute");if(1e3<=t)return Le(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(Pe<=t)return Math.round(e/Pe)+"d";if(Re<=t)return Math.round(e/Re)+"h";if(6e4<=t)return Math.round(e/6e4)+"m";if(1e3<=t)return Math.round(e/1e3)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Le(e,t,n,r){var i=1.5*n<=t;return Math.round(e/n)+" "+r+(i?"s":"")}var je=function(t){function n(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return c.colors[Math.abs(t)%c.colors.length]}function c(e){var a;function u(){if(u.enabled){for(var e=arguments.length,i=new Array(e),t=0;t<e;t++)i[t]=arguments[t];var o=u,n=Number(new Date),r=n-(a||n);o.diff=r,o.prev=a,o.curr=n,a=n,i[0]=c.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var s=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(e,t){if("%%"===e)return e;s++;var n=c.formatters[t];if("function"==typeof n){var r=i[s];e=n.call(o,r),i.splice(s,1),s--}return e}),c.formatArgs.call(o,i),(o.log||c.log).apply(o,i)}}return u.namespace=e,u.enabled=c.enabled(e),u.useColors=c.useColors(),u.color=n(e),u.destroy=r,u.extend=i,"function"==typeof c.init&&c.init(u),c.instances.push(u),u}function r(){var e=c.instances.indexOf(this);return-1!==e&&(c.instances.splice(e,1),!0)}function i(e,t){return c(this.namespace+(void 0===t?":":t)+e)}return((c.debug=c).default=c).coerce=function(e){return e instanceof Error?e.stack||e.message:e},c.disable=function(){c.enable("")},c.enable=function(e){var t;c.save(e),c.names=[],c.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(t=0;t<r;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?c.skips.push(new RegExp("^"+e.substr(1)+"$")):c.names.push(new RegExp("^"+e+"$")));for(t=0;t<c.instances.length;t++){var i=c.instances[t];i.enabled=c.enabled(i.namespace)}},c.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=c.skips.length;t<n;t++)if(c.skips[t].test(e))return!1;for(t=0,n=c.names.length;t<n;t++)if(c.names[t].test(e))return!0;return!1},c.humanize=Ne,Object.keys(t).forEach(function(e){c[e]=t[e]}),c.instances=[],c.names=[],c.skips=[],c.formatters={},c.selectColor=n,c.enable(c.load()),c},De=n(function(i,t){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)}t.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":n(console))&&console.log&&(e=console).log.apply(e,arguments)},t.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+i.exports.humanize(this.diff),!this.useColors)return;var t="color: "+this.color;e.splice(1,0,t,"color: inherit");var n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(r=n))}),e.splice(r,0,t)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==u&&"env"in u&&(e=u.env.DEBUG);return e},t.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+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.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"],i.exports=je(t),i.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}),Fe=(De.log,De.formatArgs,De.save,De.load,De.useColors,De.storage,De.colors,n(function(e){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}(e.exports=n).prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}})),Ue=Ye;(Ye.default=Ye).stable=ze,Ye.stableStringify=ze;var Be=[],Ve=[];function Ye(e,t,n){var r;for(!function e(t,n,r,i){var o;if("object"==typeof t&&null!==t){for(o=0;o<r.length;o++)if(r[o]===t){var s=Object.getOwnPropertyDescriptor(i,n);return void(void 0!==s.get?s.configurable?(Object.defineProperty(i,n,{value:"[Circular]"}),Be.push([i,n,t,s])):Ve.push([t,n]):(i[n]="[Circular]",Be.push([i,n,t])))}if(r.push(t),Array.isArray(t))for(o=0;o<t.length;o++)e(t[o],o,r,t);else{var a=Object.keys(t);for(o=0;o<a.length;o++){var u=a[o];e(t[u],u,r,t)}}r.pop()}}(e,"",[],void 0),r=0===Ve.length?JSON.stringify(e,t,n):JSON.stringify(e,We(t),n);0!==Be.length;){var i=Be.pop();4===i.length?Object.defineProperty(i[0],i[1],i[3]):i[0][i[1]]=i[2]}return r}function qe(e,t){return e<t?-1:t<e?1:0}function ze(e,t,n){var r,i=function e(t,n,r,i){var o;if("object"==typeof t&&null!==t){for(o=0;o<r.length;o++)if(r[o]===t){var s=Object.getOwnPropertyDescriptor(i,n);return void(void 0!==s.get?s.configurable?(Object.defineProperty(i,n,{value:"[Circular]"}),Be.push([i,n,t,s])):Ve.push([t,n]):(i[n]="[Circular]",Be.push([i,n,t])))}if("function"==typeof t.toJSON)return;if(r.push(t),Array.isArray(t))for(o=0;o<t.length;o++)e(t[o],o,r,t);else{var a={},u=Object.keys(t).sort(qe);for(o=0;o<u.length;o++){var c=u[o];e(t[c],c,r,t),a[c]=t[c]}if(void 0===i)return a;Be.push([i,n,t]),i[n]=a}r.pop()}}(e,"",[],void 0)||e;for(r=0===Ve.length?JSON.stringify(i,t,n):JSON.stringify(i,We(t),n);0!==Be.length;){var o=Be.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}return r}function We(i){return i=void 0!==i?i:function(e,t){return t},function(e,t){if(0<Ve.length)for(var n=0;n<Ve.length;n++){var r=Ve[n];if(r[1]===e&&r[0]===t){t="[Circular]",Ve.splice(n,1);break}}return i.call(this,e,t)}}function Ge(e){return(Ge="function"==typeof Symbol&&"symbol"===m(Symbol.iterator)?function(e){return m(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":m(e)})(e)}var $e=function(e){return null!==e&&"object"===Ge(e)};function Je(e){return(Je="function"==typeof Symbol&&"symbol"===m(Symbol.iterator)?function(e){return m(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":m(e)})(e)}var He=Ze;function Ze(e){if(e)return function(e){for(var t in Ze.prototype)Object.prototype.hasOwnProperty.call(Ze.prototype,t)&&(e[t]=Ze.prototype[t]);return e}(e)}Ze.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Ze.prototype.parse=function(e){return this._parser=e,this},Ze.prototype.responseType=function(e){return this._responseType=e,this},Ze.prototype.serialize=function(e){return this._serializer=e,this},Ze.prototype.timeout=function(e){if(!e||"object"!==Je(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Ze.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Xe=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];Ze.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&500<=t.status&&501!==t.status)return!0;if(e){if(e.code&&-1!==Xe.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Ze.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},Ze.prototype.then=function(e,t){var i=this;if(!this._fullfilledPromise){var o=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(n,r){o.on("abort",function(){var e=new Error("Aborted");e.code="ABORTED",e.status=i.status,e.method=i.method,e.url=i.url,r(e)}),o.end(function(e,t){e?r(e):n(t)})})}return this._fullfilledPromise.then(e,t)},Ze.prototype.catch=function(e){return this.then(void 0,e)},Ze.prototype.use=function(e){return e(this),this},Ze.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Ze.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):200<=e.status&&e.status<300)},Ze.prototype.getHeader=Ze.prototype.get=function(e){return this._header[e.toLowerCase()]},Ze.prototype.set=function(e,t){if($e(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Ze.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Ze.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if($e(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Ze.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Ze.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Ze.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Ze.prototype.redirects=function(e){return this._maxRedirects=e,this},Ze.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Ze.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Ze.prototype.send=function(e){var t=$e(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&$e(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else this._data="string"==typeof e?(n||this.type("form"),"application/x-www-form-urlencoded"===(n=this._header["content-type"])?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):e;return!t||this._isHost(e)||n||this.type("json"),this},Ze.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Ze.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(0<=this.url.indexOf("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(0<=t){var n=this.url.substring(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.substring(0,t)+"?"+n.join("&")}}},Ze.prototype._appendQueryString=function(){console.warn("Unsupported")},Ze.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.abort(),this.callback(r)}},Ze.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var Ke=function(e){return e.split(/ *; */).shift()},Qe=function(e){return e.split(/ *; */).reduce(function(e,t){var n=t.split(/ *= */),r=n.shift(),i=n.shift();return r&&i&&(e[r]=i),e},{})},et=function(e){return e.split(/ *, */).reduce(function(e,t){var n=t.split(/ *; */),r=n[0].slice(1,-1);return e[n[1].split(/ *= */)[1].slice(1,-1)]=r,e},{})},tt=nt;function nt(e){if(e)return function(e){for(var t in nt.prototype)Object.prototype.hasOwnProperty.call(nt.prototype,t)&&(e[t]=nt.prototype[t]);return e}(e)}function rt(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function it(){this._defaults=[]}nt.prototype.get=function(e){return this.header[e.toLowerCase()]},nt.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=Ke(t);var n=Qe(t);for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(this[r]=n[r]);this.links={};try{e.link&&(this.links=et(e.link))}catch(e){}},nt.prototype._setStatusProperties=function(e){var t=e/100|0;this.statusCode=e,this.status=this.statusCode,this.statusType=t,this.info=1===t,this.ok=2===t,this.redirect=3===t,this.clientError=4===t,this.serverError=5===t,this.error=(4===t||5===t)&&this.toError(),this.created=201===e,this.accepted=202===e,this.noContent=204===e,this.badRequest=400===e,this.unauthorized=401===e,this.notAcceptable=406===e,this.forbidden=403===e,this.notFound=404===e,this.unprocessableEntity=422===e},["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(r){it.prototype[r]=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._defaults.push({fn:r,args:t}),this}}),it.prototype._setDefaults=function(t){this._defaults.forEach(function(e){t[e.fn].apply(t,rt(e.args))})};var ot=it,st=n(function(e,n){function r(e){return(r="function"==typeof Symbol&&"symbol"===m(Symbol.iterator)?function(e){return m(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":m(e)})(e)}var t;function i(){}t="undefined"!=typeof window?window:"undefined"==typeof self?void console.warn("Using browser-only version of superagent in non-browser environment"):self,e.exports=function(e,t){return"function"==typeof t?new n.Request("GET",e).end(t):1===arguments.length?new n.Request("GET",e):new n.Request(e,t)};var a=n=e.exports;n.Request=h,a.getXHR=function(){if(t.XMLHttpRequest&&(!t.location||"file:"!==t.location.protocol||!t.ActiveXObject))return new d;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw new Error("Browser-only version of superagent could not find XHR")};var c="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};function o(e){if(!$e(e))return e;var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s(t,n,e[n]);return t.join("&")}function s(t,n,e){if(void 0!==e)if(null!==e)if(Array.isArray(e))e.forEach(function(e){s(t,n,e)});else if($e(e))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&s(t,"".concat(n,"[").concat(r,"]"),e[r]);else t.push(encodeURIComponent(n)+"="+encodeURIComponent(e));else t.push(encodeURIComponent(n))}function u(e){for(var t,n,r={},i=e.split("&"),o=0,s=i.length;o<s;++o)-1===(n=(t=i[o]).indexOf("="))?r[decodeURIComponent(t)]="":r[decodeURIComponent(t.slice(0,n))]=decodeURIComponent(t.slice(n+1));return r}function f(e){return/[/+]json($|[^-\w])/.test(e)}function l(e){this.req=e,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.headers=function(e){for(var t,n,r,i,o=e.split(/\r?\n/),s={},a=0,u=o.length;a<u;++a)-1!==(t=(n=o[a]).indexOf(":"))&&(r=n.slice(0,t).toLowerCase(),i=c(n.slice(t+1)),s[r]=i);return s}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&e._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function h(e,t){var r=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",function(){var t,n=null,e=null;try{e=new l(r)}catch(e){return(n=new Error("Parser is unable to parse the response")).parse=!0,n.original=e,r.xhr?(n.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,n.status=r.xhr.status?r.xhr.status:null,n.statusCode=n.status):(n.rawResponse=null,n.status=null),r.callback(n)}r.emit("response",e);try{r._isResponseOK(e)||(t=new Error(e.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=n,t.response=e,t.status=e.status,r.callback(t,e)):r.callback(null,e)})}function p(e,t,n){var r=a("DELETE",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}a.serializeObject=o,a.parseString=u,a.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},a.serialize={"application/x-www-form-urlencoded":o,"application/json":Ue},a.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},tt(l.prototype),l.prototype._parseBody=function(e){var t=a.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&f(this.type)&&(t=a.parse["application/json"]),t&&e&&(0<e.length||e instanceof Object)?t(e):null)},l.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},a.Response=l,Fe(h.prototype),He(h.prototype),h.prototype.type=function(e){return this.set("Content-Type",a.types[e]||e),this},h.prototype.accept=function(e){return this.set("Accept",a.types[e]||e),this},h.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"===r(t)&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});return this._auth(e,t,n,function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")})},h.prototype.query=function(e){return"string"!=typeof e&&(e=o(e)),e&&this._query.push(e),this},h.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},h.prototype._getFormData=function(){return this._formData||(this._formData=new t.FormData),this._formData},h.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},h.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},h.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},h.prototype.buffer=h.prototype.ca,h.prototype.ca=h.prototype.agent,h.prototype.pipe=h.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},h.prototype._isHost=function(e){return e&&"object"===r(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},h.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||i,this._finalizeQueryString(),this._end()},h.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},h.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var n=this;this.xhr=a.getXHR();var r=this.xhr,e=this._formData||this._data;this._setTimeouts(),r.onreadystatechange=function(){var e=r.readyState;if(2<=e&&n._responseTimeoutTimer&&clearTimeout(n._responseTimeoutTimer),4===e){var t;try{t=r.status}catch(e){t=0}if(!t){if(n.timedout||n._aborted)return;return n.crossDomainError()}n.emit("end")}};var t=function(e,t){0<t.total&&(t.percent=t.loaded/t.total*100,100===t.percent&&clearTimeout(n._uploadTimeoutTimer)),t.direction=e,n.emit("progress",t)};if(this.hasListeners("progress"))try{r.addEventListener("progress",t.bind(null,"download")),r.upload&&r.upload.addEventListener("progress",t.bind(null,"upload"))}catch(e){}r.upload&&this._setUploadTimeout();try{this.username&&this.password?r.open(this.method,this.url,!0,this.username,this.password):r.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(r.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof e&&!this._isHost(e)){var i=this._header["content-type"],o=this._serializer||a.serialize[i?i.split(";")[0]:""];!o&&f(i)&&(o=a.serialize["application/json"]),o&&(e=o(e))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&r.setRequestHeader(s,this.header[s]);this._responseType&&(r.responseType=this._responseType),this.emit("request",this),r.send(void 0===e?null:e)},a.agent=function(){return new ot},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(r){ot.prototype[r.toLowerCase()]=function(e,t){var n=new a.Request(r,e);return this._setDefaults(n),t&&n.end(t),n}}),ot.prototype.del=ot.prototype.delete,a.get=function(e,t,n){var r=a("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},a.head=function(e,t,n){var r=a("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},a.options=function(e,t,n){var r=a("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},a.del=p,a.delete=p,a.patch=function(e,t,n){var r=a("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},a.post=function(e,t,n){var r=a("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},a.put=function(e,t,n){var r=a("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}});st.Request;var at=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t},ut=Math.floor,ct=Math.random;var ft=function(e,t){return e+ut(ct()*(t-e+1))};var lt=function(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n<t;){var o=ft(n,i),s=e[o];e[o]=e[n],e[n]=s}return e.length=t,e};var ht=function(e){return lt(at(e))};var pt=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i};var dt=function(t,e){return pt(e,function(e){return t[e]})};var mt=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},gt="object"==typeof i&&i&&i.Object===Object&&i,yt="object"==typeof self&&self&&self.Object===Object&&self,vt=gt||yt||Function("return this")(),bt=vt.Symbol,wt=Object.prototype,_t=wt.hasOwnProperty,Et=wt.toString,Tt=bt?bt.toStringTag:void 0;var St=function(e){var t=_t.call(e,Tt),n=e[Tt];try{var r=!(e[Tt]=void 0)}catch(e){}var i=Et.call(e);return r&&(t?e[Tt]=n:delete e[Tt]),i},At=Object.prototype.toString;var It=function(e){return At.call(e)},Ot=bt?bt.toStringTag:void 0;var Ct=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Ot&&Ot in Object(e)?St(e):It(e)};var xt=function(e){return null!=e&&"object"==typeof e};var Mt=function(e){return xt(e)&&"[object Arguments]"==Ct(e)},kt=Object.prototype,Rt=kt.hasOwnProperty,Pt=kt.propertyIsEnumerable,Nt=Mt(function(){return arguments}())?Mt:function(e){return xt(e)&&Rt.call(e,"callee")&&!Pt.call(e,"callee")},Lt=Array.isArray;var jt=function(){return!1},Dt=n(function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?vt.Buffer:void 0,o=(i?i.isBuffer:void 0)||jt;e.exports=o}),Ft=/^(?:0|[1-9]\d*)$/;var Ut=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Ft.test(e))&&-1<e&&e%1==0&&e<t};var Bt=function(e){return"number"==typeof e&&-1<e&&e%1==0&&e<=9007199254740991},Vt={};Vt["[object Float32Array]"]=Vt["[object Float64Array]"]=Vt["[object Int8Array]"]=Vt["[object Int16Array]"]=Vt["[object Int32Array]"]=Vt["[object Uint8Array]"]=Vt["[object Uint8ClampedArray]"]=Vt["[object Uint16Array]"]=Vt["[object Uint32Array]"]=!0,Vt["[object Arguments]"]=Vt["[object Array]"]=Vt["[object ArrayBuffer]"]=Vt["[object Boolean]"]=Vt["[object DataView]"]=Vt["[object Date]"]=Vt["[object Error]"]=Vt["[object Function]"]=Vt["[object Map]"]=Vt["[object Number]"]=Vt["[object Object]"]=Vt["[object RegExp]"]=Vt["[object Set]"]=Vt["[object String]"]=Vt["[object WeakMap]"]=!1;var Yt=function(e){return xt(e)&&Bt(e.length)&&!!Vt[Ct(e)]};var qt=function(t){return function(e){return t(e)}},zt=n(function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&gt.process,o=function(){try{var e=r&&r.require&&r.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o}),Wt=zt&&zt.isTypedArray,Gt=Wt?qt(Wt):Yt,$t=Object.prototype.hasOwnProperty;var Jt=function(e,t){var n=Lt(e),r=!n&&Nt(e),i=!n&&!r&&Dt(e),o=!n&&!r&&!i&&Gt(e),s=n||r||i||o,a=s?mt(e.length,String):[],u=a.length;for(var c in e)!t&&!$t.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ut(c,u))||a.push(c);return a},Ht=Object.prototype;var Zt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ht)};var Xt=function(t,n){return function(e){return t(n(e))}},Kt=Xt(Object.keys,Object),Qt=Object.prototype.hasOwnProperty;var en=function(e){if(!Zt(e))return Kt(e);var t=[];for(var n in Object(e))Qt.call(e,n)&&"constructor"!=n&&t.push(n);return t};var tn=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var nn=function(e){if(!tn(e))return!1;var t=Ct(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var rn=function(e){return null!=e&&Bt(e.length)&&!nn(e)};var on=function(e){return rn(e)?Jt(e):en(e)};var sn=function(e){return null==e?[]:dt(e,on(e))};var an=function(e){return lt(sn(e))};var un=function(e){return(Lt(e)?ht:an)(e)},cn=n(function(e,t){var h;h={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,r=e.terminal||e.final,i=t||e.target||{},o=e.events||[],s=e.callbacks||{},a={},u={},c=function(e){var t=Array.isArray(e.from)?e.from:e.from?[e.from]:[h.WILDCARD];a[e.name]=a[e.name]||{};for(var n=0;n<t.length;n++)u[t[n]]=u[t[n]]||[],u[t[n]].push(e.name),a[e.name][t[n]]=e.to||t[n];e.to&&(u[e.to]=u[e.to]||[])};n&&(n.event=n.event||"startup",c({name:n.event,from:"none",to:n.state}));for(var f=0;f<o.length;f++)c(o[f]);for(var l in a)a.hasOwnProperty(l)&&(i[l]=h.buildEvent(l,a[l]));for(var l in s)s.hasOwnProperty(l)&&(i[l]=s[l]);return i.current="none",i.is=function(e){return Array.isArray(e)?0<=e.indexOf(this.current):this.current===e},i.can=function(e){return!this.transition&&void 0!==a[e]&&(a[e].hasOwnProperty(this.current)||a[e].hasOwnProperty(h.WILDCARD))},i.cannot=function(e){return!this.can(e)},i.transitions=function(){return(u[this.current]||[]).concat(u[h.WILDCARD]||[])},i.isFinished=function(){return this.is(r)},i.error=e.error||function(e,t,n,r,i,o,s){throw s||o},i.states=function(){return Object.keys(u).sort()},n&&!n.defer&&i[n.event](),i},doCallback:function(t,e,n,r,i,o){if(e)try{return e.apply(t,[n,r,i].concat(o))}catch(e){return t.error(n,r,i,o,h.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",e)}},beforeAnyEvent:function(e,t,n,r,i){return h.doCallback(e,e.onbeforeevent,t,n,r,i)},afterAnyEvent:function(e,t,n,r,i){return h.doCallback(e,e.onafterevent||e.onevent,t,n,r,i)},leaveAnyState:function(e,t,n,r,i){return h.doCallback(e,e.onleavestate,t,n,r,i)},enterAnyState:function(e,t,n,r,i){return h.doCallback(e,e.onenterstate||e.onstate,t,n,r,i)},changeState:function(e,t,n,r,i){return h.doCallback(e,e.onchangestate,t,n,r,i)},beforeThisEvent:function(e,t,n,r,i){return h.doCallback(e,e["onbefore"+t],t,n,r,i)},afterThisEvent:function(e,t,n,r,i){return h.doCallback(e,e["onafter"+t]||e["on"+t],t,n,r,i)},leaveThisState:function(e,t,n,r,i){return h.doCallback(e,e["onleave"+n],t,n,r,i)},enterThisState:function(e,t,n,r,i){return h.doCallback(e,e["onenter"+r]||e["on"+r],t,n,r,i)},beforeEvent:function(e,t,n,r,i){if(!1===h.beforeThisEvent(e,t,n,r,i)||!1===h.beforeAnyEvent(e,t,n,r,i))return!1},afterEvent:function(e,t,n,r,i){h.afterThisEvent(e,t,n,r,i),h.afterAnyEvent(e,t,n,r,i)},leaveState:function(e,t,n,r,i){var o=h.leaveThisState(e,t,n,r,i),s=h.leaveAnyState(e,t,n,r,i);return!1!==o&&!1!==s&&(h.ASYNC===o||h.ASYNC===s?h.ASYNC:void 0)},enterState:function(e,t,n,r,i){h.enterThisState(e,t,n,r,i),h.enterAnyState(e,t,n,r,i)},buildEvent:function(o,s){return function(){var e=this.current,t=s[e]||(s[h.WILDCARD]!=h.WILDCARD?s[h.WILDCARD]:e)||e,n=Array.prototype.slice.call(arguments);if(this.transition)return this.error(o,e,t,n,h.Error.PENDING_TRANSITION,"event "+o+" inappropriate because previous transition did not complete");if(this.cannot(o))return this.error(o,e,t,n,h.Error.INVALID_TRANSITION,"event "+o+" inappropriate in current state "+this.current);if(!1===h.beforeEvent(this,o,e,t,n))return h.Result.CANCELLED;if(e===t)return h.afterEvent(this,o,e,t,n),h.Result.NOTRANSITION;var r=this;this.transition=function(){return r.transition=null,r.current=t,h.enterState(r,o,e,t,n),h.changeState(r,o,e,t,n),h.afterEvent(r,o,e,t,n),h.Result.SUCCEEDED},this.transition.cancel=function(){r.transition=null,h.afterEvent(r,o,e,t,n)};var i=h.leaveState(this,o,e,t,n);return!1===i?(this.transition=null,h.Result.CANCELLED):h.ASYNC===i?h.Result.PENDING:this.transition?this.transition():void 0}}},e.exports&&(t=e.exports=h),t.StateMachine=h}),fn=(cn.StateMachine,Xt(Object.getPrototypeOf,Object)),ln=Function.prototype,hn=Object.prototype,pn=ln.toString,dn=hn.hasOwnProperty,mn=pn.call(Object);var gn=function(e){if(!xt(e)||"[object Object]"!=Ct(e))return!1;var t=fn(e);if(null===t)return!0;var n=dn.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&pn.call(n)==mn},yn="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},vn=Symbol("expired"),bn=De("LC:Expirable"),wn=function(){function e(e,t){this.originalValue=e,"number"==typeof t&&(this.expiredAt=Date.now()+t)}return o(e,[{key:"value",get:function(){var e=this.expiredAt&&this.expiredAt<=Date.now();return e&&bn("expired: ".concat(this.originalValue)),e?vn:this.originalValue}}]),e}();wn.EXPIRED=vn;var _n,En=De("LC:Cache"),Tn=function(){function e(){var e=0<arguments.length&&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 n=t.value;if(n!==wn.EXPIRED)return En("[%s] hit: %s",this.name,e),n;delete this._map[e]}return En("[".concat(this.name,"] missed: ").concat(e)),null},t.set=function(e,t,n){En("[%s] set: %s %d",this.name,e,n),this._map[e]=new wn(t,n)},e}(),Sn={enable:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"LC*";return De.enable(e)},disable:De.disable},An=function(t){return function(e){return t(e),e}},In=function(t){return[function(e){return t(),e},function(e){throw t(),e}]},On=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},Cn=function(e){return e&&e.getTime?e.getTime():void 0},xn=function n(r){return r?"Date"===r.__type&&r.iso?new Date(r.iso):Array.isArray(r)?r.map(n):gn(r)?Object.keys(r).reduce(function(e,t){return T({},e,a({},t,n(r[t])))},{}):r:r},Mn=function n(r){return r instanceof Date?{__type:"Date",iso:r.toJSON()}:Array.isArray(r)?r.map(n):gn(r)?Object.keys(r).reduce(function(e,t){return T({},e,a({},t,n(r[t])))},{}):r},kn=function(r,i){return Object.keys(i).reduce(function(e,t){var n=r[t]||t;return Object.assign(e,a({},n,i[t]))},{})},Rn=yn.navigator&&yn.navigator.userAgent&&-1!==yn.navigator.userAgent.indexOf("MSIE 10."),Pn=function e(t,n){return t[n]||(t.__proto__?e(t.__proto__,n):void 0)},Nn=function(e,t){return Array.from(new Set([].concat(v(e),v(t))))},Ln=function(e,t){return Array.from((n=new Set(t),new Set(e.filter(function(e){return!n.has(e)}))));var n},jn=new WeakMap,Dn=function(e){return jn.has(e)||jn.set(e,{}),jn.get(e)},Fn=function e(t,n){if(!gn(t))return t;var r=Object.assign({},t);for(var i in r)if({}.hasOwnProperty.call(r,i)){var o=r[i];o===n?delete r[i]:r[i]=e(o,n)}return r},Un=function(e){return t=JSON.parse(JSON.stringify(e)),Fn(t,null);var t},Bn=function(e){return Array.isArray(e)?e:null==e?[]:[e]},Vn=function(e,t,n){var r=t.split("."),i=r.pop(),o=e;return r.forEach(function(e){void 0===o[e]&&(o[e]={}),o=o[e]}),o[i]=n,e},Yn="object"===("undefined"==typeof wx?"undefined":m(wx))&&"function"==typeof wx.connectSocket,qn=function(l){return function(e,c,t){var f=t.value;if(f.length)throw new Error("throttled function should not accept any arguments");return T({},t,{value:function(){var e=this,t=Dn(this).throttleMeta;t||(t={},Dn(this).throttleMeta=t);var n=t[c];n||(n={},t[c]=n);var r=n,i=r.previouseTimestamp,o=void 0===i?0:i,s=r.timeout,a=Date.now(),u=l-(a-o);u<=0?(t[c].previouseTimestamp=a,f.apply(this)):s||(n.timeout=setTimeout(function(){n.previouseTimestamp=Date.now(),delete n.timeout,f.apply(e)},u))}})}},zn=De("LC:WebSocketPlus"),Wn="disconnect",Gn="reconnect",$n="retry",Jn="schedule",Hn="offline",Zn="online",Xn="error",Kn="message",Qn=function(e,i,o){return Object.assign({},o,{value:function(){var e;this.checkConnectionAvailability(i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=o.value).call.apply(e,[this].concat(n))}})},er=(t((_n=function(r){function e(e,t){var n;if(void 0===z)throw new Error("WebSocket is undefined. Polyfill is required in this runtime.");return(n=r.call(this)||this).init(),n._protocol=t,Promise.resolve("function"==typeof e?e():e).then(Bn).then(function(e){return n._urls=e,n._open()}).then(function(){n.__postponeTimeoutTimer=n._postponeTimeoutTimer.bind(g(n)),yn.addEventListener&&(n.__pause=function(){n.can("pause")&&n.pause()},n.__resume=function(){n.can("resume")&&n.resume()},yn.addEventListener("offline",n.__pause),yn.addEventListener("online",n.__resume)),n.open()}).catch(n.throw.bind(g(n))),n}f(e,r),o(e,[{key:"urls",get:function(){return this._urls},set:function(e){this._urls=Bn(e)}}]);var t=e.prototype;return t._open=function(){var o=this;return this._createWs(this._urls,this._protocol).then(function(e){var t,n=s(t=o._urls)||l(t)||h(),r=n[0],i=n.slice(1);return o._urls=[].concat(v(i),[r]),e})},t._createWs=function(e,i){var o=this;return function e(t){var n=new Promise(t[0]);return 1===t.length?n:n.catch(function(){return e(t.slice(1))})}(e.map(function(r){return function(e,t){zn("connect [".concat(r,"] ").concat(i));var n=i?new z(r,i):new z(r);n.binaryType=o.binaryType||"arraybuffer",n.onopen=function(){return e(n)},n.onclose=function(e){return e instanceof Error?t(e):t(new Error("Failed to connect [".concat(r,"]")))},n.onerror=n.onclose}})).then(function(e){return o._ws=e,o._ws.onclose=o._handleClose.bind(o),o._ws.onmessage=o._handleMessage.bind(o),e})},t._destroyWs=function(){var e=this._ws;e&&(e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null,this._ws=null,e.close())},t.onbeforeevent=function(e,t,n){for(var r=arguments.length,i=new Array(3<r?r-3:0),o=3;o<r;o++)i[o-3]=arguments[o];zn("".concat(e,": ").concat(t," -> ").concat(n," %o"),i)},t.onopen=function(){this.emit("open")},t.onconnected=function(){this._startConnectionKeeper()},t.onleaveconnected=function(e,t,n){this._stopConnectionKeeper(),this._destroyWs(),"offline"!==n&&"disconnected"!==n||this.emit(Wn)},t.onpause=function(){this.emit(Hn)},t.onbeforeresume=function(){this.emit(Zn)},t.onreconnect=function(){this.emit(Gn)},t.ondisconnected=function(e,t,n){var r=this,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,o=function(e){return Math.min(1e3*Math.pow(2,e),3e5)}.call(null,i);zn("schedule attempt=".concat(i," delay=").concat(o)),this.emit(Jn,i,o),this.__scheduledRetry&&clearTimeout(this.__scheduledRetry),this.__scheduledRetry=setTimeout(function(){r.is("disconnected")&&r.retry(i)},o)},t.onretry=function(e,t,n){var r=this,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;this.emit($n,i),this._open().then(function(){return r.can("reconnect")?r.reconnect():r._destroyWs()},function(){return r.can("fail")&&r.fail(i+1)})},t.onerror=function(e,t,n,r){this.emit(Xn,r)},t.onclose=function(){yn.removeEventListener&&(this.__pause&&yn.removeEventListener("offline",this.__pause),this.__resume&&yn.removeEventListener("online",this.__resume))},t.checkConnectionAvailability=function(){var e=0<arguments.length&&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")}},t._ping=function(){zn("ping");try{this.ping()}catch(e){console.warn("websocket ping error: ".concat(e.message))}},t.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.")},t._postponeTimeoutTimer=function(){var e=this;zn("_postponeTimeoutTimer"),this._clearTimeoutTimers(),this._timeoutTimer=setTimeout(function(){zn("timeout"),e.disconnect()},38e4)},t._clearTimeoutTimers=function(){this._timeoutTimer&&clearTimeout(this._timeoutTimer)},t._startConnectionKeeper=function(){zn("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()):zn("connection keeper disabled due to the lack of #addEventListener.")},t._stopConnectionKeeper=function(){zn("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)},t._handleClose=function(e){zn("ws closed [".concat(e.code,"] ").concat(e.reason)),this.isFinished()||this.handleClose(e)},t.handleClose=function(){this.disconnect()},t.send=function(e){zn("send",e),this._ws.send(e)},t._handleMessage=function(e){zn("message",e.data),this.handleMessage(e.data)},t.handleMessage=function(e){this.emit(Kn,e)},e}(Ae)).prototype,"_ping",[Qn],Object.getOwnPropertyDescriptor(_n.prototype,"_ping"),_n.prototype),t(_n.prototype,"send",[Qn],Object.getOwnPropertyDescriptor(_n.prototype,"send"),_n.prototype),_n);cn.create({target:er.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"}]});for(var tr=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."}}),nr=Object.freeze(Object.keys(tr).reduce(function(e,t){return Object.assign(e,a({},tr[t].name,Number(t)))},{})),rr=function(e){var t=e.code,n=e.reason,r=e.appCode,i=e.detail,o=e.error,s=n||i||o,a=n;!s&&tr[t]&&(a=tr[t].name,s=tr[t].message||a),s||(s="Unknow Error: ".concat(t));var u=new Error(s);return Object.assign(u,{code:t,appCode:r,detail:i,name:a})},ir=De("LC:Connection"),or=Symbol("expire"),sr=function(a){function e(e,t){var n,r=t.format,i=t.version;ir("initializing Connection");var o="lc.".concat(r,".").concat(i);return(n=Yn?a.call(this,e().then(function(e){return e.map(function(e){return"".concat(e).concat(-1===e.indexOf("?")?"?":"&","subprotocol=").concat(encodeURIComponent(o))})}))||this:a.call(this,e,o)||this)._protocalFormat=r,n._commands={},n._serialId=0,g(n)}f(e,a);var t=e.prototype;return t.send=function(){var t=b(ke.mark(function e(n){var t,r,i,o=this,s=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((t=!(1<s.length&&void 0!==s[1])||s[1])&&(this._serialId+=1,r=this._serialId,n.i=r),ir.enabled&&ir("↑ %O sent",Un(n)),"proto2base64"===this._protocalFormat?i=n.toBase64():n.toArrayBuffer&&(i=n.toArrayBuffer()),i){e.next=6;break}throw new TypeError("".concat(n," is not a GenericCommand"));case 6:if(a.prototype.send.call(this,i),t){e.next=9;break}return e.abrupt("return",void 0);case 9:return e.abrupt("return",new Promise(function(e,t){o._commands[r]={resolve:e,reject:t,timeout:setTimeout(function(){o._commands[r]&&(ir.enabled&&ir("✗ %O timeout",Un(n)),t(rr({error:"Command Timeout [cmd:".concat(n.cmd," op:").concat(n.op,"]"),name:"COMMAND_TIMEOUT"})),delete o._commands[r])},2e4)}}));case 10:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.handleMessage=function(t){var e;try{e=ge.decode(t),ir.enabled&&ir("↓ %O received",Un(e))}catch(e){return void console.warn("Decode message failed:",e.message,t)}var n=e.i;if(n)this._commands[n]?(clearTimeout(this._commands[n].timeout),e.cmd===_e.error?this._commands[n].reject(rr(e.errorMessage)):this._commands[n].resolve(e),delete this._commands[n]):console.warn("Unexpected command received with serialId [".concat(n,"],\n which have timed out or never been requested."));else switch(e.cmd){case _e.error:return void this.emit(Xn,rr(e.errorMessage));case _e.goaway:return void this.emit(or);default:this.emit(Kn,e)}},t.ping=function(){return this.send(new ge({cmd:_e.echo})).catch(function(e){return ir("ping failed:",e)})},e}(er),ar=function(e,n){e&&e.forEach(function(t){try{t(n)}catch(e){throw t._pluginName&&(e.message+="[".concat(t._pluginName,"]")),e}})},ur=function(t){return function(e){return Bn(t).reduce(function(e,t){return e.then((r=t,function(t){var n=t.constructor;return Promise.resolve(t).then(r).then(An(function(e){return null==e?console.warn("Middleware[".concat(r._pluginName||"anonymous plugin",":").concat(r.name||"anonymous middleware","] param/return types not match. It returns ").concat(e," while a ").concat(t.constructor.name," expected.")):e instanceof n?0:console.warn("Middleware[".concat(r._pluginName||"anonymous plugin",":").concat(r.name||"anonymous middleware","] param/return types not match. It returns a ").concat(e.constructor.name," while a ").concat(t.constructor.name," expected."))}))})).catch(function(e){throw t._pluginName&&(e.message+="[".concat(t._pluginName,"]")),e});var r},Promise.resolve(e))}},cr=function(e,n){return Bn(e).reduce(function(e,t){return e.then(function(e){return!1!==e&&t.apply(void 0,v(n))}).catch(function(e){throw t._pluginName&&(e.message+="[".concat(t._pluginName,"]")),e})},Promise.resolve(!0))},fr="5.0.0-beta.0",lr=De("LC:Realtime"),hr=De("LC:request"),pr=new Tn("push-router"),dr=function(s){function a(e){var t,n=e.plugins,r=S(e,["plugins"]);if(lr("initializing Realtime %s %O",fr,r),t=s.call(this)||this,"string"!=typeof r.appId)throw new TypeError("appId [".concat(r.appId,"] is not a string"));if("string"!=typeof r.appKey)throw new TypeError("appKey [".concat(r.appKey,"] is not a string"));if("-MdYXbMMI"!==r.appId.slice(-9)&&!r.server)throw new TypeError("server option is required for apps from CN region");t._options=Object.assign({appId:void 0,appKey:void 0,pushOfflineMessages:!1,noBinary:!1,ssl:!0,RTMServerName:u.env.RTM_SERVER_NAME},r),t._cache=new Tn("endpoints");var i=Dn(g(t));i.clients=new Set,i.pendingClients=new Set;var o=[].concat(v(Bn(a.__preRegisteredPlugins)),v(Bn(n)));return lr("Using plugins %o",o.map(function(e){return e.name})),t._plugins=o.reduce(function(e,t){for(var n in t)({}).hasOwnProperty.call(t,n)&&"name"!==n&&(t.name&&Bn(t[n]).forEach(function(e){e._pluginName=t.name}),e[n]=Bn(e[n]).concat(t[n]));return e},{}),ar(t._plugins.onRealtimeCreate,g(t)),t}f(a,s);var e=a.prototype;return e._request=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d,m;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.method,r=t.version,i=void 0===r?"1.1":r,o=t.path,s=t.query,a=t.headers,u=t.data,c=void 0===u?{}:u,f=this._options,l=f.appId,h=f.server,e.next=4,this.constructor._getServerUrls({appId:l,server:h});case 4:return p=e.sent,d=p.api,m="".concat(d,"/").concat(i).concat(o),hr("Req: %O %O %O",n,m,{query:s,headers:a,data:c}),e.abrupt("return",st(n,m).set(T({"X-LC-Id":this._options.appId,"X-LC-Key":this._options.appKey},a)).query(s).send(c).then(function(e){return hr("Res: %O %O %O",m,e.status,e.body),e.body},function(e){if(hr("Error: %O %O %O",m,e.response.status,e.response.body),e.response&&e.response.body&&e.response.body.code)throw rr(e.response.body);throw e}));case 9:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),e._open=function(){var i=this;if(this._openPromise)return this._openPromise;var e="protobuf2";this._options.noBinary&&(e="proto2base64");var t=3;this._options.pushOfflineMessages&&(t=1);var r={format:e,version:t};return this._openPromise=new Promise(function(e,t){lr("No connection established, create a new one.");var n=new sr(function(){return i._getRTMServers(i._options)},r);n.on("open",function(){return e(n)}).on(Xn,t).on(or,b(ke.mark(function e(){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return lr("Connection expired. Refresh endpoints."),i._cache.set("endpoints",null,0),e.next=4,i._getRTMServers(i._options);case 4:n.urls=e.sent,n.disconnect();case 6:case"end":return e.stop()}},e,this)}))).on(Kn,i._dispatchCommand.bind(i)),[Wn,Gn,$n,Jn,Hn,Zn].forEach(function(r){return n.on(r,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];lr("".concat(r," event emitted. %o"),t),i.emit.apply(i,[r].concat(t)),r!==Gn&&Dn(i).clients.forEach(function(e){e.emit.apply(e,[r].concat(t))})})}),n.handleClose=function(t){[nr.APP_NOT_AVAILABLE,nr.INVALID_LOGIN,nr.INVALID_ORIGIN].some(function(e){return e===t.code})?this.throw(rr(t)):this.disconnect()},Dn(i).connection=n}),this._openPromise},e._getRTMServers=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.RTMServers)return e.abrupt("return",un(Bn(t.RTMServers)));e.next=2;break;case 2:if(r=this._cache.get("endpoints"))return e.next=6,r;e.next=9;break;case 6:n=e.sent,e.next=13;break;case 9:return e.next=11,this.constructor._fetchRTMServers(t);case 11:n=e.sent,this._cache.set("endpoints",n,1e3*n.ttl);case 13:return lr("endpoint info: %O",n),e.abrupt("return",[n.server,n.secondary]);case 15:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),a._getServerUrls=function(){var t=b(ke.mark(function e(t){var s,n,r,a;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(s=t.appId,n=t.server,lr("fetch server urls"),!n){e.next=6;break}if("string"!=typeof n)return e.abrupt("return",n);e.next=5;break;case 5:return e.abrupt("return",{RTMRouter:n,api:n});case 6:if(r=pr.get(s))return e.abrupt("return",r);e.next=9;break;case 9:return a="https://",e.abrupt("return",st.get("https://app-router.com/2/route").query({appId:s}).timeout(2e4).then(function(e){return e.body}).then(An(lr)).then(function(e){var t=e.rtm_router_server,n=e.api_server,r=e.ttl,i=void 0===r?3600:r;if(!t)throw new Error("rtm router not exists");var o={RTMRouter:"".concat(a).concat(t),api:"".concat(a).concat(n)};return pr.set(s,o,1e3*i),o}).catch(function(){var e=s.slice(0,8).toLowerCase(),t="lncldglobal.com";return{RTMRouter:"".concat(a).concat(e,".rtm.").concat(t),api:"".concat(a).concat(e,".api.").concat(t)}}));case 11:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),a._fetchRTMServers=function(e){var n=e.appId,r=e.ssl,t=e.server,i=e.RTMServerName;return lr("fetch endpoint info"),this._getServerUrls({appId:n,server:t}).then(An(lr)).then(function(e){var t=e.RTMRouter;return st.get("".concat(t,"/v1/route")).query({appId:n,secure:r,features:Yn?"wechat":void 0,server:i,_t:Date.now()}).timeout(2e4).then(function(e){return e.body}).then(An(lr))})},e._close=function(){this._openPromise&&this._openPromise.then(function(e){return e.close()}),delete this._openPromise},e.retry=function(){var e=Dn(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()},e.pause=function(){var e=Dn(this).connection;e&&e.can("pause")&&e.pause()},e.resume=function(){var e=Dn(this).connection;e&&e.can("resume")&&e.resume()},e._registerPending=function(e){Dn(this).pendingClients.add(e)},e._deregisterPending=function(e){Dn(this).pendingClients.delete(e)},e._register=function(e){Dn(this).clients.add(e)},e._deregister=function(e){var t=Dn(this);t.clients.delete(e),t.clients.size+t.pendingClients.size===0&&this._close()},e._dispatchCommand=function(t){return cr(this._plugins.beforeCommandDispatch,[t,this]).then(function(e){return!!e&&lr("[WARN] Unexpected message received: %O",Un(t))})},a}(Ae),mr=Promise,gr=n(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 n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}}),yr=[],vr=0;vr<256;++vr)yr[vr]=(vr+256).toString(16).substr(1);var br=function(e,t){var n=t||0,r=yr;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")};var wr=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||gr)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[r+o]=i[o];return t||br(i)},_r=n(function(e,t){!function(){for(var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=new Uint8Array(256),e=0;e<o.length;e++)l[o.charCodeAt(e)]=e;t.encode=function(e){var t,n=new Uint8Array(e),r=n.length,i="";for(t=0;t<r;t+=3)i+=o[n[t]>>2],i+=o[(3&n[t])<<4|n[t+1]>>4],i+=o[(15&n[t+1])<<2|n[t+2]>>6],i+=o[63&n[t+2]];return r%3==2?i=i.substring(0,i.length-1)+"=":r%3==1&&(i=i.substring(0,i.length-2)+"=="),i},t.decode=function(e){var t,n,r,i,o,s=.75*e.length,a=e.length,u=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var c=new ArrayBuffer(s),f=new Uint8Array(c);for(t=0;t<a;t+=4)n=l[e.charCodeAt(t)],r=l[e.charCodeAt(t+1)],i=l[e.charCodeAt(t+2)],o=l[e.charCodeAt(t+3)],f[u++]=n<<2|r>>4,f[u++]=(15&r)<<4|i>>2,f[u++]=(3&i)<<6|63&o;return c}}()}),Er=_r.encode,Tr=_r.decode;var Sr=function(){this.__data__=[],this.size=0};var Ar=function(e,t){return e===t||e!=e&&t!=t};var Ir=function(e,t){for(var n=e.length;n--;)if(Ar(e[n][0],t))return n;return-1},Or=Array.prototype.splice;var Cr=function(e){var t=this.__data__,n=Ir(t,e);return!(n<0||(n==t.length-1?t.pop():Or.call(t,n,1),--this.size,0))};var xr=function(e){var t=this.__data__,n=Ir(t,e);return n<0?void 0:t[n][1]};var Mr=function(e){return-1<Ir(this.__data__,e)};var kr=function(e,t){var n=this.__data__,r=Ir(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function Rr(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Rr.prototype.clear=Sr,Rr.prototype.delete=Cr,Rr.prototype.get=xr,Rr.prototype.has=Mr,Rr.prototype.set=kr;var Pr=Rr;var Nr=function(){this.__data__=new Pr,this.size=0};var Lr=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n};var jr=function(e){return this.__data__.get(e)};var Dr,Fr=function(e){return this.__data__.has(e)},Ur=vt["__core-js_shared__"],Br=(Dr=/[^.]+$/.exec(Ur&&Ur.keys&&Ur.keys.IE_PROTO||""))?"Symbol(src)_1."+Dr:"";var Vr=function(e){return!!Br&&Br in e},Yr=Function.prototype.toString;var qr=function(e){if(null!=e){try{return Yr.call(e)}catch(e){}try{return e+""}catch(e){}}return""},zr=/^\[object .+?Constructor\]$/,Wr=Function.prototype,Gr=Object.prototype,$r=Wr.toString,Jr=Gr.hasOwnProperty,Hr=RegExp("^"+$r.call(Jr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Zr=function(e){return!(!tn(e)||Vr(e))&&(nn(e)?Hr:zr).test(qr(e))};var Xr=function(e,t){return null==e?void 0:e[t]};var Kr=function(e,t){var n=Xr(e,t);return Zr(n)?n:void 0},Qr=Kr(vt,"Map"),ei=Kr(Object,"create");var ti=function(){this.__data__=ei?ei(null):{},this.size=0};var ni=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ri=Object.prototype.hasOwnProperty;var ii=function(e){var t=this.__data__;if(ei){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return ri.call(t,e)?t[e]:void 0},oi=Object.prototype.hasOwnProperty;var si=function(e){var t=this.__data__;return ei?void 0!==t[e]:oi.call(t,e)};var ai=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ei&&void 0===t?"__lodash_hash_undefined__":t,this};function ui(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ui.prototype.clear=ti,ui.prototype.delete=ni,ui.prototype.get=ii,ui.prototype.has=si,ui.prototype.set=ai;var ci=ui;var fi=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var li=function(e,t){var n=e.__data__;return fi(t)?n["string"==typeof t?"string":"hash"]:n.map};var hi=function(e){var t=li(this,e).delete(e);return this.size-=t?1:0,t};var pi=function(e){return li(this,e).get(e)};var di=function(e){return li(this,e).has(e)};var mi=function(e,t){var n=li(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function gi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}gi.prototype.clear=function(){this.size=0,this.__data__={hash:new ci,map:new(Qr||Pr),string:new ci}},gi.prototype.delete=hi,gi.prototype.get=pi,gi.prototype.has=di,gi.prototype.set=mi;var yi=gi;var vi=function(e,t){var n=this.__data__;if(n instanceof Pr){var r=n.__data__;if(!Qr||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new yi(r)}return n.set(e,t),this.size=n.size,this};function bi(e){var t=this.__data__=new Pr(e);this.size=t.size}bi.prototype.clear=Nr,bi.prototype.delete=Lr,bi.prototype.get=jr,bi.prototype.has=Fr,bi.prototype.set=vi;var wi=bi;var _i=function(e){return this.__data__.has(e)};function Ei(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new yi;++t<n;)this.add(e[t])}Ei.prototype.add=Ei.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Ei.prototype.has=_i;var Ti=Ei;var Si=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1};var Ai=function(e,t){return e.has(t)};var Ii=function(e,t,n,r,i,o){var s=1&n,a=e.length,u=t.length;if(a!=u&&!(s&&a<u))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var f=-1,l=!0,h=2&n?new Ti:void 0;for(o.set(e,t),o.set(t,e);++f<a;){var p=e[f],d=t[f];if(r)var m=s?r(d,p,f,t,e,o):r(p,d,f,e,t,o);if(void 0!==m){if(m)continue;l=!1;break}if(h){if(!Si(t,function(e,t){if(!Ai(h,t)&&(p===e||i(p,e,n,r,o)))return h.push(t)})){l=!1;break}}else if(p!==d&&!i(p,d,n,r,o)){l=!1;break}}return o.delete(e),o.delete(t),l},Oi=vt.Uint8Array;var Ci=function(e){var n=-1,r=Array(e.size);return e.forEach(function(e,t){r[++n]=[t,e]}),r};var xi=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n},Mi=bt?bt.prototype:void 0,ki=Mi?Mi.valueOf:void 0;var Ri=function(e,t,n,r,i,o,s){switch(n){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 Ar(+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=Ci;case"[object Set]":var u=1&r;if(a||(a=xi),e.size!=t.size&&!u)return!1;var c=s.get(e);if(c)return c==t;r|=2,s.set(e,t);var f=Ii(a(e),a(t),r,i,o,s);return s.delete(e),f;case"[object Symbol]":if(ki)return ki.call(e)==ki.call(t)}return!1};var Pi=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e};var Ni=function(e,t,n){var r=t(e);return Lt(e)?r:Pi(r,n(e))};var Li=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o};var ji=function(){return[]},Di=Object.prototype.propertyIsEnumerable,Fi=Object.getOwnPropertySymbols,Ui=Fi?function(t){return null==t?[]:(t=Object(t),Li(Fi(t),function(e){return Di.call(t,e)}))}:ji;var Bi=function(e){return Ni(e,on,Ui)},Vi=Object.prototype.hasOwnProperty;var Yi=function(e,t,n,r,i,o){var s=1&n,a=Bi(e),u=a.length;if(u!=Bi(t).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in t:Vi.call(t,f)))return!1}var l=o.get(e);if(l&&o.get(t))return l==t;var h=!0;o.set(e,t),o.set(t,e);for(var p=s;++c<u;){var d=e[f=a[c]],m=t[f];if(r)var g=s?r(m,d,f,t,e,o):r(d,m,f,e,t,o);if(!(void 0===g?d===m||i(d,m,n,r,o):g)){h=!1;break}p||(p="constructor"==f)}if(h&&!p){var y=e.constructor,v=t.constructor;y!=v&&"constructor"in e&&"constructor"in t&&!("function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v)&&(h=!1)}return o.delete(e),o.delete(t),h},qi=Kr(vt,"DataView"),zi=Kr(vt,"Promise"),Wi=Kr(vt,"Set"),Gi=Kr(vt,"WeakMap"),$i="[object Map]",Ji="[object Promise]",Hi="[object Set]",Zi="[object WeakMap]",Xi="[object DataView]",Ki=qr(qi),Qi=qr(Qr),eo=qr(zi),to=qr(Wi),no=qr(Gi),ro=Ct;(qi&&ro(new qi(new ArrayBuffer(1)))!=Xi||Qr&&ro(new Qr)!=$i||zi&&ro(zi.resolve())!=Ji||Wi&&ro(new Wi)!=Hi||Gi&&ro(new Gi)!=Zi)&&(ro=function(e){var t=Ct(e),n="[object Object]"==t?e.constructor:void 0,r=n?qr(n):"";if(r)switch(r){case Ki:return Xi;case Qi:return $i;case eo:return Ji;case to:return Hi;case no:return Zi}return t});var io=ro,oo="[object Arguments]",so="[object Array]",ao="[object Object]",uo=Object.prototype.hasOwnProperty;var co=function(e,t,n,r,i,o){var s=Lt(e),a=Lt(t),u=s?so:io(e),c=a?so:io(t),f=(u=u==oo?ao:u)==ao,l=(c=c==oo?ao:c)==ao,h=u==c;if(h&&Dt(e)){if(!Dt(t))return!1;f=!(s=!0)}if(h&&!f)return o||(o=new wi),s||Gt(e)?Ii(e,t,n,r,i,o):Ri(e,t,u,n,r,i,o);if(!(1&n)){var p=f&&uo.call(e,"__wrapped__"),d=l&&uo.call(t,"__wrapped__");if(p||d){var m=p?e.value():e,g=d?t.value():t;return o||(o=new wi),i(m,g,n,r,o)}}return!!h&&(o||(o=new wi),Yi(e,t,n,r,i,o))};var fo=function e(t,n,r,i,o){return t===n||(null==t||null==n||!xt(t)&&!xt(n)?t!=t&&n!=n:co(t,n,r,i,e,o))};var lo=function(e,t,n,r){var i=n.length,o=i,s=!r;if(null==e)return!o;for(e=Object(e);i--;){var a=n[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){var u=(a=n[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 wi;if(r)var h=r(c,f,u,e,t,l);if(!(void 0===h?fo(f,c,3,r,l):h))return!1}}return!0};var ho=function(e){return e==e&&!tn(e)};var po=function(e){for(var t=on(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ho(i)]}return t};var mo=function(t,n){return function(e){return null!=e&&e[t]===n&&(void 0!==n||t in Object(e))}};var go=function(t){var n=po(t);return 1==n.length&&n[0][2]?mo(n[0][0],n[0][1]):function(e){return e===t||lo(e,t,n)}};var yo=function(e){return"symbol"==typeof e||xt(e)&&"[object Symbol]"==Ct(e)},vo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bo=/^\w*$/;var wo=function(e,t){if(Lt(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!yo(e))||bo.test(e)||!vo.test(e)||null!=t&&e in Object(t)},_o="Expected a function";function Eo(i,o){if("function"!=typeof i||null!=o&&"function"!=typeof o)throw new TypeError(_o);var s=function(){var e=arguments,t=o?o.apply(this,e):e[0],n=s.cache;if(n.has(t))return n.get(t);var r=i.apply(this,e);return s.cache=n.set(t,r)||n,r};return s.cache=new(Eo.Cache||yi),s}Eo.Cache=yi;var To=Eo;var So=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ao=/\\(\\)?/g,Io=function(e){var t=To(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var i=[];return 46===e.charCodeAt(0)&&i.push(""),e.replace(So,function(e,t,n,r){i.push(n?r.replace(Ao,"$1"):t||e)}),i}),Oo=1/0,Co=bt?bt.prototype:void 0,xo=Co?Co.toString:void 0;var Mo=function e(t){if("string"==typeof t)return t;if(Lt(t))return pt(t,e)+"";if(yo(t))return xo?xo.call(t):"";var n=t+"";return"0"==n&&1/t==-Oo?"-0":n};var ko=function(e){return null==e?"":Mo(e)};var Ro=function(e,t){return Lt(e)?e:wo(e,t)?[e]:Io(ko(e))};var Po=function(e){if("string"==typeof e||yo(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var No=function(e,t){for(var n=0,r=(t=Ro(t,e)).length;null!=e&&n<r;)e=e[Po(t[n++])];return n&&n==r?e:void 0};var Lo=function(e,t,n){var r=null==e?void 0:No(e,t);return void 0===r?n:r};var jo=function(e,t){return null!=e&&t in Object(e)};var Do=function(e,t,n){for(var r=-1,i=(t=Ro(t,e)).length,o=!1;++r<i;){var s=Po(t[r]);if(!(o=null!=e&&n(e,s)))break;e=e[s]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&Bt(i)&&Ut(s,i)&&(Lt(e)||Nt(e))};var Fo=function(e,t){return null!=e&&Do(e,t,jo)};var Uo=function(n,r){return wo(n)&&ho(r)?mo(Po(n),r):function(e){var t=Lo(e,n);return void 0===t&&t===r?Fo(e,n):fo(r,t,3)}};var Bo=function(e){return e};var Vo=function(t){return function(e){return null==e?void 0:e[t]}};var Yo=function(t){return function(e){return No(e,t)}};var qo=function(e){return wo(e)?Vo(Po(e)):Yo(e)};var zo=function(e){return"function"==typeof e?e:null==e?Bo:"object"==typeof e?Lt(e)?Uo(e[0],e[1]):go(e):qo(e)};var Wo=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var Go=function(e,t,n){var r=-1,i=e.length;t<0&&(t=i<-t?0:i+t),(n=i<n?i:n)<0&&(n+=i),i=n<t?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o};var $o=function(e,t){return t.length<2?e:No(e,Go(t,0,-1))};var Jo=function(e,t){return t=Ro(t,e),null==(e=$o(e,t))||delete e[Po(Wo(t))]},Ho=Array.prototype.splice;var Zo=function(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;Ut(i)?Ho.call(e,i,1):Jo(e,i)}}return e};var Xo=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],o=e.length;for(t=zo(t,3);++r<o;){var s=e[r];t(s,r,e)&&(n.push(s),i.push(r))}return Zo(e,i),n},Ko=Object.prototype.hasOwnProperty;var Qo=function(e){if(null==e)return!0;if(rn(e)&&(Lt(e)||"string"==typeof e||"function"==typeof e.splice||Dt(e)||Gt(e)||Nt(e)))return!e.length;var t=io(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(Zt(e))return!en(e).length;for(var n in e)if(Ko.call(e,n))return!1;return!0};var es=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e},ts=function(){try{var e=Kr(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var ns=function(e,t,n){"__proto__"==t&&ts?ts(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},rs=Object.prototype.hasOwnProperty;var is=function(e,t,n){var r=e[t];rs.call(e,t)&&Ar(r,n)&&(void 0!==n||t in e)||ns(e,t,n)};var os=function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var a=t[o],u=r?r(n[a],e[a],a,n,e):void 0;void 0===u&&(u=e[a]),i?ns(n,a,u):is(n,a,u)}return n};var ss=function(e,t){return e&&os(t,on(t),e)};var as=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t},us=Object.prototype.hasOwnProperty;var cs=function(e){if(!tn(e))return as(e);var t=Zt(e),n=[];for(var r in e)("constructor"!=r||!t&&us.call(e,r))&&n.push(r);return n};var fs=function(e){return rn(e)?Jt(e,!0):cs(e)};var ls=function(e,t){return e&&os(t,fs(t),e)},hs=n(function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?vt.Buffer:void 0,o=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}});var ps=function(e,t){return os(e,Ui(e),t)},ds=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Pi(t,Ui(e)),e=fn(e);return t}:ji;var ms=function(e,t){return os(e,ds(e),t)};var gs=function(e){return Ni(e,fs,ds)},ys=Object.prototype.hasOwnProperty;var vs=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&ys.call(e,"index")&&(n.index=e.index,n.input=e.input),n};var bs=function(e){var t=new e.constructor(e.byteLength);return new Oi(t).set(new Oi(e)),t};var ws=function(e,t){var n=t?bs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)},_s=/\w*$/;var Es=function(e){var t=new e.constructor(e.source,_s.exec(e));return t.lastIndex=e.lastIndex,t},Ts=bt?bt.prototype:void 0,Ss=Ts?Ts.valueOf:void 0;var As=function(e){return Ss?Object(Ss.call(e)):{}};var Is=function(e,t){var n=t?bs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)};var Os=function(e,t,n){var r=e.constructor;switch(t){case"[object ArrayBuffer]":return bs(e);case"[object Boolean]":case"[object Date]":return new r(+e);case"[object DataView]":return ws(e,n);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 Is(e,n);case"[object Map]":return new r;case"[object Number]":case"[object String]":return new r(e);case"[object RegExp]":return Es(e);case"[object Set]":return new r;case"[object Symbol]":return As(e)}},Cs=Object.create,xs=function(){function n(){}return function(e){if(!tn(e))return{};if(Cs)return Cs(e);n.prototype=e;var t=new n;return n.prototype=void 0,t}}();var Ms=function(e){return"function"!=typeof e.constructor||Zt(e)?{}:xs(fn(e))};var ks=function(e){return xt(e)&&"[object Map]"==io(e)},Rs=zt&&zt.isMap,Ps=Rs?qt(Rs):ks;var Ns=function(e){return xt(e)&&"[object Set]"==io(e)},Ls=zt&&zt.isSet,js=Ls?qt(Ls):Ns,Ds=1,Fs=2,Us=4,Bs="[object Arguments]",Vs="[object Function]",Ys="[object GeneratorFunction]",qs="[object Object]",zs={};zs[Bs]=zs["[object Array]"]=zs["[object ArrayBuffer]"]=zs["[object DataView]"]=zs["[object Boolean]"]=zs["[object Date]"]=zs["[object Float32Array]"]=zs["[object Float64Array]"]=zs["[object Int8Array]"]=zs["[object Int16Array]"]=zs["[object Int32Array]"]=zs["[object Map]"]=zs["[object Number]"]=zs[qs]=zs["[object RegExp]"]=zs["[object Set]"]=zs["[object String]"]=zs["[object Symbol]"]=zs["[object Uint8Array]"]=zs["[object Uint8ClampedArray]"]=zs["[object Uint16Array]"]=zs["[object Uint32Array]"]=!0,zs["[object Error]"]=zs[Vs]=zs["[object WeakMap]"]=!1;var Ws=function n(r,i,o,e,t,s){var a,u=i&Ds,c=i&Fs,f=i&Us;if(o&&(a=t?o(r,e,t,s):o(r)),void 0!==a)return a;if(!tn(r))return r;var l=Lt(r);if(l){if(a=vs(r),!u)return at(r,a)}else{var h=io(r),p=h==Vs||h==Ys;if(Dt(r))return hs(r,u);if(h==qs||h==Bs||p&&!t){if(a=c||p?{}:Ms(r),!u)return c?ms(r,ls(a,r)):ps(r,ss(a,r))}else{if(!zs[h])return t?r:{};a=Os(r,h,u)}}s||(s=new wi);var d=s.get(r);if(d)return d;if(s.set(r,a),js(r))return r.forEach(function(e){a.add(n(e,i,o,e,r,s))}),a;if(Ps(r))return r.forEach(function(e,t){a.set(t,n(e,i,o,t,r,s))}),a;var m=f?c?gs:Bi:c?keysIn:on,g=l?void 0:m(r);return es(g||r,function(e,t){g&&(e=r[t=e]),is(a,t,n(e,i,o,t,r,s))}),a};var Gs=function(e){return Ws(e,5)};var $s=function(s){return function(e,t,n){var r=Object(e);if(!rn(e)){var i=zo(t,3);e=on(e),t=function(e){return i(r[e],e,r)}}var o=s(e,t,n);return-1<o?r[i?e[o]:o]:void 0}};var Js=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1},Hs=/^\s+|\s+$/g,Zs=/^[-+]0x[0-9a-f]+$/i,Xs=/^0b[01]+$/i,Ks=/^0o[0-7]+$/i,Qs=parseInt;var ea=function(e){if("number"==typeof e)return e;if(yo(e))return NaN;if(tn(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=tn(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Hs,"");var n=Xs.test(e);return n||Ks.test(e)?Qs(e.slice(2),n?2:8):Zs.test(e)?NaN:+e};var ta=function(e){return e?(e=ea(e))!==1/0&&e!==-1/0?e==e?e:0:17976931348623157e292*(e<0?-1:1):0===e?e:0};var na=function(e){var t=ta(e),n=t%1;return t==t?n?t-n:t:0},ra=Math.max;var ia,oa=$s(function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:na(n);return i<0&&(i=ra(r+i,0)),Js(e,zo(t,3),i)}),sa="unreadmessagescountupdate",aa="conflict",ua="conversationinfoupdated",ca="unhandledmessage",fa="invited",la="membersjoined",ha="membersleft",pa="memberinfoupdated",da="blocked",ma="unblocked",ga="membersblocked",ya="membersunblocked",va="unmuted",ba="membersmuted",wa="membersunmuted",_a="message",Ea="messagerecall",Ta="messageupdate",Sa="lastdeliveredatupdate",Aa="lastreadatupdate",Ia="infoupdated",Oa=Object.freeze({UNREAD_MESSAGES_COUNT_UPDATE:sa,CLOSE:"close",CONFLICT:aa,CONVERSATION_INFO_UPDATED:ua,UNHANDLED_MESSAGE:ca,INVITED:fa,KICKED:"kicked",MEMBERS_JOINED:la,MEMBERS_LEFT:ha,MEMBER_INFO_UPDATED:pa,BLOCKED:da,UNBLOCKED:ma,MEMBERS_BLOCKED:ga,MEMBERS_UNBLOCKED:ya,MUTED:"muted",UNMUTED:va,MEMBERS_MUTED:ba,MEMBERS_UNMUTED:wa,MESSAGE:_a,MESSAGE_RECALL:Ea,MESSAGE_UPDATE:Ta,LAST_DELIVERED_AT_UPDATE:Sa,LAST_READ_AT_UPDATE:Aa,INFO_UPDATED:Ia}),Ca={NONE:Symbol("none"),SENDING:Symbol("sending"),SENT:Symbol("sent"),DELIVERED:Symbol("delivered"),FAILED:Symbol("failed")};Object.freeze(Ca);var xa,Ma,ka=(a(ia={},Ca.NONE,!0),a(ia,Ca.SENDING,!0),a(ia,Ca.SENT,!0),a(ia,Ca.DELIVERED,!0),a(ia,Ca.READ,!0),a(ia,Ca.FAILED,!0),ia),Ra=function(){function e(e){Object.assign(this,{content:e},{id:wr(),cid:null,timestamp:new Date,from:void 0,mentionList:[],mentionedAll:!1,_mentioned:!1}),this._setStatus(Ca.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 T({},this._toJSON(),{data:this.content})},t.toFullJSON=function(){var e=this.content,t=this.id,n=this.cid,r=this.from,i=this.timestamp,o=this.deliveredAt,s=this._updatedAt,a=this.mentionList,u=this.mentionedAll;return{data:e,id:t,cid:n,from:r,timestamp:Cn(i),deliveredAt:Cn(o),updatedAt:Cn(s),mentionList:a,mentionedAll:u}},t._setStatus=function(e){if(!ka[e])throw new Error("Invalid message status");this._status=e},t._updateMentioned=function(e){this._mentioned=this.from!==e&&(this.mentionedAll||-1<this.mentionList.indexOf(e))},t.getMentionList=function(){return this.mentionList},t.setMentionList=function(e){return this.mentionList=Bn(e),this},t.mentionAll=function(){var e=!(0<arguments.length&&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)},o(e,[{key:"status",get:function(){return this._status}},{key:"timestamp",get:function(){return this._timestamp},set:function(e){this._timestamp=On(e)}},{key:"deliveredAt",get:function(){return this._deliveredAt},set:function(e){this._deliveredAt=On(e)}},{key:"updatedAt",get:function(){return this._updatedAt||this.timestamp},set:function(e){this._updatedAt=On(e)}},{key:"mentioned",get:function(){return this._mentioned}}]),e}(),Pa=function(t){if("number"!=typeof t)throw new TypeError("".concat(t," is not a Number"));return function(e){e.TYPE=t,e.validate=function(e){return e._lctype===t},e.prototype._getType=function(){return{_lctype:t}}}},Na=function(n){if("string"!=typeof n){if(!Array.isArray(n))throw new TypeError("".concat(n," is not an Array"));if(n.some(function(e){return"string"!=typeof e}))throw new TypeError("fields contains non-string typed member")}return function(e){var t=Rn?Pn(e,"_customFields"):e._customFields;t=Array.isArray(t)?t:[],e._customFields=t.concat(n)}},La=function(e){Rn&&(e.parse=Pn(e,"parse"))},ja=Na(["_lctext","_lcattrs"])(xa=function(i){function e(){return i.apply(this,arguments)||this}f(e,i);var t=e.prototype;return t.setText=function(e){return this._lctext=e,this},t.getText=function(){return this._lctext},t.setAttributes=function(e){return this._lcattrs=e,this},t.getAttributes=function(){return this._lcattrs},t._getCustomFields=function(){var n=this;return(Array.isArray(this.constructor._customFields)?this.constructor._customFields:[]).reduce(function(e,t){return"string"!=typeof t||(e[t]=n[t]),e},{})},t._getType=function(){throw new Error("not implemented")},t.getPayload=function(){return Fn(Object.assign({_lctext:this.getText(),_lcattrs:this.getAttributes()},this._getCustomFields(),this._getType()))},t.toJSON=function(){var e=this.type,t=this.text,n=this.attributes,r=this.summary;return T({},i.prototype._toJSON.call(this),{type:e,text:t,attributes:n,summary:r})},t.toFullJSON=function(){return T({},i.prototype.toFullJSON.call(this),{data:this.getPayload()})},e.parse=function(n){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:new this;e.content=n;var t=Rn?Pn(e.constructor,"_customFields"):e.constructor._customFields,r=Array.isArray(t)?t:[];return r=r.reduce(function(e,t){return"string"!=typeof t||(e[t]=n[t]),e},{}),Object.assign(e,r),i.parse.call(this,n,e)},o(e,[{key:"type",get:function(){return this.constructor.TYPE}},{key:"text",set:function(e){return this.setText(e)},get:function(){return this.getText()}},{key:"attributes",set:function(e){return this.setAttributes(e)},get:function(){return this.getAttributes()}},{key:"summary",get:function(){return this.text}}]),e}(Ra))||xa,Da=Pa(-127)(Ma=La(Ma=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),o(t,[{key:"summary",get:function(){return"[该消息已撤回]"}}]),t}(ja))||Ma)||Ma,Fa=De("LC:Conversation"),Ua=function(e){var t,n,r=e.getPayload();return r instanceof ArrayBuffer?n=r:t="string"!=typeof r?JSON.stringify(r):r,{msg:t,binaryMsg:n}},Ba=ce.QueryDirection,Va=Ba.NEW,Ya={NEW_TO_OLD:Ba.OLD,OLD_TO_NEW:Va};Object.freeze(Ya);var qa=function(m){function e(e,t){var i,n=e.id,r=e.lastMessageAt,o=e.lastMessage,s=e.lastDeliveredAt,a=e.lastReadAt,u=e.unreadMessagesCount,c=void 0===u?0:u,f=e.members,l=void 0===f?[]:f,h=e.mentioned,p=void 0!==h&&h,d=S(e,["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"]);return i=m.call(this)||this,Object.assign(g(i),T({id:n,lastMessageAt:r,lastMessage:o,members:l},d)),i.members=Array.from(new Set(i.members)),Object.assign(Dn(g(i)),{messagesWaitingForReceipt:{},lastDeliveredAt:s,lastReadAt:a,unreadMessagesCount:c,mentioned:p}),i._client=t,Fa.enabled&&sn(Oa).forEach(function(r){return i.on(r,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i._debug("".concat(r," event emitted. %o"),t)})}),ar(i._client._plugins.onConversationCreate,g(i)),i}f(e,m);var t=e.prototype;return t._setUnreadMessagesMentioned=function(e){Dn(this).unreadMessagesMentioned=Boolean(e)},t._setLastDeliveredAt=function(e){var t=On(e);t<Dn(this).lastDeliveredAt||(Dn(this).lastDeliveredAt=t,this.emit(Sa))},t._setLastReadAt=function(e){var t=On(e);t<Dn(this).lastReadAt||(Dn(this).lastReadAt=t,this.emit(Aa))},t.toFullJSON=function(){var e=this.id,t=this.members,n=this.lastMessageAt,r=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount;return{id:e,members:t,lastMessageAt:Cn(n),lastDeliveredAt:Cn(r),lastReadAt:Cn(i),lastMessage:o?o.toFullJSON():void 0,unreadMessagesCount:s}},t.toJSON=function(){var e=this.id,t=this.members,n=this.lastMessageAt,r=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount,a=this.unreadMessagesMentioned;return{id:e,members:t,lastMessageAt:n,lastDeliveredAt:r,lastReadAt:i,lastMessage:o?o.toJSON():void 0,unreadMessagesCount:s,unreadMessagesMentioned:a}},t._debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Fa.apply(void 0,t.concat(["[".concat(this.id,"]")]))},t._send=function(e){var t;null===e.cmd&&(e.cmd="conv"),"conv"===e.cmd&&null===e.convMessage&&(e.convMessage=new ae),e.convMessage&&null===e.convMessage.cid&&(e.convMessage.cid=this.id);for(var n=arguments.length,r=new Array(1<n?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(t=this._client)._send.apply(t,[e].concat(r))},t.send=function(){var n=b(ke.mark(function e(t,n){var r,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug(t,"send"),t instanceof Ra){e.next=3;break}throw new TypeError("".concat(t," is not a Message"));case 3:return r=Object.assign({},t.constructor.sendOptions,"function"==typeof t.constructor.getSendOptions?t.constructor.getSendOptions(t):{},n),i=r.transient,o=r.receipt,s=r.priority,a=r.pushData,u=r.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."):2<this.members.length&&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(Ca.SENDING),c=Ua(t),f=c.msg,l=c.binaryMsg,h=new ge({cmd:"direct",directMessage:new ie({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)throw rr({code:y,reason:v,appCode:b});e.next=17;break;case 17:return Object.assign(t,{id:m,timestamp:g}),i||(this.lastMessage=t,this.lastMessageAt=t.timestamp),t._setStatus(Ca.SENT),o&&(Dn(this).messagesWaitingForReceipt[t.id]=t),e.abrupt("return",t);case 24:throw e.prev=24,e.t0=e.catch(10),t._setStatus(Ca.FAILED),e.t0;case 28:case"end":return e.stop()}},e,this,[[10,24]])}));return function(e,t){return n.apply(this,arguments)}}(),t._update=function(){var r=b(ke.mark(function e(t,n,r){var i,o,s,a,u,c,f,l;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("patch %O %O %O",t,n,r),!(t instanceof Ra)){e.next=8;break}if(t.from!==this._client.id)throw new Error("Updating message from others is not allowed");e.next=4;break;case 4:if(t.status!==Ca.SENT&&t.status!==Ca.DELIVERED)throw new Error("Message is not sent");e.next=6;break;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 r||(s=Ua(n),i=s.msg,o=s.binaryMsg),e.next=13,this._send(new ge({cmd:_e.patch,op:Ee.modify,patchMessage:new ve({patches:[new be({cid:this.id,mid:t.id,timestamp:Number(t.timestamp),recall:r,data:i,binaryMsg:o,mentionPids:n.mentionList,mentionAll:n.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(n,{id:a,cid:u,timestamp:c,from:f,_status:l}),this.lastMessage.id===n.id&&(this.lastMessage=n),e.abrupt("return",n);case 17:case"end":return e.stop()}},e,this)}));return function(e,t,n){return r.apply(this,arguments)}}(),t.count=function(){var e=b(ke.mark(function e(){var t;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("count"),e.next=3,this._send(new ge({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)}}(),t._addMembers=function(){},t._removeMembers=function(){},t.update=function(){var n=b(ke.mark(function e(t,n){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n instanceof Ra){e.next=2;break}throw new TypeError("".concat(n," is not a Message"));case 2:return e.abrupt("return",this._update(t,n,!1));case 3:case"end":return e.stop()}},e,this)}));return function(e,t){return n.apply(this,arguments)}}(),t.recall=function(){var t=b(ke.mark(function e(t){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._update(t,new Da,!0));case 1:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.queryMessages=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,y=this,v=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0<v.length&&void 0!==v[0]?v[0]:{},this._debug("query messages %O",t),n=t.beforeTime,r=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,r||n||o||i)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:n,startMessageId:r,endTime:i,endMessageId:o,limit:s}));e.next=6;break;case 6:if(f&&!c)throw new Error("query option startMessageId must be used with option startTime");e.next=8;break;case 8:if(p&&!h)throw new Error("query option endMessageId must be used with option endTime");e.next=10;break;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=Ya.OLD_TO_NEW),e.next=16,this._send(new ge({cmd:"logs",logsMessage:new ce(Object.assign(m,{cid:this.id}))}));case 16:return g=e.sent,e.abrupt("return",Promise.all(g.logsMessage.logs.map(function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.msgId,r=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:n,cid:y.id,timestamp:r,from:o,deliveredAt:s,updatedAt:i,mentionList:f,mentionedAll:c},e.next=4,y._client.parseMessage(h);case 4:return p=e.sent,d=Ca.SENT,2===y.members.length&&(s&&(d=Ca.DELIVERED),s&&y._setLastDeliveredAt(s),a&&y._setLastReadAt(a)),p._setStatus(d),e.abrupt("return",p);case 9:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}())));case 18:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.createMessagesIterator=function(){var e,t=this,n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},r=n.beforeTime,i=n.beforeMessageId,o=n.limit;return{next:function(){return(e=void 0===e?t.queryMessages({limit:o,startTime:r,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}})}}},t.read=function(){var e=b(ke.mark(function e(){var t;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.unreadMessagesCount=0,this._setUnreadMessagesMentioned(!1),this.transient)return e.abrupt("return",this);e.next=4;break;case 4:return t=this._client,Dn(t).readConversationsBuffer||(Dn(t).readConversationsBuffer=new Set),Dn(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)}}(),t._handleReceipt=function(e){var t=e.messageId,n=e.timestamp;e.read?this._setLastReadAt(n):this._setLastDeliveredAt(n);var r=Dn(this).messagesWaitingForReceipt,i=r[t];i&&(i._setStatus(Ca.DELIVERED),i.deliveredAt=n,delete r[t])},t.fetchReceiptTimestamps=function(){var e=b(ke.mark(function e(){var t,n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._send(new ge({op:"max_read"}));case 2:return t=e.sent,n=t.convMessage,r=n.maxReadTimestamp,i=n.maxAckTimestamp,this._setLastDeliveredAt(i),this._setLastReadAt(r),e.abrupt("return",this);case 9:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t._fetchAllReceiptTimestamps=function(){var e=new ae({queryAllMembers:!0});return this._send(new ge({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,n=e.maxAckTimestamp,r=e.maxReadTimestamp;return{pid:t,lastDeliveredAt:On(n),lastReadAt:On(r)}})})},o(e,[{key:"unreadMessagesMentioned",get:function(){return Dn(this).unreadMessagesMentioned}},{key:"unreadMessagesCount",set:function(e){e!==this.unreadMessagesCount&&(Dn(this).unreadMessagesCount=e,this._client.emit(sa,[this]))},get:function(){return Dn(this).unreadMessagesCount}},{key:"lastMessageAt",set:function(e){var t=On(e);t<=this._lastMessageAt||(this._lastMessageAt=t)},get:function(){return this._lastMessageAt}},{key:"lastDeliveredAt",get:function(){return 2!==this.members.length?null:Dn(this).lastDeliveredAt}},{key:"lastReadAt",get:function(){return 2!==this.members.length?null:Dn(this).lastReadAt}}]),e}(Ae),za=De("LC:SignatureFactoryRunner");function Wa(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=e.signature,n=e.timestamp,r=e.nonce;if("string"!=typeof t||"number"!=typeof n||"string"!=typeof r)throw new Error("malformed signature");return{signature:t,timestamp:n,nonce:r}}var Ga=function(e,t){return Promise.resolve().then(function(){return za("call signatureFactory with %O",t),e.apply(void 0,v(t))}).then(An(function(e){return za("sign result %O",e)}),function(e){throw e.message="sign error: ".concat(e.message),za(e),e}).then(Wa)},$a=function(e){return{successfulClientIds:e.allowedPids,failures:e.failedPids.map(function(e){var t=e.pids,n=S(e,["pids"]);return Object.assign(rr(n),{clientIds:t})})}},Ja=function(g){function e(e,t,n){var r,i=t.creator,o=t.createdAt,s=t.updatedAt,a=t.transient,u=void 0!==a&&a,c=t.system,f=void 0!==c&&c,l=t.muted,h=void 0!==l&&l,p=t.mutedMembers,d=void 0===p?[]:p,m=S(t,["creator","createdAt","updatedAt","transient","system","muted","mutedMembers"]);return(r=g.call(this,T({},e,{creator:i,createdAt:o,updatedAt:s,mutedMembers:d,transient:u,system:f,muted:h,_attributes:m}),n)||this)._reset(),r}f(e,g);var t=e.prototype;return t.get=function(e){return Dn(this).currentAttributes[e]},t.set=function(t,e){this._debug("set [".concat(t,"]: ").concat(e));var n=Dn(this).pendingAttributes,r=Object.keys(n),i=new RegExp("^".concat(t)),o=r.filter(i.test.bind(i));if(o.forEach(function(e){delete n[e]}),o.length)n[t]=e;else{var s=oa(r,function(e){return 0===t.indexOf(e)});s?Vn(n[s],t.slice(s.length+1),e):n[t]=e}return this._buildCurrentAttributes(),this},t._buildCurrentAttributes=function(){var n=Dn(this).pendingAttributes;Dn(this).currentAttributes=Object.keys(n).reduce(function(e,t){return Vn(e,t,n[t])},Gs(this._attributes))},t._updateServerAttributes=function(t){var n=this;Object.keys(t).forEach(function(e){return Vn(n._attributes,e,t[e])}),this._buildCurrentAttributes()},t._reset=function(){Object.assign(Dn(this),{pendingAttributes:{},currentAttributes:this._attributes})},t.save=function(){var e=b(ke.mark(function e(){var t,n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("save"),t=Dn(this).pendingAttributes,Qo(t))return this._debug("nothing touched, resolve with self"),e.abrupt("return",this);e.next=5;break;case 5:return this._debug("attr: %O",t),n=new ae({attr:new K({data:JSON.stringify(Mn(t))})}),e.next=9,this._send(new ge({op:"update",convMessage:n}));case 9:return r=e.sent,this.updatedAt=r.convMessage.udate,this._attributes=Dn(this).currentAttributes,Dn(this).pendingAttributes={},e.abrupt("return",this);case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.fetch=function(){var e=b(ke.mark(function e(){var t;return ke.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)}}(),t.mute=function(){var e=b(ke.mark(function e(){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute"),e.next=3,this._send(new ge({op:"mute"}));case 3:return this.transient||(this.muted=!0,this.mutedMembers=Nn(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)}}(),t.unmute=function(){var e=b(ke.mark(function e(){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute"),e.next=3,this._send(new ge({op:"unmute"}));case 3:return this.transient||(this.muted=!1,this.mutedMembers=Ln(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)}}(),t._appendConversationSignature=function(){var r=b(ke.mark(function e(t,n,r){var i,o;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._client.options.conversationSignatureFactory)return i=[this.id,this._client.id,r.sort(),n],e.next=4,Ga(this._client.options.conversationSignatureFactory,i);e.next=6;break;case 4:o=e.sent,Object.assign(t.convMessage,kn({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}},e,this)}));return function(e,t,n){return r.apply(this,arguments)}}(),t._appendBlacklistSignature=function(){var r=b(ke.mark(function e(t,n,r){var i,o;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._client.options.blacklistSignatureFactory)return i=[this._client.id,this.id,r.sort(),n],e.next=4,Ga(this._client.options.blacklistSignatureFactory,i);e.next=6;break;case 4:o=e.sent,Object.assign(t.blacklistMessage,kn({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}},e,this)}));return function(e,t,n){return r.apply(this,arguments)}}(),t.add=function(){var t=b(ke.mark(function e(t){var n,r,i,o;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("add",t),"string"==typeof t&&(t=[t]),n=new ge({op:"add",convMessage:new ae({m:t})}),e.next=5,this._appendConversationSignature(n,"add",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.convMessage,o=r.convMessage.allowedPids,this._addMembers(o),e.abrupt("return",$a(i));case 12:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.remove=function(){var t=b(ke.mark(function e(t){var n,r,i,o;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("remove",t),"string"==typeof t&&(t=[t]),n=new ge({op:"remove",convMessage:new ae({m:t})}),e.next=5,this._appendConversationSignature(n,"remove",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.convMessage,o=r.convMessage.allowedPids,this._removeMembers(o),e.abrupt("return",$a(i));case 12:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.join=function(){var e=b(ke.mark(function e(){var n=this;return ke.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 t=e.failures;if(t[0])throw t[0];return n}));case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.quit=function(){var e=b(ke.mark(function e(){var n=this;return ke.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 t=e.failures;if(t[0])throw t[0];return n}));case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.muteMembers=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute",t),t=Bn(t),n=new ge({op:Ee.add_shutup,convMessage:new ae({m:t})}),e.next=5,this._send(n);case 5:return r=e.sent,i=r.convMessage,e.abrupt("return",$a(i));case 8:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.unmuteMembers=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute",t),t=Bn(t),n=new ge({op:Ee.remove_shutup,convMessage:new ae({m:t})}),e.next=5,this._send(n);case 5:return r=e.sent,i=r.convMessage,e.abrupt("return",$a(i));case 8:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.queryMutedMembers=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s,a,u,c=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=0<c.length&&void 0!==c[0]?c[0]:{},n=t.limit,r=t.next,this._debug("query muted: limit %O, next: %O",n,r),i=new ge({op:Ee.query_shutup,convMessage:new ae({limit:n,next:r})}),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)}}(),t.blockMembers=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("block",t),t=Bn(t),n=new ge({cmd:"blacklist",op:Ee.block,blacklistMessage:new ye({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(n,"conversation-block-clients",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.blacklistMessage,e.abrupt("return",$a(i));case 10:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.unblockMembers=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unblock",t),t=Bn(t),n=new ge({cmd:"blacklist",op:Ee.unblock,blacklistMessage:new ye({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(n,"conversation-unblock-clients",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.blacklistMessage,e.abrupt("return",$a(i));case 10:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.queryBlockedMembers=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s,a,u,c=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=0<c.length&&void 0!==c[0]?c[0]:{},n=t.limit,r=t.next,this._debug("query blocked: limit %O, next: %O",n,r),i=new ge({cmd:"blacklist",op:Ee.query,blacklistMessage:new ye({srcCid:this.id,limit:n,next:r})}),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)}}(),t.toFullJSON=function(){var e=this.creator,t=this.system,n=this.transient,r=this.createdAt,i=this.updatedAt,o=this._attributes;return T({},g.prototype.toFullJSON.call(this),{creator:e,system:t,transient:n,createdAt:Cn(r),updatedAt:Cn(i)},o)},t.toJSON=function(){var e=this.creator,t=this.system,n=this.transient,r=this.muted,i=this.mutedMembers,o=this.createdAt,s=this.updatedAt,a=this._attributes;return T({},g.prototype.toJSON.call(this),{creator:e,system:t,transient:n,muted:r,mutedMembers:i,createdAt:o,updatedAt:s},a)},o(e,[{key:"createdAt",set:function(e){this._createdAt=On(e)},get:function(){return this._createdAt}},{key:"updatedAt",set:function(e){this._updatedAt=On(e)},get:function(){return this._updatedAt}},{key:"name",get:function(){return this.get("name")},set:function(e){this.set("name",e)}}]),e}(qa),Ha={OWNER:"Owner",MANAGER:"Manager",MEMBER:"Member"};Object.freeze(Ha);var Za,Xa,Ka,Qa,eu,tu,nu=function(){function e(e){var t=e.conversation,n=e.memberId,r=e.role;if(!t)throw new Error("conversation requried");if(!n)throw new Error("memberId requried");Object.assign(Dn(this),{conversation:t,memberId:n,role:r})}return e.prototype.toJSON=function(){return{conversationId:this.conversationId,memberId:this.memberId,role:this.role,isOwner:this.isOwner}},o(e,[{key:"conversationId",get:function(){return Dn(this).conversation.id}},{key:"memberId",get:function(){return Dn(this).memberId}},{key:"role",get:function(){return this.isOwner?Ha.OWNER:Dn(this).role}},{key:"isOwner",get:function(){return this.memberId===Dn(this).conversation.creator}}]),e}(),ru=function(r){function e(){return r.apply(this,arguments)||this}f(e,r);var t=e.prototype;return t._addMembers=function(e){var t=this;r.prototype._addMembers.call(this,e),this.members=Nn(this.members,e);var n=Dn(this).memberInfoMap;n&&e.forEach(function(e){n[e]=n[e]||new nu({conversation:t,memberId:e,role:Ha.MEMBER})})},t._removeMembers=function(e){r.prototype._removeMembers.call(this,e),this.members=Ln(this.members,e);var t=Dn(this).memberInfoMap;t&&e.forEach(function(e){delete t[e]})},t._fetchAllMemberInfo=function(){var e=b(ke.mark(function e(){var t,n,r,i=this;return ke.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,n=t.results.map(function(e){return new nu({conversation:i,memberId:e.clientId,role:e.role})}),r={},n.forEach(function(e){r[e.memberId]=e}),this.members.forEach(function(e){r[e]=r[e]||new nu({conversation:i,memberId:e,role:Ha.MEMBER})}),Dn(this).memberInfoMap=r,e.abrupt("return",r);case 9:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.getAllMemberInfo=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0<s.length&&void 0!==s[0]?s[0]:{},n=t.noCache,r=void 0!==n&&n,i=Dn(this),!(o=i.memberInfoMap)||r)return e.next=5,this._fetchAllMemberInfo();e.next=6;break;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)}}(),t.getMemberInfo=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===this.members.indexOf(t))throw new Error("".concat(t," is not the mumber of conversation[").concat(this.id,"]"));e.next=2;break;case 2:if(n=Dn(this),(r=n.memberInfoMap)&&r[t]){e.next=6;break}return e.next=6,this.getAllMemberInfo();case 6:return e.abrupt("return",Dn(this).memberInfoMap[t]);case 7:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.updateMemberRole=function(){var n=b(ke.mark(function e(t,n){var r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("update member role"),n===Ha.OWNER)throw rr({code:nr.OWNER_PROMOTION_NOT_ALLOWED});e.next=3;break;case 3:return e.next=5,this._send(new ge({op:Ee.member_info_update,convMessage:new ae({targetClientId:t,info:new we({pid:t,role:n})})}));case 5:return r=Dn(this),(i=r.memberInfos)&&i[t]&&(Dn(i[t]).role=n),e.abrupt("return",this);case 8:case"end":return e.stop()}},e,this)}));return function(e,t){return n.apply(this,arguments)}}(),e}(Ja),iu=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(Ja),ou=function(e){function t(){return e.apply(this,arguments)||this}f(t,e);var n=t.prototype;return n.subscribe=function(){var e=b(ke.mark(function e(){return ke.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)}}(),n.unsubscribe=function(){var e=b(ke.mark(function e(){return ke.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}(Ja),su=function(e){return e.code===nr.CONVERSATION_NOT_FOUND?rr({code:nr.TEMPORARY_CONVERSATION_EXPIRED}):e},au=function(s){function e(e,t,n){var r=t.expiredAt;return s.call(this,T({},e,{expiredAt:r}),n)||this}f(e,s);var t=e.prototype;return t._send=function(){var e=b(ke.mark(function e(){var t,n,r,i,o=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.expired)throw rr({code:nr.TEMPORARY_CONVERSATION_EXPIRED});e.next=2;break;case 2:for(e.prev=2,n=o.length,r=new Array(n),i=0;i<n;i++)r[i]=o[i];return e.next=6,(t=s.prototype._send).call.apply(t,[this].concat(r));case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(2),su(e.t0);case 12:case"end":return e.stop()}},e,this,[[2,9]])}));return function(){return e.apply(this,arguments)}}(),t.send=function(){var e=b(ke.mark(function e(){var t,n,r,i,o=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,n=o.length,r=new Array(n),i=0;i<n;i++)r[i]=o[i];return e.next=4,(t=s.prototype.send).call.apply(t,[this].concat(r));case 4:return e.abrupt("return",e.sent);case 7:throw e.prev=7,e.t0=e.catch(0),su(e.t0);case 10:case"end":return e.stop()}},e,this,[[0,7]])}));return function(){return e.apply(this,arguments)}}(),t.toFullJSON=function(){var e=this.expiredAt;return T({},s.prototype.toFullJSON.call(this),{expiredAt:Cn(e)})},t.toJSON=function(){var e=this.expiredAt,t=this.expired;return T({},s.prototype.toJSON.call(this),{expiredAt:e,expired:t})},o(e,[{key:"expiredAt",set:function(e){this._expiredAt=On(e)},get:function(){return this._expiredAt}},{key:"expired",get:function(){return this.expiredAt<new Date}}]),e}(qa),uu=De("LC:ConversationQuery"),cu=function(){function n(e){this._client=e,this._where={},this._extraOptions={}}n._encode=function(e){return e instanceof Date?{__type:"Date",iso:e.toJSON()}:e instanceof RegExp?e.source:e},n._quote=function(e){return"\\Q".concat(e.replace("\\E","\\E\\\\E\\Q"),"\\E")},n._calculateFlag=function(n){return["withLastMessagesRefreshed","compact"].reduce(function(e,t){return(e<<1)+Boolean(n[t])},0)};var e=n.prototype;return e._addCondition=function(e,t,n){return this._where[e]||(this._where[e]={}),this._where[e][t]=this.constructor._encode(n),this},e.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),uu(e),e},e.containsMembers=function(e){return this.containsAll("m",e)},e.withMembers=function(e,t){var n=new Set(e);return t&&n.add(this._client.id),this.sizeEqualTo("m",n.size),this.containsMembers(Array.from(n))},e.equalTo=function(e,t){return this._where[e]=this.constructor._encode(t),this},e.lessThan=function(e,t){return this._addCondition(e,"$lt",t)},e.lessThanOrEqualTo=function(e,t){return this._addCondition(e,"$lte",t)},e.greaterThan=function(e,t){return this._addCondition(e,"$gt",t)},e.greaterThanOrEqualTo=function(e,t){return this._addCondition(e,"$gte",t)},e.notEqualTo=function(e,t){return this._addCondition(e,"$ne",t)},e.exists=function(e){return this._addCondition(e,"$exists",!0)},e.doesNotExist=function(e){return this._addCondition(e,"$exists",!1)},e.containedIn=function(e,t){return this._addCondition(e,"$in",t)},e.notContainsIn=function(e,t){return this._addCondition(e,"$nin",t)},e.containsAll=function(e,t){return this._addCondition(e,"$all",t)},e.contains=function(e,t){return this._addCondition(e,"$regex",n._quote(t))},e.startsWith=function(e,t){return this._addCondition(e,"$regex","^".concat(n._quote(t)))},e.endsWith=function(e,t){return this._addCondition(e,"$regex","".concat(n._quote(t),"$"))},e.matches=function(e,t){this._addCondition(e,"$regex",t);var n="";return t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),n&&n.length&&this._addCondition(e,"$options",n),this},e.sizeEqualTo=function(e,t){return this._addCondition(e,"$size",t)},e.limit=function(e){return this._limit=e,this},e.skip=function(e){return this._skip=e,this},e.ascending=function(e){return this._order=e,this},e.addAscending=function(e){return this._order?this._order+=",".concat(e):this._order=e,this},e.descending=function(e){return this._order="-".concat(e),this},e.addDescending=function(e){return this._order?this._order+=",-".concat(e):this._order="-".concat(e),this},e.withLastMessagesRefreshed=function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];return this._extraOptions.withLastMessagesRefreshed=e,this},e.compact=function(){var e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];return this._extraOptions.compact=e,this},e.find=function(){var e=b(ke.mark(function e(){return ke.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)}}(),n}(),fu=De("LC:SessionManager"),lu=function(){function e(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=e.refresh,n=e.onBeforeGetSessionToken;this.refresh=t,this._onBeforeGetSessionToken=n,this.setSessionToken(null,0)}var t=e.prototype;return t.setSessionToken=function(e,t){fu("set session token",e,t);var n=new wn(e,1e3*t);return this._sessionToken=n,delete this._pendingSessionTokenPromise,n},t.setSessionTokenAsync=function(){var t=b(ke.mark(function e(t){var n,r=this;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._sessionToken,this._pendingSessionTokenPromise=t.catch(function(e){throw r._sessionToken=n,e}),e.t0=this.setSessionToken,e.t1=this,e.t2=v,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(e){return t.apply(this,arguments)}}(),t.getSessionToken=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s,a,u,c=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0<c.length&&void 0!==c[0]?c[0]:{},n=t.autoRefresh,r=void 0===n||n,fu("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===wn.EXPIRED&&r&&this.refresh)return fu("refresh expired session token"),e.next=15,this.setSessionTokenAsync(this.refresh(this,s));e.next=19;break;case 15:return a=e.sent,u=a.value,fu("session token",u),e.abrupt("return",u);case 19:return fu("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}(),hu=De("LC:IMClient"),pu=fa,du=la,mu=ha,gu=pa,yu=da,vu=ma,bu=ga,wu=ya,_u=va,Eu=ba,Tu=wa,Su=_a,Au=ca,Iu=Ea,Ou=Ta,Cu=function(e){return/^_tmp:/.test(e)},xu=(Za=qn(1e3),Xa=qn(1e3),t((Ka=function(r){function e(e){var i,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0;if(void 0!==e&&"string"!=typeof e)throw new TypeError("Client id [".concat(e,"] is not a String"));if(i=r.call(this)||this,Object.assign(g(i),{id:e,options:t},n),!i._messageParser)throw new Error("IMClient must be initialized with a MessageParser");return i._conversationCache=new Tn("client:".concat(i.id)),i._ackMessageBuffer={},Dn(g(i)).lastPatchTime=Date.now(),Dn(g(i)).lastNotificationTime=void 0,Dn(g(i))._eventemitter=new Ae,hu.enabled&&sn(Oa).forEach(function(r){return i.on(r,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i._debug("".concat(r," event emitted. %o"),t)})}),ar(i._plugins.onIMClientCreate,g(i)),i}f(e,r);var t=e.prototype;return t._debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];hu.apply(void 0,t.concat(["[".concat(this.id,"]")]))},t._dispatchCommand=function(){var t=b(ke.mark(function e(t){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this._debug(Un(t),"received"),t.serverTs&&1===t.notificationType&&(Dn(this).lastNotificationTime=Cn(On(t.serverTs))),e.t0=t.cmd,e.next=e.t0===_e.conv?5:e.t0===_e.direct?6:e.t0===_e.session?7:e.t0===_e.unread?8:e.t0===_e.rcp?9:e.t0===_e.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(Au,t));case 12:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._dispatchSessionMessage=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=t.sessionMessage,r=n.code,i=n.reason,e.t0=t.op,e.next=e.t0===Ee.closed?4:8;break;case 4:if(Dn(this)._eventemitter.emit("close"),r===nr.SESSION_CONFLICT)return e.abrupt("return",this.emit("conflict",{reason:i}));e.next=7;break;case 7:return e.abrupt("return",this.emit("close",{code:r,reason:i}));case 8:throw this.emit(Au,t),new Error("Unrecognized session command");case 10:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._dispatchUnreadMessage=function(e){var h=this,t=e.unreadMessage,n=t.convs,r=t.notifTime;return Dn(this).lastUnreadNotifTime=r,this.getConversations(n.map(function(e){return e.cid})).then(function(){return Promise.all(n.map(function(e){var n,r=e.cid,t=e.unread,i=e.mid,o=e.timestamp,s=e.from,a=e.data,u=e.binaryMsg,c=e.patchTimestamp,f=e.mentioned,l=h._conversationCache.get(r);return l?(o&&(n=On(o),l.lastMessageAt=n),(i?h._messageParser.parse(u||a).then(function(e){var t={id:i,cid:r,timestamp:n,updatedAt:c,from:s};Object.assign(e,t),l.lastMessage=e}):Promise.resolve()).then(function(){return l._setUnreadMessagesMentioned(f),t===Dn(l).unreadMessagesCount?null:(Dn(l).unreadMessagesCount=t,l)})):null})).then(function(e){return e.filter(function(e){return e})})}).then(function(e){e.length&&h.emit("unreadmessagescountupdate",e)})},t._dispatchRcpMessage=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.rcpMessage,r=t.rcpMessage.read,i=n.cid,o=n.id,s=On(n.t),a=this._conversationCache.get(i)){e.next=7;break}return e.abrupt("return");case 7:a._handleReceipt({messageId:o,timestamp:s,read:r});case 8:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._dispatchPatchMessage=function(e){var m=this,t=e.patchMessage.patches;return this.getConversations(t.map(function(e){return e.cid})).then(function(){return Promise.all(t.map(function(e){var i=e.cid,o=e.mid,s=e.timestamp,a=e.recall,t=e.data,u=e.patchTimestamp,c=e.from,n=e.binaryMsg,f=e.mentionAll,l=e.mentionPids,h=e.patchCode,p=e.patchReason,d=m._conversationCache.get(i);return d?m._messageParser.parse(n||t).then(function(e){var t,n=Cn(On(u)),r={id:o,cid:i,timestamp:s,updatedAt:n,from:c,mentionList:l,mentionedAll:f};Object.assign(e,r),e._setStatus(Ca.SENT),e._updateMentioned(m.id),Dn(m).lastPatchTime<n&&(Dn(m).lastPatchTime=n),d.lastMessage&&d.lastMessage.id===o&&(d.lastMessage=e),h&&(t={code:h.toNumber(),detail:p}),a?(m.emit(Iu,e,d,t),d.emit(Iu,e,t)):(m.emit(Ou,e,d,t),d.emit(Ou,e,t))}):null}))})},t._dispatchConvMessage=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,E,T,S,A,I,O;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.convMessage,r=t.convMessage,i=r.initBy,o=r.m,s=r.info,a=r.attr,e.next=3,this.getConversation(n.cid);case 3:u=e.sent,e.t0=t.op,e.next=e.t0===Ee.joined?7:e.t0===Ee.left?12:e.t0===Ee.members_joined?17:e.t0===Ee.members_left?22:e.t0===Ee.members_blocked?27:e.t0===Ee.members_unblocked?31:e.t0===Ee.blocked?35:e.t0===Ee.unblocked?39:e.t0===Ee.members_shutuped?43:e.t0===Ee.members_unshutuped?47:e.t0===Ee.shutuped?51:e.t0===Ee.unshutuped?55:e.t0===Ee.member_info_changed?59:e.t0===Ee.updated?71:77;break;case 7:return u._addMembers([this.id]),c={invitedBy:i},this.emit(pu,c,u),u.emit(pu,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(du,l,u),u.emit(du,l),e.abrupt("return");case 22:return u._removeMembers(o),h={kickedBy:i,members:o},this.emit(mu,h,u),u.emit(mu,h),e.abrupt("return");case 27:return p={blockedBy:i,members:o},this.emit(bu,p,u),u.emit(bu,p),e.abrupt("return");case 31:return d={unblockedBy:i,members:o},this.emit(wu,d,u),u.emit(wu,d),e.abrupt("return");case 35:return m={blockedBy:i},this.emit(yu,m,u),u.emit(yu,m),e.abrupt("return");case 39:return g={unblockedBy:i},this.emit(vu,g,u),u.emit(vu,g),e.abrupt("return");case 43:return y={mutedBy:i,members:o},this.emit(Eu,y,u),u.emit(Eu,y),e.abrupt("return");case 47:return v={unmutedBy:i,members:o},this.emit(Tu,v,u),u.emit(Tu,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(_u,w,u),u.emit(_u,w),e.abrupt("return");case 59:if(_=s.pid,E=s.role,T=Dn(u),T.memberInfoMap||E){e.next=63;break}return e.abrupt("return");case 63:return e.next=65,u.getMemberInfo(_);case 65:return S=e.sent,Dn(S).role=E,A={member:_,memberInfo:S,updatedBy:i},this.emit(gu,A,u),u.emit(gu,A),e.abrupt("return");case 71:return I=xn(JSON.parse(a.data)),u._updateServerAttributes(I),O={attributes:I,updatedBy:i},this.emit("conversationinfoupdated",O,u),u.emit("infoupdated",O),e.abrupt("return");case 77:throw this.emit(Au,t),new Error("Unrecognized conversation command");case 79:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._dispatchDirectMessage=function(e){var o=this,t=e.directMessage,n=e.directMessage,s=n.id,a=n.cid,u=n.fromPeerId,c=n.timestamp,f=n.transient,l=n.patchTimestamp,h=n.mentionPids,p=n.mentionAll,r=n.binaryMsg,i=n.msg,d=r?r.toArrayBuffer():i;return Promise.all([this.getConversation(t.cid),this._messageParser.parse(d)]).then(function(e){var t=y(e,2),n=t[0],r=t[1];if(n){var i={id:s,cid:a,timestamp:c,updatedAt:l,from:u,mentionList:h,mentionedAll:p};return Object.assign(r,i),r._updateMentioned(o.id),r._setStatus(Ca.SENT),r.from!==o.id&&(f||n.transient||o._sendAck(r)),o._dispatchParsedMessage(r,n)}})},t._dispatchParsedMessage=function(t,n){var r=this;return cr(this._plugins.beforeMessageDispatch,[t,n]).then(function(e){!1!==e&&(n.lastMessage=t,n.lastMessageAt=t.timestamp,t.from!==r.id&&(n.unreadMessagesCount+=1,t.mentioned&&n._setUnreadMessagesMentioned(!0)),r.emit(Su,t,n),n.emit(Su,t))})},t._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()},t._doSendAck=function(){var i=this;this._connection.is("connected")&&(this._debug("do send ack %O",this._ackMessageBuffer),Promise.all(Object.keys(this._ackMessageBuffer).map(function(t){var n=i._ackMessageBuffer[t],e=n.map(function(e){return e.timestamp}),r=new ge({cmd:"ack",peerId:i.id,ackMessage:new oe({cid:t,fromts:Math.min.apply(null,e),tots:Math.max.apply(null,e)})});return delete i._ackMessageBuffer[t],i._send(r,!1).catch(function(e){i._debug("send ack failed: %O",e),i._ackMessageBuffer[t]=n})})))},t._omitPeerId=function(e){Dn(this).peerIdOmittable=e},t._send=function(e){var t,n=e;!Dn(this).peerIdOmittable&&this.id&&(n.peerId=this.id);for(var r=arguments.length,i=new Array(1<r?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return(t=this._connection).send.apply(t,[n].concat(i))},t._open=function(){var r=b(ke.mark(function e(t,n,r){var i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,E=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=3<E.length&&void 0!==E[3]&&E[3],this._debug("open session"),o=Dn(this),s=o.lastUnreadNotifTime,a=o.lastPatchTime,u=o.lastNotificationTime,c=new ge({cmd:"session",op:"open",appId:t,peerId:this.id,sessionMessage:new ne({ua:"js/".concat(fr),r:i,lastUnreadNotifTime:s,lastPatchTime:a,configBitmap:59})}),i){e.next=13;break}if(Object.assign(c.sessionMessage,Un({tag:n,deviceId:r})),this.options.signatureFactory)return e.next=9,Ga(this.options.signatureFactory,[this._identity]);e.next=11;break;case 9:f=e.sent,Object.assign(c.sessionMessage,kn({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!==wn.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!==nr.SESSION_TOKEN_EXPIRED){e.next=31;break}if(this._sessionManager){e.next=28;break}throw new Error("Unexpected session expiration");case 28:return hu("Session token expired, reopening"),this._sessionManager.revoke(),e.abrupt("return",this._open(t,n,r,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)throw rr(m);e.next=35;break;case 35:return d?(this.id=d,this._identity||(this._identity=d),y&&(this._sessionManager=this._sessionManager||this._createSessionManager(),this._sessionManager.setSessionToken(y,v)),_=Cn(On(w)),w&&(Dn(this).lastPatchTime=_),u?this._syncNotifications(u).catch(function(e){return console.warn("Syncing notifications failed:",e)}):Dn(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(e,t,n){return r.apply(this,arguments)}}(),t._syncNotifications=function(){var t=b(ke.mark(function e(t){var n,r,s=this;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchNotifications(t);case 2:if(n=e.sent,r=n.hasMore,n.notifications.forEach(function(e){var t=e.cmd,n=e.op,r=e.serverTs,i=e.notificationType,o=S(e,["cmd","op","serverTs","notificationType"]);s._dispatchCommand(a({cmd:_e[t],op:Ee[n],serverTs:r,notificationType:i},"".concat(t,"Message"),o))}),r)return e.abrupt("return",this._syncNotifications(Dn(this).lastNotificationTime));e.next=8;break;case 8:return e.abrupt("return",void 0);case 9:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._fetchNotifications=function(){var t=b(ke.mark(function e(t){return ke.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(e){return t.apply(this,arguments)}}(),t._createSessionManager=function(){var r=this;return hu("create SessionManager"),new lu({onBeforeGetSessionToken:this._connection.checkConnectionAvailability.bind(this._connection),refresh:function(e,t){return e.setSessionTokenAsync(Promise.resolve(new ge({cmd:"session",op:"refresh",sessionMessage:new ne({ua:"js/".concat(fr),st:t})})).then(function(){var t=b(ke.mark(function e(t){var n;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r.options.signatureFactory)return e.next=3,Ga(r.options.signatureFactory,[r._identity]);e.next=5;break;case 3:n=e.sent,Object.assign(t.sessionMessage,kn({signature:"s",timestamp:"t",nonce:"n"},n));case 5:return e.abrupt("return",t);case 6:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}()).then(r._send.bind(r)).then(function(e){var t=e.sessionMessage;return[t.st,t.stTtl]}))}})},t._requestWithSessionToken=function(){var t=b(ke.mark(function e(t){var n,r,i,o;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.headers,r=t.query,i=S(t,["headers","query"]),e.next=3,this._sessionManager.getSessionToken();case 3:return o=e.sent,e.abrupt("return",this._request(T({headers:T({"X-LC-IM-Session-Token":o},n),query:T({client_id:this.id},r)},i)));case 5:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.close=function(){var e=b(ke.mark(function e(){var t,n;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("close session"),(t=Dn(this)._eventemitter).emit("beforeclose"),this._connection.is("connected"))return n=new ge({cmd:"session",op:"close"}),e.next=7,this._send(n);e.next=7;break;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)}}(),t.ping=function(){var t=b(ke.mark(function e(t){var n,r;return ke.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 n=new ge({cmd:"session",op:"query",sessionMessage:new ne({sessionPeerIds:t})}),e.next=8,this._send(n);case 8:return r=e.sent,e.abrupt("return",r.sessionMessage.onlineSessionPeerIds);case 10:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.getConversation=function(){var t=b(ke.mark(function e(t){var n,r,i=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=1<i.length&&void 0!==i[1]&&i[1],"string"!=typeof t)throw new TypeError("".concat(t," is not a String"));e.next=3;break;case 3:if(n){e.next=7;break}if(r=this._conversationCache.get(t))return e.abrupt("return",r);e.next=7;break;case 7:if(Cu(t))return e.next=10,this._getTemporaryConversations([t]);e.next=14;break;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(e){return t.apply(this,arguments)}}(),t.getConversations=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a=this,u=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=1<u.length&&void 0!==u[1]&&u[1],(r=n?t:t.filter(function(e){return null===a._conversationCache.get(e)})).length)return i=Xo(r,Cu),o=[],r.length&&o.push(this.getQuery().containedIn("objectId",r).limit(999).find()),i.length&&(s=i.map(this._getTemporaryConversations.bind(this)),o.push.apply(o,v(s))),e.next=9,Promise.all(o);e.next=9;break;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(e){return t.apply(this,arguments)}}(),t._getTemporaryConversations=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=new ge({cmd:"conv",op:"query",convMessage:new ae({tempConvIds:t})}),e.next=3,this._send(n);case 3:return r=e.sent,e.abrupt("return",this._handleQueryResults(r));case 5:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.getQuery=function(){return new cu(this)},t.getChatRoomQuery=function(){return this.getQuery().equalTo("tr",!0)},t.getServiceConversationQuery=function(){return this.getQuery().equalTo("sys",!0)},t._executeQuery=function(){var t=b(ke.mark(function e(t){var n,r,i;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.toJSON()).where=new K({data:JSON.stringify(Mn(n.where))}),r=new ge({cmd:"conv",op:"query",convMessage:new ae(n)}),e.next=5,this._send(r);case 5:return i=e.sent,e.abrupt("return",this._handleQueryResults(i));case 7:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._handleQueryResults=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,n=xn(JSON.parse(t.convMessage.results.data)),e.next=8;break;case 4:throw e.prev=4,e.t0=e.catch(0),r=JSON.stringify(Un(t)),new Error("Parse query result failed: ".concat(e.t0.message,". Command: ").concat(r));case 8:return e.next=10,Promise.all(n.map(this._parseConversationFromRawData.bind(this)));case 10:return n=e.sent,e.abrupt("return",n.map(this._upsertConversationToCache.bind(this)));case 12:case"end":return e.stop()}},e,this,[[0,4]])}));return function(e){return t.apply(this,arguments)}}(),t._upsertConversationToCache=function(n){var r=this._conversationCache.get(n.id);return r?(this._debug("update cached conversation"),["creator","createdAt","updatedAt","lastMessageAt","lastMessage","mutedMembers","members","_attributes","transient","muted"].forEach(function(e){var t=n[e];void 0!==t&&(r[e]=t)}),r._reset&&r._reset()):(r=n,this._debug("no match, set cache"),this._conversationCache.set(n.id,n)),r},t.parseMessage=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.data,r=t.bin,i=void 0!==r&&r,o=S(t,["data","bin"]),s=i?Tr(n):n,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(e){return t.apply(this,arguments)}}(),t.parseConversation=function(){var t=b(ke.mark(function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.id,r=t.lastMessageAt,i=t.lastMessage,o=t.lastDeliveredAt,s=t.lastReadAt,a=t.unreadMessagesCount,u=t.members,c=t.mentioned,f=S(t,["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"]),l={id:n,lastMessageAt:r,lastMessage:i,lastDeliveredAt:o,lastReadAt:s,unreadMessagesCount:a,members:u,mentioned:c},i)return e.next=5,this.parseMessage(i);e.next=7;break;case 5:l.lastMessage=e.sent,l.lastMessage._setStatus(Ca.SENT);case 7:if(h=f.transient,p=f.system,d=f.expiredAt,h)return e.abrupt("return",new iu(l,f,this));e.next=10;break;case 10:if(p)return e.abrupt("return",new ou(l,f,this));e.next=12;break;case 12:if(d||Cu(n))return e.abrupt("return",new au(l,{expiredAt:d},this));e.next=14;break;case 14:return e.abrupt("return",new ru(l,f,this));case 15:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._parseConversationFromRawData=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return(n=kn({objectId:"id",lm:"lastMessageAt",m:"members",tr:"transient",sys:"system",c:"creator",mu:"mutedMembers"},t)).msg&&(n.lastMessage={data:n.msg,bin:n.bin,from:n.msg_from,id:n.msg_mid,timestamp:n.msg_timestamp,updatedAt:n.patch_timestamp},delete n.lastMessageFrom,delete n.lastMessageId,delete n.lastMessageTimestamp,delete n.lastMessagePatchTimestamp),(r=n.ttl)&&(n.expiredAt=Date.now()+1e3*r),e.abrupt("return",this.parseConversation(n));case 5:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.createConversation=function(){var e=b(ke.mark(function e(){var t,n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,E=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=0<E.length&&void 0!==E[0]?E[0]:{},n=t.members,r=t.name,i=t.transient,o=t.unique,s=void 0===o||o,a=t._tempConv,u=t._tempConvTTL,c=S(t,["members","name","transient","unique","_tempConv","_tempConvTTL"]),i||Array.isArray(n)){e.next=3;break}throw new TypeError("conversation members ".concat(n," is not an array"));case 3:if((f=new Set(n)).add(this.id),f=Array.from(f).sort(),l=c||{},!r){e.next=11;break}if("string"!=typeof r)throw new TypeError("conversation name ".concat(r," is not a string"));e.next=10;break;case 10:l.name=r;case 11:if(l=new K({data:JSON.stringify(Mn(l))}),h=new ge({cmd:"conv",op:"start",convMessage:new ae({m:f,attr:l,transient:i,unique:s,tempConv:a,tempConvTTL:u})}),this.options.conversationSignatureFactory)return p=[null,this._identity,f,"create"],e.next=18,Ga(this.options.conversationSignatureFactory,p);e.next=20;break;case 18:d=e.sent,Object.assign(h.convMessage,kn({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,b=g.tempConvTTL,w=T({name:r,transient:i,unique:s,id:y,createdAt:v,updatedAt:v,lastMessageAt:null,creator:this.id,members:i?[]:f},c),b&&(w.expiredAt=Date.now()+1e3*b),e.next=31,this.parseConversation(w);case 31:return _=e.sent,e.abrupt("return",this._upsertConversationToCache(_));case 33:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),t.createChatRoom=function(){var t=b(ke.mark(function e(t){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.createConversation(T({},t,{transient:!0,members:null,unique:!1,_tempConv:!1})));case 1:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t.createTemporaryConversation=function(){var t=b(ke.mark(function e(t){var n,r;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ttl,r=S(t,["ttl"]),e.abrupt("return",this.createConversation(T({},r,{transient:!1,unique:!1,_tempConv:!0,_tempConvTTL:n})));case 2:case"end":return e.stop()}},e,this)}));return function(e){return t.apply(this,arguments)}}(),t._doSendRead=function(){var t=this;if(this._connection.is("connected")){var n=Dn(this).readConversationsBuffer,r=Array.from(n);if(r.length){var e=r.map(function(e){if(!(e instanceof qa))throw new TypeError("".concat(e," is not a Conversation"));return e.id});this._debug("mark [".concat(e,"] as read")),n.clear(),this._sendReadCommand(r).catch(function(e){t._debug("send read failed: %O",e),r.forEach(n.add.bind(n))})}}},t._sendReadCommand=function(e){var t=this;return this._send(new ge({cmd:"read",readMessage:new pe({convs:e.map(function(e){return new le({cid:e.id,mid:e.lastMessage&&e.lastMessage.from!==t.id?e.lastMessage.id:void 0,timestamp:(e.lastMessageAt||new Date).getTime()})})})}),!1)},e}(Ae)).prototype,"_doSendAck",[Za],Object.getOwnPropertyDescriptor(Ka.prototype,"_doSendAck"),Ka.prototype),t(Ka.prototype,"_doSendRead",[Xa],Object.getOwnPropertyDescriptor(Ka.prototype,"_doSendRead"),Ka.prototype),Ka),Mu="reconnecterror",ku=Object.freeze({RECONNECT_ERROR:Mu,DISCONNECT:Wn,RECONNECT:Gn,RETRY:$n,SCHEDULE:Jn,OFFLINE:Hn,ONLINE:Zn}),Ru=La(Qa=function(t){function e(e){if(!(e instanceof ArrayBuffer))throw new TypeError("".concat(e," is not an ArrayBuffer"));return t.call(this,e)||this}f(e,t),e.validate=function(e){return e instanceof ArrayBuffer};var n=e.prototype;return n.toJSON=function(){return T({},t.prototype._toJSON.call(this),{data:Er(this.content)})},n.toFullJSON=function(){return T({},t.prototype.toFullJSON.call(this),{bin:!0,data:Er(this.content)})},o(e,[{key:"buffer",get:function(){return this.content},set:function(e){this.content=e}}]),e}(Ra))||Qa,Pu=Pa(-1)(eu=La(eu=function(n){function e(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";if("string"!=typeof t)throw new TypeError("".concat(t," is not a string"));return(e=n.call(this)||this).setText(t),e}return f(e,n),e}(ja))||eu)||eu,Nu=De("LC:MessageParser"),Lu=(t((tu=function(){function e(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this._plugins=e,this._messageClasses=[]}var t=e.prototype;return 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){Nu("parsing message: %O",e);var t=!0,n=!1,r=void 0;try{for(var i,o=this._messageClasses[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value,a=gn(e)?Object.assign({},e):e,u=void 0,c=void 0;try{u=s.validate(a)}catch(e){}if(u){try{c=s.parse(a)}catch(e){console.warn("parsing a valid message content error",{error:e,Klass:s,content:a})}if(void 0!==c)return Nu("parse result: %O",c),c}}}catch(e){n=!0,r=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw r}}throw new Error("No Message Class matched")},e}()).prototype,"parse",[function(e,t,n){var r=n.value;n.value=function(t){var n;if("string"!=typeof t)n=t;else try{n=JSON.parse(t)}catch(e){n=t}return r.call(this,n)}},function(e,t,n){var r=n.value;n.value=function(e){var t=this;return Promise.resolve(e).then(ur(this._plugins.beforeMessageParse)).then(function(e){return r.call(t,e)}).then(ur(this._plugins.afterMessageParse))}}],Object.getOwnPropertyDescriptor(tu.prototype,"parse"),tu.prototype),tu),ju=De("LC:IMPlugin"),Du={HIGH:1,NORMAL:2,LOW:3};Object.freeze(Du);var Fu=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{get:function(){return this.get(t)},set:function(e){this.set(t,e)}};Object.defineProperty(ru.prototype,t,e)},Uu={name:"leancloud-realtime-plugin-im",onRealtimeCreate:function(p){var d=wr();p._IMClients={},p._IMClientsCreationCount=0;var m=new Lu(p._plugins);p._messageParser=m;var g=(t=b(ke.mark(function e(t){return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",p._request({method:"POST",path:"/rtm/sign",data:{session_token:t.getSessionToken()}}));case 1:case"end":return e.stop()}},e,this)})),function(e){return t.apply(this,arguments)}),e=function(e){return Bn(e).map(m.register.bind(m))};var t;e(Bn(p._plugins.messageClasses));var n=(r=b(ke.mark(function e(n){var t,r,i,o,s,a,u,c,f,l,h=arguments;return ke.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=1<h.length&&void 0!==h[1]?h[1]:{},i=r.tag,o=r.isReconnect,s=S(r,["tag","isReconnect"]),a=2<h.length?h[2]:void 0,c={},!n){e.next=19;break}if("string"!=typeof n){e.next=8;break}u=n,e.next=17;break;case 8:if(!n.id||!n.getSessionToken){e.next=16;break}if(u=n.id,n.getSessionToken()){e.next=13;break}throw new Error("User must be authenticated");case 13:c.signatureFactory=g,e.next=17;break;case 16:throw new TypeError("Identity must be a String or an AV.User");case 17:if(void 0!==p._IMClients[u])return e.abrupt("return",p._IMClients[u]);e.next=19;break;case 19:return a&&console.warn("DEPRECATION createIMClient tag param: Use options.tag instead."),f=i||a,l=(t=p._open().then(function(e){var t=new xu(u,T({},c,s),{_connection:e,_request:p._request.bind(p),_messageParser:m,_plugins:p._plugins,_identity:n});return e.on(Gn,function(){return t._open(p._options.appId,f,d,!0).then(function(){return t.emit(Gn)},function(e){return t.emit(Mu,e)})}),Dn(t)._eventemitter.on("beforeclose",function(){delete p._IMClients[t.id],p._firstIMClient===t&&delete p._firstIMClient},p),Dn(t)._eventemitter.on("close",function(){p._deregister(t)},p),t._open(p._options.appId,f,d,o).then(function(){return p._IMClients[t.id]=t,p._IMClientsCreationCount+=1,1===p._IMClientsCreationCount?(t._omitPeerId(!0),p._firstIMClient=t):1<p._IMClientsCreationCount&&p._firstIMClient&&p._firstIMClient._omitPeerId(!1),p._register(t),t}).catch(function(e){throw delete p._IMClients[t.id],e})})).then.apply(t,v(In(function(){p._deregisterPending(l)}))),n&&(p._IMClients[u]=l),p._registerPending(l),e.abrupt("return",l);case 25:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)});var r;Object.assign(p,{register:e,createIMClient:n})},beforeCommandDispatch:function(t,e){if(null!==t.service&&2!==t.service)return!0;var n=t.peerId?e._IMClients[t.peerId]:e._firstIMClient;return n?Promise.resolve(n).then(function(e){return e._dispatchCommand(t)}).catch(ju):ju("[WARN] Unexpected message received without any live client match: %O",Un(t)),!1},messageClasses:[Ra,Ru,Da,Pu]};dr.defineConversationProperty=Fu,dr.__preRegisteredPlugins=[Uu];var Bu=T({},ku,Oa);e.Event=Bu,e.ErrorCode=nr,e.Protocals=Se,e.Promise=mr,e.EventEmitter=Ae,e.Realtime=dr,e.debug=Sn,e.Message=Ra,e.BinaryMessage=Ru,e.TypedMessage=ja,e.TextMessage=Pu,e.RecalledMessage=Da,e.MessagePriority=Du,e.MessageStatus=Ca,e.MessageQueryDirection=Ya,e.defineConversationProperty=Fu,e.IMPlugin=Uu,e.messageType=Pa,e.messageField=Na,e.IE10Compatible=La,e.ConversationMemberRole=Ha,e.Conversation=ru,e.ChatRoom=iu,e.ServiceConversation=ou,e.TemporaryConversation=au,Object.defineProperty(e,"__esModule",{value:!0})});
2//# sourceMappingURL=realtime-weapp.min.js.map