!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("leancloud-realtime",["exports"],t):t((e=e||self).AV=e.AV||{})}(this,(function(e){"use strict";var t="undefined"!=typeof window&&window.process||{};t.env=t.env||{};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return o(null==t&&r.path)}},r.exports),r.exports}function o(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var s=i((function(e){function t(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=t=function(e){return typeof e}:e.exports=t=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(r)}e.exports=t})),a=i((function(e){function t(e){if(e)return function(e){for(var r in t.prototype)e[r]=t.prototype[r];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;it?1:0}function p(e,t,r){var n,i=function e(t,r,n,i){var o;if("object"==typeof t&&null!==t){for(o=0;o0)for(var n=0;n=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!==t.status)return!0;if(e){if(e.code&&w.includes(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},b.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},b.prototype.then=function(e,t){var r=this;if(!this._fullfilledPromise){var n=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(e,t){n.on("abort",(function(){if(r.timedout&&r.timedoutError)t(r.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=r.status,e.method=r.method,e.url=r.url,t(e)}})),n.end((function(r,n){r?t(r):e(n)}))}))}return this._fullfilledPromise.then(e,t)},b.prototype.catch=function(e){return this.then(void 0,e)},b.prototype.use=function(e){return e(this),this},b.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},b.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},b.prototype.get=function(e){return this._header[e.toLowerCase()]},b.prototype.getHeader=b.prototype.get,b.prototype.set=function(e,t){if(y(e)){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},b.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},b.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(y(e)){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.field(r,e[r]);return this}if(Array.isArray(t)){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.field(e,t[n]);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},b.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},b.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic ".concat(n("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},b.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},b.prototype.redirects=function(e){return this._maxRedirects=e,this},b.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},b.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},b.prototype.send=function(e){var t=y(e),r=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&&y(this._data))for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(this._data[n]=e[n]);else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"===r?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||r||this.type("json"),this},b.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},b.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.slice(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.slice(0,t)+"?"+r.join("&")}}},b.prototype._appendQueryString=function(){console.warn("Unsupported")},b.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error("".concat(e+t,"ms exceeded"));n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.timedoutError=n,this.abort(),this.callback(n)}},b.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 _=function(e){return e.split(/ *; */).shift()},E=function(e){return e.split(/ *; */).reduce((function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e}),{})},T=function(e){return e.split(/ *, */).reduce((function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e}),{})},O=S;function S(e){if(e)return function(e){for(var t in S.prototype)Object.prototype.hasOwnProperty.call(S.prototype,t)&&(e[t]=S.prototype[t]);return e}(e)}function A(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t0||e instanceof Object)?t(e):null)},d.prototype.toError=function(){var e=this.req,t=e.method,r=e.url,n="cannot ".concat(t," ").concat(r," (").concat(this.status,")"),i=new Error(n);return i.status=this.status,i.method=t,i.url=r,i},o.Response=d,a(m.prototype),v(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",o.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",o.types[e]||e),this},m.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"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=f(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,r){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var r=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),r(e,t)},m.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)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===r(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.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()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=o.getXHR();var t=this.xhr,r=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var r=t.readyState;if(r>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100,100===r.percent&&clearTimeout(e._uploadTimeoutTimer)),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.addEventListener("progress",n.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",n.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],s=this._serializer||o.serialize[i?i.split(";")[0]:""];!s&&p(i)&&(s=o.serialize["application/json"]),s&&(r=s(r))}for(var a in this.header)null!==this.header[a]&&Object.prototype.hasOwnProperty.call(this.header,a)&&t.setRequestHeader(a,this.header[a]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===r?null:r)},o.agent=function(){return new C},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){C.prototype[e.toLowerCase()]=function(t,r){var n=new o.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}})),C.prototype.del=C.prototype.delete,o.get=function(e,t,r){var n=o("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},o.head=function(e,t,r){var n=o("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},o.options=function(e,t,r){var n=o("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},o.del=g,o.delete=g,o.patch=function(e,t,r){var n=o("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},o.post=function(e,t,r){var n=o("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},o.put=function(e,t,r){var n=o("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}})),k=(x.Request,i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.request=function(e,t){void 0===t&&(t={});var r=t.method,n=void 0===r?"GET":r,i=t.data,o=t.headers,s=t.onprogress,a=x(n,e);return o&&a.set(o),s&&a.on("progress",s),a.send(i).catch((function(e){if(e.response)return e.response;throw e})).then((function(e){return{status:e.status,ok:e.ok,headers:e.header,data:e.body}}))},t.upload=function(e,t,r){void 0===r&&(r={});var n=r.data,i=r.headers,o=r.onprogress,s=x("POST",e).attach(t.field,t.data,t.name);return n&&s.field(n),i&&s.set(i),o&&s.on("progress",o),s.catch((function(e){if(e.response)return e.response;throw e})).then((function(e){return{status:e.status,ok:e.ok,headers:e.header,data:e.body}}))}})));n(k);k.request,k.upload;var P=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.request=k.request,t.upload=k.upload,t.storage=window.localStorage,t.WebSocket=window.WebSocket,t.platformInfo={name:"Browser"}}));n(P);var M=P.request,j=(P.upload,P.storage,P.WebSocket);P.platformInfo;var R,N=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},L=i((function(e){ /** * @license long.js (c) 2013 Daniel Wirtz * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/long.js for details */ !function(t,r){e&&e.exports?e.exports=r():(t.dcodeIO=t.dcodeIO||{}).Long=r()}(r,(function(){function e(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function t(e){return!0===(e&&e.__isLong__)}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=t;var r={},n={};function i(e,t){var i,o,a;return t?(a=0<=(e>>>=0)&&e<256)&&(o=n[e])?o:(i=s(e,(0|e)<0?-1:0,!0),a&&(n[e]=i),i):(a=-128<=(e|=0)&&e<128)&&(o=r[e])?o:(i=s(e,e<0?-1:0,!1),a&&(r[e]=i),i)}function o(e,t){if(isNaN(e)||!isFinite(e))return t?m:d;if(t){if(e<0)return m;if(e>=l)return w}else{if(e<=-h)return _;if(e+1>=h)return b}return e<0?o(-e,t).neg():s(e%f|0,e/f|0,t)}function s(t,r,n){return new e(t,r,n)}e.fromInt=i,e.fromNumber=o,e.fromBits=s;var a=Math.pow;function u(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return d;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||360)throw Error("interior hyphen");if(0===n)return u(e.substring(1),t,r).neg();for(var i=o(a(r,8)),s=d,c=0;c>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)},E.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=c).isZero())return f+u;for(;f.length<6;)f="0"+f;u=""+f+u}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},E.isOdd=function(){return 1==(1&this.low)},E.isEven=function(){return 0==(1&this.low)},E.equals=function(e){return t(e)||(e=c(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},E.eq=E.equals,E.notEquals=function(e){return!this.eq(e)},E.neq=E.notEquals,E.lessThan=function(e){return this.comp(e)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(e){return this.comp(e)<=0},E.lte=E.lessThanOrEqual,E.greaterThan=function(e){return this.comp(e)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(e){return this.comp(e)>=0},E.gte=E.greaterThanOrEqual,E.compare=function(e){if(t(e)||(e=c(e)),this.eq(e))return 0;var r=this.isNegative(),n=e.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(y)},E.neg=E.negate,E.add=function(e){t(e)||(e=c(e));var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,a=e.high>>>16,u=65535&e.high,f=e.low>>>16,l=0,h=0,p=0,d=0;return p+=(d+=o+(65535&e.low))>>>16,h+=(p+=i+f)>>>16,l+=(h+=n+u)>>>16,l+=r+a,s((p&=65535)<<16|(d&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},E.subtract=function(e){return t(e)||(e=c(e)),this.add(e.neg())},E.sub=E.subtract,E.multiply=function(e){if(this.isZero())return d;if(t(e)||(e=c(e)),e.isZero())return d;if(this.eq(_))return e.isOdd()?_:d;if(e.eq(_))return this.isOdd()?_:d;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(p)&&e.lt(p))return o(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,a=65535&this.low,u=e.high>>>16,f=65535&e.high,l=e.low>>>16,h=65535&e.low,m=0,y=0,g=0,v=0;return g+=(v+=a*h)>>>16,y+=(g+=i*h)>>>16,g&=65535,y+=(g+=a*l)>>>16,m+=(y+=n*h)>>>16,y&=65535,m+=(y+=i*l)>>>16,y&=65535,m+=(y+=a*f)>>>16,m+=r*h+n*l+i*f+a*u,s((g&=65535)<<16|(v&=65535),(m&=65535)<<16|(y&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(e){if(t(e)||(e=c(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:d;var r,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return m;if(e.gt(this.shru(1)))return g;i=m}else{if(this.eq(_))return e.eq(y)||e.eq(v)?_:e.eq(_)?y:(r=this.shr(1).div(e).shl(1)).eq(d)?e.isNegative()?y:v:(n=this.sub(e.mul(r)),i=r.add(n.div(e)));if(e.eq(_))return this.unsigned?m:d;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=d}for(n=this;n.gte(e);){r=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:a(2,s-48),f=o(r),l=f.mul(e);l.isNegative()||l.gt(n);)l=(f=o(r-=u,this.unsigned)).mul(e);f.isZero()&&(f=y),i=i.add(f),n=n.sub(l)}return i},E.div=E.divide,E.modulo=function(e){return t(e)||(e=c(e)),this.sub(this.div(e).mul(e))},E.mod=E.modulo,E.not=function(){return s(~this.low,~this.high,this.unsigned)},E.and=function(e){return t(e)||(e=c(e)),s(this.low&e.low,this.high&e.high,this.unsigned)},E.or=function(e){return t(e)||(e=c(e)),s(this.low|e.low,this.high|e.high,this.unsigned)},E.xor=function(e){return t(e)||(e=c(e)),s(this.low^e.low,this.high^e.high,this.unsigned)},E.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low<>>32-e,this.unsigned):s(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):s(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var r=this.high;return e<32?s(this.low>>>e|r<<32-e,r>>>e,this.unsigned):s(32===e?r:r>>>e-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},E.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},E.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e}))})),D=i((function(e){ /** * @license bytebuffer.js (c) 2015 Daniel Wirtz * Backing buffer: ArrayBuffer, Accessor: Uint8Array * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/bytebuffer.js for details */ !function(t,r){e&&e.exports?e.exports=function(){var e;try{e=L}catch(e){}return r(e)}():(t.dcodeIO=t.dcodeIO||{}).ByteBuffer=r(t.dcodeIO.Long)}(r,(function(e){var t=function(e,r,i){if(void 0===e&&(e=t.DEFAULT_CAPACITY),void 0===r&&(r=t.DEFAULT_ENDIAN),void 0===i&&(i=t.DEFAULT_NOASSERT),!i){if((e|=0)<0)throw RangeError("Illegal capacity");r=!!r,i=!!i}this.buffer=0===e?n:new ArrayBuffer(e),this.view=0===e?null:new Uint8Array(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=r,this.noAssert=i};t.VERSION="5.0.1",t.LITTLE_ENDIAN=!0,t.BIG_ENDIAN=!1,t.DEFAULT_CAPACITY=16,t.DEFAULT_ENDIAN=t.BIG_ENDIAN,t.DEFAULT_NOASSERT=!1,t.Long=e||null;var r=t.prototype;r.__isByteBuffer__,Object.defineProperty(r,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var n=new ArrayBuffer(0),i=String.fromCharCode;function o(e){var t=0;return function(){return t1024&&(t.push(i.apply(String,e)),e.length=0),Array.prototype.push.apply(e,arguments)}}function a(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)}function u(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*m}t.accessor=function(){return Uint8Array},t.allocate=function(e,r,n){return new t(e,r,n)},t.concat=function(e,r,n,i){"boolean"!=typeof r&&"string"==typeof r||(i=n,n=r,r=void 0);for(var o,s=0,a=0,u=e.length;a0&&(s+=o);if(0===s)return new t(0,n,i);var c,f=new t(s,n,i);for(a=0;a0&&(s.buffer=e.buffer,s.offset=e.byteOffset,s.limit=e.byteOffset+e.byteLength,s.view=new Uint8Array(e.buffer));else if(e instanceof ArrayBuffer)s=new t(0,i,o),e.byteLength>0&&(s.buffer=e,s.offset=0,s.limit=e.byteLength,s.view=e.byteLength>0?new Uint8Array(e):null);else{if("[object Array]"!==Object.prototype.toString.call(e))throw TypeError("Illegal buffer");(s=new t(e.length,i,o)).limit=e.length;for(var a=0;a>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n,i=t,o=e.length,s=o>>3,a=0;for(t+=this.writeVarint32(o,t);s--;)n=1&!!e[a++]|(1&!!e[a++])<<1|(1&!!e[a++])<<2|(1&!!e[a++])<<3|(1&!!e[a++])<<4|(1&!!e[a++])<<5|(1&!!e[a++])<<6|(1&!!e[a++])<<7,this.writeByte(n,t++);if(a>3,s=0,a=[];for(e+=n.length;o--;)r=this.readByte(e++),a[s++]=!!(1&r),a[s++]=!!(2&r),a[s++]=!!(4&r),a[s++]=!!(8&r),a[s++]=!!(16&r),a[s++]=!!(32&r),a[s++]=!!(64&r),a[s++]=!!(128&r);if(s>u++&1)}return t&&(this.offset=e),a},r.readBytes=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+"+e+") <= "+this.buffer.byteLength)}var n=this.slice(t,t+e);return r&&(this.offset+=e),n},r.writeBytes=r.append,r.writeInt8=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeByte=r.writeInt8,r.readInt8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=this.view[e];return 128==(128&r)&&(r=-(255-r+1)),t&&(this.offset+=1),r},r.readByte=r.readInt8,r.writeUint8=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=1;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=1,this.view[t]=e,r&&(this.offset+=1),this},r.writeUInt8=r.writeUint8,r.readUint8=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r=this.view[e];return t&&(this.offset+=1),r},r.readUInt8=r.readUint8,r.writeInt16=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},r.writeShort=r.writeInt16,r.readInt16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),32768==(32768&r)&&(r=-(65535-r+1)),t&&(this.offset+=2),r},r.readShort=r.readInt16,r.writeUint16=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=2;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=2,this.littleEndian?(this.view[t+1]=(65280&e)>>>8,this.view[t]=255&e):(this.view[t]=(65280&e)>>>8,this.view[t+1]=255&e),r&&(this.offset+=2),this},r.writeUInt16=r.writeUint16,r.readUint16=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+2) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e],r|=this.view[e+1]<<8):(r=this.view[e]<<8,r|=this.view[e+1]),t&&(this.offset+=2),r},r.readUInt16=r.readUint16,r.writeInt32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),r&&(this.offset+=4),this},r.writeInt=r.writeInt32,r.readInt32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),r|=0,t&&(this.offset+=4),r},r.readInt=r.readInt32,r.writeUint32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,this.littleEndian?(this.view[t+3]=e>>>24&255,this.view[t+2]=e>>>16&255,this.view[t+1]=e>>>8&255,this.view[t]=255&e):(this.view[t]=e>>>24&255,this.view[t+1]=e>>>16&255,this.view[t+2]=e>>>8&255,this.view[t+3]=255&e),r&&(this.offset+=4),this},r.writeUInt32=r.writeUint32,r.readUint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=0;return this.littleEndian?(r=this.view[e+2]<<16,r|=this.view[e+1]<<8,r|=this.view[e],r+=this.view[e+3]<<24>>>0):(r=this.view[e+1]<<16,r|=this.view[e+2]<<8,r|=this.view[e+3],r+=this.view[e]<<24>>>0),t&&(this.offset+=4),r},r.readUInt32=r.readUint32,e&&(r.writeInt64=function(t,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var i=this.buffer.byteLength;r>i&&this.resize((i*=2)>r?i:r),r-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o,r+=4,this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s):(this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s,r+=4,this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o),n&&(this.offset+=8),this},r.writeLong=r.writeInt64,r.readInt64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var n=0,i=0;this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0);var o=new e(n,i,!1);return r&&(this.offset+=8),o},r.readLong=r.readInt64,r.writeUint64=function(t,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"==typeof t)t=e.fromNumber(t);else if("string"==typeof t)t=e.fromString(t);else if(!(t&&t instanceof e))throw TypeError("Illegal value: "+t+" (not an integer or Long)");if("number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t)),r+=8;var i=this.buffer.byteLength;r>i&&this.resize((i*=2)>r?i:r),r-=8;var o=t.low,s=t.high;return this.littleEndian?(this.view[r+3]=o>>>24&255,this.view[r+2]=o>>>16&255,this.view[r+1]=o>>>8&255,this.view[r]=255&o,r+=4,this.view[r+3]=s>>>24&255,this.view[r+2]=s>>>16&255,this.view[r+1]=s>>>8&255,this.view[r]=255&s):(this.view[r]=s>>>24&255,this.view[r+1]=s>>>16&255,this.view[r+2]=s>>>8&255,this.view[r+3]=255&s,r+=4,this.view[r]=o>>>24&255,this.view[r+1]=o>>>16&255,this.view[r+2]=o>>>8&255,this.view[r+3]=255&o),n&&(this.offset+=8),this},r.writeUInt64=r.writeUint64,r.readUint64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+8) <= "+this.buffer.byteLength)}var n=0,i=0;this.littleEndian?(n=this.view[t+2]<<16,n|=this.view[t+1]<<8,n|=this.view[t],n+=this.view[t+3]<<24>>>0,t+=4,i=this.view[t+2]<<16,i|=this.view[t+1]<<8,i|=this.view[t],i+=this.view[t+3]<<24>>>0):(i=this.view[t+1]<<16,i|=this.view[t+2]<<8,i|=this.view[t+3],i+=this.view[t]<<24>>>0,t+=4,n=this.view[t+1]<<16,n|=this.view[t+2]<<8,n|=this.view[t+3],n+=this.view[t]<<24>>>0);var o=new e(n,i,!0);return r&&(this.offset+=8),o},r.readUInt64=r.readUint64),r.writeFloat32=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=4;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=4,u(this.view,e,t,this.littleEndian,23,4),r&&(this.offset+=4),this},r.writeFloat=r.writeFloat32,r.readFloat32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var r=a(this.view,e,this.littleEndian,23,4);return t&&(this.offset+=4),r},r.readFloat=r.readFloat32,r.writeFloat64=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof e)throw TypeError("Illegal value: "+e+" (not a number)");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}t+=8;var n=this.buffer.byteLength;return t>n&&this.resize((n*=2)>t?n:t),t-=8,u(this.view,e,t,this.littleEndian,52,8),r&&(this.offset+=8),this},r.writeDouble=r.writeFloat64,r.readFloat64=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+8) <= "+this.buffer.byteLength)}var r=a(this.view,e,this.littleEndian,52,8);return t&&(this.offset+=8),r},r.readDouble=r.readFloat64,t.MAX_VARINT32_BYTES=5,t.calculateVarint32=function(e){return(e>>>=0)<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5},t.zigZagEncode32=function(e){return((e|=0)<<1^e>>31)>>>0},t.zigZagDecode32=function(e){return e>>>1^-(1&e)|0},r.writeVarint32=function(e,r){var n=void 0===r;if(n&&(r=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal offset: "+r+" (not an integer)");if((r>>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var i,o=t.calculateVarint32(e);r+=o;var s=this.buffer.byteLength;for(r>s&&this.resize((s*=2)>r?s:r),r-=o,e>>>=0;e>=128;)i=127&e|128,this.view[r++]=i,e>>>=7;return this.view[r++]=e,n?(this.offset=r,this):o},r.writeVarint32ZigZag=function(e,r){return this.writeVarint32(t.zigZagEncode32(e),r)},r.readVarint32=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r,n=0,i=0;do{if(!this.noAssert&&e>this.limit){var o=Error("Truncated");throw o.truncated=!0,o}r=this.view[e++],n<5&&(i|=(127&r)<<7*n),++n}while(0!=(128&r));return i|=0,t?(this.offset=e,i):{value:i,length:n}},r.readVarint32ZigZag=function(e){var r=this.readVarint32(e);return"object"==typeof r?r.value=t.zigZagDecode32(r.value):r=t.zigZagDecode32(r),r},e&&(t.MAX_VARINT64_BYTES=10,t.calculateVarint64=function(t){"number"==typeof t?t=e.fromNumber(t):"string"==typeof t&&(t=e.fromString(t));var r=t.toInt()>>>0,n=t.shiftRightUnsigned(28).toInt()>>>0,i=t.shiftRightUnsigned(56).toInt()>>>0;return 0==i?0==n?r<16384?r<128?1:2:r<1<<21?3:4:n<16384?n<128?5:6:n<1<<21?7:8:i<128?9:10},t.zigZagEncode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftLeft(1).xor(t.shiftRight(63)).toUnsigned()},t.zigZagDecode64=function(t){return"number"==typeof t?t=e.fromNumber(t,!1):"string"==typeof t?t=e.fromString(t,!1):!1!==t.unsigned&&(t=t.toSigned()),t.shiftRightUnsigned(1).xor(t.and(e.ONE).toSigned().negate()).toSigned()},r.writeVarint64=function(r,n){var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"==typeof r)r=e.fromNumber(r);else if("string"==typeof r)r=e.fromString(r);else if(!(r&&r instanceof e))throw TypeError("Illegal value: "+r+" (not an integer or Long)");if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}"number"==typeof r?r=e.fromNumber(r,!1):"string"==typeof r?r=e.fromString(r,!1):!1!==r.unsigned&&(r=r.toSigned());var o=t.calculateVarint64(r),s=r.toInt()>>>0,a=r.shiftRightUnsigned(28).toInt()>>>0,u=r.shiftRightUnsigned(56).toInt()>>>0;n+=o;var c=this.buffer.byteLength;switch(n>c&&this.resize((c*=2)>n?c:n),n-=o,o){case 10:this.view[n+9]=u>>>7&1;case 9:this.view[n+8]=9!==o?128|u:127&u;case 8:this.view[n+7]=8!==o?a>>>21|128:a>>>21&127;case 7:this.view[n+6]=7!==o?a>>>14|128:a>>>14&127;case 6:this.view[n+5]=6!==o?a>>>7|128:a>>>7&127;case 5:this.view[n+4]=5!==o?128|a:127&a;case 4:this.view[n+3]=4!==o?s>>>21|128:s>>>21&127;case 3:this.view[n+2]=3!==o?s>>>14|128:s>>>14&127;case 2:this.view[n+1]=2!==o?s>>>7|128:s>>>7&127;case 1:this.view[n]=1!==o?128|s:127&s}return i?(this.offset+=o,this):o},r.writeVarint64ZigZag=function(e,r){return this.writeVarint64(t.zigZagEncode64(e),r)},r.readVarint64=function(t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+1) <= "+this.buffer.byteLength)}var n=t,i=0,o=0,s=0,a=0;if(i=127&(a=this.view[t++]),128&a&&(i|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(i|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(i|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(o=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<7,(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<14,(128&a||this.noAssert&&void 0===a)&&(o|=(127&(a=this.view[t++]))<<21,(128&a||this.noAssert&&void 0===a)&&(s=127&(a=this.view[t++]),(128&a||this.noAssert&&void 0===a)&&(s|=(127&(a=this.view[t++]))<<7,128&a||this.noAssert&&void 0===a))))))))))throw Error("Buffer overrun");var u=e.fromBits(i|o<<28,o>>>4|s<<24,!1);return r?(this.offset=t,u):{value:u,length:t-n}},r.readVarint64ZigZag=function(r){var n=this.readVarint64(r);return n&&n.value instanceof e?n.value=t.zigZagDecode64(n.value):n=t.zigZagDecode64(n),n}),r.writeCString=function(e,t){var r=void 0===t;r&&(t=this.offset);var n,i=e.length;if(!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");for(n=0;n>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}i=f.calculateUTF16asUTF8(o(e))[1],t+=i+1;var s=this.buffer.byteLength;return t>s&&this.resize((s*=2)>t?s:t),t-=i+1,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),this.view[t++]=0,r?(this.offset=t,this):i},r.readCString=function(e){var t=void 0===e;if(t&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var r,n=e,i=-1;return f.decodeUTF8toUTF16(function(){if(0===i)return null;if(e>=this.limit)throw RangeError("Illegal range: Truncated data, "+e+" < "+this.limit);return 0===(i=this.view[e++])?null:i}.bind(this),r=s(),!0),t?(this.offset=e,r()):{string:r(),length:e-n}},r.writeIString=function(e,t){var r=void 0===t;if(r&&(t=this.offset),!this.noAssert){if("string"!=typeof e)throw TypeError("Illegal str: Not a string");if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var n,i=t;n=f.calculateUTF16asUTF8(o(e),this.noAssert)[1],t+=4+n;var s=this.buffer.byteLength;if(t>s&&this.resize((s*=2)>t?s:t),t-=4+n,this.littleEndian?(this.view[t+3]=n>>>24&255,this.view[t+2]=n>>>16&255,this.view[t+1]=n>>>8&255,this.view[t]=255&n):(this.view[t]=n>>>24&255,this.view[t+1]=n>>>16&255,this.view[t+2]=n>>>8&255,this.view[t+3]=255&n),t+=4,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),t!==i+4+n)throw RangeError("Illegal range: Truncated data, "+t+" == "+(t+4+n));return r?(this.offset=t,this):t-i},r.readIString=function(e){var r=void 0===e;if(r&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+4) <= "+this.buffer.byteLength)}var n=e,i=this.readUint32(e),o=this.readUTF8String(i,t.METRICS_BYTES,e+=4);return e+=o.length,r?(this.offset=e,o.string):{string:o.string,length:e-n}},t.METRICS_CHARS="c",t.METRICS_BYTES="b",r.writeUTF8String=function(e,t){var r,n=void 0===t;if(n&&(t=this.offset),!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: "+t+" (not an integer)");if((t>>>=0)<0||t+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+t+" (+0) <= "+this.buffer.byteLength)}var i=t;r=f.calculateUTF16asUTF8(o(e))[1],t+=r;var s=this.buffer.byteLength;return t>s&&this.resize((s*=2)>t?s:t),t-=r,f.encodeUTF16toUTF8(o(e),function(e){this.view[t++]=e}.bind(this)),n?(this.offset=t,this):t-i},r.writeString=r.writeUTF8String,t.calculateUTF8Chars=function(e){return f.calculateUTF16asUTF8(o(e))[0]},t.calculateUTF8Bytes=function(e){return f.calculateUTF16asUTF8(o(e))[1]},t.calculateString=t.calculateUTF8Bytes,r.readUTF8String=function(e,r,n){"number"==typeof r&&(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),void 0===r&&(r=t.METRICS_CHARS),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");if(e|=0,"number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}var o,a=0,u=n;if(r===t.METRICS_CHARS){if(o=s(),f.decodeUTF8(function(){return a>>=0)<0||n+e>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+"+e+") <= "+this.buffer.byteLength)}var c=n+e;if(f.decodeUTF8toUTF16(function(){return n>>=0)<0||r+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+r+" (+0) <= "+this.buffer.byteLength)}var i,s,a=r;i=f.calculateUTF16asUTF8(o(e),this.noAssert)[1],s=t.calculateVarint32(i),r+=s+i;var u=this.buffer.byteLength;if(r>u&&this.resize((u*=2)>r?u:r),r-=s+i,r+=this.writeVarint32(i,r),f.encodeUTF16toUTF8(o(e),function(e){this.view[r++]=e}.bind(this)),r!==a+i+s)throw RangeError("Illegal range: Truncated data, "+r+" == "+(r+i+s));return n?(this.offset=r,this):r-a},r.readVString=function(e){var r=void 0===e;if(r&&(e=this.offset),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal offset: "+e+" (not an integer)");if((e>>>=0)<0||e+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+1) <= "+this.buffer.byteLength)}var n=e,i=this.readVarint32(e),o=this.readUTF8String(i.value,t.METRICS_BYTES,e+=i.length);return e+=o.length,r?(this.offset=e,o.string):{string:o.string,length:e-n}},r.append=function(e,r,n){"number"!=typeof r&&"string"==typeof r||(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,r));var o=e.limit-e.offset;if(o<=0)return this;n+=o;var s=this.buffer.byteLength;return n>s&&this.resize((s*=2)>n?s:n),n-=o,this.view.set(e.view.subarray(e.offset,e.limit),n),e.offset+=o,i&&(this.offset+=o),this},r.appendTo=function(e,t){return e.append(this,t),this},r.assert=function(e){return this.noAssert=!e,this},r.capacity=function(){return this.buffer.byteLength},r.clear=function(){return this.offset=0,this.limit=this.buffer.byteLength,this.markedOffset=-1,this},r.clone=function(e){var r=new t(0,this.littleEndian,this.noAssert);return e?(r.buffer=new ArrayBuffer(this.buffer.byteLength),r.view=new Uint8Array(r.buffer)):(r.buffer=this.buffer,r.view=this.view),r.offset=this.offset,r.markedOffset=this.markedOffset,r.limit=this.limit,r},r.compact=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}if(0===e&&t===this.buffer.byteLength)return this;var r=t-e;if(0===r)return this.buffer=n,this.view=null,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=0,this;var i=new ArrayBuffer(r),o=new Uint8Array(i);return o.set(this.view.subarray(e,t)),this.buffer=i,this.view=o,this.markedOffset>=0&&(this.markedOffset-=e),this.offset=0,this.limit=r,this},r.copy=function(e,r){if(void 0===e&&(e=this.offset),void 0===r&&(r=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,e<0||e>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+r+" <= "+this.buffer.byteLength)}if(e===r)return new t(0,this.littleEndian,this.noAssert);var n=r-e,i=new t(n,this.littleEndian,this.noAssert);return i.offset=0,i.limit=n,i.markedOffset>=0&&(i.markedOffset-=e),this.copyTo(i,0,e,r),i},r.copyTo=function(e,r,n,i){var o,s;if(!this.noAssert&&!t.isByteBuffer(e))throw TypeError("Illegal target: Not a ByteBuffer");if(r=(s=void 0===r)?e.offset:0|r,n=(o=void 0===n)?this.offset:0|n,i=void 0===i?this.limit:0|i,r<0||r>e.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+r+" <= "+e.buffer.byteLength);if(n<0||i>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+n+" <= "+this.buffer.byteLength);var a=i-n;return 0===a?e:(e.ensureCapacity(r+a),e.view.set(this.view.subarray(n,i),r),o&&(this.offset+=a),s&&(e.offset+=a),this)},r.ensureCapacity=function(e){var t=this.buffer.byteLength;return te?t:e):this},r.fill=function(e,t,r){var n=void 0===t;if(n&&(t=this.offset),"string"==typeof e&&e.length>0&&(e=e.charCodeAt(0)),void 0===t&&(t=this.offset),void 0===r&&(r=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal value: "+e+" (not an integer)");if(e|=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal begin: Not an integer");if(t>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal end: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(t>=r)return this;for(;t>>=0)<0||e+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+e+" (+0) <= "+this.buffer.byteLength)}return this.markedOffset=e,this},r.order=function(e){if(!this.noAssert&&"boolean"!=typeof e)throw TypeError("Illegal littleEndian: Not a boolean");return this.littleEndian=!!e,this},r.LE=function(e){return this.littleEndian=void 0===e||!!e,this},r.BE=function(e){return this.littleEndian=void 0!==e&&!e,this},r.prepend=function(e,r,n){"number"!=typeof r&&"string"==typeof r||(n=r,r=void 0);var i=void 0===n;if(i&&(n=this.offset),!this.noAssert){if("number"!=typeof n||n%1!=0)throw TypeError("Illegal offset: "+n+" (not an integer)");if((n>>>=0)<0||n+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+n+" (+0) <= "+this.buffer.byteLength)}e instanceof t||(e=t.wrap(e,r));var o=e.limit-e.offset;if(o<=0)return this;var s=o-n;if(s>0){var a=new ArrayBuffer(this.buffer.byteLength+s),u=new Uint8Array(a);u.set(this.view.subarray(n,this.buffer.byteLength),o),this.buffer=a,this.view=u,this.offset+=s,this.markedOffset>=0&&(this.markedOffset+=s),this.limit+=s,n+=s}else new Uint8Array(this.buffer);return this.view.set(e.view.subarray(e.offset,e.limit),n-o),e.offset=e.limit,i&&(this.offset-=o),this},r.prependTo=function(e,t){return e.prepend(this,t),this},r.printDebug=function(e){"function"!=typeof e&&(e=console.log.bind(console)),e(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))},r.remaining=function(){return this.limit-this.offset},r.reset=function(){return this.markedOffset>=0?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0,this},r.resize=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal capacity: "+e+" (not an integer)");if((e|=0)<0)throw RangeError("Illegal capacity: 0 <= "+e)}if(this.buffer.byteLength>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}return e===t||Array.prototype.reverse.call(this.view.subarray(e,t)),this},r.skip=function(e){if(!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal length: "+e+" (not an integer)");e|=0}var t=this.offset+e;if(!this.noAssert&&(t<0||t>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+e+" <= "+this.buffer.byteLength);return this.offset=t,this},r.slice=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r=this.clone();return r.offset=e,r.limit=t,r},r.toBuffer=function(e){var t=this.offset,r=this.limit;if(!this.noAssert){if("number"!=typeof t||t%1!=0)throw TypeError("Illegal offset: Not an integer");if(t>>>=0,"number"!=typeof r||r%1!=0)throw TypeError("Illegal limit: Not an integer");if(r>>>=0,t<0||t>r||r>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+t+" <= "+r+" <= "+this.buffer.byteLength)}if(!e&&0===t&&r===this.buffer.byteLength)return this.buffer;if(t===r)return n;var i=new ArrayBuffer(r-t);return new Uint8Array(i).set(new Uint8Array(this.buffer).subarray(t,r),0),i},r.toArrayBuffer=r.toBuffer,r.toString=function(e,t,r){if(void 0===e)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";switch("number"==typeof e&&(r=t=e="utf8"),e){case"utf8":return this.toUTF8(t,r);case"base64":return this.toBase64(t,r);case"hex":return this.toHex(t,r);case"binary":return this.toBinary(t,r);case"debug":return this.toDebug();case"columns":return this.toColumns();default:throw Error("Unsupported encoding: "+e)}};var c=function(){for(var e={},t=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],r=[],n=0,i=t.length;n>2&63]),i=(3&n)<<4,null!==(n=e())?(r(t[63&((i|=n>>4&15)|n>>4&15)]),i=(15&n)<<2,null!==(n=e())?(r(t[63&(i|n>>6&3)]),r(t[63&n])):(r(t[63&i]),r(61))):(r(t[63&i]),r(61),r(61))},e.decode=function(e,t){var n,i,o;function s(e){throw Error("Illegal character code: "+e)}for(;null!==(n=e());)if(void 0===(i=r[n])&&s(n),null!==(n=e())&&(void 0===(o=r[n])&&s(n),t(i<<2>>>0|(48&o)>>4),null!==(n=e()))){if(void 0===(i=r[n])){if(61===n)break;s(n)}if(t((15&o)<<4>>>0|(60&i)>>2),null!==(n=e())){if(void 0===(o=r[n])){if(61===n)break;s(n)}t((3&i)<<6>>>0|o)}}},e.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},e}();r.toBase64=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),t|=0,(e|=0)<0||t>this.capacity||e>t)throw RangeError("begin, end");var r;return c.encode(function(){return ethis.capacity()||e>t)throw RangeError("begin, end");if(e===t)return"";for(var r=[],n=[];e=1024&&(n.push(String.fromCharCode.apply(String,r)),r=[]);return n.join("")+String.fromCharCode.apply(String,r)},t.fromBinary=function(e,r){if("string"!=typeof e)throw TypeError("str");for(var n,i=0,o=e.length,s=new t(o,r);i255)throw RangeError("illegal char code: "+n);s.view[i++]=n}return s.limit=o,s},r.toDebug=function(e){for(var t,r=-1,n=this.buffer.byteLength,i="",o="",s="";r32&&t<127?String.fromCharCode(t):".")),++r,e&&r>0&&r%16==0&&r!==n){for(;i.length<51;)i+=" ";s+=i+o+"\n",i=o=""}r===this.offset&&r===this.limit?i+=r===this.markedOffset?"!":"|":r===this.offset?i+=r===this.markedOffset?"[":"<":r===this.limit?i+=r===this.markedOffset?"]":">":i+=r===this.markedOffset?"'":e||0!==r&&r!==n?" ":""}if(e&&" "!==i){for(;i.length<51;)i+=" ";s+=i+o+"\n"}return e?s:i},t.fromDebug=function(e,r,n){for(var i,o,s=e.length,a=new t((s+1)/3|0,r,n),u=0,c=0,f=!1,l=!1,h=!1,p=!1,d=!1;u":if(!n){if(p){d=!0;break}p=!0}a.limit=c,f=!1;break;case"'":if(!n){if(h){d=!0;break}h=!0}a.markedOffset=c,f=!1;break;case" ":f=!1;break;default:if(!n&&f){d=!0;break}if(o=parseInt(i+e.charAt(u++),16),!n&&(isNaN(o)||o<0||o>255))throw TypeError("Illegal str: Not a debug encoded string");a.view[c++]=o,f=!0}if(d)throw TypeError("Illegal str: Invalid symbol at "+u)}if(!n){if(!l||!p)throw TypeError("Illegal str: Missing offset or limit");if(c>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}for(var r,n=new Array(t-e);e255))throw TypeError("Illegal str: Contains non-hex characters");s.view[u++]=i}return s.limit=u,s};var f=function(){var e={MAX_CODEPOINT:1114111,encodeUTF8:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<128?t(127&r):r<2048?(t(r>>6&31|192),t(63&r|128)):r<65536?(t(r>>12&15|224),t(r>>6&63|128),t(63&r|128)):(t(r>>18&7|240),t(r>>12&63|128),t(r>>6&63|128),t(63&r|128)),r=null},decodeUTF8:function(e,t){for(var r,n,i,o,s=function(e){e=e.slice(0,e.indexOf(null));var t=Error(e.toString());throw t.name="TruncatedError",t.bytes=e,t};null!==(r=e());)if(0==(128&r))t(r);else if(192==(224&r))null===(n=e())&&s([r,n]),t((31&r)<<6|63&n);else if(224==(240&r))(null===(n=e())||null===(i=e()))&&s([r,n,i]),t((15&r)<<12|(63&n)<<6|63&i);else{if(240!=(248&r))throw RangeError("Illegal starting byte: "+r);(null===(n=e())||null===(i=e())||null===(o=e()))&&s([r,n,i,o]),t((7&r)<<18|(63&n)<<12|(63&i)<<6|63&o)}},UTF16toUTF8:function(e,t){for(var r,n=null;null!==(r=null!==n?n:e());)r>=55296&&r<=57343&&null!==(n=e())&&n>=56320&&n<=57343?(t(1024*(r-55296)+n-56320+65536),n=null):t(r);null!==n&&t(n)},UTF8toUTF16:function(e,t){var r=null;for("number"==typeof e&&(r=e,e=function(){return null});null!==r||null!==(r=e());)r<=65535?t(r):(t(55296+((r-=65536)>>10)),t(r%1024+56320)),r=null},encodeUTF16toUTF8:function(t,r){e.UTF16toUTF8(t,(function(t){e.encodeUTF8(t,r)}))},decodeUTF8toUTF16:function(t,r){e.decodeUTF8(t,(function(t){e.UTF8toUTF16(t,r)}))},calculateCodePoint:function(e){return e<128?1:e<2048?2:e<65536?3:4},calculateUTF8:function(e){for(var t,r=0;null!==(t=e());)r+=t<128?1:t<2048?2:t<65536?3:4;return r},calculateUTF16asUTF8:function(t){var r=0,n=0;return e.UTF16toUTF8(t,(function(e){++r,n+=e<128?1:e<2048?2:e<65536?3:4})),[r,n]}};return e}();return r.toUTF8=function(e,t){if(void 0===e&&(e=this.offset),void 0===t&&(t=this.limit),!this.noAssert){if("number"!=typeof e||e%1!=0)throw TypeError("Illegal begin: Not an integer");if(e>>>=0,"number"!=typeof t||t%1!=0)throw TypeError("Illegal end: Not an integer");if(t>>>=0,e<0||e>t||t>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+e+" <= "+t+" <= "+this.buffer.byteLength)}var r;try{f.decodeUTF8toUTF16(function(){return e * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/protobuf.js for details */ !function(t,r){e&&e.exports?e.exports=r(D,!0):(t.dcodeIO=t.dcodeIO||{}).ProtoBuf=r(t.dcodeIO.ByteBuffer)}(r,(function(e,r){var n,i={};return i.ByteBuffer=e,i.Long=e.Long||null,i.VERSION="5.0.3",i.WIRE_TYPES={},i.WIRE_TYPES.VARINT=0,i.WIRE_TYPES.BITS64=1,i.WIRE_TYPES.LDELIM=2,i.WIRE_TYPES.STARTGROUP=3,i.WIRE_TYPES.ENDGROUP=4,i.WIRE_TYPES.BITS32=5,i.PACKABLE_WIRE_TYPES=[i.WIRE_TYPES.VARINT,i.WIRE_TYPES.BITS64,i.WIRE_TYPES.BITS32],i.TYPES={int32:{name:"int32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},uint32:{name:"uint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},sint32:{name:"sint32",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},int64:{name:"int64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},uint64:{name:"uint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.UZERO:void 0},sint64:{name:"sint64",wireType:i.WIRE_TYPES.VARINT,defaultValue:i.Long?i.Long.ZERO:void 0},bool:{name:"bool",wireType:i.WIRE_TYPES.VARINT,defaultValue:!1},double:{name:"double",wireType:i.WIRE_TYPES.BITS64,defaultValue:0},string:{name:"string",wireType:i.WIRE_TYPES.LDELIM,defaultValue:""},bytes:{name:"bytes",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},fixed32:{name:"fixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},sfixed32:{name:"sfixed32",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},fixed64:{name:"fixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.UZERO:void 0},sfixed64:{name:"sfixed64",wireType:i.WIRE_TYPES.BITS64,defaultValue:i.Long?i.Long.ZERO:void 0},float:{name:"float",wireType:i.WIRE_TYPES.BITS32,defaultValue:0},enum:{name:"enum",wireType:i.WIRE_TYPES.VARINT,defaultValue:0},message:{name:"message",wireType:i.WIRE_TYPES.LDELIM,defaultValue:null},group:{name:"group",wireType:i.WIRE_TYPES.STARTGROUP,defaultValue:null}},i.MAP_KEY_TYPES=[i.TYPES.int32,i.TYPES.sint32,i.TYPES.sfixed32,i.TYPES.uint32,i.TYPES.fixed32,i.TYPES.int64,i.TYPES.sint64,i.TYPES.sfixed64,i.TYPES.uint64,i.TYPES.fixed64,i.TYPES.bool,i.TYPES.string,i.TYPES.bytes],i.ID_MIN=1,i.ID_MAX=536870911,i.convertFieldsToCamelCase=!1,i.populateAccessors=!0,i.populateDefaults=!0,i.Util=((n={}).IS_NODE=!("object"!=typeof t||t+""!="[object process]"||t.browser),n.XHR=function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,r=0;r]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,FQTYPEREF:/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.Reflect=function(t){var r={},n=function(e,t,r){this.builder=e,this.parent=t,this.name=r,this.className},i=n.prototype;i.fqn=function(){for(var e=this.name,t=this;;){if(null==(t=t.parent))break;e=t.name+"."+e}return e},i.toString=function(e){return(e?this.className+" ":"")+this.fqn()},i.build=function(){throw Error(this.toString(!0)+" cannot be built directly")},r.T=n;var o=function(e,t,r,i,o){n.call(this,e,t,r),this.className="Namespace",this.children=[],this.options=i||{},this.syntax=o||"proto2"},s=o.prototype=Object.create(n.prototype);s.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],r=0,n=this.children.length;r4294967295?0|r:r;case t.TYPES.uint32:case t.TYPES.fixed32:return("number"!=typeof r||r==r&&r%1!=0)&&i(typeof r,"not an integer"),r<0?r>>>0:r;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:if(t.Long)try{return c(r,!1)}catch(e){i(typeof r,e.message)}else i(typeof r,"requires Long.js");case t.TYPES.uint64:case t.TYPES.fixed64:if(t.Long)try{return c(r,!0)}catch(e){i(typeof r,e.message)}else i(typeof r,"requires Long.js");case t.TYPES.bool:return"boolean"!=typeof r&&i(typeof r,"not a boolean"),r;case t.TYPES.float:case t.TYPES.double:return"number"!=typeof r&&i(typeof r,"not a number"),r;case t.TYPES.string:return"string"==typeof r||r&&r instanceof String||i(typeof r,"not a string"),""+r;case t.TYPES.bytes:return e.isByteBuffer(r)?r:e.wrap(r,"base64");case t.TYPES.enum:var o=this.resolvedType.getChildren(t.Reflect.Enum.Value);for(a=0;a4294967295||r<0)&&i(typeof r,"not in range for uint32"),r;i(r,"not a valid enum value");case t.TYPES.group:case t.TYPES.message:if(r&&"object"==typeof r||i(typeof r,"object expected"),r instanceof this.resolvedType.clazz)return r;if(r instanceof t.Builder.Message){var s={};for(var a in r)r.hasOwnProperty(a)&&(s[a]=r[a]);r=s}return new this.resolvedType.clazz(r)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+r+" (undefined type "+this.type+")")},u.calculateLength=function(r,n){if(null===n)return 0;var i;switch(this.type){case t.TYPES.int32:return n<0?e.calculateVarint64(n):e.calculateVarint32(n);case t.TYPES.uint32:return e.calculateVarint32(n);case t.TYPES.sint32:return e.calculateVarint32(e.zigZagEncode32(n));case t.TYPES.fixed32:case t.TYPES.sfixed32:case t.TYPES.float:return 4;case t.TYPES.int64:case t.TYPES.uint64:return e.calculateVarint64(n);case t.TYPES.sint64:return e.calculateVarint64(e.zigZagEncode64(n));case t.TYPES.fixed64:case t.TYPES.sfixed64:return 8;case t.TYPES.bool:return 1;case t.TYPES.enum:return e.calculateVarint32(n);case t.TYPES.double:return 8;case t.TYPES.string:return i=e.calculateUTF8Bytes(n),e.calculateVarint32(i)+i;case t.TYPES.bytes:if(n.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+n.remaining()+" bytes remaining");return e.calculateVarint32(n.remaining())+n.remaining();case t.TYPES.message:return i=this.resolvedType.calculate(n),e.calculateVarint32(i)+i;case t.TYPES.group:return(i=this.resolvedType.calculate(n))+e.calculateVarint32(r<<3|t.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+n+" (unknown type)")},u.encodeValue=function(r,n,i){if(null===n)return i;switch(this.type){case t.TYPES.int32:n<0?i.writeVarint64(n):i.writeVarint32(n);break;case t.TYPES.uint32:i.writeVarint32(n);break;case t.TYPES.sint32:i.writeVarint32ZigZag(n);break;case t.TYPES.fixed32:i.writeUint32(n);break;case t.TYPES.sfixed32:i.writeInt32(n);break;case t.TYPES.int64:case t.TYPES.uint64:i.writeVarint64(n);break;case t.TYPES.sint64:i.writeVarint64ZigZag(n);break;case t.TYPES.fixed64:i.writeUint64(n);break;case t.TYPES.sfixed64:i.writeInt64(n);break;case t.TYPES.bool:"string"==typeof n?i.writeVarint32("false"===n.toLowerCase()?0:!!n):i.writeVarint32(n?1:0);break;case t.TYPES.enum:i.writeVarint32(n);break;case t.TYPES.float:i.writeFloat32(n);break;case t.TYPES.double:i.writeFloat64(n);break;case t.TYPES.string:i.writeVString(n);break;case t.TYPES.bytes:if(n.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+n.remaining()+" bytes remaining");var o=n.offset;i.writeVarint32(n.remaining()),i.append(n),n.offset=o;break;case t.TYPES.message:var s=(new e).LE();this.resolvedType.encode(n,s),i.writeVarint32(s.offset),i.append(s.flip());break;case t.TYPES.group:this.resolvedType.encode(n,i),i.writeVarint32(r<<3|t.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+n+" (unknown type)")}return i},u.decode=function(e,r,n){if(r!=this.type.wireType)throw Error("Unexpected wire type for element");var i,o;switch(this.type){case t.TYPES.int32:return 0|e.readVarint32();case t.TYPES.uint32:return e.readVarint32()>>>0;case t.TYPES.sint32:return 0|e.readVarint32ZigZag();case t.TYPES.fixed32:return e.readUint32()>>>0;case t.TYPES.sfixed32:return 0|e.readInt32();case t.TYPES.int64:return e.readVarint64();case t.TYPES.uint64:return e.readVarint64().toUnsigned();case t.TYPES.sint64:return e.readVarint64ZigZag();case t.TYPES.fixed64:return e.readUint64();case t.TYPES.sfixed64:return e.readInt64();case t.TYPES.bool:return!!e.readVarint32();case t.TYPES.enum:return e.readVarint32();case t.TYPES.float:return e.readFloat();case t.TYPES.double:return e.readDouble();case t.TYPES.string:return e.readVString();case t.TYPES.bytes:if(o=e.readVarint32(),e.remaining()>>3;switch(i){case t.WIRE_TYPES.VARINT:do{n=r.readUint8()}while(128==(128&n));break;case t.WIRE_TYPES.BITS64:r.offset+=8;break;case t.WIRE_TYPES.LDELIM:n=r.readVarint32(),r.offset+=n;break;case t.WIRE_TYPES.STARTGROUP:h(o,r);break;case t.WIRE_TYPES.ENDGROUP:if(o===e)return!1;throw Error("Illegal GROUPEND after unknown group: "+o+" ("+e+" expected)");case t.WIRE_TYPES.BITS32:r.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+e+": "+i)}return!0}l.build=function(r){if(this.clazz&&!r)return this.clazz;var n=function(t,r){var n=r.getChildren(t.Reflect.Message.Field),i=r.getChildren(t.Reflect.Message.OneOf),o=function(s,a){t.Builder.Message.call(this);for(var u=0,c=i.length;u0)if(1!==arguments.length||null===s||"object"!=typeof s||!("function"!=typeof s.encode||s instanceof o)||Array.isArray(s)||s instanceof t.Map||e.isByteBuffer(s)||s instanceof ArrayBuffer||t.Long&&s instanceof t.Long)for(u=0,c=arguments.length;u0;){if(s=(i=e.readVarint32())>>>3,(o=7&i)===t.WIRE_TYPES.ENDGROUP){if(s!==n)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+s+" ("+(n?n+" expected":"not a group")+")");break}if(a=this._fieldsById[s]){if(a.repeated&&!a.options.packed)c[a.name].push(a.decode(o,e));else if(a.map){var f=a.decode(o,e);c[a.name].set(f[0],f[1])}else if(c[a.name]=a.decode(o,e),a.oneof){var l=c[a.oneof.name];null!==l&&l!==a.name&&(c[l]=null),c[a.oneof.name]=a.name}}else switch(o){case t.WIRE_TYPES.VARINT:e.readVarint32();break;case t.WIRE_TYPES.BITS32:e.offset+=4;break;case t.WIRE_TYPES.BITS64:e.offset+=8;break;case t.WIRE_TYPES.LDELIM:var p=e.readVarint32();e.offset+=p;break;case t.WIRE_TYPES.STARTGROUP:for(;h(s,e););break;default:throw Error("Illegal wire type for unknown field "+s+" in "+this.toString(!0)+"#decode: "+o)}}for(var d=0,m=this._fields.length;d0;case t.TYPES.bytes:return e.remaining()>0;case t.TYPES.enum:return 0!==e;case t.TYPES.message:return null!==e;default:return!0}},d.encode=function(r,n,i){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===r||this.repeated&&0==r.length)return n;try{var o;if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){n.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),n.ensureCapacity(n.offset+=1);var s=n.offset;for(o=0;o1){var c=n.slice(s,n.offset);s+=u-1,n.offset=s,n.append(c)}n.writeVarint32(a,s-u)}else for(o=0;o=0){for(i+=e.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),s=0,o=0;o=0&&!n){o=r.readVarint32(),o=r.offset+o;for(var s=[];r.offset0;){var f=c.readVarint32();e=7&f;var l=f>>>3;if(1===l)u=this.keyElement.decode(c,e,l);else{if(2!==l)throw Error("Unexpected tag in map field key/value submessage");i=this.element.decode(c,e,l)}}return[u,i]}return this.element.decode(r,e,this.id)},r.Message.Field=p;var m=function(e,t,r,n,i,o,s){p.call(this,e,t,r,null,n,i,o,s),this.extension};m.prototype=Object.create(p.prototype),r.Message.ExtensionField=m;r.Message.OneOf=function(e,t,r){n.call(this,e,t,r),this.fields=[]};var y=function(e,t,r,n,i){o.call(this,e,t,r,n,i),this.className="Enum",this.object=null};y.getName=function(e,t){for(var r,n=Object.keys(e),i=0;i0;){if(t=i.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var o=t.shift();if(n.isMessage(o)){var s=new r.Message(this,this.ptr,o.name,o.options,o.isGroup,o.syntax),a={};o.oneofs&&Object.keys(o.oneofs).forEach((function(e){s.addChild(a[e]=new r.Message.OneOf(this,s,e))}),this),o.fields&&o.fields.forEach((function(e){if(null!==s.getChild(0|e.id))throw Error("duplicate or invalid field id in "+s.name+": "+e.id);if(e.options&&"object"!=typeof e.options)throw Error("illegal field options in "+s.name+"#"+e.name);var t=null;if("string"==typeof e.oneof&&!(t=a[e.oneof]))throw Error("illegal oneof in "+s.name+"#"+e.name+": "+e.oneof);e=new r.Message.Field(this,s,e.rule,e.keytype,e.type,e.name,e.id,e.options,t,o.syntax),t&&t.fields.push(e),s.addChild(e)}),this);var u=[];if(o.enums&&o.enums.forEach((function(e){u.push(e)})),o.messages&&o.messages.forEach((function(e){u.push(e)})),o.services&&o.services.forEach((function(e){u.push(e)})),o.extensions&&("number"==typeof o.extensions[0]?s.extensions=[o.extensions]:s.extensions=o.extensions),this.ptr.addChild(s),u.length>0){i.push(t),t=u,u=null,this.ptr=s,s=null;continue}u=null}else if(n.isEnum(o))s=new r.Enum(this,this.ptr,o.name,o.options,o.syntax),o.values.forEach((function(e){s.addChild(new r.Enum.Value(this,s,e.name,e.id))}),this),this.ptr.addChild(s);else if(n.isService(o))s=new r.Service(this,this.ptr,o.name,o.options),Object.keys(o.rpc).forEach((function(e){var t=o.rpc[e];s.addChild(new r.Service.RPCMethod(this,s,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))}),this),this.ptr.addChild(s);else{if(!n.isExtend(o))throw Error("not a valid definition: "+JSON.stringify(o));if(s=this.ptr.resolve(o.ref,!0))o.fields.forEach((function(t){if(null!==s.getChild(0|t.id))throw Error("duplicate extended field id in "+s.name+": "+t.id);if(s.extensions){var n=!1;if(s.extensions.forEach((function(e){t.id>=e[0]&&t.id<=e[1]&&(n=!0)})),!n)throw Error("illegal extended field id in "+s.name+": "+t.id+" (not within valid ranges)")}var i=t.name;this.options.convertFieldsToCamelCase&&(i=e.Util.toCamelCase(i));var o=new r.Message.ExtensionField(this,s,t.rule,t.type,this.ptr.fqn()+"."+i,t.id,t.options),a=new r.Extension(this,this.ptr,t.name,o);o.extension=a,this.ptr.addChild(a),s.addChild(o)}),this);else if(!/\.?google\.protobuf\./.test(o.ref))throw Error("extended message "+o.ref+" is not defined")}o=null,s=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},i.import=function(t,r){var n="/";if("string"==typeof r){if(e.Util.IS_NODE&&(r=F.resolve(r)),!0===this.files[r])return this.reset();this.files[r]=!0}else if("object"==typeof r){var i,o=r.root;if(e.Util.IS_NODE&&(o=F.resolve(o)),(o.indexOf("\\")>=0||r.file.indexOf("\\")>=0)&&(n="\\"),i=e.Util.IS_NODE?F.join(o,r.file):o+n+r.file,!0===this.files[i])return this.reset();this.files[i]=!0}if(t.imports&&t.imports.length>0){var s,a=!1;"object"==typeof r?(this.importRoot=r.root,a=!0,s=this.importRoot,r=r.file,(s.indexOf("\\")>=0||r.indexOf("\\")>=0)&&(n="\\")):"string"==typeof r?this.importRoot?s=this.importRoot:r.indexOf("/")>=0?""===(s=r.replace(/\/[^\/]*$/,""))&&(s="/"):r.indexOf("\\")>=0?(s=r.replace(/\\[^\\]*$/,""),n="\\"):s=".":s=null;for(var u=0;u=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(a&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;_(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function me(e,t,r,n,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,i)}var ye=function(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function s(e){me(o,n,i,s,a,"next",e)}function a(e){me(o,n,i,s,a,"throw",e)}s(void 0)}))}};var ge=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(i[r]=e[r]);return i};var Oe=function(e,t){if(null==e)return{};var r,n,i=Te(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i};var Se=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var Ae=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t},Ie=1e3,Ce=6e4,xe=60*Ce,ke=24*xe,Pe=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*ke;case"hours":case"hour":case"hrs":case"hr":case"h":return r*xe;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ce;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ie;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(t>=ke)return Me(e,t,ke,"day");if(t>=xe)return Me(e,t,xe,"hour");if(t>=Ce)return Me(e,t,Ce,"minute");if(t>=Ie)return Me(e,t,Ie,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=ke)return Math.round(e/ke)+"d";if(t>=xe)return Math.round(e/xe)+"h";if(t>=Ce)return Math.round(e/Ce)+"m";if(t>=Ie)return Math.round(e/Ie)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Me(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var je=function(e){function t(e){for(var t=0,n=0;n=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage=function(){try{return localStorage}catch(e){}}(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=je(r),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}));Re.log,Re.formatArgs,Re.save,Re.load,Re.useColors,Re.storage,Re.colors;var Ne=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991},mt={};mt["[object Float32Array]"]=mt["[object Float64Array]"]=mt["[object Int8Array]"]=mt["[object Int16Array]"]=mt["[object Int32Array]"]=mt["[object Uint8Array]"]=mt["[object Uint8ClampedArray]"]=mt["[object Uint16Array]"]=mt["[object Uint32Array]"]=!0,mt["[object Arguments]"]=mt["[object Array]"]=mt["[object ArrayBuffer]"]=mt["[object Boolean]"]=mt["[object DataView]"]=mt["[object Date]"]=mt["[object Error]"]=mt["[object Function]"]=mt["[object Map]"]=mt["[object Number]"]=mt["[object Object]"]=mt["[object RegExp]"]=mt["[object Set]"]=mt["[object String]"]=mt["[object WeakMap]"]=!1;var yt=function(e){return nt(e)&&dt(e.length)&&!!mt[rt(e)]};var gt=function(e){return function(t){return e(t)}},vt=i((function(e,t){var r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,i=n&&n.exports===r&&ze.process,o=function(){try{var e=n&&n.require&&n.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})),bt=vt&&vt.isTypedArray,wt=bt?gt(bt):yt,_t=Object.prototype.hasOwnProperty;var Et=function(e,t){var r=ct(e),n=!r&&ut(e),i=!r&&!n&<(e),o=!r&&!n&&!i&&wt(e),s=r||n||i||o,a=s?qe(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)||pt(c,u))||a.push(c);return a},Tt=Object.prototype;var Ot=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Tt)};var St=function(e,t){return function(r){return e(t(r))}},At=St(Object.keys,Object),It=Object.prototype.hasOwnProperty;var Ct=function(e){if(!Ot(e))return At(e);var t=[];for(var r in Object(e))It.call(e,r)&&"constructor"!=r&&t.push(r);return t};var xt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var kt=function(e){if(!xt(e))return!1;var t=rt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var Pt=function(e){return null!=e&&dt(e.length)&&!kt(e)};var Mt=function(e){return Pt(e)?Et(e):Ct(e)};var jt=function(e){return null==e?[]:Ye(e,Mt(e))};var Rt=function(e){return Ue(jt(e))};var Nt=function(e){return(ct(e)?Be:Rt)(e)};var Lt=function(e){if(Array.isArray(e))return e};var Dt=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var Ft=function(e){return Lt(e)||be(e)||we(e)||Dt()};function Ut(e,t){for(var r=0;r=0:this.current===e},o.can=function(e){return!this.transition&&void 0!==u[e]&&(u[e].hasOwnProperty(this.current)||u[e].hasOwnProperty(r.WILDCARD))},o.cannot=function(e){return!this.can(e)},o.transitions=function(){return(c[this.current]||[]).concat(c[r.WILDCARD]||[])},o.isFinished=function(){return this.is(i)},o.error=e.error||function(e,t,r,n,i,o,s){throw s||o},o.states=function(){return Object.keys(c).sort()},n&&!n.defer&&o[n.event](),o},doCallback:function(e,t,n,i,o,s){if(t)try{return t.apply(e,[n,i,o].concat(s))}catch(t){return e.error(n,i,o,s,r.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",t)}},beforeAnyEvent:function(e,t,n,i,o){return r.doCallback(e,e.onbeforeevent,t,n,i,o)},afterAnyEvent:function(e,t,n,i,o){return r.doCallback(e,e.onafterevent||e.onevent,t,n,i,o)},leaveAnyState:function(e,t,n,i,o){return r.doCallback(e,e.onleavestate,t,n,i,o)},enterAnyState:function(e,t,n,i,o){return r.doCallback(e,e.onenterstate||e.onstate,t,n,i,o)},changeState:function(e,t,n,i,o){return r.doCallback(e,e.onchangestate,t,n,i,o)},beforeThisEvent:function(e,t,n,i,o){return r.doCallback(e,e["onbefore"+t],t,n,i,o)},afterThisEvent:function(e,t,n,i,o){return r.doCallback(e,e["onafter"+t]||e["on"+t],t,n,i,o)},leaveThisState:function(e,t,n,i,o){return r.doCallback(e,e["onleave"+n],t,n,i,o)},enterThisState:function(e,t,n,i,o){return r.doCallback(e,e["onenter"+i]||e["on"+i],t,n,i,o)},beforeEvent:function(e,t,n,i,o){if(!1===r.beforeThisEvent(e,t,n,i,o)||!1===r.beforeAnyEvent(e,t,n,i,o))return!1},afterEvent:function(e,t,n,i,o){r.afterThisEvent(e,t,n,i,o),r.afterAnyEvent(e,t,n,i,o)},leaveState:function(e,t,n,i,o){var s=r.leaveThisState(e,t,n,i,o),a=r.leaveAnyState(e,t,n,i,o);return!1!==s&&!1!==a&&(r.ASYNC===s||r.ASYNC===a?r.ASYNC:void 0)},enterState:function(e,t,n,i,o){r.enterThisState(e,t,n,i,o),r.enterAnyState(e,t,n,i,o)},buildEvent:function(e,t){return function(){var n=this.current,i=t[n]||(t[r.WILDCARD]!=r.WILDCARD?t[r.WILDCARD]:n)||n,o=Array.prototype.slice.call(arguments);if(this.transition)return this.error(e,n,i,o,r.Error.PENDING_TRANSITION,"event "+e+" inappropriate because previous transition did not complete");if(this.cannot(e))return this.error(e,n,i,o,r.Error.INVALID_TRANSITION,"event "+e+" inappropriate in current state "+this.current);if(!1===r.beforeEvent(this,e,n,i,o))return r.Result.CANCELLED;if(n===i)return r.afterEvent(this,e,n,i,o),r.Result.NOTRANSITION;var s=this;this.transition=function(){return s.transition=null,s.current=i,r.enterState(s,e,n,i,o),r.changeState(s,e,n,i,o),r.afterEvent(s,e,n,i,o),r.Result.SUCCEEDED},this.transition.cancel=function(){s.transition=null,r.afterEvent(s,e,n,i,o)};var a=r.leaveState(this,e,n,i,o);return!1===a?(this.transition=null,r.Result.CANCELLED):r.ASYNC===a?r.Result.PENDING:this.transition?this.transition():void 0}}},e.exports&&(t=e.exports=r),t.StateMachine=r})),qt=(Yt.StateMachine,{}),zt=function(e){var t=qt[e];if(void 0===t)throw new Error("".concat(e," adapter is not configured"));return t},Wt=function(e){Object.assign(qt,e)},$t=St(Object.getPrototypeOf,Object),Gt=Function.prototype,Jt=Object.prototype,Zt=Gt.toString,Ht=Jt.hasOwnProperty,Xt=Zt.call(Object);var Qt=function(e){if(!nt(e)||"[object Object]"!=rt(e))return!1;var t=$t(e);if(null===t)return!0;var r=Ht.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Zt.call(r)==Xt},Kt="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},er=Symbol("expired"),tr=Re("LC:Expirable"),rr=function(){function e(e,t){this.originalValue=e,"number"==typeof t&&(this.expiredAt=Date.now()+t)}return Bt(e,[{key:"value",get:function(){var e=this.expiredAt&&this.expiredAt<=Date.now();return e&&tr("expired: ".concat(this.originalValue)),e?er:this.originalValue}}]),e}();rr.EXPIRED=er;var nr=Re("LC:Cache"),ir=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"anonymous";this.name=e,this._map={}}var t=e.prototype;return t.get=function(e){var t=this._map[e];if(t){var r=t.value;if(r!==rr.EXPIRED)return nr("[%s] hit: %s",this.name,e),r;delete this._map[e]}return nr("[".concat(this.name,"] missed: ").concat(e)),null},t.set=function(e,t,r){nr("[%s] set: %s %d",this.name,e,r),this._map[e]=new rr(t,r)},e}();function or(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function sr(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:"LC*";return Re.enable(e)},disable:Re.disable},cr=function(e){return function(t){return e(t),t}},fr=function(e){return[function(t){return e(),t},function(t){throw e(),t}]},lr=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},hr=function(e){return e&&e.getTime?e.getTime():void 0},pr=function e(t){return t?"Date"===t.__type&&t.iso?new Date(t.iso):Array.isArray(t)?t.map(e):Qt(t)?Object.keys(t).reduce((function(r,n){return sr(sr({},r),{},N({},n,e(t[n])))}),{}):t:t},dr=function e(t){return t instanceof Date?{__type:"Date",iso:t.toJSON()}:Array.isArray(t)?t.map(e):Qt(t)?Object.keys(t).reduce((function(r,n){return sr(sr({},r),{},N({},n,e(t[n])))}),{}):t},mr=function(e,t){return Object.keys(t).reduce((function(r,n){var i=e[n]||n;return Object.assign(r,N({},i,t[n]))}),{})},yr=Kt.navigator&&Kt.navigator.userAgent&&-1!==Kt.navigator.userAgent.indexOf("MSIE 10."),gr=function e(t,r){return t[r]||(t.__proto__?e(t.__proto__,r):void 0)},vr=function(e,t){return Array.from(new Set([].concat(Ee(e),Ee(t))))},br=function(e,t){return Array.from((r=new Set(t),new Set(e.filter((function(e){return!r.has(e)})))));var r},wr=new WeakMap,_r=function(e){return wr.has(e)||wr.set(e,{}),wr.get(e)},Er=function e(t,r){if(!Qt(t))return t;var n=sr({},t);return Object.keys(n).forEach((function(t){var i=n[t];i===r?delete n[t]:n[t]=e(i,r)})),n},Tr=function(e){return t=JSON.parse(JSON.stringify(e)),Er(t,null);var t},Or=function(e){return Array.isArray(e)?e:null==e?[]:[e]},Sr=function(e,t,r){var n=t.split("."),i=n.pop(),o=e;return n.forEach((function(e){void 0===o[e]&&(o[e]={}),o=o[e]})),o[i]=r,e},Ar="object"===("undefined"==typeof wx?"undefined":s(wx))&&"function"==typeof wx.connectSocket,Ir=function(e){return function(t,r,n){var i=n.value;if(i.length)throw new Error("throttled function should not accept any arguments");return sr(sr({},n),{},{value:function(){var t=this,n=_r(this).throttleMeta;n||(n={},_r(this).throttleMeta=n);var o=n[r];o||(o={},n[r]=o);var s=o,a=s.previouseTimestamp,u=void 0===a?0:a,c=s.timeout,f=Date.now(),l=e-(f-u);l<=0?(n[r].previouseTimestamp=f,i.apply(this)):c||(o.timeout=setTimeout((function(){o.previouseTimestamp=Date.now(),delete o.timeout,i.apply(t)}),l))}})}},Cr=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;var r=new Uint8Array(e),n=new Uint8Array(t);return!r.some((function(e,t){return e!==n[t]}))};function xr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function kr(e){for(var t=1;t3?n-3:0),o=3;o ").concat(r," %o"),i)},r.onopen=function(){this.emit("open")},r.onconnected=function(){this._startConnectionKeeper()},r.onleaveconnected=function(e,t,r){this._stopConnectionKeeper(),this._destroyWs(),"offline"!==r&&"disconnected"!==r||this.emit(Mr)},r.onpause=function(){this.emit(Lr)},r.onbeforeresume=function(){this.emit(Dr)},r.onreconnect=function(){this.emit(jr)},r.ondisconnected=function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=t===Lr?0:Fr.call(null,i);Pr("schedule attempt=".concat(i," delay=").concat(o)),this.emit(Nr,i,o),this.__scheduledRetry&&clearTimeout(this.__scheduledRetry),this.__scheduledRetry=setTimeout((function(){n.is("disconnected")&&n.retry(i)}),o)},r.onretry=function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.emit(Rr,i),this._open().then((function(){return n.can("reconnect")&&n.reconnect()}),(function(){return n.can("fail")&&n.fail(i+1)}))},r.onerror=function(e,t,r,n){this.emit("error",n)},r.onclose=function(){Kt.removeEventListener&&(this.__pause&&Kt.removeEventListener("offline",this.__pause),this.__resume&&Kt.removeEventListener("online",this.__resume))},r.checkConnectionAvailability=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"API";if(!this.is("connected")){var t=this.current;throw console.warn("".concat(e," should not be called when the connection is ").concat(t)),(this.is("disconnected")||this.is("reconnecting"))&&console.warn("disconnect and reconnect event should be handled to avoid such calls."),new Error("Connection unavailable")}},r._ping=function(){Pr("ping");try{this.ping()}catch(e){console.warn("websocket ping error: ".concat(e.message))}},r.ping=function(){this._ws.ping?this._ws.ping():console.warn("The WebSocket implement does not support sending ping frame.\n Override ping method to use application defined ping/pong mechanism.")},r._postponeTimeoutTimer=function(){var e=this;Pr("_postponeTimeoutTimer"),this._clearTimeoutTimers(),this._timeoutTimer=setTimeout((function(){Pr("timeout"),e.disconnect()}),38e4)},r._clearTimeoutTimers=function(){this._timeoutTimer&&clearTimeout(this._timeoutTimer)},r._startConnectionKeeper=function(){Pr("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()):Pr("connection keeper disabled due to the lack of #addEventListener.")},r._stopConnectionKeeper=function(){Pr("stop connection keeper");var e=this._ws.removeListener||this._ws.removeEventListener;e&&(e.call(this._ws,"message",this.__postponeTimeoutTimer),e.call(this._ws,"pong",this.__postponeTimeoutTimer),this._clearTimeoutTimers()),this._heartbeatTimer&&clearInterval(this._heartbeatTimer)},r._handleClose=function(e){Pr("ws closed [".concat(e.code,"] ").concat(e.reason)),this.isFinished()||this.handleClose(e)},r.handleClose=function(){this.disconnect()},r.send=function(e){Pr("send",e),this._ws.send(e)},r._handleMessage=function(e){Pr("message",e.data),this.handleMessage(e.data)},r.handleMessage=function(e){this.emit("message",e)},t}(pe)).prototype,"_ping",[Ur],Object.getOwnPropertyDescriptor(ar.prototype,"_ping"),ar.prototype),Vt(ar.prototype,"send",[Ur],Object.getOwnPropertyDescriptor(ar.prototype,"send"),ar.prototype),ar);Yt.create({target:Br.prototype,initial:{state:"initialized",event:"init",defer:!0},terminal:"closed",events:[{name:"open",from:"initialized",to:"connected"},{name:"disconnect",from:"connected",to:"disconnected"},{name:"retry",from:"disconnected",to:"reconnecting"},{name:"fail",from:"reconnecting",to:"disconnected"},{name:"reconnect",from:"reconnecting",to:"connected"},{name:"pause",from:["connected","disconnected","reconnecting"],to:"offline"},{},{name:"resume",from:"offline",to:"disconnected"},{name:"close",from:["connected","disconnected","reconnecting","offline"],to:"closed"},{name:"throw",from:"*",to:"error"}]});var Vr=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."}}),Yr=Object.freeze(Object.keys(Vr).reduce((function(e,t){return Object.assign(e,N({},Vr[t].name,Number(t)))}),{})),qr=function(e){var t=e.code,r=e.reason,n=e.appCode,i=e.detail,o=e.error,s=r||i||o,a=r;!s&&Vr[t]&&(a=Vr[t].name,s=Vr[t].message||a),s||(s="Unknow Error: ".concat(t));var u=new Error(s);return Object.assign(u,{code:t,appCode:n,detail:i,name:a})},zr=Re("LC:Connection"),Wr=Symbol("expire"),$r=function(e){return!(e.cmd===ce.direct||e.cmd===ce.session&&e.op===fe.open||e.cmd===ce.conv&&(e.op===fe.start||e.op===fe.update||e.op===fe.members))},Gr=function(e){function t(t,r){var n,i=r.format,o=r.version;zr("initializing Connection");var s="lc.".concat(i,".").concat(o);return(n=e.call(this,t,s)||this)._protocolFormat=i,n._commands={},n._serialId=0,n}Ae(t,e);var r=t.prototype;return r.send=function(){var t=ye(de.mark((function t(r){var n,i,o,s,a,u,c=this,f=arguments;return de.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(n=!(f.length>1&&void 0!==f[1])||f[1])){t.next=11;break}if(!$r(r)){t.next=8;break}if(i=r.toArrayBuffer(),!(s=jt(this._commands).find((function(e){var t=e.buffer,n=e.command;return n.cmd===r.cmd&&n.op===r.op&&Cr(t,i)})))){t.next=8;break}return console.warn("Duplicated command [cmd:".concat(r.cmd," op:").concat(r.op,"] is throttled.")),t.abrupt("return",s.promise);case 8:this._serialId+=1,o=this._serialId,r.i=o;case 11:if(zr.enabled&&zr("↑ %O sent",Tr(r)),"proto2base64"===this._protocolFormat?a=r.toBase64():r.toArrayBuffer&&(a=r.toArrayBuffer()),a){t.next=15;break}throw new TypeError("".concat(r," is not a GenericCommand"));case 15:if(e.prototype.send.call(this,a),n){t.next=18;break}return t.abrupt("return",void 0);case 18:return u=new Promise((function(e,t){c._commands[o]={command:r,buffer:i,resolve:e,reject:t,timeout:setTimeout((function(){c._commands[o]&&(zr.enabled&&zr("✗ %O timeout",Tr(r)),t(qr({error:"Command Timeout [cmd:".concat(r.cmd," op:").concat(r.op,"]"),name:"COMMAND_TIMEOUT"})),delete c._commands[o])}),2e4)}})),this._commands[o].promise=u,t.abrupt("return",u);case 21:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.handleMessage=function(e){var t;try{t=ie.decode(e),zr.enabled&&zr("↓ %O received",Tr(t))}catch(t){return void console.warn("Decode message failed:",t.message,e)}var r=t.i;if(r)this._commands[r]?(clearTimeout(this._commands[r].timeout),t.cmd===ce.error?this._commands[r].reject(qr(t.errorMessage)):this._commands[r].resolve(t),delete this._commands[r]):console.warn("Unexpected command received with serialId [".concat(r,"],\n which have timed out or never been requested."));else switch(t.cmd){case ce.error:return void this.emit("error",qr(t.errorMessage));case ce.goaway:return void this.emit(Wr);default:this.emit("message",t)}},r.ping=function(){return this.send(new ie({cmd:ce.echo})).catch((function(e){return zr("ping failed:",e)}))},t}(Br),Jr=i((function(e){var t;e.exports.timeout=function(e,r){var n,i=new t;return Promise.race([e,new Promise((function(e,t){n=setTimeout((function(){t(i)}),r)}))]).then((function(e){return clearTimeout(n),e}),(function(e){throw clearTimeout(n),e}))};(t=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),t.prototype.name="TimeoutError"})),Zr=Jr.timeout,Hr=(Jr.TimeoutError,Re("LC:request")),Xr=function(e){var t=e.method,r=void 0===t?"GET":t,n=e.url,i=e.query,o=e.headers,s=e.data,a=e.timeout,u=n;if(i){var c=Object.keys(i).map((function(e){var t=i[e];if(void 0!==t){var r=Qt(t)?JSON.stringify(t):t;return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))}})).filter((function(e){return e})).join("&");u="".concat(u,"?").concat(c)}Hr("Req: %O %O %O",r,u,{headers:o,data:s});var f=zt("request")(u,{method:r,headers:o,data:s}).then((function(e){if(!1===e.ok){var t=qr(e.data);throw t.response=e,t}return Hr("Res: %O %O %O",u,e.status,e.data),e.data})).catch((function(e){throw e.response&&Hr("Error: %O %O %O",u,e.response.status,e.response.data),e}));return a?Zr(f,a):f},Qr=function(e,t){e&&e.forEach((function(e){try{e(t)}catch(t){throw e._pluginName&&(t.message+="[".concat(e._pluginName,"]")),t}}))},Kr=function(e){return function(t){return Or(e).reduce((function(e,t){return e.then(function(e){return function(t){var r=t.constructor;return Promise.resolve(t).then(e).then(cr((function(n){return null==n?console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns ").concat(n," while a ").concat(t.constructor.name," expected.")):n instanceof r?0:console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns a ").concat(n.constructor.name," while a ").concat(t.constructor.name," expected."))})))}}(t)).catch((function(e){throw t._pluginName&&(e.message+="[".concat(t._pluginName,"]")),e}))}),Promise.resolve(t))}},en=function(e,t){return Or(e).reduce((function(e,r){return e.then((function(e){return!1!==e&&r.apply(void 0,Ee(t))})).catch((function(e){throw r._pluginName&&(e.message+="[".concat(r._pluginName,"]")),e}))}),Promise.resolve(!0))};function tn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function rn(e){for(var t=1;t>>((3&t)<<3)&255;return n}}})),fn=[],ln=0;ln<256;++ln)fn[ln]=(ln+256).toString(16).substr(1);var hn=function(e,t){var r=t||0,n=fn;return[n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],"-",n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]],n[e[r++]]].join("")};var pn=function(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||cn)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[n+o]=i[o];return t||hn(i)};var dn=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw o}}return r}};var mn=function(e,t){return Lt(e)||dn(e,t)||we(e,t)||Dt()},yn=i((function(e,t){!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n>2],o+=e[(3&n[r])<<4|n[r+1]>>4],o+=e[(15&n[r+1])<<2|n[r+2]>>6],o+=e[63&n[r+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=function(e){var t,n,i,o,s,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return f}}()})),gn=yn.encode,vn=yn.decode;var bn=function(){this.__data__=[],this.size=0};var wn=function(e,t){return e===t||e!=e&&t!=t};var _n=function(e,t){for(var r=e.length;r--;)if(wn(e[r][0],t))return r;return-1},En=Array.prototype.splice;var Tn=function(e){var t=this.__data__,r=_n(t,e);return!(r<0)&&(r==t.length-1?t.pop():En.call(t,r,1),--this.size,!0)};var On=function(e){var t=this.__data__,r=_n(t,e);return r<0?void 0:t[r][1]};var Sn=function(e){return _n(this.__data__,e)>-1};var An=function(e,t){var r=this.__data__,n=_n(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};function In(e){var t=-1,r=null==e?0:e.length;for(this.clear();++ta))return!1;var c=o.get(e),f=o.get(t);if(c&&f)return c==t&&f==e;var l=-1,h=!0,p=2&r?new wi:void 0;for(o.set(e,t),o.set(t,e);++li?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1?i[o?t[s]:s]:void 0}};var Cs=function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1)},t.getMentionList=function(){return this.mentionList},t.setMentionList=function(e){return this.mentionList=Or(e),this},t.mentionAll=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.mentionedAll=Boolean(e),this},e.validate=function(){return!0},e.parse=function(e,t){return t||new this(e)},Bt(e,[{key:"status",get:function(){return this._status}},{key:"timestamp",get:function(){return this._timestamp},set:function(e){this._timestamp=lr(e)}},{key:"deliveredAt",get:function(){return this._deliveredAt},set:function(e){this._deliveredAt=lr(e)}},{key:"updatedAt",get:function(){return this._updatedAt||this.timestamp},set:function(e){this._updatedAt=lr(e)}},{key:"mentioned",get:function(){return this._mentioned}}]),e}(),Hs=function(e){if("number"!=typeof e)throw new TypeError("".concat(e," is not a Number"));return function(t){t.TYPE=e,t.validate=function(t){return t._lctype===e},t.prototype._getType=function(){return{_lctype:e}}}},Xs=function(e){if("string"!=typeof e){if(!Array.isArray(e))throw new TypeError("".concat(e," is not an Array"));if(e.some((function(e){return"string"!=typeof e})))throw new TypeError("fields contains non-string typed member")}return function(t){var r=yr?gr(t,"_customFields"):t._customFields;r=Array.isArray(r)?r:[],t._customFields=r.concat(e)}},Qs=function(e){yr&&(e.parse=gr(e,"parse"))};function Ks(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ea(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:new this;r.content=t;var n=yr?gr(r.constructor,"_customFields"):r.constructor._customFields,i=Array.isArray(n)?n:[];return i=i.reduce((function(e,r){return"string"!=typeof r||(e[r]=t[r]),e}),{}),Object.assign(r,i),e.parse.call(this,t,r)},Bt(t,[{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}}]),t}(Zs))||Gs,na=Hs(-127)(ta=Qs(ta=function(e){function t(){return e.apply(this,arguments)||this}return Ae(t,e),Bt(t,[{key:"summary",get:function(){return"[该消息已撤回]"}}]),t}(ra))||ta)||ta;function ia(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function oa(e){for(var t=1;t1?r-1:0),i=1;i2&&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($s.SENDING),c=aa(t),f=c.msg,l=c.binaryMsg,h=new ie({cmd:"direct",directMessage:new $({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,y=d.t,g=d.code,v=d.reason,b=d.appCode,null===g){e.next=17;break}throw qr({code:g,reason:v,appCode:b});case 17:return Object.assign(t,{id:m,timestamp:y}),i||(this.lastMessage=t,this.lastMessageAt=t.timestamp),t._setStatus($s.SENT),o&&(_r(this).messagesWaitingForReceipt[t.id]=t),e.abrupt("return",t);case 24:throw e.prev=24,e.t0=e.catch(10),t._setStatus($s.FAILED),e.t0;case 28:case"end":return e.stop()}}),e,this,[[10,24]])})));return function(t,r){return e.apply(this,arguments)}}(),r._update=function(){var e=ye(de.mark((function e(t,r,n){var i,o,s,a,u,c,f,l;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("patch %O %O %O",t,r,n),!(t instanceof Zs)){e.next=8;break}if(t.from===this._client.id){e.next=4;break}throw new Error("Updating message from others is not allowed");case 4:if(t.status===$s.SENT||t.status===$s.DELIVERED){e.next=6;break}throw new Error("Message is not sent");case 6:e.next=10;break;case 8:if(t.id&&t.timestamp){e.next=10;break}throw new TypeError("".concat(t," is not a Message"));case 10:return n||(s=aa(r),i=s.msg,o=s.binaryMsg),e.next=13,this._send(new ie({cmd:ce.patch,op:fe.modify,patchMessage:new se({patches:[new ae({cid:this.id,mid:t.id,timestamp:Number(t.timestamp),recall:n,data:i,binaryMsg:o,mentionPids:r.mentionList,mentionAll:r.mentionedAll})],lastPatchTime:this._client._lastPatchTime})}));case 13:return a=t.id,u=t.cid,c=t.timestamp,f=t.from,l=t._status,Object.assign(r,{id:a,cid:u,timestamp:c,from:f,_status:l}),this.lastMessage&&this.lastMessage.id===r.id&&(this.lastMessage=r),e.abrupt("return",r);case 17:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}(),r.count=function(){var e=ye(de.mark((function e(){var t;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("count"),e.next=3,this._send(new ie({op:"count"}));case 3:return t=e.sent,e.abrupt("return",t.convMessage.count);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r._addMembers=function(){},r._removeMembers=function(){},r.update=function(){var e=ye(de.mark((function e(t,r){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r instanceof Zs){e.next=2;break}throw new TypeError("".concat(r," is not a Message"));case 2:return e.abrupt("return",this._update(t,r,!1));case 3:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),r.recall=function(){var e=ye(de.mark((function e(t){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._update(t,new na,!0));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.queryMessages=function(){var e=ye(de.mark((function e(){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,m,y,g=this,v=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=v.length>0&&void 0!==v[0]?v[0]:{},this._debug("query messages %O",t),r=t.beforeTime,n=t.beforeMessageId,i=t.afterTime,o=t.afterMessageId,s=t.limit,a=t.direction,u=t.type,c=t.startTime,f=t.startMessageId,l=t.startClosed,h=t.endTime,p=t.endMessageId,d=t.endClosed,!(n||r||o||i)){e.next=6;break}return console.warn("DEPRECATION: queryMessages options beforeTime, beforeMessageId, afterTime and afterMessageId are deprecated in favor of startTime, startMessageId, endTime and endMessageId."),e.abrupt("return",this.queryMessages({startTime:r,startMessageId:n,endTime:i,endMessageId:o,limit:s}));case 6:if(!f||c){e.next=8;break}throw new Error("query option startMessageId must be used with option startTime");case 8:if(!p||h){e.next=10;break}throw new Error("query option endMessageId must be used with option endTime");case 10:return(m={t:c,mid:f,tIncluded:l,tt:h,tmid:p,ttIncluded:d,l:s,lctype:u}).t instanceof Date&&(m.t=m.t.getTime()),m.tt instanceof Date&&(m.tt=m.tt.getTime()),void 0!==a?m.direction=a:m.tt>m.t&&(m.direction=fa.OLD_TO_NEW),e.next=16,this._send(new ie({cmd:"logs",logsMessage:new X(Object.assign(m,{cid:this.id}))}));case 16:return y=e.sent,e.abrupt("return",Promise.all(y.logsMessage.logs.map(function(){var e=ye(de.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.msgId,n=t.timestamp,i=t.patchTimestamp,o=t.from,s=t.ackAt,a=t.readAt,u=t.data,c=t.mentionAll,f=t.mentionPids,l=t.bin,h={data:u,bin:l,id:r,cid:g.id,timestamp:n,from:o,deliveredAt:s,updatedAt:i,mentionList:f,mentionedAll:c},e.next=4,g._client.parseMessage(h);case 4:return p=e.sent,d=$s.SENT,2===g.members.length&&(s&&(d=$s.DELIVERED),s&&g._setLastDeliveredAt(s),a&&g._setLastReadAt(a)),p._setStatus(d),e.abrupt("return",p);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 18:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.createMessagesIterator=function(){var e,t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.beforeTime,i=r.beforeMessageId,o=r.limit;return{next:function(){return(e=void 0===e?t.queryMessages({limit:o,startTime:n,startMessageId:i}):e.then((function(e){return 0===e.length||e.length0&&void 0!==arguments[0]?arguments[0]:{},t=e.signature,r=e.timestamp,n=e.nonce;if("string"!=typeof t||"number"!=typeof r||"string"!=typeof n)throw new Error("malformed signature");return{signature:t,timestamp:r,nonce:n}}var da=function(e,t){return Promise.resolve().then((function(){return ha("call signatureFactory with %O",t),e.apply(void 0,Ee(t))})).then(cr((function(e){return ha("sign result %O",e)})),(function(e){throw e.message="sign error: ".concat(e.message),ha(e),e})).then(pa)};function ma(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ya(e){for(var t=1;t0&&void 0!==c[0]?c[0]:{},r=t.limit,n=t.next,this._debug("query muted: limit %O, next: %O",r,n),i=new ie({op:fe.query_shutup,convMessage:new Z({limit:r,next:n})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.convMessage,a=s.m,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.blockMembers=function(){var e=ye(de.mark((function e(t){var r,n,i;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("block",t),t=Or(t),r=new ie({cmd:"blacklist",op:fe.block,blacklistMessage:new oe({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(r,"conversation-block-clients",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.blacklistMessage,e.abrupt("return",ga(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.unblockMembers=function(){var e=ye(de.mark((function e(t){var r,n,i;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unblock",t),t=Or(t),r=new ie({cmd:"blacklist",op:fe.unblock,blacklistMessage:new oe({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(r,"conversation-unblock-clients",t);case 5:return e.next=7,this._send(r);case 7:return n=e.sent,i=n.blacklistMessage,e.abrupt("return",ga(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.queryBlockedMembers=function(){var e=ye(de.mark((function e(){var t,r,n,i,o,s,a,u,c=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.limit,n=t.next,this._debug("query blocked: limit %O, next: %O",r,n),i=new ie({cmd:"blacklist",op:fe.query,blacklistMessage:new oe({srcCid:this.id,limit:r,next:n})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.blacklistMessage,a=s.blockedPids,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.toFullJSON=function(){var t=this.creator,r=this.system,n=this.transient,i=this.createdAt,o=this.updatedAt,s=this._attributes;return ya(ya({},e.prototype.toFullJSON.call(this)),{},{creator:t,system:r,transient:n,createdAt:hr(i),updatedAt:hr(o)},s)},r.toJSON=function(){var t=this.creator,r=this.system,n=this.transient,i=this.muted,o=this.mutedMembers,s=this.createdAt,a=this.updatedAt,u=this._attributes;return ya(ya({},e.prototype.toJSON.call(this)),{},{creator:t,system:r,transient:n,muted:i,mutedMembers:o,createdAt:s,updatedAt:a},u)},Bt(t,[{key:"createdAt",set:function(e){this._createdAt=lr(e)},get:function(){return this._createdAt}},{key:"updatedAt",set:function(e){this._updatedAt=lr(e)},get:function(){return this._updatedAt}},{key:"name",get:function(){return this.get("name")},set:function(e){this.set("name",e)}}]),t}(la),ba={OWNER:"Owner",MANAGER:"Manager",MEMBER:"Member"};Object.freeze(ba);var wa=function(){function e(e){var t=e.conversation,r=e.memberId,n=e.role;if(!t)throw new Error("conversation requried");if(!r)throw new Error("memberId requried");Object.assign(_r(this),{conversation:t,memberId:r,role:n})}return e.prototype.toJSON=function(){return{conversationId:this.conversationId,memberId:this.memberId,role:this.role,isOwner:this.isOwner}},Bt(e,[{key:"conversationId",get:function(){return _r(this).conversation.id}},{key:"memberId",get:function(){return _r(this).memberId}},{key:"role",get:function(){return this.isOwner?ba.OWNER:_r(this).role}},{key:"isOwner",get:function(){return this.memberId===_r(this).conversation.creator}}]),e}(),_a=function(e){function t(){return e.apply(this,arguments)||this}Ae(t,e);var r=t.prototype;return r._addMembers=function(t){var r=this;e.prototype._addMembers.call(this,t),this.members=vr(this.members,t);var n=_r(this).memberInfoMap;n&&t.forEach((function(e){n[e]=n[e]||new wa({conversation:r,memberId:e,role:ba.MEMBER})}))},r._removeMembers=function(t){e.prototype._removeMembers.call(this,t),this.members=br(this.members,t);var r=_r(this).memberInfoMap;r&&t.forEach((function(e){delete r[e]}))},r._fetchAllMemberInfo=function(){var e=ye(de.mark((function e(){var t,r,n,i=this;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._client._requestWithSessionToken({method:"GET",path:"/classes/_ConversationMemberInfo",query:{where:{cid:this.id}}});case 2:return t=e.sent,r=t.results.map((function(e){return new wa({conversation:i,memberId:e.clientId,role:e.role})})),n={},r.forEach((function(e){n[e.memberId]=e})),this.members.forEach((function(e){n[e]=n[e]||new wa({conversation:i,memberId:e,role:ba.MEMBER})})),_r(this).memberInfoMap=n,e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getAllMemberInfo=function(){var e=ye(de.mark((function e(){var t,r,n,i,o,s=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{},r=t.noCache,n=void 0!==r&&r,i=_r(this),(o=i.memberInfoMap)&&!n){e.next=6;break}return e.next=5,this._fetchAllMemberInfo();case 5:o=e.sent;case 6:return e.abrupt("return",this.members.map((function(e){return o[e]})));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.getMemberInfo=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1!==this.members.indexOf(t)){e.next=2;break}throw new Error("".concat(t," is not the mumber of conversation[").concat(this.id,"]"));case 2:if(r=_r(this),(n=r.memberInfoMap)&&n[t]){e.next=6;break}return e.next=6,this.getAllMemberInfo();case 6:return e.abrupt("return",_r(this).memberInfoMap[t]);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.updateMemberRole=function(){var e=ye(de.mark((function e(t,r){var n,i;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("update member role"),r!==ba.OWNER){e.next=3;break}throw qr({code:Yr.OWNER_PROMOTION_NOT_ALLOWED});case 3:return e.next=5,this._send(new ie({op:fe.member_info_update,convMessage:new Z({targetClientId:t,info:new ue({pid:t,role:r})})}));case 5:return n=_r(this),(i=n.memberInfos)&&i[t]&&(_r(i[t]).role=r),e.abrupt("return",this);case 8:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t}(va),Ea=function(e){function t(){return e.apply(this,arguments)||this}return Ae(t,e),t}(va),Ta=function(e){function t(){return e.apply(this,arguments)||this}Ae(t,e);var r=t.prototype;return r.subscribe=function(){var e=ye(de.mark((function e(){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.join());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.unsubscribe=function(){var e=ye(de.mark((function e(){return de.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}(va);function Oa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Sa(e){for(var t=1;t0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.withLastMessagesRefreshed=e,this},t.compact=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.compact=e,this},t.find=function(){var e=ye(de.mark((function e(){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._client._executeQuery(this));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.first=function(){var e=ye(de.mark((function e(){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.limit(1).find();case 2:return e.abrupt("return",e.sent[0]);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),ja=Re("LC:SessionManager"),Ra=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refresh,r=e.onBeforeGetSessionToken;this.refresh=t,this._onBeforeGetSessionToken=r,this.setSessionToken(null,0)}var t=e.prototype;return t.setSessionToken=function(e,t){ja("set session token",e,t);var r=new rr(e,1e3*t);return this._sessionToken=r,delete this._pendingSessionTokenPromise,r},t.setSessionTokenAsync=function(){var e=ye(de.mark((function e(t){var r,n=this;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sessionToken,this._pendingSessionTokenPromise=t.catch((function(e){throw n._sessionToken=r,e})),e.t0=this.setSessionToken,e.t1=this,e.t2=Ee,e.next=7,this._pendingSessionTokenPromise;case 7:return e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.abrupt("return",e.t0.apply.call(e.t0,e.t1,e.t4));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getSessionToken=function(){var e=ye(de.mark((function e(){var t,r,n,i,o,s,a,u,c=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{},r=t.autoRefresh,n=void 0===r||r,ja("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!==rr.EXPIRED||!n||!this.refresh){e.next=19;break}return ja("refresh expired session token"),e.next=15,this.setSessionTokenAsync(this.refresh(this,s));case 15:return a=e.sent,u=a.value,ja("session token",u),e.abrupt("return",u);case 19:return ja("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}();function Na(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function La(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Client id [".concat(t,"] is not a String"));if(r=e.call(this)||this,Object.assign(Se(r),{id:t,options:n},i),!r._messageParser)throw new Error("IMClient must be initialized with a MessageParser");return r._conversationCache=new ir("client:".concat(r.id)),r._ackMessageBuffer={},_r(Se(r)).lastPatchTime=Date.now(),_r(Se(r)).lastNotificationTime=void 0,_r(Se(r))._eventemitter=new pe,Fa.enabled&&jt(qs).forEach((function(e){return r.on(e,(function(){for(var t=arguments.length,n=new Array(t),i=0;i1?n-1:0),o=1;o3&&void 0!==E[3]&&E[3],this._debug("open session"),o=_r(this),s=o.lastUnreadNotifTime,a=o.lastPatchTime,u=o.lastNotificationTime,c=new ie({cmd:"session",op:"open",appId:t,peerId:this.id,sessionMessage:new z({ua:"js/".concat("5.0.0-rc.7"),r:i,lastUnreadNotifTime:s,lastPatchTime:a,configBitmap:187})}),i){e.next=13;break}if(Object.assign(c.sessionMessage,Tr({tag:r,deviceId:n})),!this.options.signatureFactory){e.next=11;break}return e.next=9,da(this.options.signatureFactory,[this._identity]);case 9:f=e.sent,Object.assign(c.sessionMessage,mr({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!==rr.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!==Yr.SESSION_TOKEN_EXPIRED){e.next=31;break}if(this._sessionManager){e.next=28;break}throw new Error("Unexpected session expiration");case 28:return Fa("Session token expired, reopening"),this._sessionManager.revoke(),e.abrupt("return",this._open(t,r,n,i));case 31:throw e.t0;case 32:if(d=(p=h).peerId,m=p.sessionMessage,y=p.sessionMessage,g=y.st,v=y.stTtl,b=y.code,w=p.serverTs,!b){e.next=35;break}throw qr(m);case 35:return d?(this.id=d,this._identity||(this._identity=d),g&&(this._sessionManager=this._sessionManager||this._createSessionManager(),this._sessionManager.setSessionToken(g,v)),_=hr(lr(w)),w&&(_r(this).lastPatchTime=_),u?this._syncNotifications(u).catch((function(e){return console.warn("Syncing notifications failed:",e)})):_r(this).lastNotificationTime=_):console.warn("Unexpected session opened without peerId."),e.abrupt("return",void 0);case 37:case"end":return e.stop()}}),e,this,[[17,23]])})));return function(t,r,n){return e.apply(this,arguments)}}(),r._syncNotifications=function(){var e=ye(de.mark((function e(t){var r,n,i=this;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchNotifications(t);case 2:if(r=e.sent,n=r.hasMore,r.notifications.forEach((function(e){var t=e.cmd,r=e.op,n=e.serverTs,o=e.notificationType,s=Oe(e,["cmd","op","serverTs","notificationType"]);i._dispatchCommand(N({cmd:ce[t],op:fe[r],serverTs:n,notificationType:o},"".concat(t,"Message"),s))})),!n){e.next=8;break}return e.abrupt("return",this._syncNotifications(_r(this).lastNotificationTime));case 8:return e.abrupt("return",void 0);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._fetchNotifications=function(){var e=ye(de.mark((function e(t){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._requestWithSessionToken({method:"GET",path:"/rtm/notifications",query:{start_ts:t,notification_type:"permanent"}}));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._createSessionManager=function(){var e=this;return Fa("create SessionManager"),new Ra({onBeforeGetSessionToken:this._connection.checkConnectionAvailability.bind(this._connection),refresh:function(t,r){return t.setSessionTokenAsync(Promise.resolve(new ie({cmd:"session",op:"refresh",sessionMessage:new z({ua:"js/".concat("5.0.0-rc.7"),st:r})})).then(function(){var t=ye(de.mark((function t(r){var n;return de.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.options.signatureFactory){t.next=5;break}return t.next=3,da(e.options.signatureFactory,[e._identity]);case 3:n=t.sent,Object.assign(r.sessionMessage,mr({signature:"s",timestamp:"t",nonce:"n"},n));case 5:return t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()).then(e._send.bind(e)).then((function(e){var t=e.sessionMessage;return[t.st,t.stTtl]})))}})},r._requestWithSessionToken=function(){var e=ye(de.mark((function e(t){var r,n,i,o;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.headers,n=t.query,i=Oe(t,["headers","query"]),e.next=3,this._sessionManager.getSessionToken();case 3:return o=e.sent,e.abrupt("return",this._request(La({headers:La({"X-LC-IM-Session-Token":o},r),query:La({client_id:this.id},n)},i)));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.close=function(){var e=ye(de.mark((function e(){var t,r;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("close session"),(t=_r(this)._eventemitter).emit("beforeclose"),!this._connection.is("connected")){e.next=7;break}return r=new ie({cmd:"session",op:"close"}),e.next=7,this._send(r);case 7:t.emit("close"),this.emit("close",{code:0});case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.ping=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("ping"),t instanceof Array){e.next=3;break}throw new TypeError("clientIds ".concat(t," is not an Array"));case 3:if(t.length){e.next=5;break}return e.abrupt("return",Promise.resolve([]));case 5:return r=new ie({cmd:"session",op:"query",sessionMessage:new z({sessionPeerIds:t})}),e.next=8,this._send(r);case 8:return n=e.sent,e.abrupt("return",n.sessionMessage.onlineSessionPeerIds);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getConversation=function(){var e=ye(de.mark((function e(t){var r,n,i=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],"string"==typeof t){e.next=3;break}throw new TypeError("".concat(t," is not a String"));case 3:if(r){e.next=7;break}if(!(n=this._conversationCache.get(t))){e.next=7;break}return e.abrupt("return",n);case 7:if(!Ua(t)){e.next=14;break}return e.next=10,this._getTemporaryConversations([t]);case 10:if(e.t0=e.sent[0],e.t0){e.next=13;break}e.t0=null;case 13:return e.abrupt("return",e.t0);case 14:return e.abrupt("return",this.getQuery().equalTo("objectId",t).find().then((function(e){return e[0]||null})));case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getConversations=function(){var e=ye(de.mark((function e(t){var r,n,i,o,s,a=this,u=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>1&&void 0!==u[1]&&u[1],!(n=r?t:t.filter((function(e){return null===a._conversationCache.get(e)}))).length){e.next=9;break}return i=Fo(n,Ua),o=[],n.length&&o.push(this.getQuery().containedIn("objectId",n).limit(999).find()),i.length&&(s=i.map(this._getTemporaryConversations.bind(this)),o.push.apply(o,Ee(s))),e.next=9,Promise.all(o);case 9:return e.abrupt("return",t.map((function(e){return a._conversationCache.get(e)})));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._getTemporaryConversations=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new ie({cmd:"conv",op:"query",convMessage:new Z({tempConvIds:t})}),e.next=3,this._send(r);case 3:return n=e.sent,e.abrupt("return",this._handleQueryResults(n));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.getQuery=function(){return new Ma(this)},r.getChatRoomQuery=function(){return this.getQuery().equalTo("tr",!0)},r.getServiceConversationQuery=function(){return this.getQuery().equalTo("sys",!0)},r._executeQuery=function(){var e=ye(de.mark((function e(t){var r,n,i;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=t.toJSON()).where=new B({data:JSON.stringify(dr(r.where))}),n=new ie({cmd:"conv",op:"query",convMessage:new Z(r)}),e.next=5,this._send(n);case 5:return i=e.sent,e.abrupt("return",this._handleQueryResults(i));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._handleQueryResults=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,r=pr(JSON.parse(t.convMessage.results.data)),e.next=8;break;case 4:throw e.prev=4,e.t0=e.catch(0),n=JSON.stringify(Tr(t)),new Error("Parse query result failed: ".concat(e.t0.message,". Command: ").concat(n));case 8:return e.next=10,Promise.all(r.map(this._parseConversationFromRawData.bind(this)));case 10:return r=e.sent,e.abrupt("return",r.map(this._upsertConversationToCache.bind(this)));case 12:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(t){return e.apply(this,arguments)}}(),r._upsertConversationToCache=function(e){var t=this._conversationCache.get(e.id);return t?(this._debug("update cached conversation"),["creator","createdAt","updatedAt","lastMessageAt","lastMessage","mutedMembers","members","_attributes","transient","muted"].forEach((function(r){var n=e[r];void 0!==n&&(t[r]=n)})),t._reset&&t._reset()):(t=e,this._debug("no match, set cache"),this._conversationCache.set(e.id,e)),t},r.parseMessage=function(){var e=ye(de.mark((function e(t){var r,n,i,o,s,a;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=t.bin,i=void 0!==n&&n,o=Oe(t,["data","bin"]),s=i?vn(r):r,e.next=4,this._messageParser.parse(s);case 4:return a=e.sent,Object.assign(a,o),a._updateMentioned(this.id),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.parseConversation=function(){var e=ye(de.mark((function e(t){var r,n,i,o,s,a,u,c,f,l,h,p,d;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.id,n=t.lastMessageAt,i=t.lastMessage,o=t.lastDeliveredAt,s=t.lastReadAt,a=t.unreadMessagesCount,u=t.members,c=t.mentioned,f=Oe(t,["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"]),l={id:r,lastMessageAt:n,lastMessage:i,lastDeliveredAt:o,lastReadAt:s,unreadMessagesCount:a,members:u,mentioned:c},!i){e.next=7;break}return e.next=5,this.parseMessage(i);case 5:l.lastMessage=e.sent,l.lastMessage._setStatus($s.SENT);case 7:if(h=f.transient,p=f.system,d=f.expiredAt,!h){e.next=10;break}return e.abrupt("return",new Ea(l,f,this));case 10:if(!p){e.next=12;break}return e.abrupt("return",new Ta(l,f,this));case 12:if(!d&&!Ua(r)){e.next=14;break}return e.abrupt("return",new ka(l,{expiredAt:d},this));case 14:return e.abrupt("return",new _a(l,f,this));case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._parseConversationFromRawData=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=mr({objectId:"id",lm:"lastMessageAt",m:"members",tr:"transient",sys:"system",c:"creator",mu:"mutedMembers"},t)).msg&&(r.lastMessage={data:r.msg,bin:r.bin,from:r.msg_from,id:r.msg_mid,timestamp:r.msg_timestamp,updatedAt:r.patch_timestamp},delete r.lastMessageFrom,delete r.lastMessageId,delete r.lastMessageTimestamp,delete r.lastMessagePatchTimestamp),(n=r.ttl)&&(r.expiredAt=Date.now()+1e3*n),e.abrupt("return",this.parseConversation(r));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.createConversation=function(){var e=ye(de.mark((function e(){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,m,y,g,v,b,w,_,E=arguments;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=E.length>0&&void 0!==E[0]?E[0]:{},r=t.members,n=t.name,i=t.transient,o=t.unique,s=void 0===o||o,a=t._tempConv,u=t._tempConvTTL,c=Oe(t,["members","name","transient","unique","_tempConv","_tempConvTTL"]),i||Array.isArray(r)){e.next=3;break}throw new TypeError("conversation members ".concat(r," is not an array"));case 3:if((f=new Set(r)).add(this.id),f=Array.from(f).sort(),l=c||{},!n){e.next=11;break}if("string"==typeof n){e.next=10;break}throw new TypeError("conversation name ".concat(n," is not a string"));case 10:l.name=n;case 11:if(l=new B({data:JSON.stringify(dr(l))}),h=new ie({cmd:"conv",op:"start",convMessage:new Z({m:f,attr:l,transient:i,unique:s,tempConv:a,tempConvTTL:u})}),!this.options.conversationSignatureFactory){e.next=20;break}return p=[null,this._identity,f,"create"],e.next=18,da(this.options.conversationSignatureFactory,p);case 18:d=e.sent,Object.assign(h.convMessage,mr({signature:"s",timestamp:"t",nonce:"n"},d));case 20:return e.next=22,this._send(h);case 22:return m=e.sent,y=m.convMessage,g=y.cid,v=y.cdate,b=y.tempConvTTL,w=La({name:n,transient:i,unique:s,id:g,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)}}(),r.createChatRoom=function(){var e=ye(de.mark((function e(t){return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.createConversation(La(La({},t),{},{transient:!0,members:null,unique:!1,_tempConv:!1})));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.createTemporaryConversation=function(){var e=ye(de.mark((function e(t){var r,n;return de.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.ttl,n=Oe(t,["ttl"]),e.abrupt("return",this.createConversation(La(La({},n),{},{_tempConv:!0,_tempConvTTL:r})));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._doSendRead=function(){var e=this;if(this._connection.is("connected")){var t=_r(this).readConversationsBuffer,r=Array.from(t);if(r.length){var n=r.map((function(e){if(!(e instanceof la))throw new TypeError("".concat(e," is not a Conversation"));return e.id}));this._debug("mark [".concat(n,"] as read")),t.clear(),this._sendReadCommand(r).catch((function(n){e._debug("send read failed: %O",n),r.forEach(t.add.bind(t))}))}}},r._sendReadCommand=function(e){var t=this;return this._send(new ie({cmd:"read",readMessage:new te({convs:e.map((function(e){return new K({cid:e.id,mid:e.lastMessage&&e.lastMessage.from!==t.id?e.lastMessage.id:void 0,timestamp:(e.lastMessageAt||new Date).getTime()})}))})}),!1)},t}(pe)).prototype,"_doSendAck",[Aa],Object.getOwnPropertyDescriptor(Ca.prototype,"_doSendAck"),Ca.prototype),Vt(Ca.prototype,"_doSendRead",[Ia],Object.getOwnPropertyDescriptor(Ca.prototype,"_doSendRead"),Ca.prototype),Ca),Va=Object.freeze({__proto__:null,RECONNECT_ERROR:"reconnecterror",DISCONNECT:Mr,RECONNECT:jr,RETRY:Rr,SCHEDULE:Nr,OFFLINE:Lr,ONLINE:Dr});function Ya(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function qa(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:"";if("string"!=typeof r)throw new TypeError("".concat(r," is not a string"));return(t=e.call(this)||this).setText(r),t}return Ae(t,e),t}(ra))||za)||za;function Ja(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Za(e){for(var t=1;t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function Xa(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==arguments[0]?arguments[0]:{};this._plugins=e,this._messageClasses=[],this.register(e.messageClasses)}var t=e.prototype;return t.register=function(e){var t=this;Or(e).map((function(e){return t._register(e)}))},t._register=function(e){if(!(e&&e.parse&&e.prototype&&e.prototype.getPayload))throw new TypeError("Invalid messageClass");this._messageClasses.unshift(e)},t.parse=function(e){Qa("parsing message: %O",e);var t,r=Ha(this._messageClasses);try{for(r.s();!(t=r.n()).done;){var n=t.value,i=Qt(e)?Za({},e):e,o=void 0,s=void 0;try{o=n.validate(i)}catch(e){}if(o){try{s=n.parse(i)}catch(e){console.warn("parsing a valid message content error",{error:e,Klass:n,content:i})}if(void 0!==s)return Qa("parse result: %O",s),s}}}catch(e){r.e(e)}finally{r.f()}throw new Error("No Message Class matched")},e}()).prototype,"parse",[function(e,t,r){var n=r.value;r.value=function(e){var t;if("string"!=typeof e)t=e;else try{t=JSON.parse(e)}catch(r){t=e}return n.call(this,t)}},function(e,t,r){var n=r.value;r.value=function(e){var t=this;return Promise.resolve(e).then(Kr(this._plugins.beforeMessageParse)).then((function(e){return n.call(t,e)})).then(Kr(this._plugins.afterMessageParse))}}],Object.getOwnPropertyDescriptor(Wa.prototype,"parse"),Wa.prototype),Wa);function eu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function tu(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{get:function(){return this.get(e)},set:function(t){this.set(e,t)}};Object.defineProperty(_a.prototype,e,t)},ou={name:"leancloud-realtime-plugin-im",onRealtimeCreate:function(e){var t=pn();e._IMClients={},e._IMClientsCreationCount=0;var r=new Ka(e._plugins);e._messageParser=r;var n=function(){var t=ye(de.mark((function t(r){return de.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._request({method:"POST",path:"/rtm/sign",data:{session_token:r.getSessionToken()}}));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),i=r.register.bind(r),o=function(){var i=ye(de.mark((function i(o){var s,a,u,c,f,l,h,p,d,m,y=arguments;return de.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=y.length>1&&void 0!==y[1]?y[1]:{},u=a.tag,c=a.isReconnect,f=Oe(a,["tag","isReconnect"]),l=y.length>2?y[2]:void 0,p={},!o){i.next=19;break}if("string"!=typeof o){i.next=8;break}h=o,i.next=17;break;case 8:if(!o.id||!o.getSessionToken){i.next=16;break}if(h=o.id,o.getSessionToken()){i.next=13;break}throw new Error("User must be authenticated");case 13:p.signatureFactory=n,i.next=17;break;case 16:throw new TypeError("Identity must be a String or an AV.User");case 17:if(void 0===e._IMClients[h]){i.next=19;break}return i.abrupt("return",e._IMClients[h]);case 19:return l&&console.warn("DEPRECATION createIMClient tag param: Use options.tag instead."),d=u||l,m=(s=e._open().then((function(n){var i=new Ba(h,tu(tu({},p),f),{_connection:n,_request:e._request.bind(e),_messageParser:r,_plugins:e._plugins,_identity:o});return n.on(jr,(function(){return i._open(e._options.appId,d,t,!0).then((function(){return i.emit(jr)}),(function(e){return i.emit("reconnecterror",e)}))})),_r(i)._eventemitter.on("beforeclose",(function(){delete e._IMClients[i.id],e._firstIMClient===i&&delete e._firstIMClient}),e),_r(i)._eventemitter.on("close",(function(){e._deregister(i)}),e),i._open(e._options.appId,d,t,c).then((function(){return e._IMClients[i.id]=i,e._IMClientsCreationCount+=1,1===e._IMClientsCreationCount?(i._omitPeerId(!0),e._firstIMClient=i):e._IMClientsCreationCount>1&&e._firstIMClient&&e._firstIMClient._omitPeerId(!1),e._register(i),i})).catch((function(t){throw delete e._IMClients[i.id],t}))}))).then.apply(s,Ee(fr((function(){e._deregisterPending(m)})))).catch((function(t){throw delete e._IMClients[h],t})),o&&(e._IMClients[h]=m),e._registerPending(m),i.abrupt("return",m);case 25:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}();Object.assign(e,{register:i,createIMClient:o})},beforeCommandDispatch:function(e,t){if(!(null===e.service||2===e.service))return!0;var r=e.peerId?t._IMClients[e.peerId]:t._firstIMClient;return r?Promise.resolve(r).then((function(t){return t._dispatchCommand(e)})).catch(ru):ru("[WARN] Unexpected message received without any live client match: %O",Tr(e)),!1},messageClasses:[Zs,$a,na,Ga]};function su(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function au(e){for(var t=1;t