35 | !function(t,n){e&&e.exports?e.exports=n(d,!0):(t.dcodeIO=t.dcodeIO||{}).ProtoBuf=n(t.dcodeIO.ByteBuffer)}(r,(function(e,n){var r,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=((r={}).IS_NODE=!("object"!=typeof t||t+""!="[object process]"||t.browser),r.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,n=0;n<e.length;n++){try{t=e[n]()}catch(e){continue}break}if(!t)throw Error("XMLHttpRequest is not supported");return t},r.fetch=function(e,t){if(t&&"function"!=typeof t&&(t=null),r.IS_NODE){var n=m;if(t)n.readFile(e,(function(e,n){t(e?null:""+n)}));else try{return n.readFileSync(e)}catch(e){return null}}else{var i=r.XHR();if(i.open("GET",e,!!t),i.setRequestHeader("Accept","text/plain"),"function"==typeof i.overrideMimeType&&i.overrideMimeType("text/plain"),!t)return i.send(null),200==i.status||0==i.status&&"string"==typeof i.responseText?i.responseText:null;if(i.onreadystatechange=function(){4==i.readyState&&(200==i.status||0==i.status&&"string"==typeof i.responseText?t(i.responseText):t(null))},4==i.readyState)return;i.send(null)}},r.toCamelCase=function(e){return e.replace(/_([a-zA-Z])/g,(function(e,t){return t.toUpperCase()}))},r),i.Lang={DELIM:/[\s\{\}=;:\[\],'"\(\)<>]/g,RULE:/^(?:required|optional|repeated|map)$/,TYPE:/^(?:double|float|int32|uint32|sint32|int64|uint64|sint64|fixed32|sfixed32|fixed64|sfixed64|bool|string|bytes)$/,NAME:/^[a-zA-Z_][a-zA-Z_0-9]*$/,TYPEDEF:/^[a-zA-Z][a-zA-Z_0-9]*$/,TYPEREF:/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,FQTYPEREF:/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/,NUMBER:/^-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+|([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?)|inf|nan)$/,NUMBER_DEC:/^(?:[1-9][0-9]*|0)$/,NUMBER_HEX:/^0[xX][0-9a-fA-F]+$/,NUMBER_OCT:/^0[0-7]+$/,NUMBER_FLT:/^([0-9]*(\.[0-9]*)?([Ee][+-]?[0-9]+)?|inf|nan)$/,BOOL:/^(?:true|false)$/i,ID:/^(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,NEGID:/^\-?(?:[1-9][0-9]*|0|0[xX][0-9a-fA-F]+|0[0-7]+)$/,WHITESPACE:/\s/,STRING:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")|(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,STRING_DQ:/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,STRING_SQ:/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g},i.Reflect=function(t){var n={},r=function(e,t,n){this.builder=e,this.parent=t,this.name=n,this.className},i=r.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")},n.T=r;var o=function(e,t,n,i,o){r.call(this,e,t,n),this.className="Namespace",this.children=[],this.options=i||{},this.syntax=o||"proto2"},s=o.prototype=Object.create(r.prototype);s.getChildren=function(e){if(null==(e=e||null))return this.children.slice();for(var t=[],n=0,r=this.children.length;n<r;++n)this.children[n]instanceof e&&t.push(this.children[n]);return t},s.addChild=function(e){var t;if(t=this.getChild(e.name))if(t instanceof f.Field&&t.name!==t.originalName&&null===this.getChild(t.originalName))t.name=t.originalName;else{if(!(e instanceof f.Field&&e.name!==e.originalName&&null===this.getChild(e.originalName)))throw Error("Duplicate name in namespace "+this.toString(!0)+": "+e.name);e.name=e.originalName}this.children.push(e)},s.getChild=function(e){for(var t="number"==typeof e?"id":"name",n=0,r=this.children.length;n<r;++n)if(this.children[n][t]===e)return this.children[n];return null},s.resolve=function(e,t){var r,i="string"==typeof e?e.split("."):e,o=this,s=0;if(""===i[s]){for(;null!==o.parent;)o=o.parent;s++}do{do{if(!(o instanceof n.Namespace)){o=null;break}if(!(r=o.getChild(i[s]))||!(r instanceof n.T)||t&&!(r instanceof n.Namespace)){o=null;break}o=r,s++}while(s<i.length);if(null!=o)break;if(null!==this.parent)return this.parent.resolve(e,t)}while(null!=o);return o},s.qn=function(e){var t=[],r=e;do{t.unshift(r.name),r=r.parent}while(null!==r);for(var i=1;i<=t.length;i++){var o=t.slice(t.length-i);if(e===this.resolve(o,e instanceof n.Namespace))return o.join(".")}return e.fqn()},s.build=function(){for(var e,t={},n=this.children,r=0,i=n.length;r<i;++r)(e=n[r])instanceof o&&(t[e.name]=e.build());return Object.defineProperty&&Object.defineProperty(t,"$options",{value:this.buildOpt()}),t},s.buildOpt=function(){for(var e={},t=Object.keys(this.options),n=0,r=t.length;n<r;++n){var i=t[n],o=this.options[t[n]];e[i]=o}return e},s.getOption=function(e){return void 0===e?this.options:void 0!==this.options[e]?this.options[e]:null},n.Namespace=o;var a=function(e,n,r,i,o){if(this.type=e,this.resolvedType=n,this.isMapKey=r,this.syntax=i,this.name=o,r&&t.MAP_KEY_TYPES.indexOf(e)<0)throw Error("Invalid map key type: "+e.name)},u=a.prototype;function c(e,n){if(e&&"number"==typeof e.low&&"number"==typeof e.high&&"boolean"==typeof e.unsigned&&e.low==e.low&&e.high==e.high)return new t.Long(e.low,e.high,void 0===n?e.unsigned:n);if("string"==typeof e)return t.Long.fromString(e,n||!1,10);if("number"==typeof e)return t.Long.fromNumber(e,n||!1);throw Error("not convertible to Long")}a.defaultFieldValue=function(n){if("string"==typeof n&&(n=t.TYPES[n]),void 0===n.defaultValue)throw Error("default value for type "+n.name+" is not supported");return n==t.TYPES.bytes?new e(0):n.defaultValue},u.toString=function(){return(this.name||"")+(this.isMapKey?"map":"value")+" element"},u.verifyValue=function(n){var r=this;function i(e,t){throw Error("Illegal value for "+r.toString(!0)+" of type "+r.type.name+": "+e+" ("+t+")")}switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:return("number"!=typeof n||n==n&&n%1!=0)&&i(typeof n,"not an integer"),n>4294967295?0|n:n;case t.TYPES.uint32:case t.TYPES.fixed32:return("number"!=typeof n||n==n&&n%1!=0)&&i(typeof n,"not an integer"),n<0?n>>>0:n;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:if(t.Long)try{return c(n,!1)}catch(e){i(typeof n,e.message)}else i(typeof n,"requires Long.js");case t.TYPES.uint64:case t.TYPES.fixed64:if(t.Long)try{return c(n,!0)}catch(e){i(typeof n,e.message)}else i(typeof n,"requires Long.js");case t.TYPES.bool:return"boolean"!=typeof n&&i(typeof n,"not a boolean"),n;case t.TYPES.float:case t.TYPES.double:return"number"!=typeof n&&i(typeof n,"not a number"),n;case t.TYPES.string:return"string"==typeof n||n&&n instanceof String||i(typeof n,"not a string"),""+n;case t.TYPES.bytes:return e.isByteBuffer(n)?n:e.wrap(n,"base64");case t.TYPES.enum:var o=this.resolvedType.getChildren(t.Reflect.Enum.Value);for(a=0;a<o.length;a++){if(o[a].name==n)return o[a].id;if(o[a].id==n)return o[a].id}if("proto3"===this.syntax)return("number"!=typeof n||n==n&&n%1!=0)&&i(typeof n,"not an integer"),(n>4294967295||n<0)&&i(typeof n,"not in range for uint32"),n;i(n,"not a valid enum value");case t.TYPES.group:case t.TYPES.message:if(n&&"object"==typeof n||i(typeof n,"object expected"),n instanceof this.resolvedType.clazz)return n;if(n instanceof t.Builder.Message){var s={};for(var a in n)n.hasOwnProperty(a)&&(s[a]=n[a]);n=s}return new this.resolvedType.clazz(n)}throw Error("[INTERNAL] Illegal value for "+this.toString(!0)+": "+n+" (undefined type "+this.type+")")},u.calculateLength=function(n,r){if(null===r)return 0;var i;switch(this.type){case t.TYPES.int32:return r<0?e.calculateVarint64(r):e.calculateVarint32(r);case t.TYPES.uint32:return e.calculateVarint32(r);case t.TYPES.sint32:return e.calculateVarint32(e.zigZagEncode32(r));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(r);case t.TYPES.sint64:return e.calculateVarint64(e.zigZagEncode64(r));case t.TYPES.fixed64:case t.TYPES.sfixed64:return 8;case t.TYPES.bool:return 1;case t.TYPES.enum:return e.calculateVarint32(r);case t.TYPES.double:return 8;case t.TYPES.string:return i=e.calculateUTF8Bytes(r),e.calculateVarint32(i)+i;case t.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");return e.calculateVarint32(r.remaining())+r.remaining();case t.TYPES.message:return i=this.resolvedType.calculate(r),e.calculateVarint32(i)+i;case t.TYPES.group:return(i=this.resolvedType.calculate(r))+e.calculateVarint32(n<<3|t.WIRE_TYPES.ENDGROUP)}throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")},u.encodeValue=function(n,r,i){if(null===r)return i;switch(this.type){case t.TYPES.int32:r<0?i.writeVarint64(r):i.writeVarint32(r);break;case t.TYPES.uint32:i.writeVarint32(r);break;case t.TYPES.sint32:i.writeVarint32ZigZag(r);break;case t.TYPES.fixed32:i.writeUint32(r);break;case t.TYPES.sfixed32:i.writeInt32(r);break;case t.TYPES.int64:case t.TYPES.uint64:i.writeVarint64(r);break;case t.TYPES.sint64:i.writeVarint64ZigZag(r);break;case t.TYPES.fixed64:i.writeUint64(r);break;case t.TYPES.sfixed64:i.writeInt64(r);break;case t.TYPES.bool:"string"==typeof r?i.writeVarint32("false"===r.toLowerCase()?0:!!r):i.writeVarint32(r?1:0);break;case t.TYPES.enum:i.writeVarint32(r);break;case t.TYPES.float:i.writeFloat32(r);break;case t.TYPES.double:i.writeFloat64(r);break;case t.TYPES.string:i.writeVString(r);break;case t.TYPES.bytes:if(r.remaining()<0)throw Error("Illegal value for "+this.toString(!0)+": "+r.remaining()+" bytes remaining");var o=r.offset;i.writeVarint32(r.remaining()),i.append(r),r.offset=o;break;case t.TYPES.message:var s=(new e).LE();this.resolvedType.encode(r,s),i.writeVarint32(s.offset),i.append(s.flip());break;case t.TYPES.group:this.resolvedType.encode(r,i),i.writeVarint32(n<<3|t.WIRE_TYPES.ENDGROUP);break;default:throw Error("[INTERNAL] Illegal value to encode in "+this.toString(!0)+": "+r+" (unknown type)")}return i},u.decode=function(e,n,r){if(n!=this.type.wireType)throw Error("Unexpected wire type for element");var i,o;switch(this.type){case t.TYPES.int32:return 0|e.readVarint32();case t.TYPES.uint32:return e.readVarint32()>>>0;case t.TYPES.sint32:return 0|e.readVarint32ZigZag();case t.TYPES.fixed32:return e.readUint32()>>>0;case t.TYPES.sfixed32:return 0|e.readInt32();case t.TYPES.int64:return e.readVarint64();case t.TYPES.uint64:return e.readVarint64().toUnsigned();case t.TYPES.sint64:return e.readVarint64ZigZag();case t.TYPES.fixed64:return e.readUint64();case t.TYPES.sfixed64:return e.readInt64();case t.TYPES.bool:return!!e.readVarint32();case t.TYPES.enum:return e.readVarint32();case t.TYPES.float:return e.readFloat();case t.TYPES.double:return e.readDouble();case t.TYPES.string:return e.readVString();case t.TYPES.bytes:if(o=e.readVarint32(),e.remaining()<o)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+o+" required but got only "+e.remaining());return(i=e.clone()).limit=i.offset+o,e.offset+=o,i;case t.TYPES.message:return o=e.readVarint32(),this.resolvedType.decode(e,o);case t.TYPES.group:return this.resolvedType.decode(e,-1,r)}throw Error("[INTERNAL] Illegal decode type")},u.valueFromString=function(n){if(!this.isMapKey)throw Error("valueFromString() called on non-map-key element");switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:case t.TYPES.uint32:case t.TYPES.fixed32:return this.verifyValue(parseInt(n));case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:case t.TYPES.uint64:case t.TYPES.fixed64:return this.verifyValue(n);case t.TYPES.bool:return"true"===n;case t.TYPES.string:return this.verifyValue(n);case t.TYPES.bytes:return e.fromBinary(n)}},u.valueToString=function(e){if(!this.isMapKey)throw Error("valueToString() called on non-map-key element");return this.type===t.TYPES.bytes?e.toString("binary"):e.toString()},n.Element=a;var f=function(e,t,n,r,i,s){o.call(this,e,t,n,r,s),this.className="Message",this.extensions=void 0,this.clazz=null,this.isGroup=!!i,this._fields=null,this._fieldsById=null,this._fieldsByName=null},l=f.prototype=Object.create(o.prototype);function h(e,n){var r=n.readVarint32(),i=7&r,o=r>>>3;switch(i){case t.WIRE_TYPES.VARINT:do{r=n.readUint8()}while(128==(128&r));break;case t.WIRE_TYPES.BITS64:n.offset+=8;break;case t.WIRE_TYPES.LDELIM:r=n.readVarint32(),n.offset+=r;break;case t.WIRE_TYPES.STARTGROUP:h(o,n);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:n.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+e+": "+i)}return!0}l.build=function(n){if(this.clazz&&!n)return this.clazz;var r=function(t,n){var r=n.getChildren(t.Reflect.Message.Field),i=n.getChildren(t.Reflect.Message.OneOf),o=function(s,a){t.Builder.Message.call(this);for(var u=0,c=i.length;u<c;++u)this[i[u].name]=null;for(u=0,c=r.length;u<c;++u){var f=r[u];this[f.name]=f.repeated?[]:f.map?new t.Map(f):null,!f.required&&"proto3"!==n.syntax||null===f.defaultValue||(this[f.name]=f.defaultValue)}var l;if(arguments.length>0)if(1!==arguments.length||null===s||"object"!=typeof s||!("function"!=typeof s.encode||s instanceof o)||Array.isArray(s)||s instanceof t.Map||e.isByteBuffer(s)||s instanceof ArrayBuffer||t.Long&&s instanceof t.Long)for(u=0,c=arguments.length;u<c;++u)void 0!==(l=arguments[u])&&this.$set(r[u].name,l);else this.$set(s)},s=o.prototype=Object.create(t.Builder.Message.prototype);s.add=function(e,r,i){var o=n._fieldsByName[e];if(!i){if(!o)throw Error(this+"#"+e+" is undefined");if(!(o instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+o.toString(!0));if(!o.repeated)throw Error(this+"#"+e+" is not a repeated field");r=o.verifyValue(r,!0)}return null===this[e]&&(this[e]=[]),this[e].push(r),this},s.$add=s.add,s.set=function(e,r,i){if(e&&"object"==typeof e){for(var o in i=r,e)e.hasOwnProperty(o)&&void 0!==(r=e[o])&&void 0===n._oneofsByName[o]&&this.$set(o,r,i);return this}var s=n._fieldsByName[e];if(i)this[e]=r;else{if(!s)throw Error(this+"#"+e+" is not a field: undefined");if(!(s instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+s.toString(!0));this[s.name]=r=s.verifyValue(r)}if(s&&s.oneof){var a=this[s.oneof.name];null!==r?(null!==a&&a!==s.name&&(this[a]=null),this[s.oneof.name]=s.name):a===e&&(this[s.oneof.name]=null)}return this},s.$set=s.set,s.get=function(e,r){if(r)return this[e];var i=n._fieldsByName[e];if(!(i&&i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: undefined");if(!(i instanceof t.Reflect.Message.Field))throw Error(this+"#"+e+" is not a field: "+i.toString(!0));return this[i.name]},s.$get=s.get;for(var a=0;a<r.length;a++){var u=r[a];u instanceof t.Reflect.Message.ExtensionField||n.builder.options.populateAccessors&&function(e){var t=e.originalName.replace(/(_[a-zA-Z])/g,(function(e){return e.toUpperCase().replace("_","")}));t=t.substring(0,1).toUpperCase()+t.substring(1);var r=e.originalName.replace(/([A-Z])/g,(function(e){return"_"+e})),i=function(t,n){return this[e.name]=n?t:e.verifyValue(t),this},o=function(){return this[e.name]};null===n.getChild("set"+t)&&(s["set"+t]=i),null===n.getChild("set_"+r)&&(s["set_"+r]=i),null===n.getChild("get"+t)&&(s["get"+t]=o),null===n.getChild("get_"+r)&&(s["get_"+r]=o)}(u)}function c(n,r,i,o){if(null===n||"object"!=typeof n){if(o&&o instanceof t.Reflect.Enum){var s=t.Reflect.Enum.getName(o.object,n);if(null!==s)return s}return n}if(e.isByteBuffer(n))return r?n.toBase64():n.toBuffer();if(t.Long.isLong(n))return i?n.toString():t.Long.fromValue(n);var a;if(Array.isArray(n))return a=[],n.forEach((function(e,t){a[t]=c(e,r,i,o)})),a;if(a={},n instanceof t.Map){for(var u=n.entries(),f=u.next();!f.done;f=u.next())a[n.keyElem.valueToString(f.value[0])]=c(f.value[1],r,i,n.valueElem.resolvedType);return a}var l=n.$type,h=void 0;for(var p in n)n.hasOwnProperty(p)&&(l&&(h=l.getChild(p))?a[p]=c(n[p],r,i,h.resolvedType):a[p]=c(n[p],r,i));return a}return s.encode=function(t,r){"boolean"==typeof t&&(r=t,t=void 0);var i=!1;t||(t=new e,i=!0);var o=t.littleEndian;try{return n.encode(this,t.LE(),r),(i?t.flip():t).LE(o)}catch(e){throw t.LE(o),e}},o.encode=function(e,t,n){return new o(e).encode(t,n)},s.calculate=function(){return n.calculate(this)},s.encodeDelimited=function(t,r){var i=!1;t||(t=new e,i=!0);var o=(new e).LE();return n.encode(this,o,r).flip(),t.writeVarint32(o.remaining()),t.append(o),i?t.flip():t},s.encodeAB=function(){try{return this.encode().toArrayBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toArrayBuffer()),e}},s.toArrayBuffer=s.encodeAB,s.encodeNB=function(){try{return this.encode().toBuffer()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBuffer()),e}},s.toBuffer=s.encodeNB,s.encode64=function(){try{return this.encode().toBase64()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toBase64()),e}},s.toBase64=s.encode64,s.encodeHex=function(){try{return this.encode().toHex()}catch(e){throw e.encoded&&(e.encoded=e.encoded.toHex()),e}},s.toHex=s.encodeHex,s.toRaw=function(e,t){return c(this,!!e,!!t,this.$type)},s.encodeJSON=function(){return JSON.stringify(c(this,!0,!0,this.$type))},o.decode=function(t,r,i){"string"==typeof r&&(i=r,r=-1),"string"==typeof t?t=e.wrap(t,i||"base64"):e.isByteBuffer(t)||(t=e.wrap(t));var o=t.littleEndian;try{var s=n.decode(t.LE(),r);return t.LE(o),s}catch(e){throw t.LE(o),e}},o.decodeDelimited=function(t,r){if("string"==typeof t?t=e.wrap(t,r||"base64"):e.isByteBuffer(t)||(t=e.wrap(t)),t.remaining()<1)return null;var i=t.offset,o=t.readVarint32();if(t.remaining()<o)return t.offset=i,null;try{var s=n.decode(t.slice(t.offset,t.offset+o).LE());return t.offset+=o,s}catch(e){throw t.offset+=o,e}},o.decode64=function(e){return o.decode(e,"base64")},o.decodeHex=function(e){return o.decode(e,"hex")},o.decodeJSON=function(e){return new o(JSON.parse(e))},s.toString=function(){return n.toString()},Object.defineProperty&&(Object.defineProperty(o,"$options",{value:n.buildOpt()}),Object.defineProperty(s,"$options",{value:o.$options}),Object.defineProperty(o,"$type",{value:n}),Object.defineProperty(s,"$type",{value:n})),o}(t,this);this._fields=[],this._fieldsById={},this._fieldsByName={},this._oneofsByName={};for(var i,o=0,s=this.children.length;o<s;o++)if((i=this.children[o])instanceof g||i instanceof f||i instanceof b){if(r.hasOwnProperty(i.name))throw Error("Illegal reflect child of "+this.toString(!0)+": "+i.toString(!0)+" cannot override static property '"+i.name+"'");r[i.name]=i.build()}else if(i instanceof f.Field)i.build(),this._fields.push(i),this._fieldsById[i.id]=i,this._fieldsByName[i.name]=i;else if(i instanceof f.OneOf)this._oneofsByName[i.name]=i;else if(!(i instanceof f.OneOf||i instanceof v))throw Error("Illegal reflect child of "+this.toString(!0)+": "+this.children[o].toString(!0));return this.clazz=r},l.encode=function(e,t,n){for(var r,i,o=null,s=0,a=this._fields.length;s<a;++s)i=e[(r=this._fields[s]).name],r.required&&null===i?null===o&&(o=r):r.encode(n?i:r.verifyValue(i),t,e);if(null!==o){var u=Error("Missing at least one required field for "+this.toString(!0)+": "+o);throw u.encoded=t,u}return t},l.calculate=function(e){for(var t,n,r=0,i=0,o=this._fields.length;i<o;++i){if(n=e[(t=this._fields[i]).name],t.required&&null===n)throw Error("Missing at least one required field for "+this.toString(!0)+": "+t);r+=t.calculate(n,e)}return r},l.decode=function(e,n,r){"number"!=typeof n&&(n=-1);for(var i,o,s,a,u=e.offset,c=new this.clazz;e.offset<u+n||-1===n&&e.remaining()>0;){if(s=(i=e.readVarint32())>>>3,(o=7&i)===t.WIRE_TYPES.ENDGROUP){if(s!==r)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+s+" ("+(r?r+" expected":"not a group")+")");break}if(a=this._fieldsById[s]){if(a.repeated&&!a.options.packed)c[a.name].push(a.decode(o,e));else if(a.map){var f=a.decode(o,e);c[a.name].set(f[0],f[1])}else if(c[a.name]=a.decode(o,e),a.oneof){var l=c[a.oneof.name];null!==l&&l!==a.name&&(c[l]=null),c[a.oneof.name]=a.name}}else switch(o){case t.WIRE_TYPES.VARINT:e.readVarint32();break;case t.WIRE_TYPES.BITS32:e.offset+=4;break;case t.WIRE_TYPES.BITS64:e.offset+=8;break;case t.WIRE_TYPES.LDELIM:var p=e.readVarint32();e.offset+=p;break;case t.WIRE_TYPES.STARTGROUP:for(;h(s,e););break;default:throw Error("Illegal wire type for unknown field "+s+" in "+this.toString(!0)+"#decode: "+o)}}for(var d=0,m=this._fields.length;d<m;++d)if(null===c[(a=this._fields[d]).name])if("proto3"===this.syntax)c[a.name]=a.defaultValue;else{if(a.required){var g=Error("Missing at least one required field for "+this.toString(!0)+": "+a.name);throw g.decoded=c,g}t.populateDefaults&&null!==a.defaultValue&&(c[a.name]=a.defaultValue)}return c},n.Message=f;var p=function(e,n,i,o,s,a,u,c,l,h){r.call(this,e,n,a),this.className="Message.Field",this.required="required"===i,this.repeated="repeated"===i,this.map="map"===i,this.keyType=o||null,this.type=s,this.resolvedType=null,this.id=u,this.options=c||{},this.defaultValue=null,this.oneof=l||null,this.syntax=h||"proto2",this.originalName=this.name,this.element=null,this.keyElement=null,!this.builder.options.convertFieldsToCamelCase||this instanceof f.ExtensionField||(this.name=t.Util.toCamelCase(this.name))},d=p.prototype=Object.create(r.prototype);d.build=function(){this.element=new a(this.type,this.resolvedType,!1,this.syntax,this.name),this.map&&(this.keyElement=new a(this.keyType,void 0,!0,this.syntax,this.name)),"proto3"!==this.syntax||this.repeated||this.map?void 0!==this.options.default&&(this.defaultValue=this.verifyValue(this.options.default)):this.defaultValue=a.defaultFieldValue(this.type)},d.verifyValue=function(e,n){n=n||!1;var r,i=this;function o(e,t){throw Error("Illegal value for "+i.toString(!0)+" of type "+i.type.name+": "+e+" ("+t+")")}if(null===e)return this.required&&o(typeof e,"required"),"proto3"===this.syntax&&this.type!==t.TYPES.message&&o(typeof e,"proto3 field without field presence cannot be null"),null;if(this.repeated&&!n){Array.isArray(e)||(e=[e]);var s=[];for(r=0;r<e.length;r++)s.push(this.element.verifyValue(e[r]));return s}return this.map&&!n?e instanceof t.Map?e:(e instanceof Object||o(typeof e,"expected ProtoBuf.Map or raw object for map field"),new t.Map(this,e)):(!this.repeated&&Array.isArray(e)&&o(typeof e,"no array expected"),this.element.verifyValue(e))},d.hasWirePresence=function(e,n){if("proto3"!==this.syntax)return null!==e;if(this.oneof&&n[this.oneof.name]===this.name)return!0;switch(this.type){case t.TYPES.int32:case t.TYPES.sint32:case t.TYPES.sfixed32:case t.TYPES.uint32:case t.TYPES.fixed32:return 0!==e;case t.TYPES.int64:case t.TYPES.sint64:case t.TYPES.sfixed64:case t.TYPES.uint64:case t.TYPES.fixed64:return 0!==e.low||0!==e.high;case t.TYPES.bool:return e;case t.TYPES.float:case t.TYPES.double:return 0!==e;case t.TYPES.string:return e.length>0;case t.TYPES.bytes:return e.remaining()>0;case t.TYPES.enum:return 0!==e;case t.TYPES.message:return null!==e;default:return!0}},d.encode=function(n,r,i){if(null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===n||this.repeated&&0==n.length)return r;try{var o;if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){r.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var s=r.offset;for(o=0;o<n.length;o++)this.element.encodeValue(this.id,n[o],r);var a=r.offset-s,u=e.calculateVarint32(a);if(u>1){var c=r.slice(s,r.offset);s+=u-1,r.offset=s,r.append(c)}r.writeVarint32(a,s-u)}else for(o=0;o<n.length;o++)r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,n[o],r);else this.map?n.forEach((function(n,i,o){var s=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,i)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,n);r.writeVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),r.writeVarint32(s),r.writeVarint32(8|this.keyType.wireType),this.keyElement.encodeValue(1,i,r),r.writeVarint32(16|this.type.wireType),this.element.encodeValue(2,n,r)}),this):this.hasWirePresence(n,i)&&(r.writeVarint32(this.id<<3|this.type.wireType),this.element.encodeValue(this.id,n,r))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+n+" ("+e+")")}return r},d.calculate=function(n,r){if(n=this.verifyValue(n),null===this.type||"object"!=typeof this.type)throw Error("[INTERNAL] Unresolved type in "+this.toString(!0)+": "+this.type);if(null===n||this.repeated&&0==n.length)return 0;var i=0;try{var o,s;if(this.repeated)if(this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0){for(i+=e.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),s=0,o=0;o<n.length;o++)s+=this.element.calculateLength(this.id,n[o]);i+=e.calculateVarint32(s),i+=s}else for(o=0;o<n.length;o++)i+=e.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,n[o]);else this.map?n.forEach((function(n,r,o){var s=e.calculateVarint32(8|this.keyType.wireType)+this.keyElement.calculateLength(1,r)+e.calculateVarint32(16|this.type.wireType)+this.element.calculateLength(2,n);i+=e.calculateVarint32(this.id<<3|t.WIRE_TYPES.LDELIM),i+=e.calculateVarint32(s),i+=s}),this):this.hasWirePresence(n,r)&&(i+=e.calculateVarint32(this.id<<3|this.type.wireType),i+=this.element.calculateLength(this.id,n))}catch(e){throw Error("Illegal value for "+this.toString(!0)+": "+n+" ("+e+")")}return i},d.decode=function(e,n,r){var i,o;if(!(!this.map&&e==this.type.wireType||!r&&this.repeated&&this.options.packed&&e==t.WIRE_TYPES.LDELIM||this.map&&e==t.WIRE_TYPES.LDELIM))throw Error("Illegal wire type for field "+this.toString(!0)+": "+e+" ("+this.type.wireType+" expected)");if(e==t.WIRE_TYPES.LDELIM&&this.repeated&&this.options.packed&&t.PACKABLE_WIRE_TYPES.indexOf(this.type.wireType)>=0&&!r){o=n.readVarint32(),o=n.offset+o;for(var s=[];n.offset<o;)s.push(this.decode(this.type.wireType,n,!0));return s}if(this.map){var u=a.defaultFieldValue(this.keyType);if(i=a.defaultFieldValue(this.type),o=n.readVarint32(),n.remaining()<o)throw Error("Illegal number of bytes for "+this.toString(!0)+": "+o+" required but got only "+n.remaining());var c=n.clone();for(c.limit=c.offset+o,n.offset+=o;c.remaining()>0;){var f=c.readVarint32();e=7&f;var l=f>>>3;if(1===l)u=this.keyElement.decode(c,e,l);else{if(2!==l)throw Error("Unexpected tag in map field key/value submessage");i=this.element.decode(c,e,l)}}return[u,i]}return this.element.decode(n,e,this.id)},n.Message.Field=p;var m=function(e,t,n,r,i,o,s){p.call(this,e,t,n,null,r,i,o,s),this.extension};m.prototype=Object.create(p.prototype),n.Message.ExtensionField=m;n.Message.OneOf=function(e,t,n){r.call(this,e,t,n),this.fields=[]};var g=function(e,t,n,r,i){o.call(this,e,t,n,r,i),this.className="Enum",this.object=null};g.getName=function(e,t){for(var n,r=Object.keys(e),i=0;i<r.length;++i)if(e[n=r[i]]===t)return n;return null},(g.prototype=Object.create(o.prototype)).build=function(e){if(this.object&&!e)return this.object;for(var n=new t.Builder.Enum,r=this.getChildren(g.Value),i=0,o=r.length;i<o;++i)n[r[i].name]=r[i].id;return Object.defineProperty&&Object.defineProperty(n,"$options",{value:this.buildOpt(),enumerable:!1}),this.object=n},n.Enum=g;var y=function(e,t,n,i){r.call(this,e,t,n),this.className="Enum.Value",this.id=i};y.prototype=Object.create(r.prototype),n.Enum.Value=y;var v=function(e,t,n,i){r.call(this,e,t,n),this.field=i};v.prototype=Object.create(r.prototype),n.Extension=v;var b=function(e,t,n,r){o.call(this,e,t,n,r),this.className="Service",this.clazz=null};(b.prototype=Object.create(o.prototype)).build=function(n){return this.clazz&&!n?this.clazz:this.clazz=function(t,n){for(var r=function(e){t.Builder.Service.call(this),this.rpcImpl=e||function(e,t,n){setTimeout(n.bind(this,Error("Not implemented, see: https://github.com/dcodeIO/ProtoBuf.js/wiki/Services")),0)}},i=r.prototype=Object.create(t.Builder.Service.prototype),o=n.getChildren(t.Reflect.Service.RPCMethod),s=0;s<o.length;s++)!function(t){i[t.name]=function(r,i){try{try{r=t.resolvedRequestType.clazz.decode(e.wrap(r))}catch(e){if(!(e instanceof TypeError))throw e}if(null===r||"object"!=typeof r)throw Error("Illegal arguments");r instanceof t.resolvedRequestType.clazz||(r=new t.resolvedRequestType.clazz(r)),this.rpcImpl(t.fqn(),r,(function(e,r){if(e)i(e);else{null===r&&(r="");try{r=t.resolvedResponseType.clazz.decode(r)}catch(e){}r&&r instanceof t.resolvedResponseType.clazz?i(null,r):i(Error("Illegal response type received in service method "+n.name+"#"+t.name))}}))}catch(e){setTimeout(i.bind(this,e),0)}},r[t.name]=function(e,n,i){new r(e)[t.name](n,i)},Object.defineProperty&&(Object.defineProperty(r[t.name],"$options",{value:t.buildOpt()}),Object.defineProperty(i[t.name],"$options",{value:r[t.name].$options}))}(o[s]);return Object.defineProperty&&(Object.defineProperty(r,"$options",{value:n.buildOpt()}),Object.defineProperty(i,"$options",{value:r.$options}),Object.defineProperty(r,"$type",{value:n}),Object.defineProperty(i,"$type",{value:n})),r}(t,this)},n.Service=b;var w=function(e,t,n,i){r.call(this,e,t,n),this.className="Service.Method",this.options=i||{}};(w.prototype=Object.create(r.prototype)).buildOpt=s.buildOpt,n.Service.Method=w;var E=function(e,t,n,r,i,o,s,a){w.call(this,e,t,n,a),this.className="Service.RPCMethod",this.requestName=r,this.responseName=i,this.requestStream=o,this.responseStream=s,this.resolvedRequestType=null,this.resolvedResponseType=null};return E.prototype=Object.create(w.prototype),n.Service.RPCMethod=E,n}(i),i.Builder=function(e,t,n){var r=function(e){this.ns=new n.Namespace(this,null,""),this.ptr=this.ns,this.resolved=!1,this.result=null,this.files={},this.importRoot=null,this.options=e||{}},i=r.prototype;return r.isMessage=function(e){return"string"==typeof e.name&&(void 0===e.values&&void 0===e.rpc)},r.isMessageField=function(e){return"string"==typeof e.rule&&"string"==typeof e.name&&"string"==typeof e.type&&void 0!==e.id},r.isEnum=function(e){return"string"==typeof e.name&&!(void 0===e.values||!Array.isArray(e.values)||0===e.values.length)},r.isService=function(e){return!("string"!=typeof e.name||"object"!=typeof e.rpc||!e.rpc)},r.isExtend=function(e){return"string"==typeof e.ref},i.reset=function(){return this.ptr=this.ns,this},i.define=function(e){if("string"!=typeof e||!t.TYPEREF.test(e))throw Error("illegal namespace: "+e);return e.split(".").forEach((function(e){var t=this.ptr.getChild(e);null===t&&this.ptr.addChild(t=new n.Namespace(this,this.ptr,e)),this.ptr=t}),this),this},i.create=function(t){if(!t)return this;if(Array.isArray(t)){if(0===t.length)return this;t=t.slice()}else t=[t];for(var i=[t];i.length>0;){if(t=i.pop(),!Array.isArray(t))throw Error("not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var o=t.shift();if(r.isMessage(o)){var s=new n.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 n.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 n.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(r.isEnum(o))s=new n.Enum(this,this.ptr,o.name,o.options,o.syntax),o.values.forEach((function(e){s.addChild(new n.Enum.Value(this,s,e.name,e.id))}),this),this.ptr.addChild(s);else if(r.isService(o))s=new n.Service(this,this.ptr,o.name,o.options),Object.keys(o.rpc).forEach((function(e){var t=o.rpc[e];s.addChild(new n.Service.RPCMethod(this,s,e,t.request,t.response,!!t.request_stream,!!t.response_stream,t.options))}),this),this.ptr.addChild(s);else{if(!r.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 r=!1;if(s.extensions.forEach((function(e){t.id>=e[0]&&t.id<=e[1]&&(r=!0)})),!r)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 n.Message.ExtensionField(this,s,t.rule,t.type,this.ptr.fqn()+"."+i,t.id,t.options),a=new n.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,n){var r="/";if("string"==typeof n){if(e.Util.IS_NODE&&(n=m.resolve(n)),!0===this.files[n])return this.reset();this.files[n]=!0}else if("object"==typeof n){var i,o=n.root;if(e.Util.IS_NODE&&(o=m.resolve(o)),(o.indexOf("\\")>=0||n.file.indexOf("\\")>=0)&&(r="\\"),i=e.Util.IS_NODE?m.join(o,n.file):o+r+n.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 n?(this.importRoot=n.root,a=!0,s=this.importRoot,n=n.file,(s.indexOf("\\")>=0||n.indexOf("\\")>=0)&&(r="\\")):"string"==typeof n?this.importRoot?s=this.importRoot:n.indexOf("/")>=0?""===(s=n.replace(/\/[^\/]*$/,""))&&(s="/"):n.indexOf("\\")>=0?(s=n.replace(/\\[^\\]*$/,""),r="\\"):s=".":s=null;for(var u=0;u<t.imports.length;u++)if("string"==typeof t.imports[u]){if(!s)throw Error("cannot determine import root");var c=t.imports[u];if("google/protobuf/descriptor.proto"===c)continue;if(c=e.Util.IS_NODE?m.join(s,c):s+r+c,!0===this.files[c])continue;/\.proto$/i.test(c)&&!e.DotProto&&(c=c.replace(/\.proto$/,".json"));var f=e.Util.fetch(c);if(null===f)throw Error("failed to import '"+c+"' in '"+n+"': file not found");/\.json$/i.test(c)?this.import(JSON.parse(f+""),c):this.import(e.DotProto.Parser.parse(f),c)}else n?/\.(\w+)$/.test(n)?this.import(t.imports[u],n.replace(/^(.+)\.(\w+)$/,(function(e,t,n){return t+"_import"+u+"."+n}))):this.import(t.imports[u],n+"_import"+u):this.import(t.imports[u]);a&&(this.importRoot=null)}t.package&&this.define(t.package),t.syntax&&function e(t){t.messages&&t.messages.forEach((function(n){n.syntax=t.syntax,e(n)})),t.enums&&t.enums.forEach((function(e){e.syntax=t.syntax}))}(t);var l=this.ptr;return t.options&&Object.keys(t.options).forEach((function(e){l.options[e]=t.options[e]})),t.messages&&(this.create(t.messages),this.ptr=l),t.enums&&(this.create(t.enums),this.ptr=l),t.services&&(this.create(t.services),this.ptr=l),t.extends&&this.create(t.extends),this.reset()},i.resolveAll=function(){var r;if(null==this.ptr||"object"==typeof this.ptr.type)return this;if(this.ptr instanceof n.Namespace)this.ptr.children.forEach((function(e){this.ptr=e,this.resolveAll()}),this);else if(this.ptr instanceof n.Message.Field){if(t.TYPE.test(this.ptr.type))this.ptr.type=e.TYPES[this.ptr.type];else{if(!t.TYPEREF.test(this.ptr.type))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(!(r=(this.ptr instanceof n.Message.ExtensionField?this.ptr.extension.parent:this.ptr.parent).resolve(this.ptr.type,!0)))throw Error("unresolvable type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);if(this.ptr.resolvedType=r,r instanceof n.Enum){if(this.ptr.type=e.TYPES.enum,"proto3"===this.ptr.syntax&&"proto3"!==r.syntax)throw Error("proto3 message cannot reference proto2 enum")}else{if(!(r instanceof n.Message))throw Error("illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.type);this.ptr.type=r.isGroup?e.TYPES.group:e.TYPES.message}}if(this.ptr.map){if(!t.TYPE.test(this.ptr.keyType))throw Error("illegal key type for map field in "+this.ptr.toString(!0)+": "+this.ptr.keyType);this.ptr.keyType=e.TYPES[this.ptr.keyType]}"proto3"===this.ptr.syntax&&this.ptr.repeated&&void 0===this.ptr.options.packed&&-1!==e.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType)&&(this.ptr.options.packed=!0)}else if(this.ptr instanceof e.Reflect.Service.Method){if(!(this.ptr instanceof e.Reflect.Service.RPCMethod))throw Error("illegal service type in "+this.ptr.toString(!0));if(!((r=this.ptr.parent.resolve(this.ptr.requestName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.requestName);if(this.ptr.resolvedRequestType=r,!((r=this.ptr.parent.resolve(this.ptr.responseName,!0))&&r instanceof e.Reflect.Message))throw Error("Illegal type reference in "+this.ptr.toString(!0)+": "+this.ptr.responseName);this.ptr.resolvedResponseType=r}else if(!(this.ptr instanceof e.Reflect.Message.OneOf||this.ptr instanceof e.Reflect.Extension||this.ptr instanceof e.Reflect.Enum.Value))throw Error("illegal object in namespace: "+typeof this.ptr+": "+this.ptr);return this.reset()},i.build=function(e){if(this.reset(),this.resolved||(this.resolveAll(),this.resolved=!0,this.result=null),null===this.result&&(this.result=this.ns.build()),!e)return this.result;for(var t="string"==typeof e?e.split("."):e,n=this.result,r=0;r<t.length;r++){if(!n[t[r]]){n=null;break}n=n[t[r]]}return n},i.lookup=function(e,t){return e?this.ns.resolve(e,t):this.ns},i.toString=function(){return"Builder"},r.Message=function(){},r.Enum=function(){},r.Service=function(){},r}(i,i.Lang,i.Reflect),i.Map=function(e,t){var n=function(e,n){if(!e.map)throw Error("field is not a map");if(this.field=e,this.keyElem=new t.Element(e.keyType,null,!0,e.syntax),this.valueElem=new t.Element(e.type,e.resolvedType,!1,e.syntax),this.map={},Object.defineProperty(this,"size",{get:function(){return Object.keys(this.map).length}}),n)for(var r=Object.keys(n),i=0;i<r.length;i++){var o=this.keyElem.valueFromString(r[i]),s=this.valueElem.verifyValue(n[r[i]]);this.map[this.keyElem.valueToString(o)]={key:o,value:s}}},r=n.prototype;function i(e){var t=0;return{next:function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}}return r.clear=function(){this.map={}},r.delete=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e)),n=t in this.map;return delete this.map[t],n},r.entries=function(){for(var e,t=[],n=Object.keys(this.map),r=0;r<n.length;r++)t.push([(e=this.map[n[r]]).key,e.value]);return i(t)},r.keys=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].key);return i(e)},r.values=function(){for(var e=[],t=Object.keys(this.map),n=0;n<t.length;n++)e.push(this.map[t[n]].value);return i(e)},r.forEach=function(e,t){for(var n,r=Object.keys(this.map),i=0;i<r.length;i++)e.call(t,(n=this.map[r[i]]).value,n.key,this)},r.set=function(e,t){var n=this.keyElem.verifyValue(e),r=this.valueElem.verifyValue(t);return this.map[this.keyElem.valueToString(n)]={key:n,value:r},this},r.get=function(e){var t=this.keyElem.valueToString(this.keyElem.verifyValue(e));if(t in this.map)return this.map[t].value},r.has=function(e){return this.keyElem.valueToString(this.keyElem.verifyValue(e))in this.map},n}(0,i.Reflect),i.newBuilder=function(e){return void 0===(e=e||{}).convertFieldsToCamelCase&&(e.convertFieldsToCamelCase=i.convertFieldsToCamelCase),void 0===e.populateAccessors&&(e.populateAccessors=i.populateAccessors),new i.Builder(e)},i.loadJson=function(e,t,n){return("string"==typeof t||t&&"string"==typeof t.file&&"string"==typeof t.root)&&(n=t,t=null),t&&"object"==typeof t||(t=i.newBuilder()),"string"==typeof e&&(e=JSON.parse(e)),t.import(e,n),t.resolveAll(),t},i.loadJsonFile=function(e,t,n){if(t&&"object"==typeof t?(n=t,t=null):t&&"function"==typeof t||(t=null),t)return i.Util.fetch("string"==typeof e?e:e.root+"/"+e.file,(function(r){if(null!==r)try{t(null,i.loadJson(JSON.parse(r),n,e))}catch(e){t(e)}else t(Error("Failed to fetch file"))}));var r=i.Util.fetch("object"==typeof e?e.root+"/"+e.file:e);return null===r?null:i.loadJson(JSON.parse(r),n,e)},i}))})).newBuilder({}).import({package:"push_server.messages2",syntax:"proto2",options:{objc_class_prefix:"AVIM"},messages:[{name:"JsonObjectMessage",syntax:"proto2",fields:[{rule:"required",type:"string",name:"data",id:1}]},{name:"UnreadTuple",syntax:"proto2",fields:[{rule:"required",type:"string",name:"cid",id:1},{rule:"required",type:"int32",name:"unread",id:2},{rule:"optional",type:"string",name:"mid",id:3},{rule:"optional",type:"int64",name:"timestamp",id:4},{rule:"optional",type:"string",name:"from",id:5},{rule:"optional",type:"string",name:"data",id:6},{rule:"optional",type:"int64",name:"patchTimestamp",id:7},{rule:"optional",type:"bool",name:"mentioned",id:8},{rule:"optional",type:"bytes",name:"binaryMsg",id:9},{rule:"optional",type:"int32",name:"convType",id:10}]},{name:"LogItem",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"from",id:1},{rule:"optional",type:"string",name:"data",id:2},{rule:"optional",type:"int64",name:"timestamp",id:3},{rule:"optional",type:"string",name:"msgId",id:4},{rule:"optional",type:"int64",name:"ackAt",id:5},{rule:"optional",type:"int64",name:"readAt",id:6},{rule:"optional",type:"int64",name:"patchTimestamp",id:7},{rule:"optional",type:"bool",name:"mentionAll",id:8},{rule:"repeated",type:"string",name:"mentionPids",id:9},{rule:"optional",type:"bool",name:"bin",id:10},{rule:"optional",type:"int32",name:"convType",id:11}]},{name:"ConvMemberInfo",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"pid",id:1},{rule:"optional",type:"string",name:"role",id:2},{rule:"optional",type:"string",name:"infoId",id:3}]},{name:"DataCommand",syntax:"proto2",fields:[{rule:"repeated",type:"string",name:"ids",id:1},{rule:"repeated",type:"JsonObjectMessage",name:"msg",id:2},{rule:"optional",type:"bool",name:"offline",id:3}]},{name:"SessionCommand",syntax:"proto2",fields:[{rule:"optional",type:"int64",name:"t",id:1},{rule:"optional",type:"string",name:"n",id:2},{rule:"optional",type:"string",name:"s",id:3},{rule:"optional",type:"string",name:"ua",id:4},{rule:"optional",type:"bool",name:"r",id:5},{rule:"optional",type:"string",name:"tag",id:6},{rule:"optional",type:"string",name:"deviceId",id:7},{rule:"repeated",type:"string",name:"sessionPeerIds",id:8},{rule:"repeated",type:"string",name:"onlineSessionPeerIds",id:9},{rule:"optional",type:"string",name:"st",id:10},{rule:"optional",type:"int32",name:"stTtl",id:11},{rule:"optional",type:"int32",name:"code",id:12},{rule:"optional",type:"string",name:"reason",id:13},{rule:"optional",type:"string",name:"deviceToken",id:14},{rule:"optional",type:"bool",name:"sp",id:15},{rule:"optional",type:"string",name:"detail",id:16},{rule:"optional",type:"int64",name:"lastUnreadNotifTime",id:17},{rule:"optional",type:"int64",name:"lastPatchTime",id:18},{rule:"optional",type:"int64",name:"configBitmap",id:19}]},{name:"ErrorCommand",syntax:"proto2",fields:[{rule:"required",type:"int32",name:"code",id:1},{rule:"required",type:"string",name:"reason",id:2},{rule:"optional",type:"int32",name:"appCode",id:3},{rule:"optional",type:"string",name:"detail",id:4},{rule:"repeated",type:"string",name:"pids",id:5},{rule:"optional",type:"string",name:"appMsg",id:6}]},{name:"DirectCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"msg",id:1},{rule:"optional",type:"string",name:"uid",id:2},{rule:"optional",type:"string",name:"fromPeerId",id:3},{rule:"optional",type:"int64",name:"timestamp",id:4},{rule:"optional",type:"bool",name:"offline",id:5},{rule:"optional",type:"bool",name:"hasMore",id:6},{rule:"repeated",type:"string",name:"toPeerIds",id:7},{rule:"optional",type:"bool",name:"r",id:10},{rule:"optional",type:"string",name:"cid",id:11},{rule:"optional",type:"string",name:"id",id:12},{rule:"optional",type:"bool",name:"transient",id:13},{rule:"optional",type:"string",name:"dt",id:14},{rule:"optional",type:"string",name:"roomId",id:15},{rule:"optional",type:"string",name:"pushData",id:16},{rule:"optional",type:"bool",name:"will",id:17},{rule:"optional",type:"int64",name:"patchTimestamp",id:18},{rule:"optional",type:"bytes",name:"binaryMsg",id:19},{rule:"repeated",type:"string",name:"mentionPids",id:20},{rule:"optional",type:"bool",name:"mentionAll",id:21},{rule:"optional",type:"int32",name:"convType",id:22}]},{name:"AckCommand",syntax:"proto2",fields:[{rule:"optional",type:"int32",name:"code",id:1},{rule:"optional",type:"string",name:"reason",id:2},{rule:"optional",type:"string",name:"mid",id:3},{rule:"optional",type:"string",name:"cid",id:4},{rule:"optional",type:"int64",name:"t",id:5},{rule:"optional",type:"string",name:"uid",id:6},{rule:"optional",type:"int64",name:"fromts",id:7},{rule:"optional",type:"int64",name:"tots",id:8},{rule:"optional",type:"string",name:"type",id:9},{rule:"repeated",type:"string",name:"ids",id:10},{rule:"optional",type:"int32",name:"appCode",id:11},{rule:"optional",type:"string",name:"appMsg",id:12}]},{name:"UnreadCommand",syntax:"proto2",fields:[{rule:"repeated",type:"UnreadTuple",name:"convs",id:1},{rule:"optional",type:"int64",name:"notifTime",id:2}]},{name:"ConvCommand",syntax:"proto2",fields:[{rule:"repeated",type:"string",name:"m",id:1},{rule:"optional",type:"bool",name:"transient",id:2},{rule:"optional",type:"bool",name:"unique",id:3},{rule:"optional",type:"string",name:"cid",id:4},{rule:"optional",type:"string",name:"cdate",id:5},{rule:"optional",type:"string",name:"initBy",id:6},{rule:"optional",type:"string",name:"sort",id:7},{rule:"optional",type:"int32",name:"limit",id:8},{rule:"optional",type:"int32",name:"skip",id:9},{rule:"optional",type:"int32",name:"flag",id:10},{rule:"optional",type:"int32",name:"count",id:11},{rule:"optional",type:"string",name:"udate",id:12},{rule:"optional",type:"int64",name:"t",id:13},{rule:"optional",type:"string",name:"n",id:14},{rule:"optional",type:"string",name:"s",id:15},{rule:"optional",type:"bool",name:"statusSub",id:16},{rule:"optional",type:"bool",name:"statusPub",id:17},{rule:"optional",type:"int32",name:"statusTTL",id:18},{rule:"optional",type:"string",name:"uniqueId",id:19},{rule:"optional",type:"string",name:"targetClientId",id:20},{rule:"optional",type:"int64",name:"maxReadTimestamp",id:21},{rule:"optional",type:"int64",name:"maxAckTimestamp",id:22},{rule:"optional",type:"bool",name:"queryAllMembers",id:23},{rule:"repeated",type:"MaxReadTuple",name:"maxReadTuples",id:24},{rule:"repeated",type:"string",name:"cids",id:25},{rule:"optional",type:"ConvMemberInfo",name:"info",id:26},{rule:"optional",type:"bool",name:"tempConv",id:27},{rule:"optional",type:"int32",name:"tempConvTTL",id:28},{rule:"repeated",type:"string",name:"tempConvIds",id:29},{rule:"repeated",type:"string",name:"allowedPids",id:30},{rule:"repeated",type:"ErrorCommand",name:"failedPids",id:31},{rule:"optional",type:"string",name:"next",id:40},{rule:"optional",type:"JsonObjectMessage",name:"results",id:100},{rule:"optional",type:"JsonObjectMessage",name:"where",id:101},{rule:"optional",type:"JsonObjectMessage",name:"attr",id:103},{rule:"optional",type:"JsonObjectMessage",name:"attrModified",id:104}]},{name:"RoomCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"roomId",id:1},{rule:"optional",type:"string",name:"s",id:2},{rule:"optional",type:"int64",name:"t",id:3},{rule:"optional",type:"string",name:"n",id:4},{rule:"optional",type:"bool",name:"transient",id:5},{rule:"repeated",type:"string",name:"roomPeerIds",id:6},{rule:"optional",type:"string",name:"byPeerId",id:7}]},{name:"LogsCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"optional",type:"int32",name:"l",id:2},{rule:"optional",type:"int32",name:"limit",id:3},{rule:"optional",type:"int64",name:"t",id:4},{rule:"optional",type:"int64",name:"tt",id:5},{rule:"optional",type:"string",name:"tmid",id:6},{rule:"optional",type:"string",name:"mid",id:7},{rule:"optional",type:"string",name:"checksum",id:8},{rule:"optional",type:"bool",name:"stored",id:9},{rule:"optional",type:"QueryDirection",name:"direction",id:10,options:{default:"OLD"}},{rule:"optional",type:"bool",name:"tIncluded",id:11},{rule:"optional",type:"bool",name:"ttIncluded",id:12},{rule:"optional",type:"int32",name:"lctype",id:13},{rule:"repeated",type:"LogItem",name:"logs",id:105}],enums:[{name:"QueryDirection",syntax:"proto2",values:[{name:"OLD",id:1},{name:"NEW",id:2}]}]},{name:"RcpCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"id",id:1},{rule:"optional",type:"string",name:"cid",id:2},{rule:"optional",type:"int64",name:"t",id:3},{rule:"optional",type:"bool",name:"read",id:4},{rule:"optional",type:"string",name:"from",id:5}]},{name:"ReadTuple",syntax:"proto2",fields:[{rule:"required",type:"string",name:"cid",id:1},{rule:"optional",type:"int64",name:"timestamp",id:2},{rule:"optional",type:"string",name:"mid",id:3}]},{name:"MaxReadTuple",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"pid",id:1},{rule:"optional",type:"int64",name:"maxAckTimestamp",id:2},{rule:"optional",type:"int64",name:"maxReadTimestamp",id:3}]},{name:"ReadCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"repeated",type:"string",name:"cids",id:2},{rule:"repeated",type:"ReadTuple",name:"convs",id:3}]},{name:"PresenceCommand",syntax:"proto2",fields:[{rule:"optional",type:"StatusType",name:"status",id:1},{rule:"repeated",type:"string",name:"sessionPeerIds",id:2},{rule:"optional",type:"string",name:"cid",id:3}]},{name:"ReportCommand",syntax:"proto2",fields:[{rule:"optional",type:"bool",name:"initiative",id:1},{rule:"optional",type:"string",name:"type",id:2},{rule:"optional",type:"string",name:"data",id:3}]},{name:"PatchItem",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"optional",type:"string",name:"mid",id:2},{rule:"optional",type:"int64",name:"timestamp",id:3},{rule:"optional",type:"bool",name:"recall",id:4},{rule:"optional",type:"string",name:"data",id:5},{rule:"optional",type:"int64",name:"patchTimestamp",id:6},{rule:"optional",type:"string",name:"from",id:7},{rule:"optional",type:"bytes",name:"binaryMsg",id:8},{rule:"optional",type:"bool",name:"mentionAll",id:9},{rule:"repeated",type:"string",name:"mentionPids",id:10},{rule:"optional",type:"int64",name:"patchCode",id:11},{rule:"optional",type:"string",name:"patchReason",id:12}]},{name:"PatchCommand",syntax:"proto2",fields:[{rule:"repeated",type:"PatchItem",name:"patches",id:1},{rule:"optional",type:"int64",name:"lastPatchTime",id:2}]},{name:"PubsubCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"cid",id:1},{rule:"repeated",type:"string",name:"cids",id:2},{rule:"optional",type:"string",name:"topic",id:3},{rule:"optional",type:"string",name:"subtopic",id:4},{rule:"repeated",type:"string",name:"topics",id:5},{rule:"repeated",type:"string",name:"subtopics",id:6},{rule:"optional",type:"JsonObjectMessage",name:"results",id:7}]},{name:"BlacklistCommand",syntax:"proto2",fields:[{rule:"optional",type:"string",name:"srcCid",id:1},{rule:"repeated",type:"string",name:"toPids",id:2},{rule:"optional",type:"string",name:"srcPid",id:3},{rule:"repeated",type:"string",name:"toCids",id:4},{rule:"optional",type:"int32",name:"limit",id:5},{rule:"optional",type:"string",name:"next",id:6},{rule:"repeated",type:"string",name:"blockedPids",id:8},{rule:"repeated",type:"string",name:"blockedCids",id:9},{rule:"repeated",type:"string",name:"allowedPids",id:10},{rule:"repeated",type:"ErrorCommand",name:"failedPids",id:11},{rule:"optional",type:"int64",name:"t",id:12},{rule:"optional",type:"string",name:"n",id:13},{rule:"optional",type:"string",name:"s",id:14}]},{name:"GenericCommand",syntax:"proto2",fields:[{rule:"optional",type:"CommandType",name:"cmd",id:1},{rule:"optional",type:"OpType",name:"op",id:2},{rule:"optional",type:"string",name:"appId",id:3},{rule:"optional",type:"string",name:"peerId",id:4},{rule:"optional",type:"int32",name:"i",id:5},{rule:"optional",type:"string",name:"installationId",id:6},{rule:"optional",type:"int32",name:"priority",id:7},{rule:"optional",type:"int32",name:"service",id:8},{rule:"optional",type:"int64",name:"serverTs",id:9},{rule:"optional",type:"int64",name:"clientTs",id:10},{rule:"optional",type:"int32",name:"notificationType",id:11},{rule:"optional",type:"DataCommand",name:"dataMessage",id:101},{rule:"optional",type:"SessionCommand",name:"sessionMessage",id:102},{rule:"optional",type:"ErrorCommand",name:"errorMessage",id:103},{rule:"optional",type:"DirectCommand",name:"directMessage",id:104},{rule:"optional",type:"AckCommand",name:"ackMessage",id:105},{rule:"optional",type:"UnreadCommand",name:"unreadMessage",id:106},{rule:"optional",type:"ReadCommand",name:"readMessage",id:107},{rule:"optional",type:"RcpCommand",name:"rcpMessage",id:108},{rule:"optional",type:"LogsCommand",name:"logsMessage",id:109},{rule:"optional",type:"ConvCommand",name:"convMessage",id:110},{rule:"optional",type:"RoomCommand",name:"roomMessage",id:111},{rule:"optional",type:"PresenceCommand",name:"presenceMessage",id:112},{rule:"optional",type:"ReportCommand",name:"reportMessage",id:113},{rule:"optional",type:"PatchCommand",name:"patchMessage",id:114},{rule:"optional",type:"PubsubCommand",name:"pubsubMessage",id:115},{rule:"optional",type:"BlacklistCommand",name:"blacklistMessage",id:116}]}],enums:[{name:"CommandType",syntax:"proto2",values:[{name:"session",id:0},{name:"conv",id:1},{name:"direct",id:2},{name:"ack",id:3},{name:"rcp",id:4},{name:"unread",id:5},{name:"logs",id:6},{name:"error",id:7},{name:"login",id:8},{name:"data",id:9},{name:"room",id:10},{name:"read",id:11},{name:"presence",id:12},{name:"report",id:13},{name:"echo",id:14},{name:"loggedin",id:15},{name:"logout",id:16},{name:"loggedout",id:17},{name:"patch",id:18},{name:"pubsub",id:19},{name:"blacklist",id:20},{name:"goaway",id:21}]},{name:"OpType",syntax:"proto2",values:[{name:"open",id:1},{name:"add",id:2},{name:"remove",id:3},{name:"close",id:4},{name:"opened",id:5},{name:"closed",id:6},{name:"query",id:7},{name:"query_result",id:8},{name:"conflict",id:9},{name:"added",id:10},{name:"removed",id:11},{name:"refresh",id:12},{name:"refreshed",id:13},{name:"start",id:30},{name:"started",id:31},{name:"joined",id:32},{name:"members_joined",id:33},{name:"left",id:39},{name:"members_left",id:40},{name:"results",id:42},{name:"count",id:43},{name:"result",id:44},{name:"update",id:45},{name:"updated",id:46},{name:"mute",id:47},{name:"unmute",id:48},{name:"status",id:49},{name:"members",id:50},{name:"max_read",id:51},{name:"is_member",id:52},{name:"member_info_update",id:53},{name:"member_info_updated",id:54},{name:"member_info_changed",id:55},{name:"join",id:80},{name:"invite",id:81},{name:"leave",id:82},{name:"kick",id:83},{name:"reject",id:84},{name:"invited",id:85},{name:"kicked",id:86},{name:"upload",id:100},{name:"uploaded",id:101},{name:"subscribe",id:120},{name:"subscribed",id:121},{name:"unsubscribe",id:122},{name:"unsubscribed",id:123},{name:"is_subscribed",id:124},{name:"modify",id:150},{name:"modified",id:151},{name:"block",id:170},{name:"unblock",id:171},{name:"blocked",id:172},{name:"unblocked",id:173},{name:"members_blocked",id:174},{name:"members_unblocked",id:175},{name:"check_block",id:176},{name:"check_result",id:177},{name:"add_shutup",id:180},{name:"remove_shutup",id:181},{name:"query_shutup",id:182},{name:"shutup_added",id:183},{name:"shutup_removed",id:184},{name:"shutup_result",id:185},{name:"shutuped",id:186},{name:"unshutuped",id:187},{name:"members_shutuped",id:188},{name:"members_unshutuped",id:189},{name:"check_shutup",id:190}]},{name:"StatusType",syntax:"proto2",values:[{name:"on",id:1},{name:"off",id:2}]}],isNamespace:!0}).build().push_server.messages2,y=g.JsonObjectMessage,v=g.UnreadTuple,b=g.LogItem,w=g.DataCommand,E=g.SessionCommand,_=g.ErrorCommand,T=g.DirectCommand,O=g.AckCommand,S=g.UnreadCommand,A=g.ConvCommand,I=g.RoomCommand,C=g.LogsCommand,P=g.RcpCommand,x=g.ReadTuple,M=g.MaxReadTuple,k=g.ReadCommand,j=g.PresenceCommand,R=g.ReportCommand,N=g.GenericCommand,L=g.BlacklistCommand,D=g.PatchCommand,F=g.PatchItem,U=g.ConvMemberInfo,B=g.CommandType,V=g.OpType,Y=g.StatusType,q=Object.freeze({__proto__:null,JsonObjectMessage:y,UnreadTuple:v,LogItem:b,DataCommand:w,SessionCommand:E,ErrorCommand:_,DirectCommand:T,AckCommand:O,UnreadCommand:S,ConvCommand:A,RoomCommand:I,LogsCommand:C,RcpCommand:P,ReadTuple:x,MaxReadTuple:M,ReadCommand:k,PresenceCommand:j,ReportCommand:R,GenericCommand:N,BlacklistCommand:L,PatchCommand:D,PatchItem:F,ConvMemberInfo:U,CommandType:B,OpType:V,StatusType:Y}),z=i((function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var u,c,f=this._events[a],l=arguments.length;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),l){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,i),!0;case 5:return f.fn.call(f.context,t,r,i,o),!0;case 6:return f.fn.call(f.context,t,r,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];f.fn.apply(f.context,u)}else{var h,p=f.length;for(c=0;c<p;c++)switch(f[c].once&&this.removeListener(e,f[c].fn,void 0,!0),l){case 1:f[c].fn.call(f[c].context);break;case 2:f[c].fn.call(f[c].context,t);break;case 3:f[c].fn.call(f[c].context,t,r);break;case 4:f[c].fn.call(f[c].context,t,r,i);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];f[c].fn.apply(f[c].context,u)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var u=0,c=[],f=a.length;u<f;u++)(a[u].fn!==t||i&&!a[u].once||r&&a[u].context!==r)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})),W=i((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",s=r.toStringTag||"@@toStringTag";function a(e,t,n,r){var i=t&&t.prototype instanceof f?t:f,o=Object.create(i.prototype),s=new _(r||[]);return o._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return O()}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var a=b(s,n);if(a){if(a===c)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var f=u(e,t,n);if("normal"===f.type){if(r=n.done?"completed":"suspendedYield",f.arg===c)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(r="completed",n.method="throw",n.arg=f.arg)}}}(e,n,s),o}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var c={};function f(){}function l(){}function h(){}var p={};p[i]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(T([])));m&&m!==t&&n.call(m,i)&&(p=m);var g=h.prototype=f.prototype=Object.create(p);function y(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function v(e,t){var r;this._invoke=function(i,o){function s(){return new t((function(r,s){!function r(i,o,s,a){var c=u(e[i],e,o);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,a)}),(function(e){r("throw",e,s,a)})):t.resolve(l).then((function(e){f.value=e,s(f)}),(function(e){return r("throw",e,s,a)}))}a(c.arg)}(i,o,r,s)}))}return r=r?r.then(s,s):s()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:O}}function O(){return{value:void 0,done:!0}}return l.prototype=g.constructor=h,h.constructor=l,h[s]=l.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s in e||(e[s]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(v.prototype),v.prototype[o]=function(){return this},e.AsyncIterator=v,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var s=new v(a(t,n,r,i),o);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},y(g),g[s]="Generator",g[i]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=T,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return s.type="throw",s.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,c):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),c},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),E(n),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;E(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=t}catch(e){}}));function G(e,t,n,r,i,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,i)}var $=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){G(o,r,i,s,a,"next",e)}function a(e){G(o,r,i,s,a,"throw",e)}s(void 0)}))}};var J=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r};var Z=function(e){if(Array.isArray(e))return J(e)};var X=function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)};var Q=function(e,t){if(e){if("string"==typeof e)return J(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?J(e,t):void 0}};var H=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")};var K=function(e){return Z(e)||X(e)||Q(e)||H()};var ee=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i};var te=function(e,t){if(null==e)return{};var n,r,i=ee(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i};var ne=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e};var re=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t},ie=1e3,oe=6e4,se=60*oe,ae=24*se,ue=function(e,t){t=t||{};var n=typeof e;if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*ae;case"hours":case"hour":case"hrs":case"hr":case"h":return n*se;case"minutes":case"minute":case"mins":case"min":case"m":return n*oe;case"seconds":case"second":case"secs":case"sec":case"s":return n*ie;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){var t=Math.abs(e);if(t>=ae)return ce(e,t,ae,"day");if(t>=se)return ce(e,t,se,"hour");if(t>=oe)return ce(e,t,oe,"minute");if(t>=ie)return ce(e,t,ie,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=ae)return Math.round(e/ae)+"d";if(t>=se)return Math.round(e/se)+"h";if(t>=oe)return Math.round(e/oe)+"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 ce(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}var fe=function(e){function t(e){for(var t=0,r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){var o;function s(){if(s.enabled){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=s,a=Number(new Date),u=a-(o||a);i.diff=u,i.prev=o,i.curr=a,o=a,t[0]=n.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");var c=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(function(e,r){if("%%"===e)return e;c++;var o=n.formatters[r];if("function"==typeof o){var s=t[c];e=o.call(i,s),t.splice(c,1),c--}return e})),n.formatArgs.call(i,t);var f=i.log||n.log;f.apply(i,t)}}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=r,s.extend=i,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function r(){var e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function i(e,t){return n(this.namespace+(void 0===t?":":t)+e)}return n.debug=n,n.default=n,n.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},n.disable=function(){n.enable("")},n.enable=function(e){var t;n.save(e),n.names=[],n.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")));for(t=0;t<n.instances.length;t++){var o=n.instances[t];o.enabled=n.enabled(o.namespace)}},n.enabled=function(e){if("*"===e[e.length-1])return!0;var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=ue,Object.keys(e).forEach((function(t){n[t]=e[t]})),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n},le=i((function(e,n){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":r(console))&&console.log&&(e=console).log.apply(e,arguments)},n.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;var n="color: "+this.color;t.splice(1,0,n,"color: inherit");var r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){var e;try{e=n.storage.getItem("debug")}catch(e){}!e&&void 0!==t&&"env"in t&&(e=t.env.DEBUG);return e},n.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage=function(){try{return localStorage}catch(e){}}(),n.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=fe(n),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}));le.log,le.formatArgs,le.save,le.load,le.useColors,le.storage,le.colors;var he=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t},pe=Math.floor,de=Math.random;var me=function(e,t){return e+pe(de()*(t-e+1))};var ge=function(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n<t;){var o=me(n,i),s=e[o];e[o]=e[n],e[n]=s}return e.length=t,e};var ye=function(e){return ge(he(e))};var ve=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i};var be=function(e,t){return ve(t,(function(t){return e[t]}))};var we=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},Ee="object"==typeof r&&r&&r.Object===Object&&r,_e="object"==typeof self&&self&&self.Object===Object&&self,Te=Ee||_e||{},Oe=Te.Symbol,Se=Object.prototype,Ae=Se.hasOwnProperty,Ie=Se.toString,Ce=Oe?Oe.toStringTag:void 0;var Pe=function(e){var t=Ae.call(e,Ce),n=e[Ce];try{e[Ce]=void 0;var r=!0}catch(e){}var i=Ie.call(e);return r&&(t?e[Ce]=n:delete e[Ce]),i},xe=Object.prototype.toString;var Me=function(e){return xe.call(e)},ke=Oe?Oe.toStringTag:void 0;var je=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ke&&ke in Object(e)?Pe(e):Me(e)};var Re=function(e){return null!=e&&"object"==typeof e};var Ne=function(e){return Re(e)&&"[object Arguments]"==je(e)},Le=Object.prototype,De=Le.hasOwnProperty,Fe=Le.propertyIsEnumerable,Ue=Ne(function(){return arguments}())?Ne:function(e){return Re(e)&&De.call(e,"callee")&&!Fe.call(e,"callee")},Be=Array.isArray;var Ve=function(){return!1},Ye=i((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?Te.Buffer:void 0,o=(i?i.isBuffer:void 0)||Ve;e.exports=o})),qe=/^(?:0|[1-9]\d*)$/;var ze=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&qe.test(e))&&e>-1&&e%1==0&&e<t};var We=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Ge={};Ge["[object Float32Array]"]=Ge["[object Float64Array]"]=Ge["[object Int8Array]"]=Ge["[object Int16Array]"]=Ge["[object Int32Array]"]=Ge["[object Uint8Array]"]=Ge["[object Uint8ClampedArray]"]=Ge["[object Uint16Array]"]=Ge["[object Uint32Array]"]=!0,Ge["[object Arguments]"]=Ge["[object Array]"]=Ge["[object ArrayBuffer]"]=Ge["[object Boolean]"]=Ge["[object DataView]"]=Ge["[object Date]"]=Ge["[object Error]"]=Ge["[object Function]"]=Ge["[object Map]"]=Ge["[object Number]"]=Ge["[object Object]"]=Ge["[object RegExp]"]=Ge["[object Set]"]=Ge["[object String]"]=Ge["[object WeakMap]"]=!1;var $e=function(e){return Re(e)&&We(e.length)&&!!Ge[je(e)]};var Je=function(e){return function(t){return e(t)}},Ze=i((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n&&Ee.process,o=function(){try{var e=r&&r.require&&r.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o})),Xe=Ze&&Ze.isTypedArray,Qe=Xe?Je(Xe):$e,He=Object.prototype.hasOwnProperty;var Ke=function(e,t){var n=Be(e),r=!n&&Ue(e),i=!n&&!r&&Ye(e),o=!n&&!r&&!i&&Qe(e),s=n||r||i||o,a=s?we(e.length,String):[],u=a.length;for(var c in e)!t&&!He.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ze(c,u))||a.push(c);return a},et=Object.prototype;var tt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||et)};var nt=function(e,t){return function(n){return e(t(n))}},rt=nt(Object.keys,Object),it=Object.prototype.hasOwnProperty;var ot=function(e){if(!tt(e))return rt(e);var t=[];for(var n in Object(e))it.call(e,n)&&"constructor"!=n&&t.push(n);return t};var st=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};var at=function(e){if(!st(e))return!1;var t=je(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var ut=function(e){return null!=e&&We(e.length)&&!at(e)};var ct=function(e){return ut(e)?Ke(e):ot(e)};var ft=function(e){return null==e?[]:be(e,ct(e))};var lt=function(e){return ge(ft(e))};var ht=function(e){return(Be(e)?ye:lt)(e)};var pt=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 mt=function(e){return pt(e)||X(e)||Q(e)||dt()};function gt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var yt=function(e,t,n){return t&>(e.prototype,t),n&>(e,n),e};var vt=function(e,t,n,r,i){var o={};return Object.keys(r).forEach((function(e){o[e]=r[e]})),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce((function(n,r){return r(e,t,n)||n}),o),i&&void 0!==o.initializer&&(o.value=o.initializer?o.initializer.call(i):void 0,o.initializer=void 0),void 0===o.initializer&&(Object.defineProperty(e,t,o),o=null),o},bt=i((function(e,t){var n;n={VERSION:"2.4.0",Result:{SUCCEEDED:1,NOTRANSITION:2,CANCELLED:3,PENDING:4},Error:{INVALID_TRANSITION:100,PENDING_TRANSITION:200,INVALID_CALLBACK:300},WILDCARD:"*",ASYNC:"async",create:function(e,t){var r="string"==typeof e.initial?{state:e.initial}:e.initial,i=e.terminal||e.final,o=t||e.target||{},s=e.events||[],a=e.callbacks||{},u={},c={},f=function(e){var t=Array.isArray(e.from)?e.from:e.from?[e.from]:[n.WILDCARD];u[e.name]=u[e.name]||{};for(var r=0;r<t.length;r++)c[t[r]]=c[t[r]]||[],c[t[r]].push(e.name),u[e.name][t[r]]=e.to||t[r];e.to&&(c[e.to]=c[e.to]||[])};r&&(r.event=r.event||"startup",f({name:r.event,from:"none",to:r.state}));for(var l=0;l<s.length;l++)f(s[l]);for(var h in u)u.hasOwnProperty(h)&&(o[h]=n.buildEvent(h,u[h]));for(var h in a)a.hasOwnProperty(h)&&(o[h]=a[h]);return o.current="none",o.is=function(e){return Array.isArray(e)?e.indexOf(this.current)>=0:this.current===e},o.can=function(e){return!this.transition&&void 0!==u[e]&&(u[e].hasOwnProperty(this.current)||u[e].hasOwnProperty(n.WILDCARD))},o.cannot=function(e){return!this.can(e)},o.transitions=function(){return(c[this.current]||[]).concat(c[n.WILDCARD]||[])},o.isFinished=function(){return this.is(i)},o.error=e.error||function(e,t,n,r,i,o,s){throw s||o},o.states=function(){return Object.keys(c).sort()},r&&!r.defer&&o[r.event](),o},doCallback:function(e,t,r,i,o,s){if(t)try{return t.apply(e,[r,i,o].concat(s))}catch(t){return e.error(r,i,o,s,n.Error.INVALID_CALLBACK,"an exception occurred in a caller-provided callback function",t)}},beforeAnyEvent:function(e,t,r,i,o){return n.doCallback(e,e.onbeforeevent,t,r,i,o)},afterAnyEvent:function(e,t,r,i,o){return n.doCallback(e,e.onafterevent||e.onevent,t,r,i,o)},leaveAnyState:function(e,t,r,i,o){return n.doCallback(e,e.onleavestate,t,r,i,o)},enterAnyState:function(e,t,r,i,o){return n.doCallback(e,e.onenterstate||e.onstate,t,r,i,o)},changeState:function(e,t,r,i,o){return n.doCallback(e,e.onchangestate,t,r,i,o)},beforeThisEvent:function(e,t,r,i,o){return n.doCallback(e,e["onbefore"+t],t,r,i,o)},afterThisEvent:function(e,t,r,i,o){return n.doCallback(e,e["onafter"+t]||e["on"+t],t,r,i,o)},leaveThisState:function(e,t,r,i,o){return n.doCallback(e,e["onleave"+r],t,r,i,o)},enterThisState:function(e,t,r,i,o){return n.doCallback(e,e["onenter"+i]||e["on"+i],t,r,i,o)},beforeEvent:function(e,t,r,i,o){if(!1===n.beforeThisEvent(e,t,r,i,o)||!1===n.beforeAnyEvent(e,t,r,i,o))return!1},afterEvent:function(e,t,r,i,o){n.afterThisEvent(e,t,r,i,o),n.afterAnyEvent(e,t,r,i,o)},leaveState:function(e,t,r,i,o){var s=n.leaveThisState(e,t,r,i,o),a=n.leaveAnyState(e,t,r,i,o);return!1!==s&&!1!==a&&(n.ASYNC===s||n.ASYNC===a?n.ASYNC:void 0)},enterState:function(e,t,r,i,o){n.enterThisState(e,t,r,i,o),n.enterAnyState(e,t,r,i,o)},buildEvent:function(e,t){return function(){var r=this.current,i=t[r]||(t[n.WILDCARD]!=n.WILDCARD?t[n.WILDCARD]:r)||r,o=Array.prototype.slice.call(arguments);if(this.transition)return this.error(e,r,i,o,n.Error.PENDING_TRANSITION,"event "+e+" inappropriate because previous transition did not complete");if(this.cannot(e))return this.error(e,r,i,o,n.Error.INVALID_TRANSITION,"event "+e+" inappropriate in current state "+this.current);if(!1===n.beforeEvent(this,e,r,i,o))return n.Result.CANCELLED;if(r===i)return n.afterEvent(this,e,r,i,o),n.Result.NOTRANSITION;var s=this;this.transition=function(){return s.transition=null,s.current=i,n.enterState(s,e,r,i,o),n.changeState(s,e,r,i,o),n.afterEvent(s,e,r,i,o),n.Result.SUCCEEDED},this.transition.cancel=function(){s.transition=null,n.afterEvent(s,e,r,i,o)};var a=n.leaveState(this,e,r,i,o);return!1===a?(this.transition=null,n.Result.CANCELLED):n.ASYNC===a?n.Result.PENDING:this.transition?this.transition():void 0}}},e.exports&&(t=e.exports=n),t.StateMachine=n})),wt=(bt.StateMachine,{}),Et=function(e){var t=wt[e];if(void 0===t)throw new Error("".concat(e," adapter is not configured"));return t},_t=function(e){Object.assign(wt,e)},Tt=nt(Object.getPrototypeOf,Object),Ot=n.prototype,St=Object.prototype,At=Ot.toString,It=St.hasOwnProperty,Ct=At.call(Object);var Pt=function(e){if(!Re(e)||"[object Object]"!=je(e))return!1;var t=Tt(e);if(null===t)return!0;var n=It.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&At.call(n)==Ct},xt="undefined"!=typeof global?global:"undefined"!=typeof window?window:{},Mt=Symbol("expired"),kt=le("LC:Expirable"),jt=function(){function e(e,t){this.originalValue=e,"number"==typeof t&&(this.expiredAt=Date.now()+t)}return yt(e,[{key:"value",get:function(){var e=this.expiredAt&&this.expiredAt<=Date.now();return e&&kt("expired: ".concat(this.originalValue)),e?Mt:this.originalValue}}]),e}();jt.EXPIRED=Mt;var Rt=le("LC:Cache"),Nt=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 n=t.value;if(n!==jt.EXPIRED)return Rt("[%s] hit: %s",this.name,e),n;delete this._map[e]}return Rt("[".concat(this.name,"] missed: ").concat(e)),null},t.set=function(e,t,n){Rt("[%s] set: %s %d",this.name,e,n),this._map[e]=new jt(t,n)},e}();function Lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Dt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lt(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ft,Ut={enable:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"LC*";return le.enable(e)},disable:le.disable},Bt=function(e){return function(t){return e(t),t}},Vt=function(e){return[function(t){return e(),t},function(t){throw e(),t}]},Yt=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},qt=function(e){return e&&e.getTime?e.getTime():void 0},zt=function e(t){return t?"Date"===t.__type&&t.iso?new Date(t.iso):Array.isArray(t)?t.map(e):Pt(t)?Object.keys(t).reduce((function(n,r){return Dt(Dt({},n),{},h({},r,e(t[r])))}),{}):t:t},Wt=function e(t){return t instanceof Date?{__type:"Date",iso:t.toJSON()}:Array.isArray(t)?t.map(e):Pt(t)?Object.keys(t).reduce((function(n,r){return Dt(Dt({},n),{},h({},r,e(t[r])))}),{}):t},Gt=function(e,t){return Object.keys(t).reduce((function(n,r){var i=e[r]||r;return Object.assign(n,h({},i,t[r]))}),{})},$t=xt.navigator&&xt.navigator.userAgent&&-1!==xt.navigator.userAgent.indexOf("MSIE 10."),Jt=function e(t,n){return t[n]||(t.__proto__?e(t.__proto__,n):void 0)},Zt=function(e,t){return Array.from(new Set([].concat(K(e),K(t))))},Xt=function(e,t){return Array.from((n=new Set(t),new Set(e.filter((function(e){return!n.has(e)})))));var n},Qt=new WeakMap,Ht=function(e){return Qt.has(e)||Qt.set(e,{}),Qt.get(e)},Kt=function e(t,n){if(!Pt(t))return t;var r=Dt({},t);return Object.keys(r).forEach((function(t){var i=r[t];i===n?delete r[t]:r[t]=e(i,n)})),r},en=function(e){return t=JSON.parse(JSON.stringify(e)),Kt(t,null);var t},tn=function(e){return Array.isArray(e)?e:null==e?[]:[e]},nn=function(e,t,n){var r=t.split("."),i=r.pop(),o=e;return r.forEach((function(e){void 0===o[e]&&(o[e]={}),o=o[e]})),o[i]=n,e},rn="object"===("undefined"==typeof wx?"undefined":a(wx))&&"function"==typeof wx.connectSocket,on=function(e){return function(t,n,r){var i=r.value;if(i.length)throw new Error("throttled function should not accept any arguments");return Dt(Dt({},r),{},{value:function(){var t=this,r=Ht(this).throttleMeta;r||(r={},Ht(this).throttleMeta=r);var o=r[n];o||(o={},r[n]=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?(r[n].previouseTimestamp=f,i.apply(this)):c||(o.timeout=setTimeout((function(){o.previouseTimestamp=Date.now(),delete o.timeout,i.apply(t)}),l))}})}},sn=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;var n=new Uint8Array(e),r=new Uint8Array(t);return!n.some((function(e,t){return e!==r[t]}))};function an(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function un(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?an(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):an(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var cn=le("LC:WebSocketPlus"),fn="disconnect",ln="reconnect",hn="retry",pn="schedule",dn="offline",mn="online",gn=function(e){return Math.min(1e3*Math.pow(2,e),3e5)},yn=function(e,t,n){return un(un({},n),{},{value:function(){var e;this.checkConnectionAvailability(t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(e=n.value).call.apply(e,[this].concat(i))}})},vn=(vt((Ft=function(e){function t(t,n){var r;return(r=e.call(this)||this).init(),r._protocol=n,Promise.resolve("function"==typeof t?t():t).then(tn).then((function(e){return r._urls=e,r._open()})).then((function(){r.__postponeTimeoutTimer=r._postponeTimeoutTimer.bind(ne(r)),xt.addEventListener&&(r.__pause=function(){r.can("pause")&&r.pause()},r.__resume=function(){r.can("resume")&&r.resume()},xt.addEventListener("offline",r.__pause),xt.addEventListener("online",r.__resume)),r.open()})).catch(r.throw.bind(ne(r))),r}re(t,e),yt(t,[{key:"urls",get:function(){return this._urls},set:function(e){this._urls=tn(e)}}]);var n=t.prototype;return n._open=function(){var e=this;return this._createWs(this._urls,this._protocol).then((function(t){var n=mt(e._urls),r=n[0],i=n.slice(1);return e._urls=[].concat(K(i),[r]),t}))},n._createWs=function(e,t){var n=this;return function e(t){var n=new Promise(t[0]);return 1===t.length?n:n.catch((function(){return e(t.slice(1))}))}(e.map((function(e){return function(r,i){cn("connect [".concat(e,"] ").concat(t));var o=Et("WebSocket"),s=t?new o(e,t):new o(e);s.binaryType=n.binaryType||"arraybuffer",s.onopen=function(){return r(s)},s.onclose=function(t){return t instanceof Error?i(t):i(new Error("Failed to connect [".concat(e,"]")))},s.onerror=s.onclose}}))).then((function(e){return n._ws=e,n._ws.onclose=n._handleClose.bind(n),n._ws.onmessage=n._handleMessage.bind(n),e}))},n._destroyWs=function(){var e=this._ws;e&&(e.onopen=null,e.onclose=null,e.onerror=null,e.onmessage=null,this._ws=null,e.close())},n.onbeforeevent=function(e,t,n){for(var r=arguments.length,i=new Array(r>3?r-3:0),o=3;o<r;o++)i[o-3]=arguments[o];cn("".concat(e,": ").concat(t," -> ").concat(n," %o"),i)},n.onopen=function(){this.emit("open")},n.onconnected=function(){this._startConnectionKeeper()},n.onleaveconnected=function(e,t,n){this._stopConnectionKeeper(),this._destroyWs(),"offline"!==n&&"disconnected"!==n||this.emit(fn)},n.onpause=function(){this.emit(dn)},n.onbeforeresume=function(){this.emit(mn)},n.onreconnect=function(){this.emit(ln)},n.ondisconnected=function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=t===dn?0:gn.call(null,i);cn("schedule attempt=".concat(i," delay=").concat(o)),this.emit(pn,i,o),this.__scheduledRetry&&clearTimeout(this.__scheduledRetry),this.__scheduledRetry=setTimeout((function(){r.is("disconnected")&&r.retry(i)}),o)},n.onretry=function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.emit(hn,i),this._open().then((function(){return r.can("reconnect")&&r.reconnect()}),(function(){return r.can("fail")&&r.fail(i+1)}))},n.onerror=function(e,t,n,r){this.emit("error",r)},n.onclose=function(){xt.removeEventListener&&(this.__pause&&xt.removeEventListener("offline",this.__pause),this.__resume&&xt.removeEventListener("online",this.__resume))},n.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")}},n._ping=function(){cn("ping");try{this.ping()}catch(e){console.warn("websocket ping error: ".concat(e.message))}},n.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.")},n._postponeTimeoutTimer=function(){var e=this;cn("_postponeTimeoutTimer"),this._clearTimeoutTimers(),this._timeoutTimer=setTimeout((function(){cn("timeout"),e.disconnect()}),38e4)},n._clearTimeoutTimers=function(){this._timeoutTimer&&clearTimeout(this._timeoutTimer)},n._startConnectionKeeper=function(){cn("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()):cn("connection keeper disabled due to the lack of #addEventListener.")},n._stopConnectionKeeper=function(){cn("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)},n._handleClose=function(e){cn("ws closed [".concat(e.code,"] ").concat(e.reason)),this.isFinished()||this.handleClose(e)},n.handleClose=function(){this.disconnect()},n.send=function(e){cn("send",e),this._ws.send(e)},n._handleMessage=function(e){cn("message",e.data),this.handleMessage(e.data)},n.handleMessage=function(e){this.emit("message",e)},t}(z)).prototype,"_ping",[yn],Object.getOwnPropertyDescriptor(Ft.prototype,"_ping"),Ft.prototype),vt(Ft.prototype,"send",[yn],Object.getOwnPropertyDescriptor(Ft.prototype,"send"),Ft.prototype),Ft);bt.create({target:vn.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 bn=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."}}),wn=Object.freeze(Object.keys(bn).reduce((function(e,t){return Object.assign(e,h({},bn[t].name,Number(t)))}),{})),En=function(e){var t=e.code,n=e.reason,r=e.appCode,i=e.detail,o=e.error,s=n||i||o,a=n;!s&&bn[t]&&(a=bn[t].name,s=bn[t].message||a),s||(s="Unknow Error: ".concat(t));var u=new Error(s);return Object.assign(u,{code:t,appCode:r,detail:i,name:a})},_n=le("LC:Connection"),Tn=Symbol("expire"),On=function(e){return!(e.cmd===B.direct||e.cmd===B.session&&e.op===V.open||e.cmd===B.conv&&(e.op===V.start||e.op===V.update||e.op===V.members))},Sn=function(e){function t(t,n){var r,i=n.format,o=n.version;_n("initializing Connection");var s="lc.".concat(i,".").concat(o);return(r=e.call(this,t,s)||this)._protocolFormat=i,r._commands={},r._serialId=0,r}re(t,e);var n=t.prototype;return n.send=function(){var t=$(W.mark((function t(n){var r,i,o,s,a,u,c=this,f=arguments;return W.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(r=!(f.length>1&&void 0!==f[1])||f[1])){t.next=11;break}if(!On(n)){t.next=8;break}if(i=n.toArrayBuffer(),!(s=ft(this._commands).find((function(e){var t=e.buffer,r=e.command;return r.cmd===n.cmd&&r.op===n.op&&sn(t,i)})))){t.next=8;break}return console.warn("Duplicated command [cmd:".concat(n.cmd," op:").concat(n.op,"] is throttled.")),t.abrupt("return",s.promise);case 8:this._serialId+=1,o=this._serialId,n.i=o;case 11:if(_n.enabled&&_n("↑ %O sent",en(n)),"proto2base64"===this._protocolFormat?a=n.toBase64():n.toArrayBuffer&&(a=n.toArrayBuffer()),a){t.next=15;break}throw new TypeError("".concat(n," is not a GenericCommand"));case 15:if(e.prototype.send.call(this,a),r){t.next=18;break}return t.abrupt("return",void 0);case 18:return u=new Promise((function(e,t){c._commands[o]={command:n,buffer:i,resolve:e,reject:t,timeout:setTimeout((function(){c._commands[o]&&(_n.enabled&&_n("✗ %O timeout",en(n)),t(En({error:"Command Timeout [cmd:".concat(n.cmd," op:").concat(n.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)}}(),n.handleMessage=function(e){var t;try{t=N.decode(e),_n.enabled&&_n("↓ %O received",en(t))}catch(t){return void console.warn("Decode message failed:",t.message,e)}var n=t.i;if(n)this._commands[n]?(clearTimeout(this._commands[n].timeout),t.cmd===B.error?this._commands[n].reject(En(t.errorMessage)):this._commands[n].resolve(t),delete this._commands[n]):console.warn("Unexpected command received with serialId [".concat(n,"],\n which have timed out or never been requested."));else switch(t.cmd){case B.error:return void this.emit("error",En(t.errorMessage));case B.goaway:return void this.emit(Tn);default:this.emit("message",t)}},n.ping=function(){return this.send(new N({cmd:B.echo})).catch((function(e){return _n("ping failed:",e)}))},t}(vn),An=i((function(e){var t;e.exports.timeout=function(e,n){var r,i=new t;return Promise.race([e,new Promise((function(e,t){r=setTimeout((function(){t(i)}),n)}))]).then((function(e){return clearTimeout(r),e}),(function(e){throw clearTimeout(r),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"})),In=An.timeout,Cn=(An.TimeoutError,le("LC:request")),Pn=function(e){var t=e.method,n=void 0===t?"GET":t,r=e.url,i=e.query,o=e.headers,s=e.data,a=e.timeout,u=r;if(i){var c=Object.keys(i).map((function(e){var t=i[e];if(void 0!==t){var n=Pt(t)?JSON.stringify(t):t;return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n))}})).filter((function(e){return e})).join("&");u="".concat(u,"?").concat(c)}Cn("Req: %O %O %O",n,u,{headers:o,data:s});var f=Et("request")(u,{method:n,headers:o,data:s}).then((function(e){if(!1===e.ok){var t=En(e.data);throw t.response=e,t}return Cn("Res: %O %O %O",u,e.status,e.data),e.data})).catch((function(e){throw e.response&&Cn("Error: %O %O %O",u,e.response.status,e.response.data),e}));return a?In(f,a):f},xn=function(e,t){e&&e.forEach((function(e){try{e(t)}catch(t){throw e._pluginName&&(t.message+="[".concat(e._pluginName,"]")),t}}))},Mn=function(e){return function(t){return tn(e).reduce((function(e,t){return e.then(function(e){return function(t){var n=t.constructor;return Promise.resolve(t).then(e).then(Bt((function(r){return null==r?console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns ").concat(r," while a ").concat(t.constructor.name," expected.")):r instanceof n?0:console.warn("Middleware[".concat(e._pluginName||"anonymous plugin",":").concat(e.name||"anonymous middleware","] param/return types not match. It returns a ").concat(r.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))}},kn=function(e,t){return tn(e).reduce((function(e,n){return e.then((function(e){return!1!==e&&n.apply(void 0,K(t))})).catch((function(e){throw n._pluginName&&(e.message+="[".concat(n._pluginName,"]")),e}))}),Promise.resolve(!0))};function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Rn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}for(var Nn=le("LC:Realtime"),Ln=new Nt("push-router"),Dn={},Fn=function(e){function n(r){var i,o=r.plugins,s=te(r,["plugins"]);Nn("initializing Realtime %s %O","5.0.0-rc.7",s),i=e.call(this)||this;var a=s.appId;if("string"!=typeof a)throw new TypeError("appId [".concat(a,"] is not a string"));if(Dn[a])throw new Error("App [".concat(a,"] is already initialized."));if(Dn[a]=!0,"string"!=typeof s.appKey)throw new TypeError("appKey [".concat(s.appKey,"] is not a string"));if(function(e){return"-MdYXbMMI"!==e.slice(-9)}(a)&&!s.server)throw new TypeError("server option is required for apps from CN region");i._options=Rn({appId:void 0,appKey:void 0,noBinary:!1,ssl:!0,RTMServerName:void 0!==t?t.env.RTM_SERVER_NAME:void 0},s),i._cache=new Nt("endpoints");var u=Ht(ne(i));u.clients=new Set,u.pendingClients=new Set;var c=[].concat(K(tn(n.__preRegisteredPlugins)),K(tn(o)));return Nn("Using plugins %o",c.map((function(e){return e.name}))),i._plugins=c.reduce((function(e,t){return Object.keys(t).forEach((function(n){({}).hasOwnProperty.call(t,n)&&"name"!==n&&(t.name&&tn(t[n]).forEach((function(e){e._pluginName=t.name})),e[n]=tn(e[n]).concat(t[n]))})),e}),{}),xn(i._plugins.onRealtimeCreate,ne(i)),i}re(n,e);var r=n.prototype;return r._request=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d,m;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.method,r=t.url,i=t.version,o=void 0===i?"1.1":i,s=t.path,a=t.query,u=t.headers,c=t.data,f=r){e.next=9;break}return l=this._options,h=l.appId,p=l.server,e.next=6,this.constructor._getServerUrls({appId:h,server:p});case 6:d=e.sent,m=d.api,f="".concat(m,"/").concat(o).concat(s);case 9:return e.abrupt("return",Pn({url:f,method:n,query:a,headers:Rn({"X-LC-Id":this._options.appId,"X-LC-Key":this._options.appKey},u),data:c}));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r._open=function(){var e=this;if(this._openPromise)return this._openPromise;var t="protobuf2";this._options.noBinary&&(t="proto2base64");var n={format:t,version:3};return this._openPromise=new Promise((function(t,r){Nn("No connection established, create a new one.");var i=new Sn((function(){return e._getRTMServers(e._options)}),n);i.on("open",(function(){return t(i)})).on("error",(function(t){delete e._openPromise,r(t)})).on(Tn,$(W.mark((function t(){return W.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Nn("Connection expired. Refresh endpoints."),e._cache.set("endpoints",null,0),t.next=4,e._getRTMServers(e._options);case 4:i.urls=t.sent,i.disconnect();case 6:case"end":return t.stop()}}),t)})))).on("message",e._dispatchCommand.bind(e)),[fn,ln,hn,pn,dn,mn].forEach((function(t){return i.on(t,(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];Nn("".concat(t," event emitted. %o"),r),e.emit.apply(e,[t].concat(r)),t!==ln&&Ht(e).clients.forEach((function(e){e.emit.apply(e,[t].concat(r))}))}))})),i.handleClose=function(e){[wn.APP_NOT_AVAILABLE,wn.INVALID_LOGIN,wn.INVALID_ORIGIN].some((function(t){return t===e.code}))?this.throw(En(e)):this.disconnect()},Ht(e).connection=i})),this._openPromise},r._getRTMServers=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.RTMServers){e.next=2;break}return e.abrupt("return",ht(tn(t.RTMServers)));case 2:if(!(r=this._cache.get("endpoints"))){e.next=7;break}n=r,e.next=14;break;case 7:return e.next=9,this.constructor._fetchRTMServers(t);case 9:if(n=e.sent,o=(i=n).server,s=i.secondary,a=i.ttl,"string"==typeof o||"string"==typeof s||"number"==typeof a){e.next=13;break}throw new Error("malformed RTM route response: ".concat(JSON.stringify(n)));case 13:this._cache.set("endpoints",n,1e3*n.ttl);case 14:return Nn("endpoint info: %O",n),e.abrupt("return",[n.server,n.secondary]);case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._getServerUrls=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.appId,r=t.server,Nn("fetch server urls"),!r){e.next=6;break}if("string"==typeof r){e.next=5;break}return e.abrupt("return",r);case 5:return e.abrupt("return",{RTMRouter:r,api:r});case 6:if(!(i=Ln.get(n))){e.next=9;break}return e.abrupt("return",i);case 9:return"https://",e.abrupt("return",Pn({url:"https://app-router.com/2/route",query:{appId:n},timeout:2e4}).then(Bt(Nn)).then((function(e){var t=e.rtm_router_server,r=e.api_server,i=e.ttl,o=void 0===i?3600:i;if(!t)throw new Error("rtm router not exists");var s={RTMRouter:"".concat("https://").concat(t),api:"".concat("https://").concat(r)};return Ln.set(n,s,1e3*o),s})).catch((function(){var e=n.slice(0,8).toLowerCase();return{RTMRouter:"".concat("https://").concat(e,".rtm.").concat("lncldglobal.com"),api:"".concat("https://").concat(e,".api.").concat("lncldglobal.com")}})));case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n._fetchRTMServers=function(e){var t=e.appId,n=e.ssl,r=e.server,i=e.RTMServerName;return Nn("fetch endpoint info"),this._getServerUrls({appId:t,server:r}).then(Bt(Nn)).then((function(e){var r=e.RTMRouter;return Pn({url:"".concat(r,"/v1/route"),query:{appId:t,secure:n,features:rn?"wechat":void 0,server:i,_t:Date.now()},timeout:2e4}).then(Bt(Nn))}))},r._close=function(){this._openPromise&&this._openPromise.then((function(e){return e.close()})),delete this._openPromise},r.retry=function(){var e=Ht(this).connection;if(!e)throw new Error("no connection established");if(e.cannot("retry"))throw new Error("retrying not allowed when not disconnected. the connection is now ".concat(e.current));return e.retry()},r.pause=function(){var e=Ht(this).connection;e&&e.can("pause")&&e.pause()},r.resume=function(){var e=Ht(this).connection;e&&e.can("resume")&&e.resume()},r._registerPending=function(e){Ht(this).pendingClients.add(e)},r._deregisterPending=function(e){Ht(this).pendingClients.delete(e)},r._register=function(e){Ht(this).clients.add(e)},r._deregister=function(e){var t=Ht(this);t.clients.delete(e),t.clients.size+t.pendingClients.size===0&&this._close()},r._dispatchCommand=function(e){return kn(this._plugins.beforeCommandDispatch,[e,this]).then((function(t){return!!t&&Nn("[WARN] Unexpected message received: %O",en(e))}))},n}(z),Un=Promise,Bn=i((function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}})),Vn=[],Yn=0;Yn<256;++Yn)Vn[Yn]=(Yn+256).toString(16).substr(1);var qn=function(e,t){var n=t||0,r=Vn;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")};var zn=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Bn)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[r+o]=i[o];return t||qn(i)};var Wn=function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],r=!0,i=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw o}}return n}};var Gn=function(e,t){return pt(e)||Wn(e,t)||Q(e,t)||dt()},$n=i((function(e,t){!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(256),r=0;r<e.length;r++)n[e.charCodeAt(r)]=r;t.encode=function(t){var n,r=new Uint8Array(t),i=r.length,o="";for(n=0;n<i;n+=3)o+=e[r[n]>>2],o+=e[(3&r[n])<<4|r[n+1]>>4],o+=e[(15&r[n+1])<<2|r[n+2]>>6],o+=e[63&r[n+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,r,i,o,s,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t<u;t+=4)r=n[e.charCodeAt(t)],i=n[e.charCodeAt(t+1)],o=n[e.charCodeAt(t+2)],s=n[e.charCodeAt(t+3)],l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return f}}()})),Jn=$n.encode,Zn=$n.decode;var Xn=function(){this.__data__=[],this.size=0};var Qn=function(e,t){return e===t||e!=e&&t!=t};var Hn=function(e,t){for(var n=e.length;n--;)if(Qn(e[n][0],t))return n;return-1},Kn=Array.prototype.splice;var er=function(e){var t=this.__data__,n=Hn(t,e);return!(n<0)&&(n==t.length-1?t.pop():Kn.call(t,n,1),--this.size,!0)};var tr=function(e){var t=this.__data__,n=Hn(t,e);return n<0?void 0:t[n][1]};var nr=function(e){return Hn(this.__data__,e)>-1};var rr=function(e,t){var n=this.__data__,r=Hn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function ir(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ir.prototype.clear=Xn,ir.prototype.delete=er,ir.prototype.get=tr,ir.prototype.has=nr,ir.prototype.set=rr;var or=ir;var sr=function(){this.__data__=new or,this.size=0};var ar=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n};var ur=function(e){return this.__data__.get(e)};var cr,fr=function(e){return this.__data__.has(e)},lr=Te["__core-js_shared__"],hr=(cr=/[^.]+$/.exec(lr&&lr.keys&&lr.keys.IE_PROTO||""))?"Symbol(src)_1."+cr:"";var pr=function(e){return!!hr&&hr in e},dr=n.prototype.toString;var mr=function(e){if(null!=e){try{return dr.call(e)}catch(e){}try{return e+""}catch(e){}}return""},gr=/^\[object .+?Constructor\]$/,yr=n.prototype,vr=Object.prototype,br=yr.toString,wr=vr.hasOwnProperty,Er=RegExp("^"+br.call(wr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var _r=function(e){return!(!st(e)||pr(e))&&(at(e)?Er:gr).test(mr(e))};var Tr=function(e,t){return null==e?void 0:e[t]};var Or=function(e,t){var n=Tr(e,t);return _r(n)?n:void 0},Sr=Or(Te,"Map"),Ar=Or(Object,"create");var Ir=function(){this.__data__=Ar?Ar(null):{},this.size=0};var Cr=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Pr=Object.prototype.hasOwnProperty;var xr=function(e){var t=this.__data__;if(Ar){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return Pr.call(t,e)?t[e]:void 0},Mr=Object.prototype.hasOwnProperty;var kr=function(e){var t=this.__data__;return Ar?void 0!==t[e]:Mr.call(t,e)};var jr=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ar&&void 0===t?"__lodash_hash_undefined__":t,this};function Rr(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Rr.prototype.clear=Ir,Rr.prototype.delete=Cr,Rr.prototype.get=xr,Rr.prototype.has=kr,Rr.prototype.set=jr;var Nr=Rr;var Lr=function(){this.size=0,this.__data__={hash:new Nr,map:new(Sr||or),string:new Nr}};var Dr=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};var Fr=function(e,t){var n=e.__data__;return Dr(t)?n["string"==typeof t?"string":"hash"]:n.map};var Ur=function(e){var t=Fr(this,e).delete(e);return this.size-=t?1:0,t};var Br=function(e){return Fr(this,e).get(e)};var Vr=function(e){return Fr(this,e).has(e)};var Yr=function(e,t){var n=Fr(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function qr(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}qr.prototype.clear=Lr,qr.prototype.delete=Ur,qr.prototype.get=Br,qr.prototype.has=Vr,qr.prototype.set=Yr;var zr=qr;var Wr=function(e,t){var n=this.__data__;if(n instanceof or){var r=n.__data__;if(!Sr||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new zr(r)}return n.set(e,t),this.size=n.size,this};function Gr(e){var t=this.__data__=new or(e);this.size=t.size}Gr.prototype.clear=sr,Gr.prototype.delete=ar,Gr.prototype.get=ur,Gr.prototype.has=fr,Gr.prototype.set=Wr;var $r=Gr;var Jr=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};var Zr=function(e){return this.__data__.has(e)};function Xr(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new zr;++t<n;)this.add(e[t])}Xr.prototype.add=Xr.prototype.push=Jr,Xr.prototype.has=Zr;var Qr=Xr;var Hr=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1};var Kr=function(e,t){return e.has(t)};var ei=function(e,t,n,r,i,o){var s=1&n,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e),f=o.get(t);if(c&&f)return c==t&&f==e;var l=-1,h=!0,p=2&n?new Qr:void 0;for(o.set(e,t),o.set(t,e);++l<a;){var d=e[l],m=t[l];if(r)var g=s?r(m,d,l,t,e,o):r(d,m,l,e,t,o);if(void 0!==g){if(g)continue;h=!1;break}if(p){if(!Hr(t,(function(e,t){if(!Kr(p,t)&&(d===e||i(d,e,n,r,o)))return p.push(t)}))){h=!1;break}}else if(d!==m&&!i(d,m,n,r,o)){h=!1;break}}return o.delete(e),o.delete(t),h},ti=Te.Uint8Array;var ni=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n};var ri=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n},ii=Oe?Oe.prototype:void 0,oi=ii?ii.valueOf:void 0;var si=function(e,t,n,r,i,o,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new ti(e),new ti(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Qn(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=ni;case"[object Set]":var u=1&r;if(a||(a=ri),e.size!=t.size&&!u)return!1;var c=s.get(e);if(c)return c==t;r|=2,s.set(e,t);var f=ei(a(e),a(t),r,i,o,s);return s.delete(e),f;case"[object Symbol]":if(oi)return oi.call(e)==oi.call(t)}return!1};var ai=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e};var ui=function(e,t,n){var r=t(e);return Be(e)?r:ai(r,n(e))};var ci=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o};var fi=function(){return[]},li=Object.prototype.propertyIsEnumerable,hi=Object.getOwnPropertySymbols,pi=hi?function(e){return null==e?[]:(e=Object(e),ci(hi(e),(function(t){return li.call(e,t)})))}:fi;var di=function(e){return ui(e,ct,pi)},mi=Object.prototype.hasOwnProperty;var gi=function(e,t,n,r,i,o){var s=1&n,a=di(e),u=a.length;if(u!=di(t).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in t:mi.call(t,f)))return!1}var l=o.get(e),h=o.get(t);if(l&&h)return l==t&&h==e;var p=!0;o.set(e,t),o.set(t,e);for(var d=s;++c<u;){var m=e[f=a[c]],g=t[f];if(r)var y=s?r(g,m,f,t,e,o):r(m,g,f,e,t,o);if(!(void 0===y?m===g||i(m,g,n,r,o):y)){p=!1;break}d||(d="constructor"==f)}if(p&&!d){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(p=!1)}return o.delete(e),o.delete(t),p},yi=Or(Te,"DataView"),vi=Or(Te,"Promise"),bi=Or(Te,"Set"),wi=Or(Te,"WeakMap"),Ei=mr(yi),_i=mr(Sr),Ti=mr(vi),Oi=mr(bi),Si=mr(wi),Ai=je;(yi&&"[object DataView]"!=Ai(new yi(new ArrayBuffer(1)))||Sr&&"[object Map]"!=Ai(new Sr)||vi&&"[object Promise]"!=Ai(vi.resolve())||bi&&"[object Set]"!=Ai(new bi)||wi&&"[object WeakMap]"!=Ai(new wi))&&(Ai=function(e){var t=je(e),n="[object Object]"==t?e.constructor:void 0,r=n?mr(n):"";if(r)switch(r){case Ei:return"[object DataView]";case _i:return"[object Map]";case Ti:return"[object Promise]";case Oi:return"[object Set]";case Si:return"[object WeakMap]"}return t});var Ii=Ai,Ci=Object.prototype.hasOwnProperty;var Pi=function(e,t,n,r,i,o){var s=Be(e),a=Be(t),u=s?"[object Array]":Ii(e),c=a?"[object Array]":Ii(t),f="[object Object]"==(u="[object Arguments]"==u?"[object Object]":u),l="[object Object]"==(c="[object Arguments]"==c?"[object Object]":c),h=u==c;if(h&&Ye(e)){if(!Ye(t))return!1;s=!0,f=!1}if(h&&!f)return o||(o=new $r),s||Qe(e)?ei(e,t,n,r,i,o):si(e,t,u,n,r,i,o);if(!(1&n)){var p=f&&Ci.call(e,"__wrapped__"),d=l&&Ci.call(t,"__wrapped__");if(p||d){var m=p?e.value():e,g=d?t.value():t;return o||(o=new $r),i(m,g,n,r,o)}}return!!h&&(o||(o=new $r),gi(e,t,n,r,i,o))};var xi=function e(t,n,r,i,o){return t===n||(null==t||null==n||!Re(t)&&!Re(n)?t!=t&&n!=n:Pi(t,n,r,i,e,o))};var Mi=function(e,t,n,r){var i=n.length,o=i,s=!r;if(null==e)return!o;for(e=Object(e);i--;){var a=n[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){var u=(a=n[i])[0],c=e[u],f=a[1];if(s&&a[2]){if(void 0===c&&!(u in e))return!1}else{var l=new $r;if(r)var h=r(c,f,u,e,t,l);if(!(void 0===h?xi(f,c,3,r,l):h))return!1}}return!0};var ki=function(e){return e==e&&!st(e)};var ji=function(e){for(var t=ct(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,ki(i)]}return t};var Ri=function(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}};var Ni=function(e){var t=ji(e);return 1==t.length&&t[0][2]?Ri(t[0][0],t[0][1]):function(n){return n===e||Mi(n,e,t)}};var Li=function(e){return"symbol"==typeof e||Re(e)&&"[object Symbol]"==je(e)},Di=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Fi=/^\w*$/;var Ui=function(e,t){if(Be(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!Li(e))||(Fi.test(e)||!Di.test(e)||null!=t&&e in Object(t))};function Bi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Bi.Cache||zr),n}Bi.Cache=zr;var Vi=Bi;var Yi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qi=/\\(\\)?/g,zi=function(e){var t=Vi(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Yi,(function(e,n,r,i){t.push(r?i.replace(qi,"$1"):n||e)})),t})),Wi=Oe?Oe.prototype:void 0,Gi=Wi?Wi.toString:void 0;var $i=function e(t){if("string"==typeof t)return t;if(Be(t))return ve(t,e)+"";if(Li(t))return Gi?Gi.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n};var Ji=function(e){return null==e?"":$i(e)};var Zi=function(e,t){return Be(e)?e:Ui(e,t)?[e]:zi(Ji(e))};var Xi=function(e){if("string"==typeof e||Li(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t};var Qi=function(e,t){for(var n=0,r=(t=Zi(t,e)).length;null!=e&&n<r;)e=e[Xi(t[n++])];return n&&n==r?e:void 0};var Hi=function(e,t,n){var r=null==e?void 0:Qi(e,t);return void 0===r?n:r};var Ki=function(e,t){return null!=e&&t in Object(e)};var eo=function(e,t,n){for(var r=-1,i=(t=Zi(t,e)).length,o=!1;++r<i;){var s=Xi(t[r]);if(!(o=null!=e&&n(e,s)))break;e=e[s]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&We(i)&&ze(s,i)&&(Be(e)||Ue(e))};var to=function(e,t){return null!=e&&eo(e,t,Ki)};var no=function(e,t){return Ui(e)&&ki(t)?Ri(Xi(e),t):function(n){var r=Hi(n,e);return void 0===r&&r===t?to(n,e):xi(t,r,3)}};var ro=function(e){return e};var io=function(e){return function(t){return null==t?void 0:t[e]}};var oo=function(e){return function(t){return Qi(t,e)}};var so=function(e){return Ui(e)?io(Xi(e)):oo(e)};var ao=function(e){return"function"==typeof e?e:null==e?ro:"object"==typeof e?Be(e)?no(e[0],e[1]):Ni(e):so(e)};var uo=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var co=function(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=e[r+t];return o};var fo=function(e,t){return t.length<2?e:Qi(e,co(t,0,-1))};var lo=function(e,t){return t=Zi(t,e),null==(e=fo(e,t))||delete e[Xi(uo(t))]},ho=Array.prototype.splice;var po=function(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;ze(i)?ho.call(e,i,1):lo(e,i)}}return e};var mo=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],o=e.length;for(t=ao(t);++r<o;){var s=e[r];t(s,r,e)&&(n.push(s),i.push(r))}return po(e,i),n},go=Object.prototype.hasOwnProperty;var yo=function(e){if(null==e)return!0;if(ut(e)&&(Be(e)||"string"==typeof e||"function"==typeof e.splice||Ye(e)||Qe(e)||Ue(e)))return!e.length;var t=Ii(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(tt(e))return!ot(e).length;for(var n in e)if(go.call(e,n))return!1;return!0};var vo=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e},bo=function(){try{var e=Or(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();var wo=function(e,t,n){"__proto__"==t&&bo?bo(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Eo=Object.prototype.hasOwnProperty;var _o=function(e,t,n){var r=e[t];Eo.call(e,t)&&Qn(r,n)&&(void 0!==n||t in e)||wo(e,t,n)};var To=function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var a=t[o],u=r?r(n[a],e[a],a,n,e):void 0;void 0===u&&(u=e[a]),i?wo(n,a,u):_o(n,a,u)}return n};var Oo=function(e,t){return e&&To(t,ct(t),e)};var So=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t},Ao=Object.prototype.hasOwnProperty;var Io=function(e){if(!st(e))return So(e);var t=tt(e),n=[];for(var r in e)("constructor"!=r||!t&&Ao.call(e,r))&&n.push(r);return n};var Co=function(e){return ut(e)?Ke(e,!0):Io(e)};var Po=function(e,t){return e&&To(t,Co(t),e)},xo=i((function(e,t){var n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,i=r&&r.exports===n?Te.Buffer:void 0,o=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}));var Mo=function(e,t){return To(e,pi(e),t)},ko=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)ai(t,pi(e)),e=Tt(e);return t}:fi;var jo=function(e,t){return To(e,ko(e),t)};var Ro=function(e){return ui(e,Co,ko)},No=Object.prototype.hasOwnProperty;var Lo=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&No.call(e,"index")&&(n.index=e.index,n.input=e.input),n};var Do=function(e){var t=new e.constructor(e.byteLength);return new ti(t).set(new ti(e)),t};var Fo=function(e,t){var n=t?Do(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)},Uo=/\w*$/;var Bo=function(e){var t=new e.constructor(e.source,Uo.exec(e));return t.lastIndex=e.lastIndex,t},Vo=Oe?Oe.prototype:void 0,Yo=Vo?Vo.valueOf:void 0;var qo=function(e){return Yo?Object(Yo.call(e)):{}};var zo=function(e,t){var n=t?Do(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)};var Wo=function(e,t,n){var r=e.constructor;switch(t){case"[object ArrayBuffer]":return Do(e);case"[object Boolean]":case"[object Date]":return new r(+e);case"[object DataView]":return Fo(e,n);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return zo(e,n);case"[object Map]":return new r;case"[object Number]":case"[object String]":return new r(e);case"[object RegExp]":return Bo(e);case"[object Set]":return new r;case"[object Symbol]":return qo(e)}},Go=Object.create,$o=function(){function e(){}return function(t){if(!st(t))return{};if(Go)return Go(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();var Jo=function(e){return"function"!=typeof e.constructor||tt(e)?{}:$o(Tt(e))};var Zo=function(e){return Re(e)&&"[object Map]"==Ii(e)},Xo=Ze&&Ze.isMap,Qo=Xo?Je(Xo):Zo;var Ho=function(e){return Re(e)&&"[object Set]"==Ii(e)},Ko=Ze&&Ze.isSet,es=Ko?Je(Ko):Ho,ts={};ts["[object Arguments]"]=ts["[object Array]"]=ts["[object ArrayBuffer]"]=ts["[object DataView]"]=ts["[object Boolean]"]=ts["[object Date]"]=ts["[object Float32Array]"]=ts["[object Float64Array]"]=ts["[object Int8Array]"]=ts["[object Int16Array]"]=ts["[object Int32Array]"]=ts["[object Map]"]=ts["[object Number]"]=ts["[object Object]"]=ts["[object RegExp]"]=ts["[object Set]"]=ts["[object String]"]=ts["[object Symbol]"]=ts["[object Uint8Array]"]=ts["[object Uint8ClampedArray]"]=ts["[object Uint16Array]"]=ts["[object Uint32Array]"]=!0,ts["[object Error]"]=ts["[object Function]"]=ts["[object WeakMap]"]=!1;var ns=function e(t,n,r,i,o,s){var a,u=1&n,c=2&n,f=4&n;if(r&&(a=o?r(t,i,o,s):r(t)),void 0!==a)return a;if(!st(t))return t;var l=Be(t);if(l){if(a=Lo(t),!u)return he(t,a)}else{var h=Ii(t),p="[object Function]"==h||"[object GeneratorFunction]"==h;if(Ye(t))return xo(t,u);if("[object Object]"==h||"[object Arguments]"==h||p&&!o){if(a=c||p?{}:Jo(t),!u)return c?jo(t,Po(a,t)):Mo(t,Oo(a,t))}else{if(!ts[h])return o?t:{};a=Wo(t,h,u)}}s||(s=new $r);var d=s.get(t);if(d)return d;s.set(t,a),es(t)?t.forEach((function(i){a.add(e(i,n,r,i,t,s))})):Qo(t)&&t.forEach((function(i,o){a.set(o,e(i,n,r,o,t,s))}));var m=l?void 0:(f?c?Ro:di:c?Co:ct)(t);return vo(m||t,(function(i,o){m&&(i=t[o=i]),_o(a,o,e(i,n,r,o,t,s))})),a};var rs=function(e){return ns(e,5)};var is=function(e){return function(t,n,r){var i=Object(t);if(!ut(t)){var o=ao(n);t=ct(t),n=function(e){return o(i[e],e,i)}}var s=e(t,n,r);return s>-1?i[o?t[s]:s]:void 0}};var os=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return-1},ss=/\s/;var as=function(e){for(var t=e.length;t--&&ss.test(e.charAt(t)););return t},us=/^\s+/;var cs=function(e){return e?e.slice(0,as(e)+1).replace(us,""):e},fs=/^[-+]0x[0-9a-f]+$/i,ls=/^0b[01]+$/i,hs=/^0o[0-7]+$/i,ps=parseInt;var ds=function(e){if("number"==typeof e)return e;if(Li(e))return NaN;if(st(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=st(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=cs(e);var n=ls.test(e);return n||hs.test(e)?ps(e.slice(2),n?2:8):fs.test(e)?NaN:+e};var ms=function(e){return e?(e=ds(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var gs=function(e){var t=ms(e),n=t%1;return t==t?n?t-n:t:0},ys=Math.max;var vs,bs=is((function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:gs(n);return i<0&&(i=ys(r+i,0)),os(e,ao(t),i)})),ws=Object.freeze({__proto__:null,UNREAD_MESSAGES_COUNT_UPDATE:"unreadmessagescountupdate",CLOSE:"close",CONFLICT:"conflict",CONVERSATION_INFO_UPDATED:"conversationinfoupdated",UNHANDLED_MESSAGE:"unhandledmessage",INVITED:"invited",KICKED:"kicked",MEMBERS_JOINED:"membersjoined",MEMBERS_LEFT:"membersleft",MEMBER_INFO_UPDATED:"memberinfoupdated",BLOCKED:"blocked",UNBLOCKED:"unblocked",MEMBERS_BLOCKED:"membersblocked",MEMBERS_UNBLOCKED:"membersunblocked",MUTED:"muted",UNMUTED:"unmuted",MEMBERS_MUTED:"membersmuted",MEMBERS_UNMUTED:"membersunmuted",MESSAGE:"message",MESSAGE_RECALL:"messagerecall",MESSAGE_UPDATE:"messageupdate",LAST_DELIVERED_AT_UPDATE:"lastdeliveredatupdate",LAST_READ_AT_UPDATE:"lastreadatupdate",INFO_UPDATED:"infoupdated"});function Es(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Es(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Es(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ts={NONE:Symbol("none"),SENDING:Symbol("sending"),SENT:Symbol("sent"),DELIVERED:Symbol("delivered"),FAILED:Symbol("failed")};Object.freeze(Ts);var Os,Ss=(h(vs={},Ts.NONE,!0),h(vs,Ts.SENDING,!0),h(vs,Ts.SENT,!0),h(vs,Ts.DELIVERED,!0),h(vs,Ts.READ,!0),h(vs,Ts.FAILED,!0),vs),As=function(){function e(e){Object.assign(this,{content:e},{id:zn(),cid:null,timestamp:new Date,from:void 0,mentionList:[],mentionedAll:!1,_mentioned:!1}),this._setStatus(Ts.NONE)}var t=e.prototype;return t.getPayload=function(){return this.content},t._toJSON=function(){return{id:this.id,cid:this.cid,from:this.from,timestamp:this.timestamp,deliveredAt:this.deliveredAt,updatedAt:this.updatedAt,mentionList:this.mentionList,mentionedAll:this.mentionedAll,mentioned:this.mentioned}},t.toJSON=function(){return _s(_s({},this._toJSON()),{},{data:this.content})},t.toFullJSON=function(){var e=this.content,t=this.id,n=this.cid,r=this.from,i=this.timestamp,o=this.deliveredAt,s=this._updatedAt,a=this.mentionList,u=this.mentionedAll;return{data:e,id:t,cid:n,from:r,timestamp:qt(i),deliveredAt:qt(o),updatedAt:qt(s),mentionList:a,mentionedAll:u}},t._setStatus=function(e){if(!Ss[e])throw new Error("Invalid message status");this._status=e},t._updateMentioned=function(e){this._mentioned=this.from!==e&&(this.mentionedAll||this.mentionList.indexOf(e)>-1)},t.getMentionList=function(){return this.mentionList},t.setMentionList=function(e){return this.mentionList=tn(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)},yt(e,[{key:"status",get:function(){return this._status}},{key:"timestamp",get:function(){return this._timestamp},set:function(e){this._timestamp=Yt(e)}},{key:"deliveredAt",get:function(){return this._deliveredAt},set:function(e){this._deliveredAt=Yt(e)}},{key:"updatedAt",get:function(){return this._updatedAt||this.timestamp},set:function(e){this._updatedAt=Yt(e)}},{key:"mentioned",get:function(){return this._mentioned}}]),e}(),Is=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}}}},Cs=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 n=$t?Jt(t,"_customFields"):t._customFields;n=Array.isArray(n)?n:[],t._customFields=n.concat(e)}},Ps=function(e){$t&&(e.parse=Jt(e,"parse"))};function xs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ms(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xs(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xs(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ks,js=Cs(["_lctext","_lcattrs"])(Os=function(e){function t(){return e.apply(this,arguments)||this}re(t,e);var n=t.prototype;return n.setText=function(e){return this._lctext=e,this},n.getText=function(){return this._lctext},n.setAttributes=function(e){return this._lcattrs=e,this},n.getAttributes=function(){return this._lcattrs},n._getCustomFields=function(){var e=this;return(Array.isArray(this.constructor._customFields)?this.constructor._customFields:[]).reduce((function(t,n){return"string"!=typeof n||(t[n]=e[n]),t}),{})},n._getType=function(){throw new Error("not implemented")},n.getPayload=function(){return Kt(Ms(Ms({_lctext:this.getText(),_lcattrs:this.getAttributes()},this._getCustomFields()),this._getType()))},n.toJSON=function(){var t=this.type,n=this.text,r=this.attributes,i=this.summary;return Ms(Ms({},e.prototype._toJSON.call(this)),{},{type:t,text:n,attributes:r,summary:i})},n.toFullJSON=function(){return Ms(Ms({},e.prototype.toFullJSON.call(this)),{},{data:this.getPayload()})},t.parse=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new this;n.content=t;var r=$t?Jt(n.constructor,"_customFields"):n.constructor._customFields,i=Array.isArray(r)?r:[];return i=i.reduce((function(e,n){return"string"!=typeof n||(e[n]=t[n]),e}),{}),Object.assign(n,i),e.parse.call(this,t,n)},yt(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}(As))||Os,Rs=Is(-127)(ks=Ps(ks=function(e){function t(){return e.apply(this,arguments)||this}return re(t,e),yt(t,[{key:"summary",get:function(){return"[该消息已撤回]"}}]),t}(js))||ks)||ks;function Ns(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ls(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ns(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ns(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ds=le("LC:Conversation"),Fs=function(e){var t,n,r=e.getPayload();return r instanceof ArrayBuffer?n=r:t="string"!=typeof r?JSON.stringify(r):r,{msg:t,binaryMsg:n}},Us=C.QueryDirection,Bs=Us.NEW,Vs={NEW_TO_OLD:Us.OLD,OLD_TO_NEW:Bs};Object.freeze(Vs);var Ys=function(e){function t(t,n){var r,i=t.id,o=t.lastMessageAt,s=t.lastMessage,a=t.lastDeliveredAt,u=t.lastReadAt,c=t.unreadMessagesCount,f=void 0===c?0:c,l=t.members,h=void 0===l?[]:l,p=t.mentioned,d=void 0!==p&&p,m=te(t,["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"]);return r=e.call(this)||this,Object.assign(ne(r),Ls({id:i,lastMessageAt:o,lastMessage:s,members:h},m)),r.members=Array.from(new Set(r.members)),Object.assign(Ht(ne(r)),{messagesWaitingForReceipt:{},lastDeliveredAt:a,lastReadAt:u,unreadMessagesCount:f,mentioned:d}),r._client=n,Ds.enabled&&ft(ws).forEach((function(e){return r.on(e,(function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r._debug("".concat(e," event emitted. %o"),n)}))})),xn(r._client._plugins.onConversationCreate,ne(r)),r}re(t,e);var n=t.prototype;return n._setUnreadMessagesMentioned=function(e){Ht(this).unreadMessagesMentioned=Boolean(e)},n._setLastDeliveredAt=function(e){var t=Yt(e);t<Ht(this).lastDeliveredAt||(Ht(this).lastDeliveredAt=t,this.emit("lastdeliveredatupdate"))},n._setLastReadAt=function(e){var t=Yt(e);t<Ht(this).lastReadAt||(Ht(this).lastReadAt=t,this.emit("lastreadatupdate"))},n.toFullJSON=function(){var e=this.id,t=this.members,n=this.lastMessageAt,r=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount;return{id:e,members:t,lastMessageAt:qt(n),lastDeliveredAt:qt(r),lastReadAt:qt(i),lastMessage:o?o.toFullJSON():void 0,unreadMessagesCount:s}},n.toJSON=function(){var e=this.id,t=this.members,n=this.lastMessageAt,r=this.lastDeliveredAt,i=this.lastReadAt,o=this.lastMessage,s=this.unreadMessagesCount,a=this.unreadMessagesMentioned;return{id:e,members:t,lastMessageAt:n,lastDeliveredAt:r,lastReadAt:i,lastMessage:o?o.toJSON():void 0,unreadMessagesCount:s,unreadMessagesMentioned:a}},n._debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Ds.apply(void 0,t.concat(["[".concat(this.id,"]")]))},n._send=function(e){var t;null===e.cmd&&(e.cmd="conv"),"conv"===e.cmd&&null===e.convMessage&&(e.convMessage=new A),e.convMessage&&null===e.convMessage.cid&&(e.convMessage.cid=this.id);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(t=this._client)._send.apply(t,[e].concat(r))},n.send=function(){var e=$(W.mark((function e(t,n){var r,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug(t,"send"),t instanceof As){e.next=3;break}throw new TypeError("".concat(t," is not a Message"));case 3:return r=Ls(Ls(Ls({},t.constructor.sendOptions),"function"==typeof t.constructor.getSendOptions?t.constructor.getSendOptions(t):{}),n),i=r.transient,o=r.receipt,s=r.priority,a=r.pushData,u=r.will,o&&(this.transient?console.warn("receipt option is ignored as the conversation is transient."):i?console.warn("receipt option is ignored as the message is sent transiently."):this.members.length>2&&console.warn("receipt option is recommended to be used in one-on-one conversation.")),s&&!this.transient&&console.warn("priority option is ignored as the conversation is not transient."),Object.assign(t,{cid:this.id,from:this._client.id}),t._setStatus(Ts.SENDING),c=Fs(t),f=c.msg,l=c.binaryMsg,h=new N({cmd:"direct",directMessage:new T({msg:f,binaryMsg:l,cid:this.id,r:o,transient:i,dt:t.id,pushData:JSON.stringify(a),will:u,mentionPids:t.mentionList,mentionAll:t.mentionedAll}),priority:s}),e.prev=10,e.next=13,this._send(h);case 13:if(p=e.sent,d=p.ackMessage,m=d.uid,g=d.t,y=d.code,v=d.reason,b=d.appCode,null===y){e.next=17;break}throw En({code:y,reason:v,appCode:b});case 17:return Object.assign(t,{id:m,timestamp:g}),i||(this.lastMessage=t,this.lastMessageAt=t.timestamp),t._setStatus(Ts.SENT),o&&(Ht(this).messagesWaitingForReceipt[t.id]=t),e.abrupt("return",t);case 24:throw e.prev=24,e.t0=e.catch(10),t._setStatus(Ts.FAILED),e.t0;case 28:case"end":return e.stop()}}),e,this,[[10,24]])})));return function(t,n){return e.apply(this,arguments)}}(),n._update=function(){var e=$(W.mark((function e(t,n,r){var i,o,s,a,u,c,f,l;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("patch %O %O %O",t,n,r),!(t instanceof As)){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===Ts.SENT||t.status===Ts.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 r||(s=Fs(n),i=s.msg,o=s.binaryMsg),e.next=13,this._send(new N({cmd:B.patch,op:V.modify,patchMessage:new D({patches:[new F({cid:this.id,mid:t.id,timestamp:Number(t.timestamp),recall:r,data:i,binaryMsg:o,mentionPids:n.mentionList,mentionAll:n.mentionedAll})],lastPatchTime:this._client._lastPatchTime})}));case 13:return a=t.id,u=t.cid,c=t.timestamp,f=t.from,l=t._status,Object.assign(n,{id:a,cid:u,timestamp:c,from:f,_status:l}),this.lastMessage&&this.lastMessage.id===n.id&&(this.lastMessage=n),e.abrupt("return",n);case 17:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.count=function(){var e=$(W.mark((function e(){var t;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("count"),e.next=3,this._send(new N({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)}}(),n._addMembers=function(){},n._removeMembers=function(){},n.update=function(){var e=$(W.mark((function e(t,n){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n instanceof As){e.next=2;break}throw new TypeError("".concat(n," is not a Message"));case 2:return e.abrupt("return",this._update(t,n,!1));case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.recall=function(){var e=$(W.mark((function e(t){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._update(t,new Rs,!0));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.queryMessages=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,y=this,v=arguments;return W.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),n=t.beforeTime,r=t.beforeMessageId,i=t.afterTime,o=t.afterMessageId,s=t.limit,a=t.direction,u=t.type,c=t.startTime,f=t.startMessageId,l=t.startClosed,h=t.endTime,p=t.endMessageId,d=t.endClosed,!(r||n||o||i)){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:n,startMessageId:r,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=Vs.OLD_TO_NEW),e.next=16,this._send(new N({cmd:"logs",logsMessage:new C(Object.assign(m,{cid:this.id}))}));case 16:return g=e.sent,e.abrupt("return",Promise.all(g.logsMessage.logs.map(function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.msgId,r=t.timestamp,i=t.patchTimestamp,o=t.from,s=t.ackAt,a=t.readAt,u=t.data,c=t.mentionAll,f=t.mentionPids,l=t.bin,h={data:u,bin:l,id:n,cid:y.id,timestamp:r,from:o,deliveredAt:s,updatedAt:i,mentionList:f,mentionedAll:c},e.next=4,y._client.parseMessage(h);case 4:return p=e.sent,d=Ts.SENT,2===y.members.length&&(s&&(d=Ts.DELIVERED),s&&y._setLastDeliveredAt(s),a&&y._setLastReadAt(a)),p._setStatus(d),e.abrupt("return",p);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 18:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.createMessagesIterator=function(){var e,t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.beforeTime,i=n.beforeMessageId,o=n.limit;return{next:function(){return(e=void 0===e?t.queryMessages({limit:o,startTime:r,startMessageId:i}):e.then((function(e){return 0===e.length||e.length<o?[]:t.queryMessages({startTime:e[0].timestamp,startMessageId:e[0].id,limit:o})}))).then((function(e){return{value:Array.from(e),done:0===e.length||e.length<o}}))}}},n.read=function(){var e=$(W.mark((function e(){var t;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.unreadMessagesCount=0,this._setUnreadMessagesMentioned(!1),!this.transient){e.next=4;break}return e.abrupt("return",this);case 4:return t=this._client,Ht(t).readConversationsBuffer||(Ht(t).readConversationsBuffer=new Set),Ht(t).readConversationsBuffer.add(this),t._doSendRead(),e.abrupt("return",this);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n._handleReceipt=function(e){var t=e.messageId,n=e.timestamp;e.read?this._setLastReadAt(n):this._setLastDeliveredAt(n);var r=Ht(this).messagesWaitingForReceipt,i=r[t];i&&(i._setStatus(Ts.DELIVERED),i.deliveredAt=n,delete r[t])},n.fetchReceiptTimestamps=function(){var e=$(W.mark((function e(){var t,n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.transient&&!this.system){e.next=2;break}return e.abrupt("return",this);case 2:return e.next=4,this._send(new N({op:"max_read"}));case 4:return t=e.sent,n=t.convMessage,r=n.maxReadTimestamp,i=n.maxAckTimestamp,this._setLastDeliveredAt(i),this._setLastReadAt(r),e.abrupt("return",this);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n._fetchAllReceiptTimestamps=function(){if(this.transient||this.system)return this;var e=new A({queryAllMembers:!0});return this._send(new N({op:"max_read",convMessage:e})).then((function(e){return e.convMessage.maxReadTuples.filter((function(e){return e.maxAckTimestamp||e.maxReadTimestamp})).map((function(e){var t=e.pid,n=e.maxAckTimestamp,r=e.maxReadTimestamp;return{pid:t,lastDeliveredAt:Yt(n),lastReadAt:Yt(r)}}))}))},yt(t,[{key:"unreadMessagesMentioned",get:function(){return Ht(this).unreadMessagesMentioned}},{key:"unreadMessagesCount",set:function(e){e!==this.unreadMessagesCount&&(Ht(this).unreadMessagesCount=e,this._client.emit("unreadmessagescountupdate",[this]))},get:function(){return Ht(this).unreadMessagesCount}},{key:"lastMessageAt",set:function(e){var t=Yt(e);t<=this._lastMessageAt||(this._lastMessageAt=t)},get:function(){return this._lastMessageAt}},{key:"lastDeliveredAt",get:function(){return 2!==this.members.length?null:Ht(this).lastDeliveredAt}},{key:"lastReadAt",get:function(){return 2!==this.members.length?null:Ht(this).lastReadAt}}]),t}(z),qs=le("LC:SignatureFactoryRunner");function zs(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.signature,n=e.timestamp,r=e.nonce;if("string"!=typeof t||"number"!=typeof n||"string"!=typeof r)throw new Error("malformed signature");return{signature:t,timestamp:n,nonce:r}}var Ws=function(e,t){return Promise.resolve().then((function(){return qs("call signatureFactory with %O",t),e.apply(void 0,K(t))})).then(Bt((function(e){return qs("sign result %O",e)})),(function(e){throw e.message="sign error: ".concat(e.message),qs(e),e})).then(zs)};function Gs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Gs(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gs(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Js=function(e){return{successfulClientIds:e.allowedPids,failures:e.failedPids.map((function(e){var t=e.pids,n=te(e,["pids"]);return Object.assign(En(n),{clientIds:t})}))}},Zs=function(e){function t(t,n,r){var i,o=n.creator,s=n.createdAt,a=n.updatedAt,u=n.transient,c=void 0!==u&&u,f=n.system,l=void 0!==f&&f,h=n.muted,p=void 0!==h&&h,d=n.mutedMembers,m=void 0===d?[]:d,g=te(n,["creator","createdAt","updatedAt","transient","system","muted","mutedMembers"]);return(i=e.call(this,$s($s({},t),{},{creator:o,createdAt:s,updatedAt:a,mutedMembers:m,transient:c,system:l,muted:p,_attributes:g}),r)||this)._reset(),i}re(t,e);var n=t.prototype;return n.get=function(e){return Hi(Ht(this).currentAttributes,e)},n.set=function(e,t){this._debug("set [".concat(e,"]: ").concat(t));var n=Ht(this).pendingAttributes,r=Object.keys(n),i=new RegExp("^".concat(e)),o=r.filter(i.test.bind(i));if(o.forEach((function(e){delete n[e]})),o.length)n[e]=t;else{var s=bs(r,(function(t){return 0===e.indexOf(t)}));s?nn(n[s],e.slice(s.length+1),t):n[e]=t}return this._buildCurrentAttributes(),this},n._buildCurrentAttributes=function(){var e=Ht(this).pendingAttributes;Ht(this).currentAttributes=Object.keys(e).reduce((function(t,n){return nn(t,n,e[n])}),rs(this._attributes))},n._updateServerAttributes=function(e){var t=this;Object.keys(e).forEach((function(n){return nn(t._attributes,n,e[n])})),this._buildCurrentAttributes()},n._reset=function(){Object.assign(Ht(this),{pendingAttributes:{},currentAttributes:this._attributes})},n.save=function(){var e=$(W.mark((function e(){var t,n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("save"),t=Ht(this).pendingAttributes,!yo(t)){e.next=5;break}return this._debug("nothing touched, resolve with self"),e.abrupt("return",this);case 5:return this._debug("attr: %O",t),n=new A({attr:new y({data:JSON.stringify(Wt(t))})}),e.next=9,this._send(new N({op:"update",convMessage:n}));case 9:return r=e.sent,this.updatedAt=r.convMessage.udate,this._attributes=Ht(this).currentAttributes,Ht(this).pendingAttributes={},e.abrupt("return",this);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.fetch=function(){var e=$(W.mark((function e(){var t;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._client.getQuery().equalTo("objectId",this.id),e.next=3,t.find();case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.mute=function(){var e=$(W.mark((function e(){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute"),e.next=3,this._send(new N({op:"mute"}));case 3:return this.transient||(this.muted=!0,this.mutedMembers=Zt(this.mutedMembers,[this._client.id])),e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.unmute=function(){var e=$(W.mark((function e(){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute"),e.next=3,this._send(new N({op:"unmute"}));case 3:return this.transient||(this.muted=!1,this.mutedMembers=Xt(this.mutedMembers,[this._client.id])),e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n._appendConversationSignature=function(){var e=$(W.mark((function e(t,n,r){var i,o;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._client.options.conversationSignatureFactory){e.next=6;break}return i=[this.id,this._client.id,r.sort(),n],e.next=4,Ws(this._client.options.conversationSignatureFactory,i);case 4:o=e.sent,Object.assign(t.convMessage,Gt({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n._appendBlacklistSignature=function(){var e=$(W.mark((function e(t,n,r){var i,o;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._client.options.blacklistSignatureFactory){e.next=6;break}return i=[this.id,this._client.id,r.sort(),n],e.next=4,Ws(this._client.options.blacklistSignatureFactory,i);case 4:o=e.sent,Object.assign(t.blacklistMessage,Gt({signature:"s",timestamp:"t",nonce:"n"},o));case 6:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.add=function(){var e=$(W.mark((function e(t){var n,r,i,o;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("add",t),"string"==typeof t&&(t=[t]),n=new N({op:"add",convMessage:new A({m:t})}),e.next=5,this._appendConversationSignature(n,"invite",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.convMessage,o=r.convMessage.allowedPids,this._addMembers(o),e.abrupt("return",Js(i));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.remove=function(){var e=$(W.mark((function e(t){var n,r,i,o;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("remove",t),"string"==typeof t&&(t=[t]),n=new N({op:"remove",convMessage:new A({m:t})}),e.next=5,this._appendConversationSignature(n,"kick",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.convMessage,o=r.convMessage.allowedPids,this._removeMembers(o),e.abrupt("return",Js(i));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.join=function(){var e=$(W.mark((function e(){var t=this;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("join"),e.abrupt("return",this.add(this._client.id).then((function(e){var n=e.failures;if(n[0])throw n[0];return t})));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.quit=function(){var e=$(W.mark((function e(){var t=this;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("quit"),e.abrupt("return",this.remove(this._client.id).then((function(e){var n=e.failures;if(n[0])throw n[0];return t})));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.muteMembers=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("mute",t),t=tn(t),n=new N({op:V.add_shutup,convMessage:new A({m:t})}),e.next=5,this._send(n);case 5:return r=e.sent,i=r.convMessage,e.abrupt("return",Js(i));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unmuteMembers=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unmute",t),t=tn(t),n=new N({op:V.remove_shutup,convMessage:new A({m:t})}),e.next=5,this._send(n);case 5:return r=e.sent,i=r.convMessage,e.abrupt("return",Js(i));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.queryMutedMembers=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s,a,u,c=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},n=t.limit,r=t.next,this._debug("query muted: limit %O, next: %O",n,r),i=new N({op:V.query_shutup,convMessage:new A({limit:n,next:r})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.convMessage,a=s.m,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.blockMembers=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("block",t),t=tn(t),n=new N({cmd:"blacklist",op:V.block,blacklistMessage:new L({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(n,"conversation-block-clients",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.blacklistMessage,e.abrupt("return",Js(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.unblockMembers=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._debug("unblock",t),t=tn(t),n=new N({cmd:"blacklist",op:V.unblock,blacklistMessage:new L({srcCid:this.id,toPids:t})}),e.next=5,this._appendBlacklistSignature(n,"conversation-unblock-clients",t);case 5:return e.next=7,this._send(n);case 7:return r=e.sent,i=r.blacklistMessage,e.abrupt("return",Js(i));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.queryBlockedMembers=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s,a,u,c=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>0&&void 0!==c[0]?c[0]:{},n=t.limit,r=t.next,this._debug("query blocked: limit %O, next: %O",n,r),i=new N({cmd:"blacklist",op:V.query,blacklistMessage:new L({srcCid:this.id,limit:n,next:r})}),e.next=5,this._send(i);case 5:return o=e.sent,s=o.blacklistMessage,a=s.blockedPids,u=s.next,e.abrupt("return",{results:a,next:u});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.toFullJSON=function(){var t=this.creator,n=this.system,r=this.transient,i=this.createdAt,o=this.updatedAt,s=this._attributes;return $s($s({},e.prototype.toFullJSON.call(this)),{},{creator:t,system:n,transient:r,createdAt:qt(i),updatedAt:qt(o)},s)},n.toJSON=function(){var t=this.creator,n=this.system,r=this.transient,i=this.muted,o=this.mutedMembers,s=this.createdAt,a=this.updatedAt,u=this._attributes;return $s($s({},e.prototype.toJSON.call(this)),{},{creator:t,system:n,transient:r,muted:i,mutedMembers:o,createdAt:s,updatedAt:a},u)},yt(t,[{key:"createdAt",set:function(e){this._createdAt=Yt(e)},get:function(){return this._createdAt}},{key:"updatedAt",set:function(e){this._updatedAt=Yt(e)},get:function(){return this._updatedAt}},{key:"name",get:function(){return this.get("name")},set:function(e){this.set("name",e)}}]),t}(Ys),Xs={OWNER:"Owner",MANAGER:"Manager",MEMBER:"Member"};Object.freeze(Xs);var Qs=function(){function e(e){var t=e.conversation,n=e.memberId,r=e.role;if(!t)throw new Error("conversation requried");if(!n)throw new Error("memberId requried");Object.assign(Ht(this),{conversation:t,memberId:n,role:r})}return e.prototype.toJSON=function(){return{conversationId:this.conversationId,memberId:this.memberId,role:this.role,isOwner:this.isOwner}},yt(e,[{key:"conversationId",get:function(){return Ht(this).conversation.id}},{key:"memberId",get:function(){return Ht(this).memberId}},{key:"role",get:function(){return this.isOwner?Xs.OWNER:Ht(this).role}},{key:"isOwner",get:function(){return this.memberId===Ht(this).conversation.creator}}]),e}(),Hs=function(e){function t(){return e.apply(this,arguments)||this}re(t,e);var n=t.prototype;return n._addMembers=function(t){var n=this;e.prototype._addMembers.call(this,t),this.members=Zt(this.members,t);var r=Ht(this).memberInfoMap;r&&t.forEach((function(e){r[e]=r[e]||new Qs({conversation:n,memberId:e,role:Xs.MEMBER})}))},n._removeMembers=function(t){e.prototype._removeMembers.call(this,t),this.members=Xt(this.members,t);var n=Ht(this).memberInfoMap;n&&t.forEach((function(e){delete n[e]}))},n._fetchAllMemberInfo=function(){var e=$(W.mark((function e(){var t,n,r,i=this;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._client._requestWithSessionToken({method:"GET",path:"/classes/_ConversationMemberInfo",query:{where:{cid:this.id}}});case 2:return t=e.sent,n=t.results.map((function(e){return new Qs({conversation:i,memberId:e.clientId,role:e.role})})),r={},n.forEach((function(e){r[e.memberId]=e})),this.members.forEach((function(e){r[e]=r[e]||new Qs({conversation:i,memberId:e,role:Xs.MEMBER})})),Ht(this).memberInfoMap=r,e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getAllMemberInfo=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{},n=t.noCache,r=void 0!==n&&n,i=Ht(this),(o=i.memberInfoMap)&&!r){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)}}(),n.getMemberInfo=function(){var e=$(W.mark((function e(t){var n,r;return W.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(n=Ht(this),(r=n.memberInfoMap)&&r[t]){e.next=6;break}return e.next=6,this.getAllMemberInfo();case 6:return e.abrupt("return",Ht(this).memberInfoMap[t]);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.updateMemberRole=function(){var e=$(W.mark((function e(t,n){var r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("update member role"),n!==Xs.OWNER){e.next=3;break}throw En({code:wn.OWNER_PROMOTION_NOT_ALLOWED});case 3:return e.next=5,this._send(new N({op:V.member_info_update,convMessage:new A({targetClientId:t,info:new U({pid:t,role:n})})}));case 5:return r=Ht(this),(i=r.memberInfos)&&i[t]&&(Ht(i[t]).role=n),e.abrupt("return",this);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t}(Zs),Ks=function(e){function t(){return e.apply(this,arguments)||this}return re(t,e),t}(Zs),ea=function(e){function t(){return e.apply(this,arguments)||this}re(t,e);var n=t.prototype;return n.subscribe=function(){var e=$(W.mark((function e(){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.join());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.unsubscribe=function(){var e=$(W.mark((function e(){return W.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}(Zs);function ta(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function na(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ta(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ta(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ra,ia,oa,sa=function(e){return e.code===wn.CONVERSATION_NOT_FOUND?En({code:wn.TEMPORARY_CONVERSATION_EXPIRED}):e},aa=function(e){function t(t,n,r){var i=n.expiredAt;return e.call(this,na(na({},t),{},{expiredAt:i}),r)||this}re(t,e);var n=t.prototype;return n._send=function(){var t=$(W.mark((function t(){var n,r,i,o,s=arguments;return W.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.expired){t.next=2;break}throw En({code:wn.TEMPORARY_CONVERSATION_EXPIRED});case 2:for(t.prev=2,r=s.length,i=new Array(r),o=0;o<r;o++)i[o]=s[o];return t.next=6,(n=e.prototype._send).call.apply(n,[this].concat(i));case 6:return t.abrupt("return",t.sent);case 9:throw t.prev=9,t.t0=t.catch(2),sa(t.t0);case 12:case"end":return t.stop()}}),t,this,[[2,9]])})));return function(){return t.apply(this,arguments)}}(),n.send=function(){var t=$(W.mark((function t(){var n,r,i,o,s=arguments;return W.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(t.prev=0,r=s.length,i=new Array(r),o=0;o<r;o++)i[o]=s[o];return t.next=4,(n=e.prototype.send).call.apply(n,[this].concat(i));case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),sa(t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(){return t.apply(this,arguments)}}(),n.toFullJSON=function(){var t=this.expiredAt;return na(na({},e.prototype.toFullJSON.call(this)),{},{expiredAt:qt(t)})},n.toJSON=function(){var t=this.expiredAt,n=this.expired;return na(na({},e.prototype.toJSON.call(this)),{},{expiredAt:t,expired:n})},yt(t,[{key:"expiredAt",set:function(e){this._expiredAt=Yt(e)},get:function(){return this._expiredAt}},{key:"expired",get:function(){return this.expiredAt<new Date}}]),t}(Ys),ua=le("LC:ConversationQuery"),ca=function(){function e(e){this._client=e,this._where={},this._extraOptions={}}e._encode=function(e){return e instanceof Date?{__type:"Date",iso:e.toJSON()}:e instanceof RegExp?e.source:e},e._quote=function(e){return"\\Q".concat(e.replace("\\E","\\E\\\\E\\Q"),"\\E")},e._calculateFlag=function(e){return["withLastMessagesRefreshed","compact"].reduce((function(t,n){return(t<<1)+Boolean(e[n])}),0)},e.and=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(n.length<2)throw new Error("The queries must contain at least two elements");if(!n.every((function(t){return t instanceof e})))throw new Error("The element of queries must be an instance of ConversationQuery");var i=new e(n[0]._client);return i._where.$and=n.map((function(e){return e._where})),i},e.or=function(){var t=e.and.apply(e,arguments);return t._where.$or=t._where.$and,delete t._where.$and,t};var t=e.prototype;return t._addCondition=function(e,t,n){return this._where[e]||(this._where[e]={}),this._where[e][t]=this.constructor._encode(n),this},t.toJSON=function(){var e={where:this._where,flag:this.constructor._calculateFlag(this._extraOptions)};return void 0!==this._skip&&(e.skip=this._skip),void 0!==this._limit&&(e.limit=this._limit),void 0!==this._order&&(e.sort=this._order),ua(e),e},t.containsMembers=function(e){return this.containsAll("m",e)},t.withMembers=function(e,t){var n=new Set(e);return t&&n.add(this._client.id),this.sizeEqualTo("m",n.size),this.containsMembers(Array.from(n))},t.equalTo=function(e,t){return this._where[e]=this.constructor._encode(t),this},t.lessThan=function(e,t){return this._addCondition(e,"$lt",t)},t.lessThanOrEqualTo=function(e,t){return this._addCondition(e,"$lte",t)},t.greaterThan=function(e,t){return this._addCondition(e,"$gt",t)},t.greaterThanOrEqualTo=function(e,t){return this._addCondition(e,"$gte",t)},t.notEqualTo=function(e,t){return this._addCondition(e,"$ne",t)},t.exists=function(e){return this._addCondition(e,"$exists",!0)},t.doesNotExist=function(e){return this._addCondition(e,"$exists",!1)},t.containedIn=function(e,t){return this._addCondition(e,"$in",t)},t.notContainsIn=function(e,t){return this._addCondition(e,"$nin",t)},t.containsAll=function(e,t){return this._addCondition(e,"$all",t)},t.contains=function(t,n){return this._addCondition(t,"$regex",e._quote(n))},t.startsWith=function(t,n){return this._addCondition(t,"$regex","^".concat(e._quote(n)))},t.endsWith=function(t,n){return this._addCondition(t,"$regex","".concat(e._quote(n),"$"))},t.matches=function(e,t){this._addCondition(e,"$regex",t);var n="";return t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),n&&n.length&&this._addCondition(e,"$options",n),this},t.sizeEqualTo=function(e,t){return this._addCondition(e,"$size",t)},t.limit=function(e){return this._limit=e,this},t.skip=function(e){return this._skip=e,this},t.ascending=function(e){return this._order=e,this},t.addAscending=function(e){return this._order?this._order+=",".concat(e):this._order=e,this},t.descending=function(e){return this._order="-".concat(e),this},t.addDescending=function(e){return this._order?this._order+=",-".concat(e):this._order="-".concat(e),this},t.withLastMessagesRefreshed=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.withLastMessagesRefreshed=e,this},t.compact=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._extraOptions.compact=e,this},t.find=function(){var e=$(W.mark((function e(){return W.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=$(W.mark((function e(){return W.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}(),fa=le("LC:SessionManager"),la=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refresh,n=e.onBeforeGetSessionToken;this.refresh=t,this._onBeforeGetSessionToken=n,this.setSessionToken(null,0)}var t=e.prototype;return t.setSessionToken=function(e,t){fa("set session token",e,t);var n=new jt(e,1e3*t);return this._sessionToken=n,delete this._pendingSessionTokenPromise,n},t.setSessionTokenAsync=function(){var e=$(W.mark((function e(t){var n,r=this;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._sessionToken,this._pendingSessionTokenPromise=t.catch((function(e){throw r._sessionToken=n,e})),e.t0=this.setSessionToken,e.t1=this,e.t2=K,e.next=7,this._pendingSessionTokenPromise;case 7:return e.t3=e.sent,e.t4=(0,e.t2)(e.t3),e.abrupt("return",e.t0.apply.call(e.t0,e.t1,e.t4));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getSessionToken=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s,a,u,c=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:{},n=t.autoRefresh,r=void 0===n||n,fa("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!==jt.EXPIRED||!r||!this.refresh){e.next=19;break}return fa("refresh expired session token"),e.next=15,this.setSessionTokenAsync(this.refresh(this,s));case 15:return a=e.sent,u=a.value,fa("session token",u),e.abrupt("return",u);case 19:return fa("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 ha(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ha(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ha(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var da,ma=le("LC:IMClient"),ga=function(e){return/^_tmp:/.test(e)},ya=(ra=on(1e3),ia=on(1e3),vt((oa=function(e){function t(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Client id [".concat(t,"] is not a String"));if(n=e.call(this)||this,Object.assign(ne(n),{id:t,options:r},i),!n._messageParser)throw new Error("IMClient must be initialized with a MessageParser");return n._conversationCache=new Nt("client:".concat(n.id)),n._ackMessageBuffer={},Ht(ne(n)).lastPatchTime=Date.now(),Ht(ne(n)).lastNotificationTime=void 0,Ht(ne(n))._eventemitter=new z,ma.enabled&&ft(ws).forEach((function(e){return n.on(e,(function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return n._debug("".concat(e," event emitted. %o"),r)}))})),xn(n._plugins.onIMClientCreate,ne(n)),n}re(t,e);var n=t.prototype;return n._debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];ma.apply(void 0,t.concat(["[".concat(this.id,"]")]))},n._dispatchCommand=function(){var e=$(W.mark((function e(t){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._debug(en(t),"received"),t.serverTs&&1===t.notificationType&&(Ht(this).lastNotificationTime=qt(Yt(t.serverTs))),e.t0=t.cmd,e.next=e.t0===B.conv?5:e.t0===B.direct?6:e.t0===B.session?7:e.t0===B.unread?8:e.t0===B.rcp?9:e.t0===B.patch?10:11;break;case 5:return e.abrupt("return",this._dispatchConvMessage(t));case 6:return e.abrupt("return",this._dispatchDirectMessage(t));case 7:return e.abrupt("return",this._dispatchSessionMessage(t));case 8:return e.abrupt("return",this._dispatchUnreadMessage(t));case 9:return e.abrupt("return",this._dispatchRcpMessage(t));case 10:return e.abrupt("return",this._dispatchPatchMessage(t));case 11:return e.abrupt("return",this.emit("unhandledmessage",t));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._dispatchSessionMessage=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.sessionMessage,r=n.code,i=n.reason,e.t0=t.op,e.next=e.t0===V.closed?4:8;break;case 4:if(Ht(this)._eventemitter.emit("close"),r!==wn.SESSION_CONFLICT){e.next=7;break}return e.abrupt("return",this.emit("conflict",{reason:i}));case 7:return e.abrupt("return",this.emit("close",{code:r,reason:i}));case 8:throw this.emit("unhandledmessage",t),new Error("Unrecognized session command");case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._dispatchUnreadMessage=function(e){var t=this,n=e.unreadMessage,r=n.convs,i=n.notifTime;return Ht(this).lastUnreadNotifTime=i,this.getConversations(r.map((function(e){return e.cid}))).then((function(){return Promise.all(r.map((function(e){var n,r=e.cid,i=e.unread,o=e.mid,s=e.timestamp,a=e.from,u=e.data,c=e.binaryMsg,f=e.patchTimestamp,l=e.mentioned,h=t._conversationCache.get(r);return h?(s&&(n=Yt(s),h.lastMessageAt=n),(o?t._messageParser.parse(c||u).then((function(e){var t={id:o,cid:r,timestamp:n,updatedAt:f,from:a};Object.assign(e,t),h.lastMessage=e})):Promise.resolve()).then((function(){return h._setUnreadMessagesMentioned(l),i===Ht(h).unreadMessagesCount?null:(Ht(h).unreadMessagesCount=i,h)}))):null}))).then((function(e){return e.filter((function(e){return e}))}))})).then((function(e){e.length&&t.emit("unreadmessagescountupdate",e)}))},n._dispatchRcpMessage=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.rcpMessage,r=t.rcpMessage.read,i=n.cid,o=n.id,s=Yt(n.t),a=this._conversationCache.get(i)){e.next=7;break}return e.abrupt("return");case 7:a._handleReceipt({messageId:o,timestamp:s,read:r});case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._dispatchPatchMessage=function(e){var t=this,n=e.patchMessage.patches;return this.getConversations(n.map((function(e){return e.cid}))).then((function(){return Promise.all(n.map((function(e){var n=e.cid,r=e.mid,i=e.timestamp,o=e.recall,s=e.data,a=e.patchTimestamp,u=e.from,c=e.binaryMsg,f=e.mentionAll,l=e.mentionPids,h=e.patchCode,p=e.patchReason,d=t._conversationCache.get(n);return d?t._messageParser.parse(c||s).then((function(e){var s,c=qt(Yt(a)),m={id:r,cid:n,timestamp:i,updatedAt:c,from:u,mentionList:l,mentionedAll:f};Object.assign(e,m),e._setStatus(Ts.SENT),e._updateMentioned(t.id),Ht(t).lastPatchTime<c&&(Ht(t).lastPatchTime=c),d.lastMessage&&d.lastMessage.id===r&&(d.lastMessage=e),h&&(s={code:h.toNumber(),detail:p}),o?(t.emit("messagerecall",e,d,s),d.emit("messagerecall",e,s)):(t.emit("messageupdate",e,d,s),d.emit("messageupdate",e,s))})):null})))}))},n._dispatchConvMessage=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,E,_,T,O,S,A,I;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.convMessage,r=t.convMessage,i=r.initBy,o=r.m,s=r.info,a=r.attr,e.next=3,this.getConversation(n.cid);case 3:u=e.sent,e.t0=t.op,e.next=e.t0===V.joined?7:e.t0===V.left?12:e.t0===V.members_joined?17:e.t0===V.members_left?22:e.t0===V.members_blocked?27:e.t0===V.members_unblocked?31:e.t0===V.blocked?35:e.t0===V.unblocked?39:e.t0===V.members_shutuped?43:e.t0===V.members_unshutuped?47:e.t0===V.shutuped?51:e.t0===V.unshutuped?55:e.t0===V.member_info_changed?59:e.t0===V.updated?71:77;break;case 7:return u._addMembers([this.id]),c={invitedBy:i},this.emit("invited",c,u),u.emit("invited",c),e.abrupt("return");case 12:return u._removeMembers([this.id]),f={kickedBy:i},this.emit("kicked",f,u),u.emit("kicked",f),e.abrupt("return");case 17:return u._addMembers(o),l={invitedBy:i,members:o},this.emit("membersjoined",l,u),u.emit("membersjoined",l),e.abrupt("return");case 22:return u._removeMembers(o),h={kickedBy:i,members:o},this.emit("membersleft",h,u),u.emit("membersleft",h),e.abrupt("return");case 27:return p={blockedBy:i,members:o},this.emit("membersblocked",p,u),u.emit("membersblocked",p),e.abrupt("return");case 31:return d={unblockedBy:i,members:o},this.emit("membersunblocked",d,u),u.emit("membersunblocked",d),e.abrupt("return");case 35:return m={blockedBy:i},this.emit("blocked",m,u),u.emit("blocked",m),e.abrupt("return");case 39:return g={unblockedBy:i},this.emit("unblocked",g,u),u.emit("unblocked",g),e.abrupt("return");case 43:return y={mutedBy:i,members:o},this.emit("membersmuted",y,u),u.emit("membersmuted",y),e.abrupt("return");case 47:return v={unmutedBy:i,members:o},this.emit("membersunmuted",v,u),u.emit("membersunmuted",v),e.abrupt("return");case 51:return b={mutedBy:i},this.emit("muted",b,u),u.emit("muted",b),e.abrupt("return");case 55:return w={unmutedBy:i},this.emit("unmuted",w,u),u.emit("unmuted",w),e.abrupt("return");case 59:if(E=s.pid,_=s.role,T=Ht(u),T.memberInfoMap||_){e.next=63;break}return e.abrupt("return");case 63:return e.next=65,u.getMemberInfo(E);case 65:return O=e.sent,Ht(O).role=_,S={member:E,memberInfo:O,updatedBy:i},this.emit("memberinfoupdated",S,u),u.emit("memberinfoupdated",S),e.abrupt("return");case 71:return A=zt(JSON.parse(a.data)),u._updateServerAttributes(A),I={attributes:A,updatedBy:i},this.emit("conversationinfoupdated",I,u),u.emit("infoupdated",I),e.abrupt("return");case 77:throw this.emit("unhandledmessage",t),new Error("Unrecognized conversation command");case 79:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._dispatchDirectMessage=function(e){var t=this,n=e.directMessage,r=e.directMessage,i=r.id,o=r.cid,s=r.fromPeerId,a=r.timestamp,u=r.transient,c=r.patchTimestamp,f=r.mentionPids,l=r.mentionAll,h=r.binaryMsg,p=r.msg,d=h?h.toArrayBuffer():p;return Promise.all([this.getConversation(n.cid),this._messageParser.parse(d)]).then((function(e){var n=Gn(e,2),r=n[0],h=n[1];if(r){var p={id:i,cid:o,timestamp:a,updatedAt:c,from:s,mentionList:f,mentionedAll:l};return Object.assign(h,p),h._updateMentioned(t.id),h._setStatus(Ts.SENT),h.from!==t.id&&(u||r.transient||t._sendAck(h)),t._dispatchParsedMessage(h,r)}}))},n._dispatchParsedMessage=function(e,t){var n=this;return kn(this._plugins.beforeMessageDispatch,[e,t]).then((function(r){!1!==r&&(t.lastMessage=e,t.lastMessageAt=e.timestamp,e.from!==n.id&&(t.unreadMessagesCount+=1,e.mentioned&&t._setUnreadMessagesMentioned(!0)),n.emit("message",e,t),t.emit("message",e))}))},n._sendAck=function(e){this._debug("send ack for %O",e);var t=e.cid;if(!t)throw new Error("missing cid");return this._ackMessageBuffer[t]||(this._ackMessageBuffer[t]=[]),this._ackMessageBuffer[t].push(e),this._doSendAck()},n._doSendAck=function(){var e=this;this._connection.is("connected")&&(this._debug("do send ack %O",this._ackMessageBuffer),Promise.all(Object.keys(this._ackMessageBuffer).map((function(t){var n=e._ackMessageBuffer[t],r=n.map((function(e){return e.timestamp})),i=new N({cmd:"ack",ackMessage:new O({cid:t,fromts:Math.min.apply(null,r),tots:Math.max.apply(null,r)})});return delete e._ackMessageBuffer[t],e._send(i,!1).catch((function(r){e._debug("send ack failed: %O",r),e._ackMessageBuffer[t]=n}))}))))},n._omitPeerId=function(e){Ht(this).peerIdOmittable=e},n._send=function(e){var t,n=e;!Ht(this).peerIdOmittable&&this.id&&(n.peerId=this.id);for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return(t=this._connection).send.apply(t,[n].concat(i))},n._open=function(){var e=$(W.mark((function e(t,n,r){var i,o,s,a,u,c,f,l,h,p,d,m,g,y,v,b,w,_,T=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=T.length>3&&void 0!==T[3]&&T[3],this._debug("open session"),o=Ht(this),s=o.lastUnreadNotifTime,a=o.lastPatchTime,u=o.lastNotificationTime,c=new N({cmd:"session",op:"open",appId:t,peerId:this.id,sessionMessage:new E({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,en({tag:n,deviceId:r})),!this.options.signatureFactory){e.next=11;break}return e.next=9,Ws(this.options.signatureFactory,[this._identity]);case 9:f=e.sent,Object.assign(c.sessionMessage,Gt({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!==jt.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!==wn.SESSION_TOKEN_EXPIRED){e.next=31;break}if(this._sessionManager){e.next=28;break}throw new Error("Unexpected session expiration");case 28:return ma("Session token expired, reopening"),this._sessionManager.revoke(),e.abrupt("return",this._open(t,n,r,i));case 31:throw e.t0;case 32:if(d=(p=h).peerId,m=p.sessionMessage,g=p.sessionMessage,y=g.st,v=g.stTtl,b=g.code,w=p.serverTs,!b){e.next=35;break}throw En(m);case 35:return d?(this.id=d,this._identity||(this._identity=d),y&&(this._sessionManager=this._sessionManager||this._createSessionManager(),this._sessionManager.setSessionToken(y,v)),_=qt(Yt(w)),w&&(Ht(this).lastPatchTime=_),u?this._syncNotifications(u).catch((function(e){return console.warn("Syncing notifications failed:",e)})):Ht(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,n,r){return e.apply(this,arguments)}}(),n._syncNotifications=function(){var e=$(W.mark((function e(t){var n,r,i=this;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchNotifications(t);case 2:if(n=e.sent,r=n.hasMore,n.notifications.forEach((function(e){var t=e.cmd,n=e.op,r=e.serverTs,o=e.notificationType,s=te(e,["cmd","op","serverTs","notificationType"]);i._dispatchCommand(h({cmd:B[t],op:V[n],serverTs:r,notificationType:o},"".concat(t,"Message"),s))})),!r){e.next=8;break}return e.abrupt("return",this._syncNotifications(Ht(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)}}(),n._fetchNotifications=function(){var e=$(W.mark((function e(t){return W.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)}}(),n._createSessionManager=function(){var e=this;return ma("create SessionManager"),new la({onBeforeGetSessionToken:this._connection.checkConnectionAvailability.bind(this._connection),refresh:function(t,n){return t.setSessionTokenAsync(Promise.resolve(new N({cmd:"session",op:"refresh",sessionMessage:new E({ua:"js/".concat("5.0.0-rc.7"),st:n})})).then(function(){var t=$(W.mark((function t(n){var r;return W.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.options.signatureFactory){t.next=5;break}return t.next=3,Ws(e.options.signatureFactory,[e._identity]);case 3:r=t.sent,Object.assign(n.sessionMessage,Gt({signature:"s",timestamp:"t",nonce:"n"},r));case 5:return t.abrupt("return",n);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]})))}})},n._requestWithSessionToken=function(){var e=$(W.mark((function e(t){var n,r,i,o;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.headers,r=t.query,i=te(t,["headers","query"]),e.next=3,this._sessionManager.getSessionToken();case 3:return o=e.sent,e.abrupt("return",this._request(pa({headers:pa({"X-LC-IM-Session-Token":o},n),query:pa({client_id:this.id},r)},i)));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.close=function(){var e=$(W.mark((function e(){var t,n;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("close session"),(t=Ht(this)._eventemitter).emit("beforeclose"),!this._connection.is("connected")){e.next=7;break}return n=new N({cmd:"session",op:"close"}),e.next=7,this._send(n);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)}}(),n.ping=function(){var e=$(W.mark((function e(t){var n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._debug("ping"),t instanceof Array){e.next=3;break}throw new TypeError("clientIds ".concat(t," is not an Array"));case 3:if(t.length){e.next=5;break}return e.abrupt("return",Promise.resolve([]));case 5:return n=new N({cmd:"session",op:"query",sessionMessage:new E({sessionPeerIds:t})}),e.next=8,this._send(n);case 8:return r=e.sent,e.abrupt("return",r.sessionMessage.onlineSessionPeerIds);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConversation=function(){var e=$(W.mark((function e(t){var n,r,i=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=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(n){e.next=7;break}if(!(r=this._conversationCache.get(t))){e.next=7;break}return e.abrupt("return",r);case 7:if(!ga(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)}}(),n.getConversations=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a=this,u=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>1&&void 0!==u[1]&&u[1],!(r=n?t:t.filter((function(e){return null===a._conversationCache.get(e)}))).length){e.next=9;break}return i=mo(r,ga),o=[],r.length&&o.push(this.getQuery().containedIn("objectId",r).limit(999).find()),i.length&&(s=i.map(this._getTemporaryConversations.bind(this)),o.push.apply(o,K(s))),e.next=9,Promise.all(o);case 9:return e.abrupt("return",t.map((function(e){return a._conversationCache.get(e)})));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._getTemporaryConversations=function(){var e=$(W.mark((function e(t){var n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new N({cmd:"conv",op:"query",convMessage:new A({tempConvIds:t})}),e.next=3,this._send(n);case 3:return r=e.sent,e.abrupt("return",this._handleQueryResults(r));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getQuery=function(){return new ca(this)},n.getChatRoomQuery=function(){return this.getQuery().equalTo("tr",!0)},n.getServiceConversationQuery=function(){return this.getQuery().equalTo("sys",!0)},n._executeQuery=function(){var e=$(W.mark((function e(t){var n,r,i;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=t.toJSON()).where=new y({data:JSON.stringify(Wt(n.where))}),r=new N({cmd:"conv",op:"query",convMessage:new A(n)}),e.next=5,this._send(r);case 5:return i=e.sent,e.abrupt("return",this._handleQueryResults(i));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._handleQueryResults=function(){var e=$(W.mark((function e(t){var n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,n=zt(JSON.parse(t.convMessage.results.data)),e.next=8;break;case 4:throw e.prev=4,e.t0=e.catch(0),r=JSON.stringify(en(t)),new Error("Parse query result failed: ".concat(e.t0.message,". Command: ").concat(r));case 8:return e.next=10,Promise.all(n.map(this._parseConversationFromRawData.bind(this)));case 10:return n=e.sent,e.abrupt("return",n.map(this._upsertConversationToCache.bind(this)));case 12:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(t){return e.apply(this,arguments)}}(),n._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(n){var r=e[n];void 0!==r&&(t[n]=r)})),t._reset&&t._reset()):(t=e,this._debug("no match, set cache"),this._conversationCache.set(e.id,e)),t},n.parseMessage=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.data,r=t.bin,i=void 0!==r&&r,o=te(t,["data","bin"]),s=i?Zn(n):n,e.next=4,this._messageParser.parse(s);case 4:return a=e.sent,Object.assign(a,o),a._updateMentioned(this.id),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.parseConversation=function(){var e=$(W.mark((function e(t){var n,r,i,o,s,a,u,c,f,l,h,p,d;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.id,r=t.lastMessageAt,i=t.lastMessage,o=t.lastDeliveredAt,s=t.lastReadAt,a=t.unreadMessagesCount,u=t.members,c=t.mentioned,f=te(t,["id","lastMessageAt","lastMessage","lastDeliveredAt","lastReadAt","unreadMessagesCount","members","mentioned"]),l={id:n,lastMessageAt:r,lastMessage:i,lastDeliveredAt:o,lastReadAt:s,unreadMessagesCount:a,members:u,mentioned:c},!i){e.next=7;break}return e.next=5,this.parseMessage(i);case 5:l.lastMessage=e.sent,l.lastMessage._setStatus(Ts.SENT);case 7:if(h=f.transient,p=f.system,d=f.expiredAt,!h){e.next=10;break}return e.abrupt("return",new Ks(l,f,this));case 10:if(!p){e.next=12;break}return e.abrupt("return",new ea(l,f,this));case 12:if(!d&&!ga(n)){e.next=14;break}return e.abrupt("return",new aa(l,{expiredAt:d},this));case 14:return e.abrupt("return",new Hs(l,f,this));case 15:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._parseConversationFromRawData=function(){var e=$(W.mark((function e(t){var n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=Gt({objectId:"id",lm:"lastMessageAt",m:"members",tr:"transient",sys:"system",c:"creator",mu:"mutedMembers"},t)).msg&&(n.lastMessage={data:n.msg,bin:n.bin,from:n.msg_from,id:n.msg_mid,timestamp:n.msg_timestamp,updatedAt:n.patch_timestamp},delete n.lastMessageFrom,delete n.lastMessageId,delete n.lastMessageTimestamp,delete n.lastMessagePatchTimestamp),(r=n.ttl)&&(n.expiredAt=Date.now()+1e3*r),e.abrupt("return",this.parseConversation(n));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.createConversation=function(){var e=$(W.mark((function e(){var t,n,r,i,o,s,a,u,c,f,l,h,p,d,m,g,v,b,w,E,_,T=arguments;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=T.length>0&&void 0!==T[0]?T[0]:{},n=t.members,r=t.name,i=t.transient,o=t.unique,s=void 0===o||o,a=t._tempConv,u=t._tempConvTTL,c=te(t,["members","name","transient","unique","_tempConv","_tempConvTTL"]),i||Array.isArray(n)){e.next=3;break}throw new TypeError("conversation members ".concat(n," is not an array"));case 3:if((f=new Set(n)).add(this.id),f=Array.from(f).sort(),l=c||{},!r){e.next=11;break}if("string"==typeof r){e.next=10;break}throw new TypeError("conversation name ".concat(r," is not a string"));case 10:l.name=r;case 11:if(l=new y({data:JSON.stringify(Wt(l))}),h=new N({cmd:"conv",op:"start",convMessage:new A({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,Ws(this.options.conversationSignatureFactory,p);case 18:d=e.sent,Object.assign(h.convMessage,Gt({signature:"s",timestamp:"t",nonce:"n"},d));case 20:return e.next=22,this._send(h);case 22:return m=e.sent,g=m.convMessage,v=g.cid,b=g.cdate,w=g.tempConvTTL,E=pa({name:r,transient:i,unique:s,id:v,createdAt:b,updatedAt:b,lastMessageAt:null,creator:this.id,members:i?[]:f},c),w&&(E.expiredAt=Date.now()+1e3*w),e.next=31,this.parseConversation(E);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)}}(),n.createChatRoom=function(){var e=$(W.mark((function e(t){return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.createConversation(pa(pa({},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)}}(),n.createTemporaryConversation=function(){var e=$(W.mark((function e(t){var n,r;return W.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.ttl,r=te(t,["ttl"]),e.abrupt("return",this.createConversation(pa(pa({},r),{},{_tempConv:!0,_tempConvTTL:n})));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n._doSendRead=function(){var e=this;if(this._connection.is("connected")){var t=Ht(this).readConversationsBuffer,n=Array.from(t);if(n.length){var r=n.map((function(e){if(!(e instanceof Ys))throw new TypeError("".concat(e," is not a Conversation"));return e.id}));this._debug("mark [".concat(r,"] as read")),t.clear(),this._sendReadCommand(n).catch((function(r){e._debug("send read failed: %O",r),n.forEach(t.add.bind(t))}))}}},n._sendReadCommand=function(e){var t=this;return this._send(new N({cmd:"read",readMessage:new k({convs:e.map((function(e){return new x({cid:e.id,mid:e.lastMessage&&e.lastMessage.from!==t.id?e.lastMessage.id:void 0,timestamp:(e.lastMessageAt||new Date).getTime()})}))})}),!1)},t}(z)).prototype,"_doSendAck",[ra],Object.getOwnPropertyDescriptor(oa.prototype,"_doSendAck"),oa.prototype),vt(oa.prototype,"_doSendRead",[ia],Object.getOwnPropertyDescriptor(oa.prototype,"_doSendRead"),oa.prototype),oa),va=Object.freeze({__proto__:null,RECONNECT_ERROR:"reconnecterror",DISCONNECT:fn,RECONNECT:ln,RETRY:hn,SCHEDULE:pn,OFFLINE:dn,ONLINE:mn});function ba(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ba(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ba(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ea,_a,Ta=Ps(da=function(e){function t(t){if(!(t instanceof ArrayBuffer))throw new TypeError("".concat(t," is not an ArrayBuffer"));return e.call(this,t)||this}re(t,e),t.validate=function(e){return e instanceof ArrayBuffer};var n=t.prototype;return n.toJSON=function(){return wa(wa({},e.prototype._toJSON.call(this)),{},{data:Jn(this.content)})},n.toFullJSON=function(){return wa(wa({},e.prototype.toFullJSON.call(this)),{},{bin:!0,data:Jn(this.content)})},yt(t,[{key:"buffer",get:function(){return this.content},set:function(e){this.content=e}}]),t}(As))||da,Oa=Is(-1)(Ea=Ps(Ea=function(e){function t(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if("string"!=typeof n)throw new TypeError("".concat(n," is not a string"));return(t=e.call(this)||this).setText(n),t}return re(t,e),t}(js))||Ea)||Ea;function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Aa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ia(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ca(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ca(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Ca(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Pa=le("LC:MessageParser"),xa=(vt((_a=function(){function e(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._plugins=e,this._messageClasses=[],this.register(e.messageClasses)}var t=e.prototype;return t.register=function(e){var t=this;tn(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){Pa("parsing message: %O",e);var t,n=Ia(this._messageClasses);try{for(n.s();!(t=n.n()).done;){var r=t.value,i=Pt(e)?Aa({},e):e,o=void 0,s=void 0;try{o=r.validate(i)}catch(e){}if(o){try{s=r.parse(i)}catch(e){console.warn("parsing a valid message content error",{error:e,Klass:r,content:i})}if(void 0!==s)return Pa("parse result: %O",s),s}}}catch(e){n.e(e)}finally{n.f()}throw new Error("No Message Class matched")},e}()).prototype,"parse",[function(e,t,n){var r=n.value;n.value=function(e){var t;if("string"!=typeof e)t=e;else try{t=JSON.parse(e)}catch(n){t=e}return r.call(this,t)}},function(e,t,n){var r=n.value;n.value=function(e){var t=this;return Promise.resolve(e).then(Mn(this._plugins.beforeMessageParse)).then((function(e){return r.call(t,e)})).then(Mn(this._plugins.afterMessageParse))}}],Object.getOwnPropertyDescriptor(_a.prototype,"parse"),_a.prototype),_a);function Ma(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ka(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ma(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ma(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ja=le("LC:IMPlugin"),Ra={HIGH:1,NORMAL:2,LOW:3};Object.freeze(Ra);var Na=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{get:function(){return this.get(e)},set:function(t){this.set(e,t)}};Object.defineProperty(Hs.prototype,e,t)},La={name:"leancloud-realtime-plugin-im",onRealtimeCreate:function(e){var t=zn();e._IMClients={},e._IMClientsCreationCount=0;var n=new xa(e._plugins);e._messageParser=n;var r=function(){var t=$(W.mark((function t(n){return W.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:n.getSessionToken()}}));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),i=n.register.bind(n),o=function(){var i=$(W.mark((function i(o){var s,a,u,c,f,l,h,p,d,m,g=arguments;return W.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=g.length>1&&void 0!==g[1]?g[1]:{},u=a.tag,c=a.isReconnect,f=te(a,["tag","isReconnect"]),l=g.length>2?g[2]:void 0,p={},!o){i.next=19;break}if("string"!=typeof o){i.next=8;break}h=o,i.next=17;break;case 8:if(!o.id||!o.getSessionToken){i.next=16;break}if(h=o.id,o.getSessionToken()){i.next=13;break}throw new Error("User must be authenticated");case 13:p.signatureFactory=r,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(r){var i=new ya(h,ka(ka({},p),f),{_connection:r,_request:e._request.bind(e),_messageParser:n,_plugins:e._plugins,_identity:o});return r.on(ln,(function(){return i._open(e._options.appId,d,t,!0).then((function(){return i.emit(ln)}),(function(e){return i.emit("reconnecterror",e)}))})),Ht(i)._eventemitter.on("beforeclose",(function(){delete e._IMClients[i.id],e._firstIMClient===i&&delete e._firstIMClient}),e),Ht(i)._eventemitter.on("close",(function(){e._deregister(i)}),e),i._open(e._options.appId,d,t,c).then((function(){return e._IMClients[i.id]=i,e._IMClientsCreationCount+=1,1===e._IMClientsCreationCount?(i._omitPeerId(!0),e._firstIMClient=i):e._IMClientsCreationCount>1&&e._firstIMClient&&e._firstIMClient._omitPeerId(!1),e._register(i),i})).catch((function(t){throw delete e._IMClients[i.id],t}))}))).then.apply(s,K(Vt((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 n=e.peerId?t._IMClients[e.peerId]:t._firstIMClient;return n?Promise.resolve(n).then((function(t){return t._dispatchCommand(e)})).catch(ja):ja("[WARN] Unexpected message received without any live client match: %O",en(e)),!1},messageClasses:[As,Ta,Rs,Oa]};function Da(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Da(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Da(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}Fn.defineConversationProperty=Na,Fn.__preRegisteredPlugins=[La];var Ua=Fa(Fa({},va),ws);_t({WebSocket:c,request:f}),e.BinaryMessage=Ta,e.ChatRoom=Ks,e.Conversation=Hs,e.ConversationMemberRole=Xs,e.ConversationQuery=ca,e.ErrorCode=wn,e.Event=Ua,e.EventEmitter=z,e.IE10Compatible=Ps,e.IMPlugin=La,e.Message=As,e.MessageParser=xa,e.MessagePriority=Ra,e.MessageQueryDirection=Vs,e.MessageStatus=Ts,e.Promise=Un,e.Protocals=q,e.Protocols=q,e.Realtime=Fn,e.RecalledMessage=Rs,e.ServiceConversation=ea,e.TemporaryConversation=aa,e.TextMessage=Oa,e.TypedMessage=js,e.debug=Ut,e.defineConversationProperty=Na,e.getAdapter=Et,e.messageField=Cs,e.messageType=Is,e.setAdapters=_t,Object.defineProperty(e,"__esModule",{value:!0})}));
|