@onyx-p/imlib-web 2.8.2 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.umd.js CHANGED
@@ -34,4 +34,4 @@ return function(){var t=e,r=t.lib,n=r.WordArray,o=r.Hasher,s=t.algo,i=n.create([
34
34
  * limitations under the License.
35
35
  *
36
36
  * SPDX-License-Identifier: Apache-2.0
37
- */var Nr=null;try{Nr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function Pr(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function Lr(e){return!0===(e&&e.__isLong__)}function Dr(e){var t=Math.clz32(e&-e);return e?31-t:t}Pr.prototype.__isLong__,Object.defineProperty(Pr.prototype,"__isLong__",{value:!0}),Pr.isLong=Lr;var jr={},Ur={};function Br(e,t){var r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=Ur[e])?n:(r=xr(e,0,!0),o&&(Ur[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=jr[e])?n:(r=xr(e,e<0?-1:0,!1),o&&(jr[e]=r),r)}function Fr(e,t){if(isNaN(e))return t?Jr:Wr;if(t){if(e<0)return Jr;if(e>=Hr)return en}else{if(e<=-zr)return tn;if(e+1>=zr)return Qr}return e<0?Fr(-e,t).neg():xr(e%Kr|0,e/Kr|0,t)}function xr(e,t,r){return new Pr(e,t,r)}Pr.fromInt=Br,Pr.fromNumber=Fr,Pr.fromBits=xr;var Gr=Math.pow;function qr(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Jr:Wr;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return qr(e.substring(1),t,r).neg();for(var o=Fr(Gr(r,8)),s=Wr,i=0;i<e.length;i+=8){var a=Math.min(8,e.length-i),c=parseInt(e.substring(i,i+a),r);if(a<8){var l=Fr(Gr(r,a));s=s.mul(l).add(Fr(c))}else s=(s=s.mul(o)).add(Fr(c))}return s.unsigned=t,s}function Vr(e,t){return"number"==typeof e?Fr(e,t):"string"==typeof e?qr(e,t):xr(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Pr.fromString=qr,Pr.fromValue=Vr;var Kr=4294967296,Hr=Kr*Kr,zr=Hr/2,$r=Br(1<<24),Wr=Br(0);Pr.ZERO=Wr;var Jr=Br(0,!0);Pr.UZERO=Jr;var Zr=Br(1);Pr.ONE=Zr;var Xr=Br(1,!0);Pr.UONE=Xr;var Yr=Br(-1);Pr.NEG_ONE=Yr;var Qr=xr(-1,2147483647,!1);Pr.MAX_VALUE=Qr;var en=xr(-1,-1,!0);Pr.MAX_UNSIGNED_VALUE=en;var tn=xr(0,-2147483648,!1);Pr.MIN_VALUE=tn;var rn=Pr.prototype;rn.toInt=function(){return this.unsigned?this.low>>>0:this.low},rn.toNumber=function(){return this.unsigned?(this.high>>>0)*Kr+(this.low>>>0):this.high*Kr+(this.low>>>0)},rn.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(tn)){var t=Fr(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=Fr(Gr(e,6),this.unsigned),s=this,i="";;){var a=s.div(o),c=(s.sub(a.mul(o)).toInt()>>>0).toString(e);if((s=a).isZero())return c+i;for(;c.length<6;)c="0"+c;i=""+c+i}},rn.getHighBits=function(){return this.high},rn.getHighBitsUnsigned=function(){return this.high>>>0},rn.getLowBits=function(){return this.low},rn.getLowBitsUnsigned=function(){return this.low>>>0},rn.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tn)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},rn.isZero=function(){return 0===this.high&&0===this.low},rn.eqz=rn.isZero,rn.isNegative=function(){return!this.unsigned&&this.high<0},rn.isPositive=function(){return this.unsigned||this.high>=0},rn.isOdd=function(){return!(1&~this.low)},rn.isEven=function(){return!(1&this.low)},rn.equals=function(e){return Lr(e)||(e=Vr(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},rn.eq=rn.equals,rn.notEquals=function(e){return!this.eq(e)},rn.neq=rn.notEquals,rn.ne=rn.notEquals,rn.lessThan=function(e){return this.comp(e)<0},rn.lt=rn.lessThan,rn.lessThanOrEqual=function(e){return this.comp(e)<=0},rn.lte=rn.lessThanOrEqual,rn.le=rn.lessThanOrEqual,rn.greaterThan=function(e){return this.comp(e)>0},rn.gt=rn.greaterThan,rn.greaterThanOrEqual=function(e){return this.comp(e)>=0},rn.gte=rn.greaterThanOrEqual,rn.ge=rn.greaterThanOrEqual,rn.compare=function(e){if(Lr(e)||(e=Vr(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},rn.comp=rn.compare,rn.negate=function(){return!this.unsigned&&this.eq(tn)?tn:this.not().add(Zr)},rn.neg=rn.negate,rn.add=function(e){Lr(e)||(e=Vr(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,s=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=o+(65535&e.low))>>>16,l+=(u+=n+a)>>>16,c+=(l+=r+i)>>>16,c+=t+s,xr((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},rn.subtract=function(e){return Lr(e)||(e=Vr(e)),this.add(e.neg())},rn.sub=rn.subtract,rn.multiply=function(e){if(this.isZero())return this;if(Lr(e)||(e=Vr(e)),Nr)return xr(Nr.mul(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Jr:Wr;if(this.eq(tn))return e.isOdd()?tn:Wr;if(e.eq(tn))return this.isOdd()?tn:Wr;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt($r)&&e.lt($r))return Fr(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,s=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=65535&e.low,l=0,u=0,d=0,g=0;return d+=(g+=o*c)>>>16,u+=(d+=n*c)>>>16,d&=65535,u+=(d+=o*a)>>>16,l+=(u+=r*c)>>>16,u&=65535,l+=(u+=n*a)>>>16,u&=65535,l+=(u+=o*i)>>>16,l+=t*c+r*a+n*i+o*s,xr((d&=65535)<<16|(g&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},rn.mul=rn.multiply,rn.divide=function(e){if(Lr(e)||(e=Vr(e)),e.isZero())throw Error("division by zero");var t,r,n;if(Nr)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?xr((this.unsigned?Nr.div_u:Nr.div_s)(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Jr:Wr;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Jr;if(e.gt(this.shru(1)))return Xr;n=Jr}else{if(this.eq(tn))return e.eq(Zr)||e.eq(Yr)?tn:e.eq(tn)?Zr:(t=this.shr(1).div(e).shl(1)).eq(Wr)?e.isNegative()?Zr:Yr:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(tn))return this.unsigned?Jr:Wr;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=Wr}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),s=o<=48?1:Gr(2,o-48),i=Fr(t),a=i.mul(e);a.isNegative()||a.gt(r);)a=(i=Fr(t-=s,this.unsigned)).mul(e);i.isZero()&&(i=Zr),n=n.add(i),r=r.sub(a)}return n},rn.div=rn.divide,rn.modulo=function(e){return Lr(e)||(e=Vr(e)),Nr?xr((this.unsigned?Nr.rem_u:Nr.rem_s)(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},rn.mod=rn.modulo,rn.rem=rn.modulo,rn.not=function(){return xr(~this.low,~this.high,this.unsigned)},rn.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},rn.clz=rn.countLeadingZeros,rn.countTrailingZeros=function(){return this.low?Dr(this.low):Dr(this.high)+32},rn.ctz=rn.countTrailingZeros,rn.and=function(e){return Lr(e)||(e=Vr(e)),xr(this.low&e.low,this.high&e.high,this.unsigned)},rn.or=function(e){return Lr(e)||(e=Vr(e)),xr(this.low|e.low,this.high|e.high,this.unsigned)},rn.xor=function(e){return Lr(e)||(e=Vr(e)),xr(this.low^e.low,this.high^e.high,this.unsigned)},rn.shiftLeft=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):xr(0,this.low<<e-32,this.unsigned)},rn.shl=rn.shiftLeft,rn.shiftRight=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):xr(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},rn.shr=rn.shiftRight,rn.shiftRightUnsigned=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):xr(32===e?this.high:this.high>>>e-32,0,this.unsigned)},rn.shru=rn.shiftRightUnsigned,rn.shr_u=rn.shiftRightUnsigned,rn.rotateLeft=function(e){var t;return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?xr(this.high,this.low,this.unsigned):e<32?(t=32-e,xr(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),xr(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},rn.rotl=rn.rotateLeft,rn.rotateRight=function(e){var t;return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?xr(this.high,this.low,this.unsigned):e<32?(t=32-e,xr(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),xr(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},rn.rotr=rn.rotateRight,rn.toSigned=function(){return this.unsigned?xr(this.low,this.high,!1):this},rn.toUnsigned=function(){return this.unsigned?this:xr(this.low,this.high,!0)},rn.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},rn.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},rn.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Pr.fromBytes=function(e,t,r){return r?Pr.fromBytesLE(e,t):Pr.fromBytesBE(e,t)},Pr.fromBytesLE=function(e,t){return new Pr(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Pr.fromBytesBE=function(e,t){return new Pr(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var nn=new class{_user;constructor(){this._user=this.createDefaultUser()}get uid(){return this.user.uid}get isActive(){return this.user.active}get user(){return this._user}setLogged(e){this._user={active:!0,uid:Pr.isLong(e.uid)?e.uid.toString():e.uid,deviceId:Pr.isLong(e.deviceId)?e.deviceId.toString():e.deviceId,sessionId:Pr.isLong(e.sessionId)?e.sessionId.toString():e.sessionId}}logOut(){this._user=this.createDefaultUser()}createDefaultUser(){return{active:!1,uid:"0",deviceId:"0",sessionId:"0",token:""}}};const on={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const sn=t=>e.ConnectionStatus[t],an=e=>{const t=new kr;return t.writeIn8(67),t.writeIn8(255),t.writeInt32(e.length+7),t.writeArr(Array.from(e)),t.writeIn8(0),new Int8Array(t.getBytesArray()).buffer},cn=e=>{const t=new Ar(new Uint8Array(e));t.readInt8(),t.readInt8();const r=t.readInt32(),n=t.readArr(r-7);if(t.readInt8(),e.byteLength!==r)throw new Error("packet resolve failed");return n};var ln=new class{url="";watcher;options;socket;status=e.ConnectionStatus.DISCONNECTED;autoReconnect=!1;isConnected=!1;responseCallbacks=new Map;failedCount=0;reconnectTimer;connectResolve;pendingMessages=[];constructor(e){this.options=Object.assign(on,e)}setServerInfo(e){this.url=e}setCallback(e){this.watcher=e}async connect(){return this.autoReconnect=!0,new Promise(t=>{this.connectResolve=t,this.open().then(r=>{t(r),r===e.ErrorCode.SUCCESS?(this.isConnected=!0,this.onConnect()):this.onDisconnect(r===e.ErrorCode.TIMEOUT?e.ConnectionStatus.NETWORK_UNAVAILABLE:e.ConnectionStatus.WEBSOCKET_UNAVAILABLE)})})}async request(t,r,n,o=this.options.signalTimeout){const{code:s,data:i}=await this.sendRawData(t,rt(r)&&rt(n.encoder)?n.encoder.encode(r).finish():new Uint8Array,o);if(0!==s)return{code:s,msg:"time out",data:null};if(!rt(i)||!rt(n.decoder))return{code:e.ErrorCode.SUCCESS,msg:""};const a=n.decoder?.decode(i);return a.errorCode?{code:a.errorCode,msg:a.errorMessage,data:null}:{data:a,code:e.ErrorCode.SUCCESS,msg:""}}async send(t,r,n,o=this.options.signalTimeout){const s=await this.request(t,r,n,o);return s.code!==e.ErrorCode.SUCCESS?{code:Mr(s.code),msg:s.msg,data:null}:{data:s.data,code:e.ErrorCode.SUCCESS,msg:s.msg}}async sendRawData(t,r,n=this.options.signalTimeout){if(!this.socket)return{code:e.ErrorCode.RC_NET_CHANNEL_INVALID};const o=this.generateMessageSeq();this.isConnected?this.doSendRawData(t,r,o):this.pendingMessages.push({cmdId:t,body:r,messageSeq:o});const s=await new Promise(e=>{this.responseCallbacks.set(o,e),setTimeout(()=>{this.responseCallbacks.get(o)&&this.responseCallbacks.delete(o),e(null)},n)});return s?{code:0,data:s}:(As.warn(`send timeout -> cmd: 0x${t.toString(16)}, messageSeq: ${o}, timeout: ${n}`),{code:e.ErrorCode.TIMEOUT})}doSendRawData(e,t,r){const n={cmdId:e,messageSeq:Pr.fromNumber(r),deviceId:Pr.fromString(nn.user.deviceId),sessionId:Pr.fromString(nn.user.sessionId),uid:Pr.fromString(nn.user.uid),protocolVersion:0,destId:"",body:t,deviceCode:Rt.getDeviceCode()??"",deviceType:Rt.getDeviceType()};e!==Tt.Heartbean&&As.info(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${r}`),this.socket?.send(an(Ir.encode(n).finish()))}close(){this.autoReconnect=!1,this.doClose(),this.setStatus(e.ConnectionStatus.DISCONNECTED),this.connectResolve?.(e.ErrorCode.RC_SOCKET_DISCONNECTED)}async open(){const t=this.url;As.info(`connect start -> ${t}`),this.setStatus(e.ConnectionStatus.CONNECTING);const r=function(e,t){const r=new WebSocket(e,t);return r.binaryType="arraybuffer",{onClose(e){r.onclose=t=>{const{code:r,reason:n}=t;e?.(r,n)}},onError(e){r.onerror=t=>{e(t)}},onMessage(e){r.onmessage=t=>{e(t.data)}},onOpen(e){r.onopen=e},send(e){r.send(e)},close(e,t){r.close(e,t)}}}(this.url);this.socket=r;return await new Promise(n=>{r.onMessage(e=>{"ArrayBuffer"===tt(e)?this.onReceiveMessage(e):As.error("Socket received invalid data:",e)}),r.onClose((t,r)=>{As.warn("websocket closed -> code:",t,"reason:",r),this.onDisconnect(e.ConnectionStatus.CONNECTION_CLOSED),n(e.ErrorCode.RC_SOCKET_DISCONNECTED)}),r.onError(t=>{As.warn("websocket error -> ",t),this.onDisconnect(e.ConnectionStatus.WEBSOCKET_ERROR),n(e.ErrorCode.RC_SOCKET_NOT_CREATED)}),r.onOpen(()=>{As.info("websocket open -> ",t),n(e.ErrorCode.SUCCESS)}),setTimeout(()=>{n(e.ErrorCode.TIMEOUT)},this.options.webSocketTimeout)})}async checkAlive(){if(!this.socket||!this.isConnected)return;As.debug("send ping ->");const t={pingId:Pr.ZERO,disconnectDelay:Pr.ZERO},{code:r}=await this.send(Tt.Heartbean,t,{encoder:Er},this.options.pingTimeout);r===e.ErrorCode.SUCCESS?(As.debug("recv pong <-"),this.failedCount=0,setTimeout(()=>this.checkAlive(),this.options.pingInterval)):(this.failedCount+=1,As.warn(`ping failed count: ${this.failedCount}, code: ${r}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,As.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.ConnectionStatus.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let r;try{const e=cn(t);r=wr.decode(e)}catch(t){return As.error("unpack payload error -> ",t),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER)}if(r.code)return As.error("on received message error -> ",r.code),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER);if(r.cmdId===Tt.SessionKilledPush)return void this.onDisconnect(e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT);if(r.cmdId===Tt.SignOutPish||r.cmdId===Tt.SignOutPish2)return As.warn("on received signoutpush -> ",r.cmdId),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER);if(r.cmdId===Tt.UserFrozenToLogin||r.cmdId===Tt.UserFrozenToLogin2)return void this.onDisconnect(e.ConnectionStatus.BLOCKED);const n=Pr.isLong(r.messageSeq)?r.messageSeq.toNumber():0,o=n>0?this.responseCallbacks.get(n):null;rt(o)?(r.cmdId!==Tt.HeartbeanResp&&As.info(`websocket recv ack -> messageSeq: ${n}`),o(r.body),this.responseCallbacks.delete(n)):(As.info(`websocket recv -> cmd: 0x${r.cmdId.toString(16)}`),this.watcher?.message(r.cmdId,r.body))}async try2Reconnect(){this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},5e3)}async onConnect(){for(this.setStatus(e.ConnectionStatus.CONNECTED),this.checkAlive(),rt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);this.pendingMessages.length>0;){let{cmdId:e,body:t,messageSeq:r}=this.pendingMessages.shift();this.doSendRawData(e,t,r),await new Promise(e=>setTimeout(e,200))}}onDisconnect(e){rt(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(rt(this.socket)){this.pendingMessages.length=0;const e=this.socket;this.socket=null,e.onClose(null),e.close()}rt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.isConnected=!1;for(const e of this.responseCallbacks.values())e(null);this.responseCallbacks.clear()}isConnectionAvailable(){return this.status!==e.ConnectionStatus.DISCONNECTED&&this.status!==e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.ConnectionStatus.BLOCKED&&this.status!==e.ConnectionStatus.DISCONNECT_BY_SERVER}setStatus(e){As.info(`socketServer is changing status from ${sn(this.status)} to ${sn(e)}`),this.status=e,this.watcher?.status(e)}idCount=0;generateMessageSeq(){return++this.idCount}};const un=vr.Reader,dn=vr.Writer,gn=vr.util,pn=vr.roots.default||(vr.roots.default={}),fn=pn.SendPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e})(),hn=pn.SendPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e})(),yn=pn.DeletePrivateChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeletePrivateChatDialogReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.destId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e})(),mn=pn.GetNewMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(8).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(16).int32(e.rows),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetNewMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.offset=e.int64();break;case 2:n.rows=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e})(),vn=pn.GetNewMessageResp=(()=>{function e(e){if(this.msg={},this.reference={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msg=gn.emptyObject,e.prototype.reference=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(24).int64(e.offset),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(32).int64(e.seqno),null!=e.msg&&Object.hasOwnProperty.call(e,"msg"))for(let r=Object.keys(e.msg),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.DialogMessageList.encode(e.msg[r[n]],t.uint32(18).fork()).ldelim().ldelim();if(null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let r=Object.keys(e.reference),n=0;n<r.length;++n)t.uint32(50).fork().uint32(10).string(r[n]),pn.ReferenceDialogMessage.encode(e.reference[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetNewMessageResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.offset=e.int64();break;case 4:s.seqno=e.int64();break;case 5:{s.msg===gn.emptyObject&&(s.msg={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.msg[r]=n;break}case 6:{s.reference===gn.emptyObject&&(s.reference={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.reference[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e})();pn.DialogMessageList=(()=>{function e(e){if(this.dialogMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.dialogMessage&&e.dialogMessage.length)for(let r=0;r<e.dialogMessage.length;++r)pn.DialogMessage.encode(e.dialogMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DialogMessageList;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.dialogMessage&&n.dialogMessage.length||(n.dialogMessage=[]),n.dialogMessage.push(pn.DialogMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e})(),pn.DialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.isOut=!1,e.prototype.senderCategory=0,e.prototype.msgCategory=0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.burnAfterReadingFlag=!1,e.prototype.atFlag=!1,e.prototype.replyFlag=!1,e.prototype.referenceFlag=!1,e.prototype.msgIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.replyMarkup="",e.prototype.extra="",e.prototype.msgArrival=!1,e.prototype.msgRead=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(8).int64(e.msgId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgStatus&&Object.hasOwnProperty.call(e,"msgStatus")&&t.uint32(24).int32(e.msgStatus),null!=e.srcId&&Object.hasOwnProperty.call(e,"srcId")&&t.uint32(32).int64(e.srcId),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(40).int64(e.destId),null!=e.isOut&&Object.hasOwnProperty.call(e,"isOut")&&t.uint32(48).bool(e.isOut),null!=e.senderCategory&&Object.hasOwnProperty.call(e,"senderCategory")&&t.uint32(56).int32(e.senderCategory),null!=e.msgCategory&&Object.hasOwnProperty.call(e,"msgCategory")&&t.uint32(64).int32(e.msgCategory),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(74).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(82).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(88).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(96).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(106).string(e.mediaAttribute),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(112).int64(e.msgSendTime),null!=e.burnAfterReadingFlag&&Object.hasOwnProperty.call(e,"burnAfterReadingFlag")&&t.uint32(120).bool(e.burnAfterReadingFlag),null!=e.atFlag&&Object.hasOwnProperty.call(e,"atFlag")&&t.uint32(128).bool(e.atFlag),null!=e.replyFlag&&Object.hasOwnProperty.call(e,"replyFlag")&&t.uint32(136).bool(e.replyFlag),null!=e.referenceFlag&&Object.hasOwnProperty.call(e,"referenceFlag")&&t.uint32(144).bool(e.referenceFlag),null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(152).int64(e.msgIdReferenced),null!=e.uploadFlag&&Object.hasOwnProperty.call(e,"uploadFlag")&&t.uint32(160).bool(e.uploadFlag),null!=e.burnAfterReadingTime&&Object.hasOwnProperty.call(e,"burnAfterReadingTime")&&t.uint32(168).int64(e.burnAfterReadingTime),null!=e.sharingGroupFlag&&Object.hasOwnProperty.call(e,"sharingGroupFlag")&&t.uint32(176).bool(e.sharingGroupFlag),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(184).int64(e.seqno),null!=e.replyMarkup&&Object.hasOwnProperty.call(e,"replyMarkup")&&t.uint32(194).string(e.replyMarkup),null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(202).string(e.extra),null!=e.msgArrival&&Object.hasOwnProperty.call(e,"msgArrival")&&t.uint32(208).bool(e.msgArrival),null!=e.msgRead&&Object.hasOwnProperty.call(e,"msgRead")&&t.uint32(216).bool(e.msgRead),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DialogMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.msgId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgStatus=e.int32();break;case 4:n.srcId=e.int64();break;case 5:n.destId=e.int64();break;case 6:n.isOut=e.bool();break;case 7:n.senderCategory=e.int32();break;case 8:n.msgCategory=e.int32();break;case 9:n.msgPreContent=e.string();break;case 10:n.msgPostContent=e.string();break;case 11:n.mediaFlag=e.bool();break;case 12:n.mediaConstructor=e.int32();break;case 13:n.mediaAttribute=e.string();break;case 14:n.msgSendTime=e.int64();break;case 15:n.burnAfterReadingFlag=e.bool();break;case 16:n.atFlag=e.bool();break;case 17:n.replyFlag=e.bool();break;case 18:n.referenceFlag=e.bool();break;case 19:n.msgIdReferenced=e.int64();break;case 20:n.uploadFlag=e.bool();break;case 21:n.burnAfterReadingTime=e.int64();break;case 22:n.sharingGroupFlag=e.bool();break;case 23:n.seqno=e.int64();break;case 24:n.replyMarkup=e.string();break;case 25:n.extra=e.string();break;case 26:n.msgArrival=e.bool();break;case 27:n.msgRead=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e})(),pn.ReferenceDialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.srcId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.srcName="",e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.destName="",e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(8).int64(e.msgId),null!=e.srcId&&Object.hasOwnProperty.call(e,"srcId")&&t.uint32(16).int64(e.srcId),null!=e.srcName&&Object.hasOwnProperty.call(e,"srcName")&&t.uint32(26).string(e.srcName),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(32).int64(e.destId),null!=e.destName&&Object.hasOwnProperty.call(e,"destName")&&t.uint32(42).string(e.destName),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(50).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(58).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(64).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(72).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(82).string(e.mediaAttribute),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(88).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReferenceDialogMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.msgId=e.int64();break;case 2:n.srcId=e.int64();break;case 3:n.srcName=e.string();break;case 4:n.destId=e.int64();break;case 5:n.destName=e.string();break;case 6:n.msgPreContent=e.string();break;case 7:n.msgPostContent=e.string();break;case 8:n.mediaFlag=e.bool();break;case 9:n.mediaConstructor=e.int32();break;case 10:n.mediaAttribute=e.string();break;case 11:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReferenceDialogMessage"},e})();const bn=pn.UpdatePrivateChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.UpdatePrivateChatDialogStickyConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e})(),Cn=pn.UpdatePrivateChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.UpdatePrivateChatDialogMuteConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.muteFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e})(),On=pn.DeleteChatMessageReq=(()=>{function e(e){if(this.msgIdList=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(let r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeleteChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;case 3:if(n.msgIdList&&n.msgIdList.length||(n.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgIdList.push(e.int64())}else n.msgIdList.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e})();pn.DeletePrivateChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeletePrivateChatHistoryReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e})();const Sn=pn.CleanHistoryMessageReq=(()=>{function e(e){if(this.msgIdList=[],this.destIdList=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gn.emptyArray,e.prototype.destIdList=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(let r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}if(null!=e.destIdList&&e.destIdList.length)for(let r=0;r<e.destIdList.length;++r)t.uint32(34).string(e.destIdList[r]);return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.CleanHistoryMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.string();break;case 2:n.msgId=e.int64();break;case 3:if(n.msgIdList&&n.msgIdList.length||(n.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgIdList.push(e.int64())}else n.msgIdList.push(e.int64());break;case 4:n.destIdList&&n.destIdList.length||(n.destIdList=[]),n.destIdList.push(e.string());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e})(),In=pn.GetBriefDialogListReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let r=0;r<e.destId.length;++r)t.int64(e.destId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetBriefDialogListReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)if(n.destId&&n.destId.length||(n.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.destId.push(e.int64())}else n.destId.push(e.int64());else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e})(),wn=pn.GetBriefDialogListResp=(()=>{function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=gn.emptyArray,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.notExistDestId&&e.notExistDestId.length){t.uint32(26).fork();for(let r=0;r<e.notExistDestId.length;++r)t.int64(e.notExistDestId[r]);t.ldelim()}if(null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(32).int64(e.seqno),null!=e.briefDialog&&Object.hasOwnProperty.call(e,"briefDialog"))for(let r=Object.keys(e.briefDialog),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.BriefDialog.encode(e.briefDialog[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetBriefDialogListResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:if(s.notExistDestId&&s.notExistDestId.length||(s.notExistDestId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)s.notExistDestId.push(e.int64())}else s.notExistDestId.push(e.int64());break;case 4:s.seqno=e.int64();break;case 5:{s.briefDialog===gn.emptyObject&&(s.briefDialog={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.briefDialog[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e})();pn.BriefDialog=(()=>{function e(e){if(this.groupMemberSmallAvatarUrl=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.dialogTitle="",e.prototype.smallAvatarUrl="",e.prototype.backgroundImage="",e.prototype.stickyFlag=!1,e.prototype.muteFlag=!1,e.prototype.blockFlag=!1,e.prototype.burnAfterReadingFlag=!1,e.prototype.takeScreenshotFlag=!1,e.prototype.groupFlag=!1,e.prototype.totalMemberNumber=0,e.prototype.groupMemberSmallAvatarUrl=gn.emptyArray,e.prototype.burnAfterReadingTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.dialogMenuContent="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.dialogTitle&&Object.hasOwnProperty.call(e,"dialogTitle")&&t.uint32(18).string(e.dialogTitle),null!=e.smallAvatarUrl&&Object.hasOwnProperty.call(e,"smallAvatarUrl")&&t.uint32(26).string(e.smallAvatarUrl),null!=e.backgroundImage&&Object.hasOwnProperty.call(e,"backgroundImage")&&t.uint32(34).string(e.backgroundImage),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(40).bool(e.stickyFlag),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(48).bool(e.muteFlag),null!=e.blockFlag&&Object.hasOwnProperty.call(e,"blockFlag")&&t.uint32(56).bool(e.blockFlag),null!=e.burnAfterReadingFlag&&Object.hasOwnProperty.call(e,"burnAfterReadingFlag")&&t.uint32(64).bool(e.burnAfterReadingFlag),null!=e.takeScreenshotFlag&&Object.hasOwnProperty.call(e,"takeScreenshotFlag")&&t.uint32(72).bool(e.takeScreenshotFlag),null!=e.groupFlag&&Object.hasOwnProperty.call(e,"groupFlag")&&t.uint32(80).bool(e.groupFlag),null!=e.totalMemberNumber&&Object.hasOwnProperty.call(e,"totalMemberNumber")&&t.uint32(88).int32(e.totalMemberNumber),null!=e.groupMemberSmallAvatarUrl&&e.groupMemberSmallAvatarUrl.length)for(let r=0;r<e.groupMemberSmallAvatarUrl.length;++r)t.uint32(98).string(e.groupMemberSmallAvatarUrl[r]);return null!=e.burnAfterReadingTime&&Object.hasOwnProperty.call(e,"burnAfterReadingTime")&&t.uint32(104).int64(e.burnAfterReadingTime),null!=e.dialogMenuContent&&Object.hasOwnProperty.call(e,"dialogMenuContent")&&t.uint32(114).string(e.dialogMenuContent),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.BriefDialog;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.dialogTitle=e.string();break;case 3:n.smallAvatarUrl=e.string();break;case 4:n.backgroundImage=e.string();break;case 5:n.stickyFlag=e.bool();break;case 6:n.muteFlag=e.bool();break;case 7:n.blockFlag=e.bool();break;case 8:n.burnAfterReadingFlag=e.bool();break;case 9:n.takeScreenshotFlag=e.bool();break;case 10:n.groupFlag=e.bool();break;case 11:n.totalMemberNumber=e.int32();break;case 12:n.groupMemberSmallAvatarUrl&&n.groupMemberSmallAvatarUrl.length||(n.groupMemberSmallAvatarUrl=[]),n.groupMemberSmallAvatarUrl.push(e.string());break;case 13:n.burnAfterReadingTime=e.int64();break;case 14:n.dialogMenuContent=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e})();const En=pn.GetDialogKeyReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let r=0;r<e.destId.length;++r)t.int64(e.destId[r]);t.ldelim()}return null!=e.clientSign&&Object.hasOwnProperty.call(e,"clientSign")&&t.uint32(18).string(e.clientSign),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetDialogKeyReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:if(n.destId&&n.destId.length||(n.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.destId.push(e.int64())}else n.destId.push(e.int64());break;case 2:n.clientSign=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e})(),Rn=pn.GetDialogKeyResp=(()=>{function e(e){if(this.retryUid=[],this.entry={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.retryUid=gn.emptyArray,e.prototype.entry=gn.emptyObject,e.prototype.serverSign="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.dialogKeyVersion&&Object.hasOwnProperty.call(e,"dialogKeyVersion")&&t.uint32(24).int64(e.dialogKeyVersion),null!=e.retryUid&&e.retryUid.length){t.uint32(34).fork();for(let r=0;r<e.retryUid.length;++r)t.int64(e.retryUid[r]);t.ldelim()}if(null!=e.entry&&Object.hasOwnProperty.call(e,"entry"))for(let r=Object.keys(e.entry),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.AesKeyAndIV.encode(e.entry[r[n]],t.uint32(18).fork()).ldelim().ldelim();return null!=e.serverSign&&Object.hasOwnProperty.call(e,"serverSign")&&t.uint32(50).string(e.serverSign),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetDialogKeyResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.dialogKeyVersion=e.int64();break;case 4:if(s.retryUid&&s.retryUid.length||(s.retryUid=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)s.retryUid.push(e.int64())}else s.retryUid.push(e.int64());break;case 5:{s.entry===gn.emptyObject&&(s.entry={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.entry[r]=n;break}case 6:s.serverSign=e.string();break;default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e})();pn.AesKeyAndIV=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.encode=function(e,t){return t||(t=dn.create()),null!=e.aesKey&&Object.hasOwnProperty.call(e,"aesKey")&&t.uint32(10).string(e.aesKey),null!=e.aesIV&&Object.hasOwnProperty.call(e,"aesIV")&&t.uint32(18).string(e.aesIV),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.AesKeyAndIV;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e})();const Tn=pn.RecallPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.RecallPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e})(),_n=pn.GetHistoryMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogKeys="",e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.dialogKeys&&Object.hasOwnProperty.call(e,"dialogKeys")&&t.uint32(10).string(e.dialogKeys),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.oldOffset&&Object.hasOwnProperty.call(e,"oldOffset")&&t.uint32(24).int64(e.oldOffset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(32).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(40).bool(e.newToOld),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetHistoryMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.dialogKeys=e.string();break;case 2:n.offset=e.int64();break;case 3:n.oldOffset=e.int64();break;case 4:n.rows=e.int32();break;case 5:n.newToOld=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e})(),kn=pn.GetHistoryMessageResp=(()=>{function e(e){if(this.reference={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.prototype.reference=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pn.DialogMessageList.encode(e.msg,t.uint32(26).fork()).ldelim(),null!=e.isEnd&&Object.hasOwnProperty.call(e,"isEnd")&&t.uint32(32).bool(e.isEnd),null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let r=Object.keys(e.reference),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.ReferenceDialogMessage.encode(e.reference[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetHistoryMessageResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.msg=pn.DialogMessageList.decode(e,e.uint32());break;case 4:s.isEnd=e.bool();break;case 5:{s.reference===gn.emptyObject&&(s.reference={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.reference[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e})(),An=pn.GetWebDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.type=0,e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(24).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(32).bool(e.newToOld),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetWebDialogListReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.type=e.int32();break;case 2:n.offset=e.int64();break;case 3:n.rows=e.int32();break;case 4:n.newToOld=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e})(),Mn=pn.GetWebDialogListResp=(()=>{function e(e){if(this.fullDialog=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.fullDialog&&e.fullDialog.length)for(let r=0;r<e.fullDialog.length;++r)pn.WebFullDialog.encode(e.fullDialog[r],t.uint32(26).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetWebDialogListResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.fullDialog&&n.fullDialog.length||(n.fullDialog=[]),n.fullDialog.push(pn.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e})();pn.WebFullDialog=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialog=null,e.prototype.msg=null,e.encode=function(e,t){return t||(t=dn.create()),null!=e.dialog&&Object.hasOwnProperty.call(e,"dialog")&&pn.BriefDialog.encode(e.dialog,t.uint32(10).fork()).ldelim(),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pn.DialogMessage.encode(e.msg,t.uint32(18).fork()).ldelim(),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.WebFullDialog;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.dialog=pn.BriefDialog.decode(e,e.uint32());break;case 2:n.msg=pn.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e})();const Nn=pn.GetNewSettingDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.time=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetNewSettingDialogListReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.time=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e})(),Pn=pn.GetNewSettingDialogListResp=(()=>{function e(e){if(this.briefDialog={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=gn.emptyObject,e.prototype.setTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.briefDialog&&Object.hasOwnProperty.call(e,"briefDialog"))for(let r=Object.keys(e.briefDialog),n=0;n<r.length;++n)t.uint32(26).fork().uint32(10).string(r[n]),pn.BriefDialog.encode(e.briefDialog[r[n]],t.uint32(18).fork()).ldelim().ldelim();return null!=e.setTime&&Object.hasOwnProperty.call(e,"setTime")&&t.uint32(32).int64(e.setTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetNewSettingDialogListResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:{s.briefDialog===gn.emptyObject&&(s.briefDialog={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.briefDialog[r]=n;break}case 4:s.setTime=e.int64();break;default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e})(),Ln=pn.NewMessageNotificationResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(24).int64(e.seqno),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.NewMessageNotificationResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e})();pn.ChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&e.msgId.length){t.uint32(18).fork();for(let r=0;r<e.msgId.length;++r)t.int64(e.msgId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ChatMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:if(n.msgId&&n.msgId.length||(n.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgId.push(e.int64())}else n.msgId.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ChatMessage"},e})();const Dn=pn.SendPrivateChatArrivalAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.chatMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.chatMessage&&e.chatMessage.length)for(let r=0;r<e.chatMessage.length;++r)pn.ChatMessage.encode(e.chatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatArrivalAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.chatMessage&&n.chatMessage.length||(n.chatMessage=[]),n.chatMessage.push(pn.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatArrivalAckReq"},e})(),jn=pn.SendPrivateChatReadAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.chatMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.chatMessage&&e.chatMessage.length)for(let r=0;r<e.chatMessage.length;++r)pn.ChatMessage.encode(e.chatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatReadAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.chatMessage&&n.chatMessage.length||(n.chatMessage=[]),n.chatMessage.push(pn.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatReadAckReq"},e})(),Un=pn.ReplyPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContentReferenced="",e.prototype.msgPostContentReferenced="",e.prototype.mediaFlagReferenced=!1,e.prototype.mediaConstructorReferenced=0,e.prototype.mediaAttributeReferenced="",e.prototype.msgSendTimeReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(64).int64(e.msgIdReferenced),null!=e.msgSrcIdReferenced&&Object.hasOwnProperty.call(e,"msgSrcIdReferenced")&&t.uint32(72).int64(e.msgSrcIdReferenced),null!=e.msgDestIdReferenced&&Object.hasOwnProperty.call(e,"msgDestIdReferenced")&&t.uint32(80).int64(e.msgDestIdReferenced),null!=e.msgPreContentReferenced&&Object.hasOwnProperty.call(e,"msgPreContentReferenced")&&t.uint32(90).string(e.msgPreContentReferenced),null!=e.msgPostContentReferenced&&Object.hasOwnProperty.call(e,"msgPostContentReferenced")&&t.uint32(98).string(e.msgPostContentReferenced),null!=e.mediaFlagReferenced&&Object.hasOwnProperty.call(e,"mediaFlagReferenced")&&t.uint32(104).bool(e.mediaFlagReferenced),null!=e.mediaConstructorReferenced&&Object.hasOwnProperty.call(e,"mediaConstructorReferenced")&&t.uint32(112).int32(e.mediaConstructorReferenced),null!=e.mediaAttributeReferenced&&Object.hasOwnProperty.call(e,"mediaAttributeReferenced")&&t.uint32(122).string(e.mediaAttributeReferenced),null!=e.msgSendTimeReferenced&&Object.hasOwnProperty.call(e,"msgSendTimeReferenced")&&t.uint32(128).int64(e.msgSendTimeReferenced),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReplyPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:n.msgIdReferenced=e.int64();break;case 9:n.msgSrcIdReferenced=e.int64();break;case 10:n.msgDestIdReferenced=e.int64();break;case 11:n.msgPreContentReferenced=e.string();break;case 12:n.msgPostContentReferenced=e.string();break;case 13:n.mediaFlagReferenced=e.bool();break;case 14:n.mediaConstructorReferenced=e.int32();break;case 15:n.mediaAttributeReferenced=e.string();break;case 16:n.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageReq"},e})(),Bn=pn.ReplyPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReplyPrivateChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageResp"},e})(),Fn=vr.Reader,xn=vr.Writer,Gn=vr.util,qn=vr.roots.default||(vr.roots.default={}),Vn=qn.SendGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(let r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:if(n.at&&n.at.length||(n.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.at.push(e.int64())}else n.at.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e})(),Kn=qn.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.seqno=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(48).int64(e.seqno),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();qn.DeleteGroupChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.DeleteGroupChatHistoryReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e})();const Hn=qn.UpdateGroupChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.UpdateGroupChatDialogStickyConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e})(),zn=qn.UpdateGroupChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.UpdateGroupChatDialogMuteConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.muteFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e})(),$n=qn.RecallGroupChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.RecallGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e})();qn.DeleteGroupChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.DeleteGroupChatDialogReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e})(),qn.GroupChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.userId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.userId&&Object.hasOwnProperty.call(e,"userId")&&t.uint32(16).int64(e.userId),null!=e.msgId&&e.msgId.length){t.uint32(26).fork();for(let r=0;r<e.msgId.length;++r)t.int64(e.msgId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.GroupChatMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.userId=e.int64();break;case 3:if(n.msgId&&n.msgId.length||(n.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgId.push(e.int64())}else n.msgId.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GroupChatMessage"},e})();const Wn=qn.SendGroupChatArrivalAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupChatMessage=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let r=0;r<e.groupChatMessage.length;++r)qn.GroupChatMessage.encode(e.groupChatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatArrivalAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupChatMessage&&n.groupChatMessage.length||(n.groupChatMessage=[]),n.groupChatMessage.push(qn.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatArrivalAckReq"},e})(),Jn=qn.SendGroupChatReadAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupChatMessage=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let r=0;r<e.groupChatMessage.length;++r)qn.GroupChatMessage.encode(e.groupChatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatReadAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupChatMessage&&n.groupChatMessage.length||(n.groupChatMessage=[]),n.groupChatMessage.push(qn.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatReadAckReq"},e})(),Zn=qn.ReplyGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Gn.emptyArray,e.prototype.msgIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContentReferenced="",e.prototype.msgPostContentReferenced="",e.prototype.mediaFlagReferenced=!1,e.prototype.mediaConstructorReferenced=0,e.prototype.mediaAttributeReferenced="",e.prototype.msgSendTimeReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(let r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(72).int64(e.msgIdReferenced),null!=e.msgSrcIdReferenced&&Object.hasOwnProperty.call(e,"msgSrcIdReferenced")&&t.uint32(80).int64(e.msgSrcIdReferenced),null!=e.msgDestIdReferenced&&Object.hasOwnProperty.call(e,"msgDestIdReferenced")&&t.uint32(88).int64(e.msgDestIdReferenced),null!=e.msgPreContentReferenced&&Object.hasOwnProperty.call(e,"msgPreContentReferenced")&&t.uint32(98).string(e.msgPreContentReferenced),null!=e.msgPostContentReferenced&&Object.hasOwnProperty.call(e,"msgPostContentReferenced")&&t.uint32(106).string(e.msgPostContentReferenced),null!=e.mediaFlagReferenced&&Object.hasOwnProperty.call(e,"mediaFlagReferenced")&&t.uint32(112).bool(e.mediaFlagReferenced),null!=e.mediaConstructorReferenced&&Object.hasOwnProperty.call(e,"mediaConstructorReferenced")&&t.uint32(120).int32(e.mediaConstructorReferenced),null!=e.mediaAttributeReferenced&&Object.hasOwnProperty.call(e,"mediaAttributeReferenced")&&t.uint32(130).string(e.mediaAttributeReferenced),null!=e.msgSendTimeReferenced&&Object.hasOwnProperty.call(e,"msgSendTimeReferenced")&&t.uint32(136).int64(e.msgSendTimeReferenced),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.ReplyGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:if(n.at&&n.at.length||(n.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.at.push(e.int64())}else n.at.push(e.int64());break;case 9:n.msgIdReferenced=e.int64();break;case 10:n.msgSrcIdReferenced=e.int64();break;case 11:n.msgDestIdReferenced=e.int64();break;case 12:n.msgPreContentReferenced=e.string();break;case 13:n.msgPostContentReferenced=e.string();break;case 14:n.mediaFlagReferenced=e.bool();break;case 15:n.mediaConstructorReferenced=e.int32();break;case 16:n.mediaAttributeReferenced=e.string();break;case 17:n.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageReq"},e})(),Xn=qn.ReplyGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.ReplyGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageResp"},e})();function Yn(t){return(lt(t)?Pr.fromString(t):t).greaterThan(Pr.fromNumber(9e10))?e.ConversationType.GROUP:e.ConversationType.PRIVATE}const Qn=e=>e.targetId,eo=e=>({conversationType:Yn(e),targetId:Pr.isLong(e)?e.toString():e});let to=0;const ro=async()=>{const t=(new Date).getTime(),{code:r,data:n}=await ln.send(Tt.GetServerTime,null,{decoder:Rr});if(r===e.ErrorCode.SUCCESS){const{currentTimeMillis:e}=n;to=e.toNumber()-t}},no=()=>(new Date).getTime()+to,oo=new Set;var so={addMessage(e){oo.add(e)},remove(e){oo.delete(e)},has:e=>oo.has(e),reset(){oo.clear()}};const io=new Set;var ao={addMessage(e){io.add(e)},remove(e){io.delete(e)},has:e=>io.has(e),reset(){io.clear()}};const co=new Map;function lo(e,t){co.set(e,t)}function uo(e,t){const r=co.get(e);if(!r)return console.warn(`No message constructor found for type: ${e}`),null;try{return new r(t)}catch(t){return console.error(`Failed to decode message type ${e}:`,t),null}}var go=new class{aesKeyRecord=new Map;async getDialogAesKey(e){return ut(e)?this.aesKeyRecord.has(e)?this.aesKeyRecord.get(e):new Promise(t=>{this.getDialogAesKeyListFromRemote([e]).then(r=>{t(r.get(e))}),setTimeout(()=>{t(null)},8e3)}):null}getDialogAesKeyList(e){return new Promise(t=>{const r=new Map;this.getDialogAesKeyListInBatches(e,(n,o)=>{if(o.size)for(const[e,t]of o)r.set(e,t);(r.size===e.length||n)&&t(r)})})}getDialogAesKeyListInBatches(e,t){const r=new Map,n=[];e.forEach(e=>{if(!ut(e))return;const t=this.getDialogAesKeyFromLocal(e);t?r.set(e,t):n.push(e)}),t(!1,r),n.length&&this.getDialogAesKeyListFromRemote(n).then(e=>{t(!0,e)})}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(t){if(!t.length)return new Map;try{const{code:n,data:o}=await(r=t.map(e=>Pr.fromString(e)),ln.send(Tt.GetDialogKey,{destId:r,clientSign:""},{encoder:En,decoder:Rn}));if(n===e.ErrorCode.SUCCESS){const e=new Map;for(const t in o.entry){const r=o.entry[t];if(r.aesKey?.length&&r.aesIV?.length){const n={key:r.aesKey,iv:r.aesIV};e.set(t,n),this.aesKeyRecord.set(t,n)}}return e}}catch(e){As.error("getDialogAesKeyListFromRemote error",e)}var r;return new Map}getDialogAesKeyFromLocal(e){return ut(e)?this.aesKeyRecord.get(e):null}};const po="time",fo=(e,t)=>[e,t,po].join("_");class ho{appkey;userId;inBoxOffset=Pr.ZERO;constructor(e,t){this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=fo(this.appkey,this.userId);Ct.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=fo(this.appkey,this.userId);this.inBoxOffset=Pr.fromString(Ct.get(e)??"0")}return this.inBoxOffset}}const yo=(e,t)=>{if(!ut(e))return"";const r=et.AES.encrypt(e,et.enc.Utf8.parse(t.key),{iv:rt(t.iv)?et.enc.Utf8.parse(t.iv):void 0});return Array.from(vo(r.ciphertext.words)).map(e=>e.toString(16).padStart(2,"0")).join("")},mo=(e,t)=>{const r=new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))||[]),n=window.btoa(String.fromCharCode(...r));return et.AES.decrypt(n,et.enc.Utf8.parse(t.key),{iv:rt(t.iv)?et.enc.Utf8.parse(t.iv):void 0}).toString(et.enc.Utf8)},vo=e=>{const t=[];let r,n,o;for(n=0;n<e.length;++n)for(r=e[n],o=3;o>=0;--o)t.push(r>>8*o&255);return new Uint8Array(t)},bo={TEXT:0,IMAGE:805310464,GIF:805310475,FILE:805310490,AUDIO:805310481,VIDEO:805310470,RECALL:1610678301,LOCATION:805310469,CHAT_RECORD:805310489,CONTACT:268439554,GROUP_INVITATION:805310467,REDPACKET:268439616,TRANSFER:268439600,LINK:268439556},Co={GROUP_ARRIVAL_RECEIPT:1610743844,GROUP_READ_RECEIPT:1610743845,PRIVATE_ARRIVAL_RECEIPT:1610678284,PRIVATE_READ_RECEIPT:1610678285,PRIVATE_OPEN_BURNAFTERREADING:1610678274,PRIVATE_CLOSE_BURNAFTERREADING:1610678275,GROUP_OPEN_BURNAFTERREADING:1610743816,GROUP_CLOSE_BURNAFTERREADING:1610743817};function Oo(e){if(!rt(e))return e;if(Array.isArray(e))return e.map(e=>Oo(e));if(at(e)){const t={};return Object.keys(e).forEach(r=>{t[r]=Oo(e[r])}),t}return e}const So={unreadMessageCount:{keyName:"c",defaultVal:0},lastUnreadTime:{keyName:"lt",defaultVal:0},notificationStatus:{keyName:"nc",defaultVal:2},notificationLevel:{keyName:"nl",defaultVal:0},isTop:{keyName:"it",defaultVal:!1},mentionedUIds:{keyName:"mu",defaultVal:null},dialogTitle:{keyName:"dt",defaultVal:null},smallAvatarUrl:{keyName:"sa",defaultVal:null},burnAfterReadingFlag:{keyName:"brf",defaultVal:!1},burnAfterReadingTime:{keyName:"brt",defaultVal:0},updateTime:{keyName:"ut",defaultVal:0}};class Io{localStore;constructor(e,t){const r=`con-${e}-${t}`;this.localStore=new St(r)}getStoreKey(e){return`${e.conversationType}_${e.targetId}\n }`}getConOptionByKey(t){const r=(t=t||"").split("_");if(r.length>=2){const e=r.shift(),t=r.shift();return{conversationType:Number(e),targetId:t}}return{conversationType:e.ConversationType.PRIVATE,targetId:"0"}}updateUnreadCount(t){const{conversationType:r,targetId:n,content:o,messageType:s,sentTime:i,isCounted:a,messageDirection:c}=t,l=c===e.MessageDirection.SEND,u=s===bo.RECALL,d=at(o),g={conversationType:r,targetId:n},p=this.get(g)||{},f=p.lastUnreadTime||Pr.ZERO,h=p.unreadMessageCount||0;if(!(i<=f)&&!l){if(a&&(p.unreadMessageCount=h+1,f||(p.lastUnreadTime=i)),u&&d){o.sentTime>=f&&h&&(p.unreadMessageCount=h-1)}this.set(g,p)}}updateMentionedData(t){const{conversationType:r,targetId:n,messageUId:o,messageType:s,isMentioned:i,messageDirection:a,content:c}=t;if(!o||a===e.MessageDirection.SEND||!i&&s!==bo.RECALL)return;const l=this.getStoreKey({conversationType:r,targetId:n}),u=this.localStore.get(l)||{},d=So.mentionedUIds.keyName,g=u[d]||[];if(i&&r===e.ConversationType.GROUP&&(g.includes(o.toString())||g.push(o.toString())),s===bo.RECALL&&r===e.ConversationType.GROUP){const e=c,t=g.indexOf(e.messageUId?.toString()??"");t>=0&&g.splice(t,1)}g.length?u[d]=g:delete u[d],dt(u)?this.localStore.set(l,u):this.localStore.remove(l)}updateUpdateTime(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};n[So.updateTime.keyName]=t,this.localStore.set(r,n)}set(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};for(const e of pt(t)){const r=So[e],o=t[e];if(st(r?.keyName)||st(o))continue;o===r.defaultVal?delete n[r.keyName]:n[r.keyName]=o,n[So.unreadMessageCount.keyName]||(delete n[So.lastUnreadTime.keyName],delete n[So.mentionedUIds.keyName])}dt(n)?this.localStore.set(r,n):this.localStore.remove(r)}remove(e){const t=this.getStoreKey(e);this.localStore.remove(t)}get(e){const t=this.getStoreKey(e),r=this.localStore.get(t)||{},n={};for(const e of pt(So)){const{keyName:t,defaultVal:o}=So[e];"mentionedUIds"===e?(n.unreadMentionedCount=r[t]?.length??0,n.hasMentioned=!!n.unreadMentionedCount):n[e]=r[t]||Oo(o)}return n}getAll(){const e=this.localStore.getCache()||{},t=[];for(const r in e){const n=this.getConOptionByKey(r),o=e[r];for(const e of pt(So)){const{keyName:t,defaultVal:r}=So[e];"mentionedUIds"!==e&&(n[e]=o[t]||Oo(r))}t.push(n)}return t}}const wo=t=>{const r=t.destId??"",n=eo(r);if(!n)return;t.dialogTitle,t.smallAvatarUrl;return{...n,unreadMessageCount:0,notificationStatus:t.muteFlag?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,notificationLevel:t.muteFlag?e.NotificationLevel.NOT_MESSAGE_NOTIFICATION:e.NotificationLevel.ALL_MESSAGE,isTop:!!t.stickyFlag,dialogTitle:t.dialogTitle,smallAvatarUrl:t.smallAvatarUrl,lastUnreadTime:"0",burnAfterReadingFlag:!!t.burnAfterReadingFlag,burnAfterReadingTime:t.burnAfterReadingTime&&t.burnAfterReadingTime.toNumber()}};class Eo{events={};on(e,t,r){const n=this.events[e]||(this.events[e]=[]);n.some(e=>e.listener===t&&e.target===r)||n.push({listener:t,target:r})}emit(e,...t){const r=this.events[e];r?.length&&r.map(e=>{const{target:r,listener:n}=e;try{n.call(r,...t)}catch(e){}})}off(e,t,r){let n=this.events[e];n?.length&&(n=n.filter(e=>e.listener!==t||e.target!==r),n.length?this.events[e]=n:delete this.events[e])}once(e,t,r){const n=(...o)=>{t.call(r,...o),this.off(e,n,r)};return this.on(e,n,r),this}}const Ro="STATUS_CHANGED";class To{storageKey;eventEmitter;isPulling=!1;constructor(e,t){this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new Eo}async pull(){if(this.isPulling)return;let t;this.isPulling=!0;const r=Ct.get(this.storageKey);t=nt(r)&&r>0?r:no()-1e4;let{code:n,data:o}=await(e=>ln.send(Tt.GetDialogChangedStatus,{time:Pr.fromNumber(e)},{encoder:Nn,decoder:Pn}))(t);n===e.ErrorCode.SUCCESS&&(Pr.isLong(o.setTime)&&o.setTime.toNumber()>0&&Ct.set(this.storageKey,o.setTime.toNumber()),o.briefDialog&&pt(o.briefDialog).forEach(e=>{const t=o.briefDialog[e],r=wo(t);r&&this.eventEmitter.emit(Ro,r)})),this.isPulling=!1}watch(e){this.eventEmitter.on(Ro,t=>{e(t)})}}class _o{updatedConversationFunc;store;draftMap=new Map;localConversationSet=new Set;updatedConversations=[];notify;statusManager;constructor(e,t,r){this.updatedConversationFunc=r,this.store=new Io(e,t),this.notify=ht(this.notifyConversationChanged.bind(this),0),this.statusManager=new To(e,t),this.statusManager.watch(e=>{this.addStatus(e,!0)})}getConversationKey(e){return`${e.conversationType}_${e.targetId}\n }`}setUpdatedConversation(e){const t=this.updatedConversations.findIndex(t=>this.getConversationKey(e.conversation)===this.getConversationKey(t.conversation));t>=0?(e={conversation:Object.assign(this.updatedConversations[t].conversation,e.conversation),updatedItems:Object.assign(this.updatedConversations[t].updatedItems,e.updatedItems)},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){const e=this.updatedConversations.map(e=>({conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems}));this.updatedConversations=[],this.updatedConversationFunc?.(e)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(t){if(!t?.length)return;const r=t.filter(e=>!this.localConversationSet.has(this.getConversationKey(e)));if(!r.length)return;const n=r.map(Qn);if(!n.length)return;const{code:o,data:s}=await(e=>ln.send(Tt.GetBriefDialogList,{destId:e.map(e=>Pr.fromString(e))},{encoder:In,decoder:wn}))(n);o===e.ErrorCode.SUCCESS&&pt(s.briefDialog).forEach(e=>{const t=s.briefDialog[e],r=wo(t);r&&(this.localConversationSet.add(this.getConversationKey(r)),this.addStatus(r,!0))})}addLocalConversation(e){const{conversationType:t,targetId:r,isTop:n,notificationStatus:o,notificationLevel:s,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:r,isTop:n,notificationStatus:o,notificationLevel:s,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u},!1)}addStatus(e,t=!1){const{conversationType:r,targetId:n,notificationStatus:o,notificationLevel:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}=e,g={conversationType:r,targetId:n},p=no(),f=this.store.get(g),h={};rt(s)&&f.notificationLevel!==s&&(h.notificationLevel={time:p,val:s}),rt(o)&&f.notificationStatus!==o&&(h.notificationStatus={time:p,val:o}),rt(i)&&f.isTop!==i&&(h.isTop={time:p,val:i}),rt(a)&&f.dialogTitle!==a&&(h.dialogTitle={time:p,val:a}),rt(c)&&f.smallAvatarUrl!==c&&(h.smallAvatarUrl={time:p,val:c}),rt(l)&&f.burnAfterReadingFlag!==l&&(h.burnAfterReadingFlag={time:p,val:l}),rt(u)&&f.burnAfterReadingTime!==u&&(h.burnAfterReadingTime={time:p,val:u}),this.store.set(g,{notificationStatus:o,isTop:i,notificationLevel:s,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}),Object.keys(h).length&&t&&this.setUpdatedConversation({conversation:g,updatedItems:h})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:r,targetId:n}=e;if(!r)return;const o={conversationType:t,targetId:n},s={conversation:o,updatedItems:{}},i=Oo(this.get(o));this.store.updateUnreadCount(e),this.store.updateMentionedData(e),this.store.updateUpdateTime(o,parseInt(e.sentTime));const a=this.get(o);i.unreadMessageCount!==a.unreadMessageCount&&(s.updatedItems.unreadMessageCount={time:parseInt(e.sentTime),val:a.unreadMessageCount}),i.hasMentioned!==a.hasMentioned&&(s.updatedItems.hasMentioned={time:parseInt(e.sentTime),val:a.hasMentioned}),i.unreadMentionedCount!==a.unreadMentionedCount&&(s.updatedItems.unreadMentionedCount={time:parseInt(e.sentTime),val:a.unreadMentionedCount}),Object.keys(s.updatedItems).length&&this.setUpdatedConversation(s)}get(e){return this.store.get(e)}getAllUnreadCount(t,r){const n=this.store.getAll();let o=0;return n.forEach(({unreadMessageCount:n,notificationStatus:s,notificationLevel:i,conversationType:a})=>{n=n||0;const c=s===e.NotificationStatus.OPEN||i>0;!r&&c||(t.length>0?t.includes(+a)&&(o+=+n):o+=+n)}),o}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:r,unreadMentionedCount:n}=t;(r||n)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const o={};r&&(o.unreadMessageCount={val:0,time:no()}),n&&(o.hasMentioned={val:!1,time:no()},o.unreadMentionedCount={val:0,time:no()}),Object.keys(o).length&&this.setUpdatedConversation({conversation:e,updatedItems:o})}clearAllUnreadCount(){this.store.getAll().forEach(e=>this.clearUnreadCount(e))}getNotificationLevel(e){return this.store.get(e).notificationLevel}getNotificationStatus(e){return this.store.get(e).notificationStatus||2}setDraft(e,t){this.draftMap.set(this.getConversationKey(e),t)}getDraft(e){return this.draftMap.get(this.getConversationKey(e))??""}clearDraft(e){this.draftMap.delete(this.getConversationKey(e))}getBlockConversationList(){return this.store.getAll().filter(t=>t.notificationStatus===e.NotificationStatus.OPEN||t.notificationLevel>0).map(e=>({conversationType:e.conversationType,targetId:e.targetId}))}getTopConversationList(){return(this.store.getAll()||{}).filter(e=>e.isTop).map(e=>({conversationType:e.conversationType,targetId:e.targetId}))}getUnreadMentionedCount(e){return this.get(e).unreadMentionedCount||0}getAllUnreadMentionedCount(){const e=this.store.getAll();let t=0;return e.forEach(({unreadMentionedCount:e})=>{e=e||0,t+=Number(e)}),t}getConversationState(e){let t=this.get(e);if(t){let{unreadMessageCount:r,unreadMentionedCount:n,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}=t;return{...e,unreadCount:r,unreadMentionedCount:n??0,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}}return null}getAllConversationState(){return this.store.getAll().map(({conversationType:e,targetId:t,unreadMessageCount:r,unreadMentionedCount:n,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l})=>({conversationType:e,targetId:t,unreadCount:r,unreadMentionedCount:n??0,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}))}remove(e){this.store.remove(e),this.localConversationSet.delete(this.getConversationKey(e))}clearHistoryMessages(e){this.clearUnreadCount(e);const t={conversation:e,updatedItems:{}};t.conversation.latestMessage=void 0,t.updatedItems.latestMessage={val:null,time:no()},this.setUpdatedConversation(t)}updateLatestMessage(e,t){rt(t)&&this.store.set(e,{updateTime:parseInt(t.sentTime)});const r={conversation:e,updatedItems:{}};rt(t)&&(r.conversation.updateTime=parseInt(t.sentTime)),r.conversation.latestMessage=t,r.updatedItems.latestMessage={val:t,time:no()},this.setUpdatedConversation(r)}destroyed(){this.updatedConversationFunc=void 0}}const ko={addStatus:function(e,t){},setConversationCacheByMessage:function(e){},updateLatestMessage:function(e,t){},get:function(e){return null},getAllUnreadCount:function(e,t){return 0},getUnreadCount:function(e){return 0},clearUnreadCount:function(e){},clearAllUnreadCount(){},getNotificationLevel:function(t){return e.NotificationLevel.NOT_SET},getNotificationStatus:function(t){return e.NotificationStatus.CLOSE},setDraft:function(e,t){},getDraft:function(e){return""},clearDraft:function(e){},getBlockConversationList:function(){return[]},getTopConversationList:function(){return[]},getUnreadMentionedCount:function(e){return 0},getAllUnreadMentionedCount:function(){return 0},getConversationState:e=>null,getAllConversationState:function(){return[]},addLocalConversation:function(e){},loadConvsationsIfNotExist:function(e){return Promise.resolve()},destroyed(){},syncConversationStatus:function(){},remove:function(e){},clearHistoryMessages:function(e){}};let Ao;var Mo={create(e,t,r){Ao=new _o(e,t,r)},get:()=>Ao??ko};const No=(t,r,n=e.SentStatus.SENDING)=>{const o=Mo.get().get(r.conversation);return{conversationType:r.conversation.conversationType,targetId:r.conversation.targetId,senderUserId:r.senderUserId,messageDirection:e.MessageDirection.SEND,isCounted:t.isCounted,isMentioned:!1,content:Oo(t.content),messageType:t.messageType,isOffLineMessage:!1,isPersited:t.isPersited,messageId:r.messageId,messageUId:"local"+r.sentTime,sentTime:r.sentTime,sentStatus:n,receivedTime:r.sentTime,isStatusMessage:t.isStatusMessage,receivedStatus:e.ReceivedStatus.IDLE,disableNotification:!0,burnAfterReadingFlag:o?.burnAfterReadingFlag??!1,burnAfterReadingTime:o?.burnAfterReadingTime??0}};function Po(e){const t={...e};return"content"in t&&delete t.content,"quotedReply"in t&&delete t.quotedReply,"msgPreContent"in t&&delete t.msgPreContent,"msgPostContent"in t&&delete t.msgPostContent,t}const Lo=(e,t,r,n)=>{const o=new Map;return e.forEach(e=>{const s=Do(e,t.get(e),r.get(e),n);s.length&&o.set(e,s)}),o},Do=(t,r,n,o)=>{const s=eo(t);if(!s)return[];const i=Mo.get().get(s);let a=[];return r.forEach(t=>{const r=t;let c=r.mediaConstructor,l=jo(r,n);if(!l)return;if(1610678290===c||1610743841===c){const{msgId:e}=l;c=bo.RECALL,l={messageUId:e}}const u=uo(c,l);if(rt(u)){const c={...s,senderUserId:r.srcId.toString(),messageDirection:r.isOut?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:u.isCounted,isMentioned:r.atFlag,content:u.content,messageType:u.messageType,isOffLineMessage:!1,isPersited:u.isPersited,messageId:Pr.isLong(r.localId)?r.localId.toNumber():0,messageUId:r.msgId.toString(),sentTime:r.seqno.toString(),sentStatus:e.SentStatus.SENT,receivedTime:no().toString(),isStatusMessage:u.isStatusMessage,receivedStatus:r.msgRead?e.ReceivedStatus.READ:r.msgArrival?e.ReceivedStatus.RECEIVED:e.ReceivedStatus.IDLE,disableNotification:i?.notificationStatus===e.NotificationStatus.OPEN||r.srcId.toString()==nn.uid,burnAfterReadingFlag:r.burnAfterReadingFlag,burnAfterReadingTime:r.burnAfterReadingTime&&r.burnAfterReadingTime.toNumber()};if(c.isStatusMessage&&Pr.fromNumber(no()).subtract(c.sentTime).greaterThan(6e3))return;if(r.msgIdReferenced&&Pr.isLong(r.msgIdReferenced)){const t=o[r.msgIdReferenced.toString()];if(t){let r=jo({mediaAttribute:t.mediaAttribute,msgPreContent:t.msgPreContent,msgPostContent:t.msgPostContent,mediaConstructor:t.mediaConstructor??0,msgId:t.msgId??Pr.fromNumber(0)},n);if(r){const n=uo(t.mediaConstructor??0,r);rt(n)&&(c.quotedReply=((t,r,n)=>({conversationType:n.conversationType,targetId:t.destId.toString(),senderUserId:t.srcId.toString(),messageDirection:t.srcId.toString()===nn.uid?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:r.isCounted,isMentioned:!1,content:Oo(r.content),messageType:r.messageType,isOffLineMessage:!1,isPersited:r.isPersited,messageId:1,messageUId:t.msgId.toString(),sentTime:t.msgSendTime.toString(),sentStatus:e.SentStatus.SENT,receivedTime:t.msgSendTime.toString(),isStatusMessage:r.isStatusMessage,receivedStatus:e.ReceivedStatus.RECEIVED,disableNotification:!0,burnAfterReadingFlag:!1,burnAfterReadingTime:0,senderUserName:t.srcName}))(t,n,s))}}}ut(c.messageUId)?a.push(c):As.error("message is invalid",Po(t))}}),a},jo=(e,t)=>{try{let r,n;return r=e.mediaAttribute?.length?mo(e.mediaAttribute,t):e.msgPreContent??"",e.msgPostContent?.length&&(n=mo(e.msgPostContent,t)),Uo(e.mediaConstructor,r,n)}catch(t){return As.error("decode message content fail",e,t),null}},Uo=(e,t,r)=>{let n={};if(e==bo.TEXT&&r)n.content=r;else if(t?.length){const e=Bo(t);n=JSON.parse(e)}return n},Bo=e=>{let t=e.replace(/("[\w\d_]+"\s*:\s*)(?<!\d\.)(\d{15,})(?!\.\d*)([\s,}\]])/g,'$1"$2"$3');return t=t.replace(/(\[\s*|,\s*)(?<!\d\.)(\d{15,})(?!\.\d*)([\s,\]])/g,'$1"$2"$3'),t};var Fo={parse:function(e,t,r){const n=new Map;if(Object.keys(e).forEach(t=>{const r=e[t].dialogMessage?.filter(e=>!e.sharingGroupFlag);r?.length&&n.set(t,r)}),!n.size)return void r(!0,new Map);const o=new Set([...n.keys()]);go.getDialogAesKeyListInBatches([...n.keys()],(e,s)=>{try{if(s.size){const e=[...s.keys()];for(const t of e)o.delete(t);r(!o.size,Lo(e,n,s,t))}o.size&&e&&r(!0,new Map)}catch(t){As.error("parseDialogsMessages error",t),o.size&&e&&r(!0,new Map)}})},parseSingleDialogMessages:Do,decodeChatRecordMsgDetails2ReceivedMessages:(t,r)=>{let n=[];return r.forEach(r=>{const o=Uo(r.mediaConstructor,r.mediaAttribute,r.msgPostContent);if(!o)return;const s=uo(r.mediaConstructor,o);if(rt(s)){const o={...t,senderUserId:r.srcId.toString(),messageDirection:r.srcId==nn.uid?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:s.isCounted,isMentioned:!1,content:s.content,messageType:s.messageType,isOffLineMessage:!1,isPersited:s.isPersited,messageId:0,messageUId:r.msgId+"",sentTime:r.msgSendTime+"",sentStatus:e.SentStatus.SENT,receivedTime:r.msgSendTime+"",isStatusMessage:s.isStatusMessage,receivedStatus:e.ReceivedStatus.READ,disableNotification:!1};n.push(o)}}),n},encodeReceivedMessage2ChatRecordMsgDetail:e=>{const t=uo(e.messageType,e.content);if(!t)return null;const r=JSON.stringify(t.content),n=e.messageType===bo.TEXT?t.content.content:void 0;return{senderNickname:e.senderNickname,senderAvatar:e.senderAvatar||void 0,msgId:e.messageUId,srcId:e.senderUserId,destId:e.targetId,mediaConstructor:e.messageType,mediaAttribute:r,msgPostContent:n,msgSendTime:e.sentTime}}};const xo="unreadMessageUids";class Go{localStore;constructor(e,t){const r=`receipt-v2-${e}-${t}`;this.localStore=new St(r)}storeUnreadMessageUids(t){const r=t.filter(t=>t.isCounted&&t.messageDirection!==e.MessageDirection.SEND).map(e=>({uid:e.messageUId,timestamp:Date.now()})),n=[...this.localStore.get(xo)||[],...r];this.localStore.set(xo,n)}cleanExpiredMessages(){const e=this.localStore.get(xo)||[],t=Date.now(),r=e.filter(e=>t-e.timestamp<=1728e5);this.localStore.set(xo,r)}formatReceiptMessages(t){const r=[],n=[];t.forEach(t=>{t.conversationType===e.ConversationType.PRIVATE?r.push(t):n.push(t)});return{privateReceiptMessages:Object.entries(r.reduce((e,t)=>(e[t.targetId]||(e[t.targetId]=[]),e[t.targetId].push(t.messageUId),e),{})).map(([e,t])=>({destId:Pr.fromString(e),msgId:t.map(e=>Pr.fromString(e))})),groupReceiptMessages:n.reduce((e,t)=>{const r=e.find(e=>e.groupId.equals(Pr.fromString(t.targetId))&&e.userId.equals(Pr.fromString(t.senderUserId)));return r?r.msgId.push(Pr.fromString(t.messageUId)):e.push({groupId:Pr.fromString(t.targetId),userId:Pr.fromString(t.senderUserId),msgId:[Pr.fromString(t.messageUId)]}),e},[])}}filterValidMessages(t){return t.filter(t=>t.isCounted&&t.messageDirection!==e.MessageDirection.SEND)}async sendArrivalReceipts(e){this.storeUnreadMessageUids(e);const t=this.filterValidMessages(e),{privateReceiptMessages:r,groupReceiptMessages:n}=this.formatReceiptMessages(t);var o;r.length&&await(o={chatMessage:r},ln.send(Tt.SendPrivateChatArrivalAck,o,{encoder:Dn,decoder:Tr})),n.length&&await(e=>ln.send(Tt.SendGroupChatReadAck,e,{encoder:Jn,decoder:Tr}))({groupChatMessage:n})}async sendReadReceipts(e){const t=this.localStore.get(xo)||[],r=this.filterValidMessages(e).filter(e=>t.some(t=>t.uid===e.messageUId));try{const{privateReceiptMessages:e,groupReceiptMessages:t}=this.formatReceiptMessages(r);e.length&&await(n={chatMessage:e},ln.send(Tt.SendPrivateChatReadAck,n,{encoder:jn,decoder:Tr})),t.length&&await(e=>ln.send(Tt.SendGroupChatArrivalAck,e,{encoder:Wn,decoder:Tr}))({groupChatMessage:t});const o=this.localStore.get(xo)||[],s=r.map(e=>e.messageUId),i=o.filter(e=>!s.includes(e.uid));this.localStore.set(xo,i)}catch(e){throw console.error("发送已读回执失败:",e),e}var n}}let qo;var Vo={create(e,t){qo=new Go(e,t),qo.cleanExpiredMessages()},get:()=>qo};let Ko=0,Ho=0;function zo(e,t){Ko=e+100,Ho=t+100}function $o(){return Ho++,Ho}function Wo(){return Ko--,Ko}function Jo(){return Ho}class Zo{loadedEndMap=new Map;db=null;currentAppKey="";currentUserId="";APP_INFO_KEY="im_app_info";DB_NAME_PREFIX="im_message_cache_1";DB_VERSION=2;STORE_NAME="messages_new";DIALOG_STATE_STORE="dialogStates_new";encryptKey={key:""};SALT_PREFIX="im_message_cache_salt_prefix";SALT_SUFFIX="im_message_cache_salt_suffix";constructor(e,t){this.generateEncryptKey(e,t),this.currentAppKey=e,this.currentUserId=t}generateEncryptKey(e,t){const r=`${this.SALT_PREFIX}${e}_${t}${this.SALT_SUFFIX}`,n=et.SHA256(r).toString(),o=n.substring(0,16),s=n.substring(16,48),i=et.SHA256(`${o}:${this.SALT_PREFIX}:${t}:${e}`).toString().substring(0,8),a=et.PBKDF2(s,i,{keySize:8,iterations:1e3,hasher:et.algo.SHA256}).toString();this.encryptKey={key:a.substring(0,32),iv:o}}async initDB(){await this.checkAndResetDatabase(),await this.initDatabase()}async checkAndResetDatabase(){const e=bt.get(this.APP_INFO_KEY);if(e)try{const t=JSON.parse(e);t.appKey===this.currentAppKey&&t.userId===this.currentUserId||await this.deleteDatabase()}catch(e){As.error("Failed to parse stored AppKey and UserId",e),await this.deleteDatabase()}bt.set(this.APP_INFO_KEY,JSON.stringify({appKey:this.currentAppKey,userId:this.currentUserId,timestamp:Date.now()}))}async deleteDatabase(){return this.db&&(this.db.close(),this.db=null),this.loadedEndMap.clear(),new Promise((e,t)=>{const r=this.getDBName(),n=indexedDB.deleteDatabase(r);n.onsuccess=()=>{As.info(`Database ${r} successfully deleted`),e()},n.onerror=t=>{As.error(`Failed to delete database ${r}`,t),e()}})}getDBName(){return`${this.DB_NAME_PREFIX}_${this.currentAppKey}_${this.currentUserId}`}initDatabase(){return new Promise((e,t)=>{const r=this.getDBName(),n=indexedDB.open(r,this.DB_VERSION);n.onerror=e=>{As.error("Failed to open database",e),t(new Error("Failed to open database"))},n.onsuccess=t=>{this.db=t.target.result,this.loadAllDialogStates().then(()=>{e()}).catch(t=>{As.error("Failed to load conversation states",t),e()})},n.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.STORE_NAME)){const e=t.createObjectStore(this.STORE_NAME,{keyPath:"messageId"});e.createIndex("messageUId","messageUId",{unique:!0}),e.createIndex("dialogId","dialogId",{unique:!1}),e.createIndex("dialogId_sentTime",["dialogId","sentTime"],{unique:!1}),e.createIndex("receivedStatus","receivedStatus",{unique:!1}),e.createIndex("burnAfterReadingFlag","burnAfterReadingFlag",{unique:!1}),e.createIndex("dialogId_receivedStatus",["dialogId","receivedStatus"],{unique:!1})}t.objectStoreNames.contains(this.DIALOG_STATE_STORE)||t.createObjectStore(this.DIALOG_STATE_STORE,{keyPath:"dialogId"})}})}async loadAllDialogStates(){if(this.db)return new Promise((e,t)=>{const r=this.db.transaction(this.DIALOG_STATE_STORE,"readonly").objectStore(this.DIALOG_STATE_STORE).getAll();r.onsuccess=()=>{const t=r.result;this.loadedEndMap.clear(),t.forEach(e=>{this.loadedEndMap.set(e.dialogId,e.isEnd)}),e()},r.onerror=e=>{t(new Error("Failed to load conversation states"))}})}async updateDialogState(e,t){if(this.db)return this.loadedEndMap.set(e,t),new Promise((r,n)=>{const o=this.db.transaction(this.DIALOG_STATE_STORE,"readwrite").objectStore(this.DIALOG_STATE_STORE).put({dialogId:e,isEnd:t,updateTime:Date.now()});o.onsuccess=()=>{r()},o.onerror=e=>{As.error("Failed to update conversation state",e),n(new Error("Failed to update conversation state"))}})}encryptContent(e){if(!e)return"";try{const t=JSON.stringify(e);return yo(t,this.encryptKey)}catch(e){return As.error("Failed to encrypt message content",e),""}}decryptContent(e){if(!e)return null;try{const t=mo(e,this.encryptKey);return JSON.parse(t)}catch(e){return As.error("Failed to decrypt message content",e),null}}decryptMessage(e){const t={...e};if("string"==typeof t.content&&t.content)try{t.content=this.decryptContent(t.content)}catch(e){As.error("Failed to decrypt message content",e),t.content=null}if(t.quotedReply&&"string"==typeof t.quotedReply.content&&t.quotedReply.content)try{t.quotedReply.content=this.decryptContent(t.quotedReply.content)}catch(e){As.error("Failed to decrypt quoted message content",e),t.quotedReply.content=null}return t}async addMessages(e,t,r=void 0){let n=e?.filter(e=>e.isPersited);if(As.info("addMessages to db -> ",n),!n||0===n.length||!this.db){if(rt(r)){const e=Qn(t);await this.updateDialogState(e,r)}return}const o=Qn(t);return new Promise(e=>{try{const t=this.db.transaction(this.STORE_NAME,"readwrite"),s=t.objectStore(this.STORE_NAME);t.oncomplete=async()=>{if(rt(r))try{await this.updateDialogState(o,r)}catch(e){As.error("Failed to update dialog state:",e)}e()},t.onerror=s=>{As.error("Transaction failed in addMessages:",function(e){return e.map(Po)}(n),t.error),rt(r)?this.updateDialogState(o,r).catch(e=>As.error("Failed to update dialog state after transaction error:",e)).finally(()=>e()):e()};for(const e of n)try{const t={...Oo(e),dialogId:o};t.content&&(t.content=this.encryptContent(t.content)),t.quotedReply?.content&&(t.quotedReply.content=this.encryptContent(t.quotedReply.content)),s.put(t)}catch(t){As.error("Error processing message:",Po(e),t)}}catch(t){As.error("Failed to start transaction:",t),rt(r)?this.updateDialogState(o,r).catch(e=>As.error("Failed to update dialog state:",e)).finally(()=>e()):e()}})}async getPreviousMessages(e,t="0",r=20){const n=Qn(e);if(!this.db)return{messages:[],hasMore:!1};const o=await this.getDialogLoadedState(n);return new Promise((e,s)=>{const i=this.db.transaction(this.STORE_NAME,"readonly"),a=i.objectStore(this.STORE_NAME).index("dialogId_sentTime");let c;c="0"===t?IDBKeyRange.bound([n,""],[n,"￿"]):IDBKeyRange.bound([n,""],[n,t]);const l=[];let u=!1,d=0;const g=a.count(c);g.onsuccess=()=>{const t=g.result;a.openCursor(c,"prev").onsuccess=e=>{const t=e.target.result;if(t)if(d<r){const e=this.decryptMessage(t.value);l.push(e),d++,t.continue()}else u=!0,n();else n()};const n=()=>{l.sort((e,t)=>Pr.fromString(e.sentTime).compare(Pr.fromString(t.sentTime))),e({messages:l,hasMore:u||t>r||!o})}},i.onerror=e=>{As.error("Failed to query message",e),s(new Error("Failed to query message"))}})}async clearConversationCache(e){const t=Qn(e);if(!this.db)return void this.loadedEndMap.set(t,!0);const r=new Promise((e,r)=>{const n=this.db.transaction(this.STORE_NAME,"readwrite");n.objectStore(this.STORE_NAME).index("dialogId").openCursor(IDBKeyRange.only(t)).onsuccess=e=>{const t=e.target.result;t&&(t.delete(),t.continue())},n.oncomplete=()=>{e()},n.onerror=e=>{As.error("Failed to clear conversation messages"),r(new Error("Failed to clear conversation messages"))}});await Promise.all([r,this.updateDialogState(t,!0)])}async clearAllCache(){if(!this.db)return void this.loadedEndMap.clear();const e=new Promise((e,t)=>{const r=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME).clear();r.onsuccess=()=>{e()},r.onerror=e=>{As.error("Failed to clear all messages"),t(new Error("Failed to clear all messages"))}}),t=new Promise((e,t)=>{const r=this.db.transaction(this.DIALOG_STATE_STORE,"readwrite").objectStore(this.DIALOG_STATE_STORE).clear();r.onsuccess=()=>{this.loadedEndMap.clear(),e()},r.onerror=e=>{As.error("Failed to clear all conversation states"),t(new Error("Failed to clear all conversation states"))}});await Promise.all([e,t])}async getDialogLoadedState(e){return this.loadedEndMap.has(e)?this.loadedEndMap.get(e):!!this.db&&new Promise((t,r)=>{const n=this.db.transaction(this.DIALOG_STATE_STORE,"readonly").objectStore(this.DIALOG_STATE_STORE).get(e);n.onsuccess=()=>{const r=n.result;r?(this.loadedEndMap.set(e,r.isEnd),t(r.isEnd)):t(!1)},n.onerror=e=>{t(!1)}})}async removeMessagesByUId(e){if(!e||0===e.length||!this.db)return;const t=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME),r=t.index("messageUId");e.forEach(e=>{const n=r.get(e);n.onsuccess=()=>{const e=n.result;e&&t.delete(e.messageId)}})}async updateMessageReceiptStatus(t,r){if(!t||!t.messageUIdList||0===t.messageUIdList.length||!this.db)return;const n=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME),o=n.index("messageUId");t.messageUIdList.forEach(t=>{const s=o.get(t);s.onsuccess=()=>{const t=s.result;if(t){let o=!1;0===r&&t.receivedStatus<e.ReceivedStatus.RECEIVED?(t.receivedStatus=e.ReceivedStatus.RECEIVED,o=!0):1===r&&t.receivedStatus<e.ReceivedStatus.READ&&(t.receivedStatus=e.ReceivedStatus.READ,o=!0),o&&n.put(t)}}})}async clearBurnAfterReadingExpiredMessages(e){const t=Qn(e);if(!this.db)return[];const r=Date.now();return new Promise((e,n)=>{const o=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME).index("dialogId"),s=[],i=o.openCursor(IDBKeyRange.only(t));i.onsuccess=t=>{const n=t.target.result;if(n){const e=n.value;if(e.burnAfterReadingFlag){const t=e.burnAfterReadingTime||0;let o=0===t;if(!o&&t>0){const n=Pr.fromString(e.sentTime),s=Pr.fromNumber(r),i=Pr.fromNumber(t),a=n.add(i);o=s.greaterThan(a)}o&&(s.push(e.messageUId),n.delete())}n.continue()}else e(s)},i.onerror=e=>{As.error("Failed to clear expired messages",e),n(new Error("Failed to clear expired messages"))}})}async getLatestMessage(e){const t=Qn(e);return this.db?new Promise((e,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).index("dialogId_sentTime"),o=IDBKeyRange.bound([t,""],[t,"￿"]),s=n.openCursor(o,"prev");s.onsuccess=t=>{const r=t.target.result;if(r){const t=this.decryptMessage(r.value);e(t)}else e(null)},s.onerror=t=>{As.error("Failed to get latest message",t),e(null)}}):null}async upsertMessage(e){this.addMessages([e],e)}async getMessageById(e){return this.db?new Promise((t,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).get(e);n.onsuccess=()=>{const e=n.result;if(e){const r=this.decryptMessage(e);t(r)}else t(null)},n.onerror=e=>{As.error("Failed to query message",e),t(null)}}):null}async getMessageIdRange(){return this.db?new Promise((e,t)=>{const r=this.db.transaction(this.STORE_NAME,"readonly"),n=r.objectStore(this.STORE_NAME);let o=null,s=null;n.openCursor().onsuccess=t=>{const r=t.target.result;if(r){s=r.value.messageId;n.openCursor(null,"prev").onsuccess=t=>{const r=t.target.result;r?(o=r.value.messageId,e(o&&s?{newest:o,oldest:s}:null)):e(null)}}else e(null)},r.onerror=t=>{e(null)}}):null}async convertToRecallMessages(e){if(e&&0!==e.length&&this.db)return new Promise(t=>{const r=this.db.transaction(this.STORE_NAME,"readwrite"),n=r.objectStore(this.STORE_NAME),o=n.index("messageUId");let s=e.length;for(const t of e){if(!t){i();continue}const e=o.get(t);e.onsuccess=()=>{const r=e.result;if(r){const e={messageUId:t},o={...r,messageType:bo.RECALL,content:this.encryptContent(e),isPersited:!0,isCounted:!1,isMentioned:!1,disableNotification:!0},s=n.put(o);s.onerror=()=>{i()},s.onsuccess=()=>{i()}}else i()},e.onerror=()=>{i()}}function i(){s--,0===s&&t()}r.oncomplete=()=>{t()},r.onerror=()=>{t()}})}async getMessageByUId(e){return this.db?new Promise((t,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).index("messageUId").get(e);n.onsuccess=()=>{const e=n.result;if(e){const r=this.decryptMessage(e);t(r)}else t(null)},n.onerror=e=>{As.error("Failed to query message",e),t(null)}}):null}}let Xo=null;var Yo={create(e,t){Xo=new Zo(e,t)},get:()=>Xo};class Qo{watcher;pullingMsg=!1;letterbox;serverMsgSeqno=Pr.ZERO;pullOfflineFinished=!1;intervalTimer;retryTimer;latestSyncTimestamp=0;started=!1;constructor(e,t){this.watcher=e,this.letterbox=new ho(t.appkey,nn.uid.toString())}start(){this.started=!0,this.pullOfflineFinished=!1,this.startPullInterval()}stop(){this.started=!1,this.stopPullInterval(),this.cancelRetryTask()}syncMsg(e){this.serverMsgSeqno=e,this.pullMsg()}startPullInterval(){this.stopPullInterval();this.intervalTimer=setInterval(()=>{Date.now()-this.latestSyncTimestamp>=18e4&&this.pullMsg()},3e4),this.latestSyncTimestamp=Date.now(),this.pullMsg()}stopPullInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}try2RePullMsg(){this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.pullMsg()},1e3)}cancelRetryTask(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}async pullMsg(){if(this.pullingMsg)return;if(!this.started)return;this.cancelRetryTask(),this.pullingMsg=!0;const t=this.letterbox.getInboxOffset();As.info(`pullMsg -> time: ${t}`),this.latestSyncTimestamp=Date.now();const{code:r,data:n}=await((e,t)=>ln.send(Tt.GetNewMessage,{offset:e,rows:t},{encoder:mn,decoder:vn}))(t,60);if(r!==e.ErrorCode.SUCCESS)return As.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void(ws.loader?.getConnectionStatus()==e.ConnectionStatus.CONNECTED&&this.try2RePullMsg());const{offset:o,seqno:s,msg:i,reference:a}=n,c=Object.keys(i).map(e=>({conversationType:Yn(Pr.fromString(e)),targetId:e}));await Mo.get().loadConvsationsIfNotExist(c),Fo.parse(i,a,async(e,t)=>{try{for(const[e,r]of t.entries()){if(0===r.length)return;await this.processMessages(r,!this.pullOfflineFinished)}}catch(e){As.error("processMessages error -> ",e)}if(e)try{let e;s&&(Pr.isLong(s)?e=s:"string"==typeof s?e=Pr.fromString(s):"number"==typeof s&&(e=Pr.fromNumber(s))),e&&Pr.isLong(e)&&e.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=e);const t=this.serverMsgSeqno.lessThanOrEqual(o);As.info(`pullMsg success -> syncTime: ${o}, finished: ${t}`),this.letterbox?.setInboxOffset(o),this.pullingMsg=!1,t&&!this.pullOfflineFinished&&(this.pullOfflineFinished=!0,this.watcher.pullFinished&&this.watcher.pullFinished()),t||this.pullMsg()}catch(e){As.error("setPullMsgDone error",e),this.pullingMsg=!1}})}async processMessages(e,t){const r={conversationType:e[0].conversationType,targetId:e[0].targetId};let n=[];const o=[];let s=[];e.forEach(e=>{e.messageType===bo.RECALL&&ao.has(e.content.messageUId)?e.content.messageUId?(ao.remove(e.content.messageUId),s.push(e.content.messageUId)):As.error("recallMessage's messageUId is undefined",Po(e)):e.messageUId?(e.isOffLineMessage=t,(!e.messageId||e.messageId>Jo())&&(e.messageId=$o()),Mo.get().setConversationCacheByMessage(e),n.push(e),e.messageType===bo.RECALL&&o.push(n.length-1),[Co.PRIVATE_OPEN_BURNAFTERREADING,Co.GROUP_OPEN_BURNAFTERREADING,Co.PRIVATE_CLOSE_BURNAFTERREADING,Co.GROUP_CLOSE_BURNAFTERREADING].includes(e.messageType)&&this.handleBurnAfterReadingMessage(e)):As.error("message's messageUId is undefined",Po(e))});let i=[];for(let e=o.length-1;e>=0;e--){const t=o[e],r=n[t],a=r.content,c=n.findIndex(e=>e.messageUId===a.messageUId);if(-1!==c){const e=n[c];r.messageId=e.messageId,r.sentTime=e.sentTime,n[c]=r,n[t]=e,i.push(t)}else s.push(a.messageUId),i.push(t)}if(i.length){let e=[];n.forEach((t,r)=>{i.includes(r)||e.push(t)}),n=e}let a=this.handleReceiptMessages(n);a.length&&(await(Yo.get()?.addMessages(a,{conversationType:a[0].conversationType,targetId:a[0].targetId})),this.handleBatchMessages(a),Vo.get()?.sendArrivalReceipts(a)),s.length&&(await(Yo.get()?.convertToRecallMessages(s)),this.watcher.onRecall?.(s));if(n.some(e=>e.isPersited)){const e=await(Yo.get()?.getLatestMessage(r));Mo.get().updateLatestMessage(r,e)}}handleBurnAfterReadingMessage(e){const t=e.content,r=e.conversationType,n=e.targetId,{templateId:o,burnAfterReadingTime:s}=t,i=60010010===o||60010011===o;Mo.get().addStatus({conversationType:r,targetId:n,burnAfterReadingFlag:i,burnAfterReadingTime:i?s:null},!0)}handleReceiptMessages(t){try{const r=[],n=[];t.forEach(e=>{e.messageType===Co.GROUP_ARRIVAL_RECEIPT||e.messageType===Co.GROUP_READ_RECEIPT||e.messageType===Co.PRIVATE_ARRIVAL_RECEIPT||e.messageType===Co.PRIVATE_READ_RECEIPT?n.push(e):r.push(e)});const o=r.filter(t=>t.messageDirection===e.MessageDirection.SEND);return n.forEach(t=>{const r=t.content,n=t.messageType===Co.GROUP_ARRIVAL_RECEIPT||t.messageType===Co.PRIVATE_ARRIVAL_RECEIPT;o.forEach(t=>{r.msgIdList.includes(t.messageUId)&&(t.receivedStatus=n?e.ReceivedStatus.RECEIVED:e.ReceivedStatus.READ)}),this.watcher.onReceiptReceived?.({conversation:{conversationType:t.conversationType,targetId:t.targetId},messageUIdList:r.msgIdList.map(e=>e.toString())},t.messageType===Co.GROUP_ARRIVAL_RECEIPT||t.messageType===Co.PRIVATE_ARRIVAL_RECEIPT?0:1)}),r}catch(e){return As.error("handleReceiptMessages error",e),[]}}async handleBatchMessages(t){const r=t.filter(t=>t.messageDirection!==e.MessageDirection.SEND||!t.messageId||!so.has(t.messageId)||(so.remove(t.messageId),!1));r.length&&this.watcher.batchMessage?.(r)}}class es{messageType;content;isPersited;isCounted;isStatusMessage;constructor(e,t,r=!0,n=!0,o=!1){this.messageType=e,this.content=t,o?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=r,this.isCounted=n),this.isStatusMessage=o}}const ts=(e,t,r,n)=>function(o){return new es(e,o,t,r,n)},rs=ts(bo.TEXT,!0,!0,!1),ns=ts(bo.IMAGE,!0,!0,!1),os=ts(bo.GIF,!0,!0,!1),ss=ts(bo.AUDIO,!0,!0,!1),is=ts(bo.FILE,!0,!0,!1),as=ts(bo.VIDEO,!0,!0,!1);let cs=ts(bo.LOCATION,!0,!0,!1),ls=ts(bo.CHAT_RECORD,!0,!0,!1),us=ts(bo.CONTACT,!0,!0,!1),ds=ts(bo.GROUP_INVITATION,!0,!0,!1),gs=ts(bo.REDPACKET,!0,!0,!1),ps=ts(bo.TRANSFER,!0,!0,!1),fs=ts(bo.LINK,!0,!0,!1);const hs=ts(Co.GROUP_ARRIVAL_RECEIPT,!1,!1,!1),ys=ts(Co.GROUP_READ_RECEIPT,!1,!1,!1),ms=ts(Co.PRIVATE_ARRIVAL_RECEIPT,!1,!1,!1),vs=ts(Co.PRIVATE_READ_RECEIPT,!1,!1,!1),bs=ts(Co.PRIVATE_OPEN_BURNAFTERREADING,!1,!1,!1),Cs=ts(Co.PRIVATE_CLOSE_BURNAFTERREADING,!1,!1,!1),Os=ts(Co.GROUP_OPEN_BURNAFTERREADING,!1,!1,!1),Ss=ts(Co.GROUP_CLOSE_BURNAFTERREADING,!1,!1,!1),Is=ts(bo.RECALL,!0,!1,!1);class ws{options;connectionStatus=e.ConnectionStatus.DISCONNECTED;isInternalConnected=!1;watcher;messageLoader;static _loader;static init(e){return this._loader||(this._loader=new ws(e)),this._loader}static get loader(){return this._loader}constructor(e){this.options=e,this.watcher={onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,pullFinished:void 0,batchMessage:void 0,conversationState:void 0,onPush:void 0,onRecall:void 0,onReceiptReceived:void 0},ln.setServerInfo(this.getWebSocketUrl()),ln.setCallback({status:this.connectionStatusListener.bind(this),message:this.messageListener.bind(this)}),this.registerMessage()}getWebSocketUrl(){const e=this.options?.serverInfo;return ut(e)?lt(t=e)&&/wss?:\/\//.test(t)?e:"ws://"+e:"wss://test.gametalk.ai";var t}registerMessage(){lo(bo.TEXT,rs),lo(bo.IMAGE,ns),lo(bo.GIF,os),lo(bo.AUDIO,ss),lo(bo.FILE,is),lo(bo.VIDEO,as),lo(bo.RECALL,Is),lo(bo.LOCATION,cs),lo(bo.CHAT_RECORD,ls),lo(bo.CONTACT,us),lo(bo.GROUP_INVITATION,ds),lo(bo.REDPACKET,gs),lo(bo.TRANSFER,ps),lo(bo.LINK,fs),lo(Co.GROUP_ARRIVAL_RECEIPT,hs),lo(Co.GROUP_READ_RECEIPT,ys),lo(Co.PRIVATE_ARRIVAL_RECEIPT,ms),lo(Co.PRIVATE_READ_RECEIPT,vs),lo(Co.PRIVATE_OPEN_BURNAFTERREADING,bs),lo(Co.PRIVATE_CLOSE_BURNAFTERREADING,Cs),lo(Co.GROUP_OPEN_BURNAFTERREADING,Os),lo(Co.GROUP_CLOSE_BURNAFTERREADING,Ss)}async connect(){if(this.connectionStatus===e.ConnectionStatus.CONNECTED)return{code:e.ErrorCode.SUCCESS};if(this.connectionStatus===e.ConnectionStatus.CONNECTING)return{code:e.ErrorCode.BIZ_ERROR_CONNECTING};ln.close();const t=await ln.connect();return this.isInternalConnected=!0,{code:t}}reconnect(){return this.isInternalConnected?Promise.resolve({code:e.ErrorCode.CAN_NOT_RECONNECT}):this.connect()}disconnect(){return this.isInternalConnected=!1,ln.close(),Promise.resolve()}async setUserLogged(){Rs.setUserId(nn.uid.toString()),Mo.get().destroyed(),Mo.create(this.options.appkey,nn.uid.toString(),this.watcher.conversationState),Vo.create(this.options.appkey,nn.uid.toString()),this.messageLoader?.stop(),this.messageLoader=new Qo(this.watcher,this.options),so.reset(),ao.reset(),go.reset(),Yo.create(this.options.appkey,nn.uid.toString()),Yo.get().initDB().then(()=>Yo.get().getMessageIdRange()).then(e=>{if(e){const{oldest:t,newest:r}=e;zo(t,r)}else zo(1e4,1e4)}),this.getConnectionStatus()===e.ConnectionStatus.CONNECTED&&this.handleUserConnected()}setUserLogout(){this.messageLoader?.stop()}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){pt(this.watcher).forEach(t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.watcher[t]=it(r)?r:void 0}})}resetWatcher(){pt(this.watcher).forEach(e=>{this.watcher[e]=void 0})}async connectionStatusListener(t){switch(this.connectionStatus=t,t){case e.ConnectionStatus.BLOCKED:case e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.ConnectionStatus.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.ConnectionStatus.CONNECTING:this.handleConnecting();break;case e.ConnectionStatus.CONNECTED:this.handleConnected();break;case e.ConnectionStatus.DISCONNECTED:this.handleDisconnect()}}handleConnecting(){this.watcher.onConnecting?.()}handleConnected(){nn.isActive&&(this.handleUserConnected(),ro()),this.watcher.onConnected?.(),As.cleanupOldLogs()}handleDisconnect(){this.watcher.onDisconnect?.(),this.messageLoader?.stop()}handleSuspend(){this.watcher.onSuspend?.()}handleUserConnected(){As.info("user connected -> ",nn.uid.toString()),this.messageLoader||(this.messageLoader=new Qo(this.watcher,this.options)),this.messageLoader?.start(),setTimeout(()=>{this.connectionStatus===e.ConnectionStatus.CONNECTED&&Mo.get().syncConversationStatus()},2e3)}messageListener(e,t){if(e===Tt.NewMessagePush){const e=Ln.decode(t);this.messageLoader?.syncMsg(e.seqno)}else e===Tt.DialogChangedPush?Mo.get().syncConversationStatus():this.watcher.onPush?.(e,t)}}class Es{static instance;messageQueue;config;flushTimer=null;userId=null;isFlushing=!1;constructor(e){this.config=e,this.messageQueue=new wt,this.startFlushTimer()}static getInstance(e){return Es.instance||(Es.instance=new Es(e)),Es.instance}trackEvent(e,t){const r={type:e,...this.collectAutomaticProperties(),content:t};this.messageQueue.enqueue(r),this.config.debugMode&&this.flush()}collectAutomaticProperties(){return{user_id:this.userId,os:"web",appVersion:Rt.appVersion,eventTime:Date.now()}}async flush(){if(!this.shouldFlush()||this.isFlushing)return;this.isFlushing=!0;let e=[];try{if(e=await this.messageQueue.dequeue(this.config.flushBulkSize),0===e.length)return;const t=await async function(e){const t=JSON.stringify(e),r=(new TextEncoder).encode(t);if("CompressionStream"in window){const e=new Response(r).body?.pipeThrough(new CompressionStream("gzip"));if(e){const t=await new Response(e).arrayBuffer();return btoa(String.fromCharCode(...new Uint8Array(t)))}}return btoa(t)}(e);await this.sendData(t)}catch(t){console.error("Failed to flush analytics data:",t),await this.messageQueue.requeueToEnd(e)}finally{this.isFlushing=!1}}shouldFlush(){return ws.loader?.getConnectionStatus()==e.ConnectionStatus.CONNECTED}async sendData(t){try{const r=await(e=>ln.send(Tt.PostAnalyticsLogs,{data:e},{encoder:_r,decoder:Tr}))(t);if(r.code!==e.ErrorCode.SUCCESS)throw new Error(`Socket error! status: ${r.code}`)}catch(e){throw e}}startFlushTimer(){this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval))}setUserId(e){this.userId=e}destroy(){this.flushTimer&&clearInterval(this.flushTimer),this.messageQueue.clear()}}var Rs=Es.getInstance({flushInterval:6e4,flushBulkSize:100,debugMode:!1});const Ts=Ct.get("ACIM-slf")===(new Date).getDate();const _s={[e.LogLevel.DEBUG]:console.debug.bind(console),[e.LogLevel.INFO]:console.info.bind(console),[e.LogLevel.WARN]:console.warn.bind(console),[e.LogLevel.ERROR]:console.error.bind(console),[e.LogLevel.FATAL]:console.log.bind(console),[e.LogLevel.NONE]:null},ks=e=>lt(e)||nt(e)||st(e)||ot(e)?e:e instanceof Error?JSON.stringify({name:e.name,message:e.message,stack:e.stack}):JSON.stringify(e);var As=new class{debug;info;warn;error;fatal;outLevel=e.LogLevel.WARN;tag;logStdout;constructor(t){this.tag=t,this.debug=this.log.bind(this,e.LogLevel.DEBUG),this.info=this.log.bind(this,e.LogLevel.INFO),this.warn=this.log.bind(this,e.LogLevel.WARN),this.error=this.log.bind(this,e.LogLevel.ERROR),this.fatal=this.log.bind(this,e.LogLevel.FATAL)}async addLog(t,r){const n={timestamp:(new Date).toISOString(),level:t,content:r};try{t===e.LogLevel.ERROR&&Rs.trackEvent("error_log",{timestamp:n.timestamp,content:n.content})}catch(e){console.error("Failed to add log:",e)}}defaultStdout(e,t,...r){const n=_s[e];rt(n)&&n(`${t}:`,...r)}reqInfo(...e){this.info(...e)}setLogLevel(e){this.outLevel=e}setLogStdout(e){this.logStdout=e}log(t,...r){if(Ts){const n=`${(new Date).toISOString()}[${this.tag}][${e.LogLevel[t]}]`;return this.defaultStdout(t,n,...r),void this.addLog(t,r.map(ks).join(" "))}if(t<this.outLevel)return;const n=`${(new Date).toISOString()}[${this.tag}][${e.LogLevel[t]}]`,o=`${n} - ${r.map(ks).join(" ")}`;if(this.logStdout)return this.logStdout(t,o),void this.addLog(t,r.map(ks).join(" "));this.defaultStdout(t,n,...r),this.addLog(t,r.map(ks).join(" "))}async exportLogs(){return[]}async clearLogs(){}async cleanupOldLogs(){}}("ACLog");const Ms=ut,Ns=nt,Ps=ot,Ls=at,Ds=ct,js=t=>nt(t)&&Object.prototype.hasOwnProperty.call(e.ConversationType,t),Us=t=>{if(!at(t))return!1;const{conversationType:r,targetId:n,channelId:o}=t;return nt(r)&&Object.prototype.hasOwnProperty.call(e.ConversationType,r)&&(nt(n)||ut(n)||Pr.isLong(n)&&!n.isZero())&&(!rt(o)||lt(o)&&!/_/g.test(o)&&o.length<=20)};class Bs extends Error{constructor(e){super(e),this.name="ACAssertError"}}const Fs=(e,t,r,n=!1)=>{if(!xs(e,t,r,n))throw new Bs(`'${e}' is invalid: ${JSON.stringify(t)}`)},xs=(e,t,r,n=!1)=>{const o=n&&!r(t)||!n&&rt(t)&&!r(t);return o&&As.error(`'${e}' is invalid: ${JSON.stringify(t)}`),!o};var Gs,qs,Vs,Ks,Hs={exports:{}},zs={exports:{}},$s={exports:{}};var Ws,Js={};var Zs,Xs,Ys,Qs,ei,ti,ri,ni,oi,si,ii,ai,ci,li,ui,di,gi,pi,fi,hi={};function yi(){return Zs||(Zs=1,function(e){var t=e,r=ta(),n=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,o={};for(t|=0;r<e.length;)o[n[r+t]]=e[r++];return o}t.basic=o([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=o([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",r.emptyArray,null]),t.long=o([0,0,0,1,1],7),t.mapKey=o([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=o([1,5,0,0,0,5,5,0,0,0,1,1,0])}(hi)),hi}function mi(){if(Ys)return Xs;Ys=1,Xs=i;var e=ra();((i.prototype=Object.create(e.prototype)).constructor=i).className="Field";var t,r=na(),n=yi(),o=ta(),s=/^required|optional|repeated$/;function i(t,r,i,a,c,l,u){if(o.isObject(a)?(u=c,l=a,a=c=void 0):o.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!o.isInteger(r)||r<0)throw TypeError("id must be a non-negative integer");if(!o.isString(i))throw TypeError("type must be a string");if(void 0!==a&&!s.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!o.isString(c))throw TypeError("extend must be a string");"proto3_optional"===a&&(a="optional"),this.rule=a&&"optional"!==a?a:void 0,this.type=i,this.id=r,this.extend=c||void 0,this.required="required"===a,this.optional=!this.required,this.repeated="repeated"===a,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!o.Long&&void 0!==n.long[i],this.bytes="bytes"===i,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}return i.fromJSON=function(e,t){return new i(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(i.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),i.prototype.setOption=function(t,r,n){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,r,n)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},i.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=n.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof t?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=o.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var s;o.base64.test(this.typeDefault)?o.base64.decode(this.typeDefault,s=o.newBuffer(o.base64.length(this.typeDefault)),0):o.utf8.write(this.typeDefault,s=o.newBuffer(o.utf8.length(this.typeDefault)),0),this.typeDefault=s}return this.map?this.defaultValue=o.emptyObject:this.repeated?this.defaultValue=o.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},i.d=function(e,t,r,n){return"function"==typeof t?t=o.decorateType(t).name:t&&"object"==typeof t&&(t=o.decorateEnum(t).name),function(s,a){o.decorateType(s.constructor).add(new i(a,e,t,r,{default:n}))}},i._configure=function(e){t=e},Xs}function vi(){if(ei)return Qs;ei=1,Qs=n;var e=ra();((n.prototype=Object.create(e.prototype)).constructor=n).className="OneOf";var t=mi(),r=ta();function n(t,r,n,o){if(Array.isArray(r)||(n=r,r=void 0),e.call(this,t,n),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=o}function o(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return n.fromJSON=function(e,t){return new n(e,t.oneof,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},n.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,o(this),this},n.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},n.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;r<this.oneof.length;++r){var n=t.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}o(this)},n.prototype.onRemove=function(t){for(var r,n=0;n<this.fieldsArray.length;++n)(r=this.fieldsArray[n]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},n.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,o){r.decorateType(t.constructor).add(new n(o,e)),Object.defineProperty(t,o,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},Qs}function bi(){if(ri)return ti;ri=1,ti=c;var e=ra();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,r,n,o=mi(),s=ta(),i=vi();function a(e,t){if(e&&e.length){for(var r={},n=0;n<e.length;++n)r[e[n].name]=e[n].toJSON(t);return r}}function c(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null}function l(e){return e._nestedArray=null,e}return c.fromJSON=function(e,t){return new c(e,t.options).addJSON(t.nested)},c.arrayToJSON=a,c.isReservedId=function(e,t){if(e)for(var r=0;r<e.length;++r)if("string"!=typeof e[r]&&e[r][0]<=t&&e[r][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=s.toArray(this.nested))}}),c.prototype.toJSON=function(e){return s.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var s,i=Object.keys(e),a=0;a<i.length;++a)s=e[i[a]],this.add((void 0!==s.fields?t.fromJSON:void 0!==s.values?n.fromJSON:void 0!==s.methods?r.fromJSON:void 0!==s.id?o.fromJSON:c.fromJSON)(i[a],s));return this},c.prototype.get=function(e){return this.nested&&this.nested[e]||null},c.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof n)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof o&&void 0!==e.extend||e instanceof t||e instanceof i||e instanceof n||e instanceof r||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var s=this.get(e.name);if(s){if(!(s instanceof c&&e instanceof c)||s instanceof t||s instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=s.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(s),this.nested||(this.nested={}),e.setOptions(s.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),l(this)},c.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),l(this)},c.prototype.define=function(e,t){if(s.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof c))throw Error("path conflicts with non-namespace objects")}else r.add(r=new c(n))}return t&&r.addJSON(t),r},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof c?e[t++].resolveAll():e[t++].resolve();return this.resolve()},c.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),s.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.get(e[0]);if(n){if(1===e.length){if(!t||t.indexOf(n.constructor)>-1)return n}else if(n instanceof c&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof c&&(n=this._nestedArray[o].lookup(e,t,!0)))return n;return null===this.parent||r?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,n]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},c.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,o,s){t=e,r=o,n=s},ti}function Ci(){if(oi)return ni;oi=1,ni=n;var e=mi();((n.prototype=Object.create(e.prototype)).constructor=n).className="MapField";var t=yi(),r=ta();function n(t,n,o,s,i,a){if(e.call(this,t,n,s,void 0,void 0,i,a),!r.isString(o))throw TypeError("keyType must be a string");this.keyType=o,this.resolvedKeyType=null,this.map=!0}return n.fromJSON=function(e,t){return new n(e,t.id,t.keyType,t.type,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},n.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},n.d=function(e,t,o){return"function"==typeof o?o=r.decorateType(o).name:o&&"object"==typeof o&&(o=r.decorateEnum(o).name),function(s,i){r.decorateType(s.constructor).add(new n(i,e,t,o))}},ni}function Oi(){if(ii)return si;ii=1,si=r;var e=ra();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=ta();function r(r,n,o,s,i,a,c,l,u){if(t.isObject(i)?(c=i,i=a=void 0):t.isObject(a)&&(c=a,a=void 0),void 0!==n&&!t.isString(n))throw TypeError("type must be a string");if(!t.isString(o))throw TypeError("requestType must be a string");if(!t.isString(s))throw TypeError("responseType must be a string");e.call(this,r,c),this.type=n||"rpc",this.requestType=o,this.requestStream=!!i||void 0,this.responseType=s,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){var r=!!e&&Boolean(e.keepComments);return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",r?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},si}function Si(){if(ci)return ai;ci=1,ai=o;var e=bi();((o.prototype=Object.create(e.prototype)).constructor=o).className="Service";var t=Oi(),r=ta(),n=hr();function o(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function s(e){return e._methodsArray=null,e}return o.fromJSON=function(e,r){var n=new o(e,r.options);if(r.methods)for(var s=Object.keys(r.methods),i=0;i<s.length;++i)n.add(t.fromJSON(s[i],r.methods[s[i]]));return r.nested&&n.addJSON(r.nested),n.comment=r.comment,n},o.prototype.toJSON=function(t){var n=e.prototype.toJSON.call(this,t),o=!!t&&Boolean(t.keepComments);return r.toObject(["options",n&&n.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",n&&n.nested||void 0,"comment",o?this.comment:void 0])},Object.defineProperty(o.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),o.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},o.prototype.resolveAll=function(){for(var t=this.methodsArray,r=0;r<t.length;++r)t[r].resolve();return e.prototype.resolve.call(this)},o.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,s(this)):e.prototype.add.call(this,r)},o.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,s(this)}return e.prototype.remove.call(this,r)},o.prototype.create=function(e,t,o){for(var s,i=new n.Service(e,t,o),a=0;a<this.methodsArray.length;++a){var c=r.lcFirst((s=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");i[c]=r.codegen(["r","c"],r.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:s,q:s.resolvedRequestType.ctor,s:s.resolvedResponseType.ctor})}return i},ai}function Ii(){if(ui)return li;ui=1,li=t;var e=nr();function t(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)this[t[r]]=e[t[r]]}return t.create=function(e){return this.$type.create(e)},t.encode=function(e,t){return this.$type.encode(e,t)},t.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},t.decode=function(e){return this.$type.decode(e)},t.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},t.verify=function(e){return this.$type.verify(e)},t.fromObject=function(e){return this.$type.fromObject(e)},t.toObject=function(e,t){return this.$type.toObject(e,t)},t.prototype.toJSON=function(){return this.$type.toObject(this,e.toJSONOptions)},li}function wi(){if(gi)return di;gi=1,di=function(o){var s=r.codegen(["r","l"],o.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(o.fieldsArray.filter(function(e){return e.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");o.group&&s("if((t&7)===4)")("break");s("switch(t>>>3){");for(var i=0;i<o.fieldsArray.length;++i){var a=o._fieldsArray[i].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+r.safeProp(a.name);s("case %i: {",a.id),a.map?(s("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?s("k=%j",t.defaults[a.keyType]):s("k=null"),void 0!==t.defaults[c]?s("value=%j",t.defaults[c]):s("value=null"),s("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===t.basic[c]?s("value=types[%i].decode(r,r.uint32())",i):s("value=r.%s()",c),s("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?s('%s[typeof k==="object"?util.longToHash(k):k]=value',l):s("%s[k]=value",l)):a.repeated?(s("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&s("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",l,c)("}else"),void 0===t.basic[c]?s(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,i):s("%s.push(r.%s())",l,c)):void 0===t.basic[c]?s(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,i):s("%s=r.%s()",l,c),s("break")("}")}for(s("default:")("r.skipType(t&7)")("break")("}")("}"),i=0;i<o._fieldsArray.length;++i){var u=o._fieldsArray[i];u.required&&s("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",n(u))}return s("return m")};var e=na(),t=yi(),r=ta();function n(e){return"missing required '"+e.name+"'"}return di}function Ei(){if(fi)return pi;fi=1,pi=function(e){var s=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),i=e.oneofsArray,a={};i.length&&s("var p={}");for(var c=0;c<e.fieldsArray.length;++c){var l=e._fieldsArray[c].resolve(),u="m"+t.safeProp(l.name);if(l.optional&&s("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)s("if(!util.isObject(%s))",u)("return%j",r(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),o(s,l,"k[i]"),n(s,l,c,u+"[k[i]]")("}");else if(l.repeated)s("if(!Array.isArray(%s))",u)("return%j",r(l,"array"))("for(var i=0;i<%s.length;++i){",u),n(s,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&s("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,s("p%s=1",d)}n(s,l,c,u)}l.optional&&s("}")}return s("return null")};var e=na(),t=ta();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function n(t,n,o,s){if(n.resolvedType)if(n.resolvedType instanceof e){t("switch(%s){",s)("default:")("return%j",r(n,"enum value"));for(var i=Object.keys(n.resolvedType.values),a=0;a<i.length;++a)t("case %i:",n.resolvedType.values[i[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",o,s)("if(e)")("return%j+e",n.name+".")("}");else switch(n.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",s)("return%j",r(n,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",s,s,s,s)("return%j",r(n,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',s)("return%j",r(n,"number"));break;case"bool":t('if(typeof %s!=="boolean")',s)("return%j",r(n,"boolean"));break;case"string":t("if(!util.isString(%s))",s)("return%j",r(n,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',s,s,s)("return%j",r(n,"buffer"))}return t}function o(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",r(t,"boolean key"))}return e}return pi}var Ri,Ti={};function _i(){return Ri||(Ri=1,function(e){var t=e,r=na(),n=ta();function o(e,t,n,o){var s=!1;if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(d%s){",o);for(var i=t.resolvedType.values,a=Object.keys(i),c=0;c<a.length;++c)i[a[c]]!==t.typeDefault||s||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',o,o,o),t.repeated||e("break"),s=!0),e("case%j:",a[c])("case %i:",i[a[c]])("m%s=%j",o,i[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',o)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",o,n,o);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",o,o);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",o,o);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",o,o);break;case"uint64":l=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",o,o,l)('else if(typeof d%s==="string")',o)("m%s=parseInt(d%s,10)",o,o)('else if(typeof d%s==="number")',o)("m%s=d%s",o,o)('else if(typeof d%s==="object")',o)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",o,o,o,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',o)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",o,o,o)("else if(d%s.length >= 0)",o)("m%s=d%s",o,o);break;case"string":e("m%s=String(d%s)",o,o);break;case"bool":e("m%s=Boolean(d%s)",o,o)}}return e}function s(e,t,n,o){if(t.resolvedType)t.resolvedType instanceof r?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",o,n,o,o,n,o,o):e("d%s=types[%i].toObject(m%s,o)",o,n,o);else{var s=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",o,o,o,o);break;case"uint64":s=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',o)("d%s=o.longs===String?String(m%s):m%s",o,o,o)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",o,o,o,o,s?"true":"",o);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",o,o,o,o,o);break;default:e("d%s=m%s",o,o)}}return e}t.fromObject=function(e){var t=e.fieldsArray,s=n.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return s("return new this.ctor");s("var m=new this.ctor");for(var i=0;i<t.length;++i){var a=t[i].resolve(),c=n.safeProp(a.name);a.map?(s("if(d%s){",c)('if(typeof d%s!=="object")',c)("throw TypeError(%j)",a.fullName+": object expected")("m%s={}",c)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",c),o(s,a,i,c+"[ks[i]]")("}")("}")):a.repeated?(s("if(d%s){",c)("if(!Array.isArray(d%s))",c)("throw TypeError(%j)",a.fullName+": array expected")("m%s=[]",c)("for(var i=0;i<d%s.length;++i){",c),o(s,a,i,c+"[i]")("}")("}")):(a.resolvedType instanceof r||s("if(d%s!=null){",c),o(s,a,i,c),a.resolvedType instanceof r||s("}"))}return s("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(n.compareFieldsById);if(!t.length)return n.codegen()("return {}");for(var o=n.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),i=[],a=[],c=[],l=0;l<t.length;++l)t[l].partOf||(t[l].resolve().repeated?i:t[l].map?a:c).push(t[l]);if(i.length){for(o("if(o.arrays||o.defaults){"),l=0;l<i.length;++l)o("d%s=[]",n.safeProp(i[l].name));o("}")}if(a.length){for(o("if(o.objects||o.defaults){"),l=0;l<a.length;++l)o("d%s={}",n.safeProp(a[l].name));o("}")}if(c.length){for(o("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=n.safeProp(u.name);if(u.resolvedType instanceof r)o("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)o("if(util.Long){")("var n=new util.Long(%i,%i,%j)",u.typeDefault.low,u.typeDefault.high,u.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",d)("}else")("d%s=o.longs===String?%j:%i",d,u.typeDefault.toString(),u.typeDefault.toNumber());else if(u.bytes){var g="["+Array.prototype.slice.call(u.typeDefault).join(",")+"]";o("if(o.bytes===String)d%s=%j",d,String.fromCharCode.apply(String,u.typeDefault))("else{")("d%s=%s",d,g)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",d,d)("}")}else o("d%s=%j",d,u.typeDefault)}o("}")}var p=!1;for(l=0;l<t.length;++l){u=t[l];var f=e._fieldsArray.indexOf(u);d=n.safeProp(u.name);u.map?(p||(p=!0,o("var ks2")),o("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),s(o,u,f,d+"[ks2[j]]")("}")):u.repeated?(o("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),s(o,u,f,d+"[j]")("}")):(o("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),s(o,u,f,d),u.partOf&&o("if(o.oneofs)")("d%s=%j",n.safeProp(u.partOf.name),u.name)),o("}")}return o("return d")}}(Ti)),Ti}var ki,Ai,Mi,Ni,Pi,Li,Di,ji,Ui,Bi,Fi,xi,Gi,qi,Vi,Ki,Hi,zi,$i,Wi,Ji,Zi,Xi={};function Yi(){return ki||(ki=1,function(e){var t=e,r=Ii();t[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var n="",o="";if(t&&t.json&&e.type_url&&e.value){o=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var s=this.lookup(o);s&&(e=s.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof r){var i=e.$type.toObject(e,t);return""===n&&(n="type.googleapis.com/"),o=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),i["@type"]=o,i}return this.toObject(e,t)}}}(Xi)),Xi}function Qi(){if(Mi)return Ai;Mi=1,Ai=h;var e=bi();((h.prototype=Object.create(e.prototype)).constructor=h).className="Type";var t=na(),r=vi(),n=mi(),o=Ci(),s=Si(),i=Ii(),a=sr(),c=or(),l=ta(),u=oa(),d=wi(),g=Ei(),p=_i(),f=Yi();function h(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function y(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(h.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var r=this.fields[e[t]],n=r.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=l.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=l.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=h.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof i||((e.prototype=new i).constructor=e,l.merge(e.prototype,t)),e.$type=e.prototype.$type=this,l.merge(e,i,!0),this._ctor=e;for(var r=0;r<this.fieldsArray.length;++r)this._fieldsArray[r].resolve();var n={};for(r=0;r<this.oneofsArray.length;++r)n[this._oneofsArray[r].resolve().name]={get:l.oneOfGetter(this._oneofsArray[r].oneof),set:l.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,n)}}}),h.generateConstructor=function(e){for(var t,r=l.codegen(["p"],e.name),n=0;n<e.fieldsArray.length;++n)(t=e._fieldsArray[n]).map?r("this%s={}",l.safeProp(t.name)):t.repeated&&r("this%s=[]",l.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},h.fromJSON=function(i,a){var c=new h(i,a.options);c.extensions=a.extensions,c.reserved=a.reserved;for(var l=Object.keys(a.fields),u=0;u<l.length;++u)c.add((void 0!==a.fields[l[u]].keyType?o.fromJSON:n.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(r.fromJSON(l[u],a.oneofs[l[u]]));if(a.nested)for(l=Object.keys(a.nested),u=0;u<l.length;++u){var d=a.nested[l[u]];c.add((void 0!==d.id?n.fromJSON:void 0!==d.fields?h.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?s.fromJSON:e.fromJSON)(l[u],d))}return a.extensions&&a.extensions.length&&(c.extensions=a.extensions),a.reserved&&a.reserved.length&&(c.reserved=a.reserved),a.group&&(c.group=!0),a.comment&&(c.comment=a.comment),c},h.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),n=!!t&&Boolean(t.keepComments);return l.toObject(["options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter(function(e){return!e.declaringField}),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",n?this.comment:void 0])},h.prototype.resolveAll=function(){for(var t=this.fieldsArray,r=0;r<t.length;)t[r++].resolve();var n=this.oneofsArray;for(r=0;r<n.length;)n[r++].resolve();return e.prototype.resolveAll.call(this)},h.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},h.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof n&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),y(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),y(this)):e.prototype.add.call(this,t)},h.prototype.remove=function(t){if(t instanceof n&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),y(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),y(this)}return e.prototype.remove.call(this,t)},h.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},h.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},h.prototype.create=function(e){return new this.ctor(e)},h.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;r<this.fieldsArray.length;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=u(this)({Writer:c,types:t,util:l}),this.decode=d(this)({Reader:a,types:t,util:l}),this.verify=g(this)({types:t,util:l}),this.fromObject=p.fromObject(this)({types:t,util:l}),this.toObject=p.toObject(this)({types:t,util:l});var n=f[e];if(n){var o=Object.create(this);o.fromObject=this.fromObject,this.fromObject=n.fromObject.bind(o),o.toObject=this.toObject,this.toObject=n.toObject.bind(o)}return this},h.prototype.encode=function(e,t){return this.setup().encode(e,t)},h.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},h.prototype.decode=function(e,t){return this.setup().decode(e,t)},h.prototype.decodeDelimited=function(e){return e instanceof a||(e=a.create(e)),this.decode(e,e.uint32())},h.prototype.verify=function(e){return this.setup().verify(e)},h.prototype.fromObject=function(e){return this.setup().fromObject(e)},h.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},h.d=function(e){return function(t){l.decorateType(t,e)}},Ai}function ea(){if(Pi)return Ni;Pi=1,Ni=c;var e=bi();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,r,n,o=mi(),s=na(),i=vi(),a=ta();function c(t){e.call(this,"",t),this.deferred=[],this.files=[]}function l(){}c.fromJSON=function(e,t){return t||(t=new c),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},c.prototype.resolvePath=a.path.resolve,c.prototype.fetch=a.fetch,c.prototype.load=function e(t,o,s){"function"==typeof o&&(s=o,o=void 0);var i=this;if(!s)return a.asPromise(e,i,t,o);var c=s===l;function u(e,t){if(s){if(c)throw e;var r=s;s=null,r(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in n)return r}return null}function g(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){r.filename=e;var n,s=r(t,i,o),l=0;if(s.imports)for(;l<s.imports.length;++l)(n=d(s.imports[l])||i.resolvePath(e,s.imports[l]))&&p(n);if(s.weakImports)for(l=0;l<s.weakImports.length;++l)(n=d(s.weakImports[l])||i.resolvePath(e,s.weakImports[l]))&&p(n,!0)}else i.setOptions(t.options).addJSON(t.nested)}catch(e){u(e)}c||f||u(null,i)}function p(e,t){if(e=d(e)||e,!(i.files.indexOf(e)>-1))if(i.files.push(e),e in n)c?g(e,n[e]):(++f,setTimeout(function(){--f,g(e,n[e])}));else if(c){var r;try{r=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}g(e,r)}else++f,i.fetch(e,function(r,n){--f,s&&(r?t?f||u(null,i):u(r):g(e,n))})}var f=0;a.isString(t)&&(t=[t]);for(var h,y=0;y<t.length;++y)(h=i.resolvePath("",t[y]))&&p(h);if(c)return i;f||u(null,i)},c.prototype.loadSync=function(e,t){if(!a.isNode)throw Error("not supported");return this.load(e,t,l)},c.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(e){return"'extend "+e.extend+"' in "+e.parent.fullName}).join(", "));return e.prototype.resolveAll.call(this)};var u=/^[A-Z]/;function d(e,t){var r=t.parent.lookup(t.extend);if(r){var n=new o(t.fullName,t.id,t.type,t.rule,void 0,t.options);return r.get(n.name)||(n.declaringField=t,t.extensionField=n,r.add(n)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof o)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof s)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof i)){if(e instanceof t)for(var r=0;r<this.deferred.length;)d(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof o){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof s)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var n=0;n<t.nestedArray.length;++n)this._handleRemove(t._nestedArray[n]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,o,s){t=e,r=o,n=s},Ni}function ta(){if(Li)return $s.exports;Li=1;var e,t,r=$s.exports=nr(),n=yr();r.codegen=function(){if(qs)return Gs;function e(t,r){"string"==typeof t&&(r=t,t=void 0);var n=[];function o(t){if("string"!=typeof t){var r=s();if(e.verbose&&console.log("codegen: "+r),r="return "+r,t){for(var i=Object.keys(t),a=new Array(i.length+1),c=new Array(i.length),l=0;l<i.length;)a[l]=i[l],c[l]=t[i[l++]];return a[l]=r,Function.apply(null,a).apply(null,c)}return Function(r)()}for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d]=arguments[++d];if(d=0,t=t.replace(/%([%dfijs])/g,function(e,t){var r=u[d++];switch(t){case"d":case"f":return String(Number(r));case"i":return String(Math.floor(r));case"j":return JSON.stringify(r);case"s":return String(r)}return"%"}),d!==u.length)throw Error("parameter count mismatch");return n.push(t),o}function s(e){return"function "+(e||r||"")+"("+(t&&t.join(",")||"")+"){\n "+n.join("\n ")+"\n}"}return o.toString=s,o}return qs=1,Gs=e,e.verbose=!1,Gs}(),r.fetch=function(){if(Ks)return Vs;Ks=1,Vs=r;var e=Nt(),t=Gt()("fs");function r(n,o,s){return"function"==typeof o?(s=o,o={}):o||(o={}),s?!o.xhr&&t&&t.readFile?t.readFile(n,function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?r.xhr(n,o,s):e?s(e):s(null,o.binary?t:t.toString("utf8"))}):r.xhr(n,o,s):e(r,this,n,o)}return r.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var o=0;o<n.responseText.length;++o)e.push(255&n.responseText.charCodeAt(o))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,n.responseText)}},t.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()},Vs}(),r.path=(Ws||(Ws=1,function(e){var t=e,r=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),o="";n&&(o=t.shift()+"/");for(var s=0;s<t.length;)".."===t[s]?s>0&&".."!==t[s-1]?t.splice(--s,2):n?t.splice(s,1):++s:"."===t[s]?t.splice(s,1):++s;return o+t.join("/")};t.resolve=function(e,t,o){return o||(t=n(t)),r(t)?t:(o||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}}(Js)),Js),r.fs=r.inquire("fs"),r.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n<t.length;)r[n]=e[t[n++]];return r}return[]},r.toObject=function(e){for(var t={},r=0;r<e.length;){var n=e[r++],o=e[r++];void 0!==o&&(t[n]=o)}return t};var o=/\\/g,s=/"/g;r.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},r.safeProp=function(e){return!/^[$\w_]+$/.test(e)||r.isReserved(e)?'["'+e.replace(o,"\\\\").replace(s,'\\"')+'"]':"."+e},r.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var i=/_([a-z])/g;r.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(i,function(e,t){return t.toUpperCase()})},r.compareFieldsById=function(e,t){return e.id-t.id},r.decorateType=function(t,n){if(t.$type)return n&&t.$type.name!==n&&(r.decorateRoot.remove(t.$type),t.$type.name=n,r.decorateRoot.add(t.$type)),t.$type;e||(e=Qi());var o=new e(n||t.name);return r.decorateRoot.add(o),o.ctor=t,Object.defineProperty(t,"$type",{value:o,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:o,enumerable:!1}),o};var a=0;return r.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=na());var n=new t("Enum"+a++,e);return r.decorateRoot.add(n),Object.defineProperty(e,"$type",{value:n,enumerable:!1}),n},r.setProperty=function(e,t,r){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var o=r.shift();if("__proto__"===o||"prototype"===o)return t;if(r.length>0)t[o]=e(t[o]||{},r,n);else{var s=t[o];s&&(n=[].concat(s).concat(n)),t[o]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(r,"decorateRoot",{get:function(){return n.decorated||(n.decorated=new(ea()))}}),$s.exports}function ra(){if(ji)return Di;ji=1,Di=r,r.className="ReflectionObject";var e,t=ta();function r(e,r){if(!t.isString(e))throw TypeError("name must be a string");if(r&&!t.isObject(r))throw TypeError("options must be an object");this.options=r,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(r.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),r.prototype.toJSON=function(){throw Error()},r.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var r=t.root;r instanceof e&&r._handleAdd(this)},r.prototype.onRemove=function(t){var r=t.root;r instanceof e&&r._handleRemove(this),this.parent=null,this.resolved=!1},r.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},r.prototype.getOption=function(e){if(this.options)return this.options[e]},r.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},r.prototype.setParsedOption=function(e,r,n){this.parsedOptions||(this.parsedOptions=[]);var o=this.parsedOptions;if(n){var s=o.find(function(t){return Object.prototype.hasOwnProperty.call(t,e)});if(s){var i=s[e];t.setProperty(i,n,r)}else(s={})[e]=t.setProperty({},n,r),o.push(s)}else{var a={};a[e]=r,o.push(a)}return this},r.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)this.setOption(r[n],e[r[n]],t);return this},r.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},r._configure=function(t){e=t},Di}function na(){if(Bi)return Ui;Bi=1,Ui=n;var e=ra();((n.prototype=Object.create(e.prototype)).constructor=n).className="Enum";var t=bi(),r=ta();function n(t,r,n,o,s,i){if(e.call(this,t,n),r&&"object"!=typeof r)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=o,this.comments=s||{},this.valuesOptions=i,this.reserved=void 0,r)for(var a=Object.keys(r),c=0;c<a.length;++c)"number"==typeof r[a[c]]&&(this.valuesById[this.values[a[c]]=r[a[c]]]=a[c])}return n.fromJSON=function(e,t){var r=new n(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,r},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},n.prototype.add=function(e,t,n,o){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return o&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=o||null),this.comments[e]=n||null,this},n.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},n.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},n.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},Ui}function oa(){if(xi)return Fi;xi=1,Fi=function(o){for(var s,i=r.codegen(["m","w"],o.name+"$encode")("if(!w)")("w=Writer.create()"),a=o.fieldsArray.slice().sort(r.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=o._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,g=t.basic[d];s="m"+r.safeProp(l.name),l.map?(i("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",s,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",s)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(l.id<<3|2)>>>0,8|t.mapKey[l.keyType],l.keyType),void 0===g?i("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,s):i(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|g,d,s),i("}")("}")):l.repeated?(i("if(%s!=null&&%s.length){",s,s),l.packed&&void 0!==t.packed[d]?i("w.uint32(%i).fork()",(l.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",s)("w.%s(%s[i])",d,s)("w.ldelim()"):(i("for(var i=0;i<%s.length;++i)",s),void 0===g?n(i,l,u,s+"[i]"):i("w.uint32(%i).%s(%s[i])",(l.id<<3|g)>>>0,d,s)),i("}")):(l.optional&&i("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",s,l.name),void 0===g?n(i,l,u,s):i("w.uint32(%i).%s(%s)",(l.id<<3|g)>>>0,d,s))}return i("return w")};var e=na(),t=yi(),r=ta();function n(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}return Fi}function sa(){if(Vi)return qi;Vi=1,qi=u;var e=/[\s{}=;:[\],'"()<>]/g,t=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,r=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,n=/^ *[*/]+ */,o=/^\s*\*?\/*/,s=/\n/g,i=/\s/,a=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function l(e){return e.replace(a,function(e,t){switch(t){case"\\":case"":return t;default:return c[t]||""}})}function u(a,c){a=a.toString();var u=0,d=a.length,g=1,p=0,f={},h=[],y=null;function m(e){return Error("illegal "+e+" (line "+g+")")}function v(e){return a.charAt(e)}function b(e,t,r){var i,l={type:a.charAt(e++),lineEmpty:!1,leading:r},u=e-(c?2:3);do{if(--u<0||"\n"===(i=a.charAt(u))){l.lineEmpty=!0;break}}while(" "===i||"\t"===i);for(var d=a.substring(e,t).split(s),h=0;h<d.length;++h)d[h]=d[h].replace(c?o:n,"").trim();l.text=d.join("\n").trim(),f[g]=l,p=g}function C(e){var t=O(e),r=a.substring(e,t);return/^\s*\/\//.test(r)}function O(e){for(var t=e;t<d&&"\n"!==v(t);)t++;return t}function S(){if(h.length>0)return h.shift();if(y)return function(){var e="'"===y?r:t;e.lastIndex=u-1;var n=e.exec(a);if(!n)throw m("string");return u=e.lastIndex,I(y),y=null,l(n[1])}();var n,o,s,p,f,S=0===u;do{if(u===d)return null;for(n=!1;i.test(s=v(u));)if("\n"===s&&(S=!0,++g),++u===d)return null;if("/"===v(u)){if(++u===d)throw m("comment");if("/"===v(u))if(c){if(p=u,f=!1,C(u-1)){f=!0;do{if((u=O(u))===d)break;if(u++,!S)break}while(C(u))}else u=Math.min(d,O(u)+1);f&&(b(p,u,S),S=!0),g++,n=!0}else{for(f="/"===v(p=u+1);"\n"!==v(++u);)if(u===d)return null;++u,f&&(b(p,u-1,S),S=!0),++g,n=!0}else{if("*"!==(s=v(u)))return"/";p=u+1,f=c||"*"===v(p);do{if("\n"===s&&++g,++u===d)throw m("comment");o=s,s=v(u)}while("*"!==o||"/"!==s);++u,f&&(b(p,u-2,S),S=!0),n=!0}}}while(n);var w=u;if(e.lastIndex=0,!e.test(v(w++)))for(;w<d&&!e.test(v(w));)++w;var E=a.substring(u,u=w);return'"'!==E&&"'"!==E||(y=E),E}function I(e){h.push(e)}function w(){if(!h.length){var e=S();if(null===e)return null;I(e)}return h[0]}return Object.defineProperty({next:S,peek:w,push:I,skip:function(e,t){var r=w();if(r===e)return S(),!0;if(!t)throw m("token '"+r+"', '"+e+"' expected");return!1},cmnt:function(e){var t,r=null;return void 0===e?(t=f[g-1],delete f[g-1],t&&(c||"*"===t.type||t.lineEmpty)&&(r=t.leading?t.text:null)):(p<e&&w(),t=f[e],delete f[e],!t||t.lineEmpty||!c&&"/"!==t.type||(r=t.leading?null:t.text)),r}},"line",{get:function(){return g}})}return u.unescape=l,qi}function ia(){if(Hi)return Ki;Hi=1,Ki=O,O.filename=null,O.defaults={keepCase:!1};var e=sa(),t=ea(),r=Qi(),n=mi(),o=Ci(),s=vi(),i=na(),a=Si(),c=Oi(),l=yi(),u=ta(),d=/^[1-9][0-9]*$/,g=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,f=/^-?0[x][0-9a-fA-F]+$/,h=/^0[0-7]+$/,y=/^-?0[0-7]+$/,m=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,v=/^[a-zA-Z_][a-zA-Z_0-9]*$/,b=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,C=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function O(S,I,w){I instanceof t||(w=I,I=new t),w||(w=O.defaults);var E,R,T,_,k,A=w.preferTrailingComment||!1,M=e(S,w.alternateCommentMode||!1),N=M.next,P=M.push,L=M.peek,D=M.skip,j=M.cmnt,U=!0,B=!1,F=I,x=w.keepCase?function(e){return e}:u.camelCase;function G(e,t,r){var n=O.filename;return r||(O.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+M.line+")")}function q(){var e,t=[];do{if('"'!==(e=N())&&"'"!==e)throw G(e);t.push(N()),D(e),e=L()}while('"'===e||"'"===e);return t.join("")}function V(e){var t=N();switch(t){case"'":case'"':return P(t),q();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(d.test(e))return r*parseInt(e,10);if(p.test(e))return r*parseInt(e,16);if(h.test(e))return r*parseInt(e,8);if(m.test(e))return r*parseFloat(e);throw G(e,"number",t)}(t,!0)}catch(r){if(e&&b.test(t))return t;throw G(t,"value")}}function K(e,t){var r,n;do{!t||'"'!==(r=L())&&"'"!==r?e.push([n=H(N()),D("to",!0)?H(N()):n]):e.push(q())}while(D(",",!0));var o={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(o,function(e){if("option"!==e)throw G(e);ee(o,e),D(";")},function(){ne(o)})}function H(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw G(e,"id");if(g.test(e))return parseInt(e,10);if(f.test(e))return parseInt(e,16);if(y.test(e))return parseInt(e,8);throw G(e,"id")}function z(){if(void 0!==E)throw G("package");if(E=N(),!b.test(E))throw G(E,"name");F=F.define(E),D(";")}function $(){var e,t=L();switch(t){case"weak":e=T||(T=[]),N();break;case"public":N();default:e=R||(R=[])}t=q(),D(";"),e.push(t)}function W(){if(D("="),_=q(),!(B="proto3"===_)&&"proto2"!==_)throw G(_,"syntax");I.setOption("syntax",_),D(";")}function J(e,t){switch(t){case"option":return ee(e,t),D(";"),!0;case"message":return X(e,t),!0;case"enum":return Q(e,t),!0;case"service":return function(e,t){if(!v.test(t=N()))throw G(t,"service name");var r=new a(t);Z(r,function(e){if(!J(r,e)){if("rpc"!==e)throw G(e);!function(e,t){var r=j(),n=t;if(!v.test(t=N()))throw G(t,"name");var o,s,i,a,l=t;D("("),D("stream",!0)&&(s=!0);if(!b.test(t=N()))throw G(t);o=t,D(")"),D("returns"),D("("),D("stream",!0)&&(a=!0);if(!b.test(t=N()))throw G(t);i=t,D(")");var u=new c(l,n,o,i,s,a);u.comment=r,Z(u,function(e){if("option"!==e)throw G(e);ee(u,e),D(";")}),e.add(u)}(r,e)}}),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!b.test(t=N()))throw G(t,"reference");var r=t;Z(null,function(t){switch(t){case"required":case"repeated":Y(e,t,r);break;case"optional":Y(e,B?"proto3_optional":"optional",r);break;default:if(!B||!b.test(t))throw G(t);P(t),Y(e,"optional",r)}})}(e,t),!0}return!1}function Z(e,t,r){var n=M.line;if(e&&("string"!=typeof e.comment&&(e.comment=j()),e.filename=O.filename),D("{",!0)){for(var o;"}"!==(o=N());)t(o);D(";",!0)}else r&&r(),D(";"),e&&("string"!=typeof e.comment||A)&&(e.comment=j(n)||e.comment)}function X(e,t){if(!v.test(t=N()))throw G(t,"type name");var n=new r(t);Z(n,function(e){if(!J(n,e))switch(e){case"map":!function(e){D("<");var t=N();if(void 0===l.mapKey[t])throw G(t,"type");D(",");var r=N();if(!b.test(r))throw G(r,"type");D(">");var n=N();if(!v.test(n))throw G(n,"name");D("=");var s=new o(x(n),H(N()),t,r);Z(s,function(e){if("option"!==e)throw G(e);ee(s,e),D(";")},function(){ne(s)}),e.add(s)}(n);break;case"required":case"repeated":Y(n,e);break;case"optional":Y(n,B?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!v.test(t=N()))throw G(t,"name");var r=new s(x(t));Z(r,function(e){"option"===e?(ee(r,e),D(";")):(P(e),Y(r,"optional"))}),e.add(r)}(n,e);break;case"extensions":K(n.extensions||(n.extensions=[]));break;case"reserved":K(n.reserved||(n.reserved=[]),!0);break;default:if(!B||!b.test(e))throw G(e);P(e),Y(n,"optional")}}),e.add(n)}function Y(e,t,o){var i=N();if("group"!==i){for(;i.endsWith(".")||L().startsWith(".");)i+=N();if(!b.test(i))throw G(i,"type");var a=N();if(!v.test(a))throw G(a,"name");a=x(a),D("=");var c=new n(a,H(N()),i,t,o);if(Z(c,function(e){if("option"!==e)throw G(e);ee(c,e),D(";")},function(){ne(c)}),"proto3_optional"===t){var d=new s("_"+a);c.setOption("proto3_optional",!0),d.add(c),e.add(d)}else e.add(c);B||!c.repeated||void 0===l.packed[i]&&void 0!==l.basic[i]||c.setOption("packed",!1,!0)}else!function(e,t){var o=N();if(!v.test(o))throw G(o,"name");var s=u.lcFirst(o);o===s&&(o=u.ucFirst(o));D("=");var i=H(N()),a=new r(o);a.group=!0;var c=new n(s,i,o,t);c.filename=O.filename,Z(a,function(e){switch(e){case"option":ee(a,e),D(";");break;case"required":case"repeated":Y(a,e);break;case"optional":Y(a,B?"proto3_optional":"optional");break;case"message":X(a,e);break;case"enum":Q(a,e);break;default:throw G(e)}}),e.add(a).add(c)}(e,t)}function Q(e,t){if(!v.test(t=N()))throw G(t,"name");var r=new i(t);Z(r,function(e){switch(e){case"option":ee(r,e),D(";");break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!v.test(t))throw G(t,"name");D("=");var r=H(N(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(n,function(e){if("option"!==e)throw G(e);ee(n,e),D(";")},function(){ne(n)}),e.add(t,r,n.comment,n.options)}(r,e)}}),e.add(r)}function ee(e,t){var r=D("(",!0);if(!b.test(t=N()))throw G(t,"name");var n,o=t,s=o;r&&(D(")"),s=o="("+o+")",t=L(),C.test(t)&&(n=t.slice(1),o+=t,N())),D("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,s,te(e,o),n)}function te(e,t){if(D("{",!0)){for(var r={};!D("}",!0);){if(!v.test(k=N()))throw G(k,"name");if(null===k)throw G(k,"end of input");var n,o=k;if(D(":",!0),"{"===L())n=te(e,t+"."+k);else if("["===L()){var s;if(n=[],D("[",!0)){do{s=V(!0),n.push(s)}while(D(",",!0));D("]"),void 0!==s&&re(e,t+"."+k,s)}}else n=V(!0),re(e,t+"."+k,n);var i=r[o];i&&(n=[].concat(i).concat(n)),r[o]=n,D(",",!0),D(";",!0)}return r}var a=V(!0);return re(e,t,a),a}function re(e,t,r){e.setOption&&e.setOption(t,r)}function ne(e){if(D("[",!0)){do{ee(e,"option")}while(D(",",!0));D("]")}return e}for(;null!==(k=N());)switch(k){case"package":if(!U)throw G(k);z();break;case"import":if(!U)throw G(k);$();break;case"syntax":if(!U)throw G(k);W();break;case"option":ee(F,k),D(";");break;default:if(J(F,k)){U=!1;continue}throw G(k)}return O.filename=null,{package:E,imports:R,weakImports:T,syntax:_,root:I}}return Ki}function aa(){if(Wi)return Hs.exports;Wi=1;var e=Hs.exports=function(){if(Gi)return zs.exports;Gi=1;var e=zs.exports=mr();return e.build="light",e.load=function(t,r,n){return"function"==typeof r?(n=r,r=new e.Root):r||(r=new e.Root),r.load(t,n)},e.loadSync=function(t,r){return r||(r=new e.Root),r.loadSync(t)},e.encoder=oa(),e.decoder=wi(),e.verifier=Ei(),e.converter=_i(),e.ReflectionObject=ra(),e.Namespace=bi(),e.Root=ea(),e.Enum=na(),e.Type=Qi(),e.Field=mi(),e.OneOf=vi(),e.MapField=Ci(),e.Service=Si(),e.Method=Oi(),e.Message=Ii(),e.wrappers=Yi(),e.types=yi(),e.util=ta(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),zs.exports}();return e.build="full",e.tokenize=sa(),e.parse=ia(),e.common=function(){if($i)return zi;$i=1,zi=r;var e,t=/\/|\./;function r(e,n){t.test(e)||(e="google/protobuf/"+e+".proto",n={nested:{google:{nested:{protobuf:{nested:n}}}}}),r[e]=n}return r("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),r("duration",{Duration:e={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),r("timestamp",{Timestamp:e}),r("empty",{Empty:{fields:{}}}),r("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),r("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),r("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),r.get=function(e){return r[e]||null},zi}(),e.Root._configure(e.Type,e.parse,e.common),Hs.exports}var ca=f(Zi?Ji:(Zi=1,Ji=aa()));const la=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},ua=e=>{const t=e.name;return ut(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},da=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},ga=e=>{const t=e.match(/data:([^;]+)/)[1],r=e.replace(/^[^,]+,/,""),n=window.atob(r);let o=n.length;const s=new Uint8Array(n.length);for(;o--;)s[o]=n.charCodeAt(o);return new Blob([s],{type:t})},pa=1680,fa=160,ha=e=>new Promise((t,r)=>{const n=e=>{0!==e.width||0!==e.height?t(e):r()},o=new Image;if(o.addEventListener("load",e=>n(e.target)),o.addEventListener("error",r),o.src=e,o.complete)return void n(o);const s=setInterval(()=>{o.complete&&(n(o),clearInterval(s))},40)}),ya=(e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d"),o=function(e,t,r){let n=e,o=t,s=0,i=0;const a=e*t,c=r.maxWidth*r.maxHeight;if(a<=c)return s=(r.maxWidth-n)/2,i=(r.maxHeight-o)/2,{w:n,h:o,x:s,y:i};const l=Math.sqrt(c/a);return n=e*l,o=t*l,s=(r.maxWidth-n)/2,i=(r.maxHeight-o)/2,{w:n,h:o,x:s,y:i}}(e.width,e.height,t);r.width=o.w,r.height=o.h,n.fillStyle="#FFFFFF",n.fillRect(0,0,r.width,r.height),n?.drawImage(e,0,0,o.w,o.h);try{let e=r.toDataURL("image/jpeg",t.quality);return ga(e)}catch(e){throw new Error(e)}};function ma(e){const t=Math.max(0,e),r=t%60,n=Math.floor(t/60%60),o=Math.floor(t/3600);return o>0?`${o}:${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${n}:${r.toString().padStart(2,"0")}`}const va={maxHeight:500,maxWidth:500,quality:.6,scale:2.4};class ba{async create(e,t){try{const r=la(e),n=await ha(r);let o,s,i;if(da(r),t?.full)o=e,s=n.width,i=n.height;else{const t=((e,t=1,r="image/jpeg")=>{t=Math.min(1,t);const n=e.width,o=e.height;let s=n,i=o;if(t<1){const e=n<o,t=e?o/pa:n/pa;n>pa&&o>pa?e?(i=pa,s/=t):(s=pa,i/=t):n>pa&&o>fa?(s=pa,i/=t,i<fa&&(i=fa,s=n/(o/fa))):o>pa&&n>fa&&(i=pa,s/=t,s<fa&&(s=fa,i=o/(n/fa)))}s=Math.floor(s),i=Math.floor(i);const a=document.createElement("canvas");a.width=s,a.height=i;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,s,i),c.drawImage(e,0,0,n,o,0,0,s,i),r&&"image/png"!=r||(r="image/jpeg"),{imageFile:ga(a.toDataURL(r,Math.min(.92,t))),compressWidth:s,compressHeight:i}})(n,.85,e.type);o=t.imageFile,s=t.compressWidth,i=t.compressHeight}const a=ya(n,va);return{success:!0,message:new ns({thumbnailObjectKey:la(a),originalObjectKey:la(o),width:s,height:i}),files:[a,o]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n,o],encryptedKey:s}=t;return r.originalObjectKey=o,r.thumbnailObjectKey=n,r.encryptKey=s,r}}class Ca{async create(e){if(e.size>2097152)return{success:!1};try{const t=la(e),r=await ha(t);return{success:!0,message:new os({originalObjectKey:t,extension:ua(e),width:r.width,height:r.height}),files:[e]}}catch{return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.originalObjectKey=n,r.encryptKey=o,r}}let Oa;class Sa{create(e){return(t=e,gt(t.arrayBuffer)?t.arrayBuffer():new Promise((e,r)=>{const n=new FileReader;n.addEventListener("load",t=>{t.target?e(t.target.result):r("null")}),n.addEventListener("error",e=>r(e)),n.readAsArrayBuffer(t)})).then(this.getAudioInfo).then(t=>({success:!0,message:new ss({audioObjectKey:la(e),length:t.duration,extension:ua(e)}),files:[e]})).catch(()=>({success:!1}));var t}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.audioObjectKey=n,r.encryptKey=o,r}getAudioInfo(e){const t=Oa||new AudioContext;return Oa=t,new Promise((r,n)=>{t.decodeAudioData(e,function(e){r({duration:e.duration,length:e.length})},n)})}}class Ia{async create(e){return e.size>104857600?{success:!1}:{success:!0,message:new is({fileKey:"",title:e.name,extension:ua(e),size:e.size}),files:[e]}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.fileKey=n,r.encryptKey=o,r}}class wa{async create(e){try{if(e.size>104857600)return{success:!1};const t=la(e),r=document.createElement("video");r.src=t,await new Promise((e,t)=>{r.onloadedmetadata=e,r.onerror=t}),r.currentTime=.001,await new Promise(e=>{r.onseeked=e});const n=r.duration,o=r.videoWidth,s=r.videoHeight,i=Math.min(va.maxWidth/o,va.maxHeight/s,va.scale),a=Math.floor(o*i),c=Math.floor(s*i),l=document.createElement("canvas");l.width=a,l.height=c;const u=l.getContext("2d");u?.drawImage(r,0,0,a,c);const d=await new Promise(e=>{l.toBlob(t=>e(t),"image/jpeg",va.quality)});return da(t),{success:!0,message:new as({videoObjectKey:"",thumbnailObjectKey:"",during:ma(n),width:o,height:s,extension:ua(e)}),files:[e,d]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n,o],encryptedKey:s}=t;return r.videoObjectKey=n,r.thumbnailObjectKey=o,r.encryptKey=s,r}}var Ea;!function(e){e[e.IMAGE=1]="IMAGE",e[e.GIF=2]="GIF",e[e.AUDIO=3]="AUDIO",e[e.FILE=4]="FILE",e[e.SIGHT=5]="SIGHT"}(Ea||(Ea={}));async function Ra(e,t,r){return Da(e,t,r)}const Ta=Pa.bind(null,Ea.IMAGE),_a=Pa.bind(null,Ea.GIF),ka=Pa.bind(null,Ea.AUDIO),Aa=Pa.bind(null,Ea.SIGHT),Ma=Pa.bind(null,Ea.FILE),Na=async(t,r)=>{const n=Qn(t);ao.addMessage(r.messageUId);const o=await((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.RecallGroupMessage,{groupId:Pr.fromString(t),msgId:Pr.fromString(r)},{encoder:$n,decoder:Tr}):ln.send(Tt.RecallPrivateMessage,{destId:Pr.fromString(t),msgId:Pr.fromString(r)},{encoder:Tn,decoder:Tr}),n})(n,r.messageUId);if(o.code!==e.ErrorCode.SUCCESS)return{code:o.code};const s=new Is({messageUId:r.messageUId}),i={conversation:t,senderUserId:nn.uid,messageId:0,sentTime:no().toString()},a=No(s,i,e.SentStatus.SENT);return a.burnAfterReadingFlag=!1,a.burnAfterReadingTime=0,Mo.get().setConversationCacheByMessage(a),{code:e.ErrorCode.SUCCESS,data:a}};async function Pa(t,r,n,o,s){const i=(e=>{let t;switch(e){case Ea.IMAGE:t=new ba;break;case Ea.AUDIO:t=new Sa;break;case Ea.GIF:t=new Ca;break;case Ea.FILE:t=new Ia;break;case Ea.SIGHT:t=new wa}return t})(t);if(!i)return{code:e.ErrorCode.NOT_SUPPORT};const{success:a,message:c,files:l}=await i.create(n.file,s);if(!a||!c||!l)return{code:e.ErrorCode.MEDIA_EXCEPTION};c.content.user=n.user,c.content.extra=n.extra;const u=Rt.getUploader();try{const e=await u.prepare(l);return c.content=i.updateMessageRemoteUrlProperty(c.content,{urls:e.items.map(e=>e.url),encryptedKey:e.encryptKey}),Da(r,c,s,{uploadItems:e,task:(e,t)=>new Promise(r=>{u.upload(t,{onProgress:e=>o?.onProgress?.(e),onError:()=>{r({finished:!1,message:e})},onCompleted:t=>{r({finished:!0,message:o?.onComplete?.(t)??e})}})})})}catch(t){return{code:e.ErrorCode.UPLOAD_FILE_FAILED}}}const La=async(t,r,n)=>{const o=await ja({conversationType:r.conversationType,targetId:r.targetId},t,r,n);if(o.code!==e.ErrorCode.SUCCESS||!o.message||!o.sentArgs)return{code:o.code};const s=No(o.message,o.sentArgs);s.quotedReply=r,await Fa(s,o.sentArgs);const i=Qn(r),a=await go.getDialogAesKey(i.toString());if(!a)return s.sentStatus=e.SentStatus.FAILED,await Fa(s,o.sentArgs),{code:e.ErrorCode.MSG_ENCRYPT_ERROR,data:s};let c,l,u,d;if(t.messageType===bo.TEXT){let e=Oo(t.content),r=e.content;delete e.content,c=yo(r,a),l=JSON.stringify(ft(e))}else l=JSON.stringify(ft(t.content));const g=yo(l,a);if(r){if(r.messageType===bo.TEXT){let e=Oo(r.content),t=e.content;delete e.content,u=yo(t,a),d=JSON.stringify(ft(e))}else d=JSON.stringify(ft(r.content));d=yo(d,a)}so.addMessage(o.sentArgs.messageId);const p={localId:Pr.fromNumber(o.sentArgs.messageId),mediaFlag:t.messageType!==bo.TEXT,mediaConstructor:t.messageType,msgPreContent:"",msgPostContent:c,mediaAttribute:g,msgIdReferenced:Pr.fromString(r.messageUId),msgSrcIdReferenced:Pr.fromString(r.senderUserId),msgDestIdReferenced:r.messageDirection==e.MessageDirection.RECEIVE?Pr.fromString(nn.uid):Pr.fromString(r.targetId),msgPostContentReferenced:u,mediaFlagReferenced:r.messageType!==bo.TEXT,mediaConstructorReferenced:r.messageType,mediaAttributeReferenced:d,msgSendTimeReferenced:Pr.fromString(r.sentTime)};let f;if(r.conversationType===e.ConversationType.GROUP){const e={...p,groupId:Pr.fromString(i)};if(rt(t.content.mentionedInfo)){const r=t.content.mentionedInfo;if(r.userList?.length){e.at=r.userList.map(e=>Pr.fromString(e.uin));const t=JSON.stringify({atInfo:JSON.stringify(r.userList)});e.msgPreContent=t}}f=await(h=e,ln.send(Tt.SendQuoteGroupChatMessage,h,{encoder:Zn,decoder:Xn}))}else{const e={...p,destId:Pr.fromString(i)};f=await(e=>ln.send(Tt.SendQuotePrivateChatMessage,e,{encoder:Un,decoder:Bn}))(e)}var h;const y=Oo(s);return f.code===e.ErrorCode.SUCCESS?(y.sentTime=f.data.msgSendTime.toString(),y.messageUId=f.data.msgId.toString(),y.sentStatus=e.SentStatus.SENT,await Fa(y,o.sentArgs)):(y.sentStatus=e.SentStatus.FAILED,await Fa(y,o.sentArgs)),{code:f.code,data:y}};async function Da(t,r,n,o){const s=await ja(t,r,null,n,o?.uploadItems);if(s.code!==e.ErrorCode.SUCCESS||!s.message||!s.sentArgs)return{code:s.code};{const e=No(s.message,s.sentArgs);await Fa(e,s.sentArgs)}let{message:i,sentArgs:a}=s;if(rt(o)){const t=await o.task(i,o.uploadItems);if(i=t.message,!t.finished){const t=No(s.message,s.sentArgs,e.SentStatus.FAILED);return await Fa(t,a),{code:e.ErrorCode.UPLOAD_FILE_FAILED,data:t}}}return async function(t,r){const n=Qn(r.conversation),o=No(t,r),s=await go.getDialogAesKey(n.toString());if(!s)return o.sentStatus=e.SentStatus.FAILED,await Fa(o,r),{code:e.ErrorCode.MSG_ENCRYPT_ERROR,data:o};let i,a;if(t.messageType===bo.TEXT){let e=Oo(t.content),r=e.content;delete e.content,i=yo(r,s),a=JSON.stringify(ft(e))}else a=JSON.stringify(ft(t.content));const c=yo(a,s);so.addMessage(r.messageId);const l={localId:Pr.fromNumber(r.messageId),mediaFlag:t.messageType!==bo.TEXT,mediaConstructor:t.messageType,msgPreContent:"",msgPostContent:i,mediaAttribute:c};let u;if(r.conversation.conversationType===e.ConversationType.GROUP){const e={...l,groupId:Pr.fromString(n)};if(rt(t.content.mentionedInfo)){const r=t.content.mentionedInfo;if(r.userList?.length){e.at=r.userList.map(e=>Pr.fromString(e.uin));const t=JSON.stringify({atInfo:JSON.stringify(r.userList)});e.msgPreContent=t}}u=await(d=e,ln.send(Tt.SendGroupChatMessage,d,{encoder:Vn,decoder:Kn}))}else{const e={...l,destId:Pr.fromString(n)};u=await(e=>ln.send(Tt.SendPrivateChatMessage,e,{encoder:fn,decoder:hn}))(e)}var d;u.code===e.ErrorCode.SUCCESS?(o.sentTime=u.data.msgSendTime.toString(),o.messageUId=u.data.msgId.toString(),o.sentStatus=e.SentStatus.SENT,await Fa(o,r)):(o.sentStatus=e.SentStatus.FAILED,await Fa(o,r));return{code:u.code,data:o}}(i,a)}async function ja(t,r,n,o,s){if(((e,t="utf-8")=>{let r=0;if("utf-16"===t)for(let t=0,n=e.length;t<n;t++)r+=e.charCodeAt(t)<=65535?2:4;else for(let t=0,n=e.length;t<n;t++){const n=e.charCodeAt(t);r+=n<127?1:n<=2047?2:n<=65535?3:4}return r})(JSON.stringify(ft(r.content)))>81920)return{code:e.ErrorCode.RC_MSG_CONTENT_EXCEED_LIMIT};r.isPersited&&await Mo.get().loadConvsationsIfNotExist([t]);const i={conversation:t,senderUserId:nn.uid,messageId:$o(),sentTime:Ba().toString(),pushConfig:o?.pushConfig};if(o?.onSendBefore){const e=No(r,i);n&&(e.quotedReply=n),o.onSendBefore(e,s)}return{code:e.ErrorCode.SUCCESS,message:r,sentArgs:i}}let Ua=1;function Ba(){Ua++;const e=no();return Ua<e&&(Ua=e),Ua}async function Fa(e,t){try{const r=Yo.get();if(e.isPersited&&r){await r.upsertMessage(e);const n=await r.getLatestMessage(t.conversation);let o=e;n&&Pr.fromString(n.sentTime).greaterThan(Pr.fromString(e.sentTime))&&(o=n),Mo.get().updateLatestMessage(t.conversation,o)}}catch(e){As.error("saveSentMessage -> ",e)}}class xa extends Eo{options;static imClient;libLoader;constructor(e){if(xa.imClient)return As.warn("Please do not perform the init method repeatedly"),xa.imClient;super(),this.options=e,this.fixedProtobuf(),rt(e.logLevel)&&As.setLogLevel(e.logLevel),rt(e.logStdout)&&As.setLogStdout(e.logStdout),As.debug("IMClient.init -> "),rt(e.uploader)&&Rt.setUploader(e.uploader),Rt.setDeviceCode(e.deviceCode),Rt.setDeviceType(e.deviceType),this.libLoader=ws.init(e),this.watch(),xa.imClient=this}fixedProtobuf(){ca.util.Long=Pr,ca.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(e.Events.CONNECTING)},onConnected:()=>{this.emit(e.Events.CONNECTED)},onDisconnect:()=>{this.emit(e.Events.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(e.Events.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:t=>{this.emit(e.Events.MESSAGES,{messages:t})},pullFinished:()=>{this.emit(e.Events.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:t=>{this.emit(e.Events.CONVERSATION,{conversations:t})},onPush:(t,r)=>{this.emit(e.Events.PUSH,{cmdId:t,body:r})},onRecall:t=>{t.forEach(t=>{this.emit(e.Events.RECALL,t)})},onReceiptReceived:(t,r)=>{Yo.get()?.updateMessageReceiptStatus(t,r),0===r?this.emit(e.Events.ARRIVAL_RECEIPT_RECEIVED,t):this.emit(e.Events.READ_RECEIPT_RECEIVED,t)}})}connect(){return this.libLoader.connect()}disconnect(){return this.libLoader.disconnect()}setUserLogged(e){e.uid!==nn.uid.toString()&&(nn.setLogged(e),this.libLoader.setUserLogged())}logOut(){nn.logOut(),this.libLoader.setUserLogout()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}getServerTime=no;async insertMessage(t,r,n){(!r.messageId||r.messageId>Jo())&&(r.messageId=$o()),Mo.get().setConversationCacheByMessage(r);try{const e=Yo.get();if(r.isPersited&&e){await e.upsertMessage(r);const t=await e.getLatestMessage(r);let n=r;t&&Pr.fromString(t.sentTime).greaterThan(Pr.fromString(r.sentTime))&&(n=t),Mo.get().updateLatestMessage(r,n)}}catch(e){As.error("insertMessage -> ",e)}return{code:e.ErrorCode.SUCCESS,data:r}}sendMessage=Ra;sendImageMessage=Ta;sendGIFMessage=_a;sendHQVoiceMessage=ka;sendFileMessage=Ma;sendSightMessage=Aa;async recallMsg(e,t){return await Na(e,t)}sendQuoteReplyMessage=La;async getRemoteHistoryMessages(t,r){const o=r.timestamp??"0",s=r.count??20,i=Qn(t);return(e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=Pr.fromString(e.offset):t.oldOffset=Pr.fromString(e.offset),ln.send(Tt.GetRemoteMessages,t,{encoder:_n,decoder:kn})})({dialogId:i,offset:o,count:s,newToOld:0===r.order}).then(({code:t,data:r})=>new Promise(o=>{t===e.ErrorCode.SUCCESS?Fo.parse({[i]:r.msg??{}},{[i]:r.reference??{}},(t,n)=>{const s=n.get(i)??[];s.sort((e,t)=>Pr.fromString(e.sentTime).lessThan(Pr.fromString(t.sentTime))?-1:1),o({code:e.ErrorCode.SUCCESS,data:{list:s,hasMore:!r.isEnd}})}):o({code:t,msg:n(t)})}))}async getPreviousHistoryMessages(t,r,n=20){const o=await Yo.get().getPreviousMessages(t,r??"0",n);if(!r&&o.messages.length&&Mo.get().updateLatestMessage(t,o.messages[o.messages.length-1]),o.messages.length>=n||!o.hasMore)return{code:e.ErrorCode.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}};const s=o.messages[0]?.sentTime??r,i=await this.getRemoteHistoryMessages(t,{timestamp:s,count:n-o.messages.length,order:0});if(i.code!==e.ErrorCode.SUCCESS)return i;const a=i.data.list;for(let e=a.length-1;e>=0;e--){const t=a[e];(!t.messageId||t.messageId>Jo())&&(t.messageId=Wo())}return s&&"0"!=s||Mo.get().updateLatestMessage(t,a[a.length-1]),Yo.get().addMessages(a,t,!i.data.hasMore),{code:e.ErrorCode.SUCCESS,data:{list:[...i.data.list,...o.messages],hasMore:i.data.hasMore}}}async deleteRemoteMessage(t,r){const n=await(o=Qn(t),s=r.map(e=>e.messageUId),ln.send(Tt.DeleteChatMessages,{destId:Pr.fromString(o),msgIdList:s.map(e=>Pr.fromString(e))},{encoder:On,decoder:Tr})).then(e=>e.code);var o,s;if(n===e.ErrorCode.SUCCESS){const e=await(Yo.get()?.getLatestMessage(t));if(await(Yo.get()?.removeMessagesByUId(r.map(e=>e.messageUId))),e&&r.some(t=>t.messageUId===e.messageUId)){const e=await(Yo.get()?.getLatestMessage(t));Mo.get().updateLatestMessage(t,e)}}return n}async deleteHistoryMessages(e){return Yo.get()?.clearConversationCache(e),Mo.get().clearHistoryMessages(e),(t=Qn(e),ln.send(Tt.ClearChatHistoryMessage,{destId:t},{encoder:Sn,decoder:Tr})).then(e=>e.code);var t}async getConversationList(t,r,n,o){const s={rows:t,type:r??0,offset:Pr.fromNumber(n),newToOld:0===o},{code:i,data:a}=await(e=>ln.send(Tt.GetDialogList,e,{encoder:An,decoder:Mn}))(s);if(i!==e.ErrorCode.SUCCESS)return{code:i};const c=a.fullDialog.map(e=>e.dialog?.destId).filter(rt);await go.getDialogAesKeyList(c.map(e=>e.toString()));let l=1e4;const u=[];for(const e of a.fullDialog){const t=this.formatConversation(e);if(!t)continue;const r={conversationType:t.conversationType,targetId:t.targetId},n=t.latestMessage;t.latestMessage=await(Yo.get()?.getLatestMessage(r));const o=Mo.get().get(r);o||Object.assign(t,o),rt(t.latestMessage)&&!t.updateTime&&(t.updateTime=parseInt(t.latestMessage.sentTime)),t.updateTime||(n?t.updateTime=parseInt(n.sentTime):(t.updateTime=l,l++)),Mo.get().addLocalConversation(t),u.push(t)}return u.sort((e,t)=>(e.updateTime??0)-(t.updateTime??0)),{code:e.ErrorCode.SUCCESS,data:u}}getBlockConversationList(){const t=Mo.get().getBlockConversationList();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})}getTopConversationList(){const t=Mo.get().getTopConversationList();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})}async getConversation(t){const r=Mo.get().get(t);if(!r)return{code:e.ErrorCode.CONVER_GET_ERROR};const n=await(Yo.get()?.getLatestMessage(t)),o={...t,...r,updateTime:rt(n?.sentTime)?parseInt(n.sentTime):void 0,latestMessage:n};return{code:e.ErrorCode.SUCCESS,data:o}}removeConversation(e){return Mo.get().remove(e),(t=Qn(e),ln.send(Tt.DeletePrivateDialog,{destId:Pr.fromString(t)},{encoder:yn,decoder:Tr})).then(e=>e.code);var t}getUnreadMentionedCount(e){return Mo.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return Mo.get().getAllUnreadMentionedCount()}getConversationState(e){return Mo.get().getConversationState(e)}getAllConversationState(){return Mo.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return Mo.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return Mo.get().getUnreadCount(e)}clearConversationUnreadCount(e){Mo.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){Mo.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return Mo.get().getNotificationLevel(e)}setConversationNotificationStatus(t,r){return((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.UpdateGroupChatMuteConfig,{groupId:Pr.fromString(t),muteFlag:r},{encoder:zn,decoder:Tr}):ln.send(Tt.UpdatePrivateChatMuteConfig,{destId:Pr.fromString(t),muteFlag:r},{encoder:Cn,decoder:Tr}),n})(Qn(t),r===e.NotificationStatus.OPEN).then(n=>(!n.code&&Mo.get().addStatus({...t,notificationStatus:r,notificationLevel:r==e.NotificationStatus.OPEN?e.NotificationLevel.AT_USER_NOTIFICATION:e.NotificationLevel.NOT_SET},!0),n.code))}getConversationNotificationStatus(e){return Mo.get().getNotificationStatus(e)}setConversationToTop(t,r){return((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.UpdateGroupChatStickyConfig,{groupId:Pr.fromString(t),stickyFlag:r},{encoder:Hn,decoder:Tr}):ln.send(Tt.UpdatePrivateChatStickyConfig,{destId:Pr.fromString(t),stickyFlag:r},{encoder:bn,decoder:Tr}),n})(Qn(t),r).then(e=>(!e.code&&Mo.get().addStatus({...t,isTop:r},!0),e.code))}saveConversationMessageDraft(e,t){Mo.get().setDraft(e,t)}getConversationMessageDraft(e){return Mo.get().getDraft(e)}clearConversationMessageDraft(e){Mo.get().clearDraft(e)}async sendReadReceipts(e){await(Vo.get()?.sendReadReceipts(e))}formatConversation(e){const{dialog:t,msg:r}=e,n=t.destId;if(!rt(n))return;const o=wo(t);if(!o)return;const s=go.getDialogAesKeyFromLocal(n.toString());if(s){if(rt(r)){const e=Fo.parseSingleDialogMessages(n.toString(),[r],s,{})[0];o.latestMessage=e}return o}}async clearBurnAfterReadingExpiredMessages(e){const t=Yo.get();if(!t)return Promise.resolve([]);const r=await t.getLatestMessage(e),n=await t.clearBurnAfterReadingExpiredMessages(e);if(r&&n.includes(r.messageUId)){const r=await t.getLatestMessage(e);Mo.get().updateLatestMessage(e,r)}return n}async getMessageById(e){return Yo.get()?.getMessageById(e)}async getMessageByUId(e){return Yo.get()?.getMessageByUId(e)}}const Ga=vr.Reader,qa=vr.Writer,Va=vr.util,Ka=vr.roots.default||(vr.roots.default={}),Ha=Ka.AuthSignIn2Req=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.langCode="",e.prototype.phoneNum="",e.prototype.password="",e.prototype.appVersionCode=0,e.prototype.deviceType=0,e.prototype.imei="",e.prototype.brand="",e.prototype.model="",e.prototype.apnsToken="",e.prototype.bandId="",e.prototype.appVersion="",e.prototype.osVersion="",e.prototype.version=0,e.encode=function(e,t){return t||(t=qa.create()),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(10).string(e.langCode),null!=e.phoneNum&&Object.hasOwnProperty.call(e,"phoneNum")&&t.uint32(18).string(e.phoneNum),null!=e.password&&Object.hasOwnProperty.call(e,"password")&&t.uint32(26).string(e.password),null!=e.appVersionCode&&Object.hasOwnProperty.call(e,"appVersionCode")&&t.uint32(32).int32(e.appVersionCode),null!=e.deviceType&&Object.hasOwnProperty.call(e,"deviceType")&&t.uint32(40).int32(e.deviceType),null!=e.imei&&Object.hasOwnProperty.call(e,"imei")&&t.uint32(50).string(e.imei),null!=e.brand&&Object.hasOwnProperty.call(e,"brand")&&t.uint32(58).string(e.brand),null!=e.model&&Object.hasOwnProperty.call(e,"model")&&t.uint32(66).string(e.model),null!=e.apnsToken&&Object.hasOwnProperty.call(e,"apnsToken")&&t.uint32(74).string(e.apnsToken),null!=e.bandId&&Object.hasOwnProperty.call(e,"bandId")&&t.uint32(82).string(e.bandId),null!=e.appVersion&&Object.hasOwnProperty.call(e,"appVersion")&&t.uint32(90).string(e.appVersion),null!=e.osVersion&&Object.hasOwnProperty.call(e,"osVersion")&&t.uint32(98).string(e.osVersion),null!=e.version&&Object.hasOwnProperty.call(e,"version")&&t.uint32(104).int32(e.version),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.AuthSignIn2Req;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.langCode=e.string();break;case 2:n.phoneNum=e.string();break;case 3:n.password=e.string();break;case 4:n.appVersionCode=e.int32();break;case 5:n.deviceType=e.int32();break;case 6:n.imei=e.string();break;case 7:n.brand=e.string();break;case 8:n.model=e.string();break;case 9:n.apnsToken=e.string();break;case 10:n.bandId=e.string();break;case 11:n.appVersion=e.string();break;case 12:n.osVersion=e.string();break;case 13:n.version=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Req"},e})(),za=Ka.AuthSignIn2Resp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.prototype.frozenDays=0,e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.noNickName&&Object.hasOwnProperty.call(e,"noNickName")&&t.uint32(40).bool(e.noNickName),null!=e.noEmail&&Object.hasOwnProperty.call(e,"noEmail")&&t.uint32(48).bool(e.noEmail),null!=e.cert&&Object.hasOwnProperty.call(e,"cert")&&t.uint32(58).string(e.cert),null!=e.userFileDomain&&Object.hasOwnProperty.call(e,"userFileDomain")&&t.uint32(74).string(e.userFileDomain),null!=e.dialogFileDomain&&Object.hasOwnProperty.call(e,"dialogFileDomain")&&t.uint32(82).string(e.dialogFileDomain),null!=e.user&&Object.hasOwnProperty.call(e,"user")&&Ka.User.encode(e.user,t.uint32(90).fork()).ldelim(),null!=e.frozenDays&&Object.hasOwnProperty.call(e,"frozenDays")&&t.uint32(104).int32(e.frozenDays),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.AuthSignIn2Resp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Ka.User.decode(e,e.uint32());break;case 13:n.frozenDays=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Resp"},e})();Ka.User=(()=>{function e(e){if(this.aliasMobile=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.uid=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.nickName="",e.prototype.langCode="",e.prototype.phone="",e.prototype.numberInPhoneBook="",e.prototype.smallAvatarUrl="",e.prototype.originalAvatarUrl="",e.prototype.email="",e.prototype.qrcodeString="",e.prototype.gender=0,e.prototype.contactStatus=0,e.prototype.alias="",e.prototype.aliasMobile=Va.emptyArray,e.prototype.aliasDesp="",e.encode=function(e,t){if(t||(t=qa.create()),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(8).int64(e.uid),null!=e.nickName&&Object.hasOwnProperty.call(e,"nickName")&&t.uint32(18).string(e.nickName),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(26).string(e.langCode),null!=e.phone&&Object.hasOwnProperty.call(e,"phone")&&t.uint32(34).string(e.phone),null!=e.numberInPhoneBook&&Object.hasOwnProperty.call(e,"numberInPhoneBook")&&t.uint32(42).string(e.numberInPhoneBook),null!=e.smallAvatarUrl&&Object.hasOwnProperty.call(e,"smallAvatarUrl")&&t.uint32(50).string(e.smallAvatarUrl),null!=e.originalAvatarUrl&&Object.hasOwnProperty.call(e,"originalAvatarUrl")&&t.uint32(58).string(e.originalAvatarUrl),null!=e.email&&Object.hasOwnProperty.call(e,"email")&&t.uint32(66).string(e.email),null!=e.qrcodeString&&Object.hasOwnProperty.call(e,"qrcodeString")&&t.uint32(74).string(e.qrcodeString),null!=e.gender&&Object.hasOwnProperty.call(e,"gender")&&t.uint32(80).int32(e.gender),null!=e.contactStatus&&Object.hasOwnProperty.call(e,"contactStatus")&&t.uint32(88).int32(e.contactStatus),null!=e.alias&&Object.hasOwnProperty.call(e,"alias")&&t.uint32(98).string(e.alias),null!=e.aliasMobile&&e.aliasMobile.length)for(let r=0;r<e.aliasMobile.length;++r)t.uint32(106).string(e.aliasMobile[r]);return null!=e.aliasDesp&&Object.hasOwnProperty.call(e,"aliasDesp")&&t.uint32(114).string(e.aliasDesp),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.User;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.uid=e.int64();break;case 2:n.nickName=e.string();break;case 3:n.langCode=e.string();break;case 4:n.phone=e.string();break;case 5:n.numberInPhoneBook=e.string();break;case 6:n.smallAvatarUrl=e.string();break;case 7:n.originalAvatarUrl=e.string();break;case 8:n.email=e.string();break;case 9:n.qrcodeString=e.string();break;case 10:n.gender=e.int32();break;case 11:n.contactStatus=e.int32();break;case 12:n.alias=e.string();break;case 13:n.aliasMobile&&n.aliasMobile.length||(n.aliasMobile=[]),n.aliasMobile.push(e.string());break;case 14:n.aliasDesp=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e})();const $a=Ka.WebGetLoginCodeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.account="",e.prototype.langCode="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.account&&Object.hasOwnProperty.call(e,"account")&&t.uint32(10).string(e.account),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(18).string(e.langCode),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.account=e.string();break;case 2:n.langCode=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeReq"},e})(),Wa=Ka.WebGetLoginCodeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeResp"},e})(),Ja=Ka.WebGetLoginCodeVerifyReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.account="",e.prototype.langCode="",e.prototype.code="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.account&&Object.hasOwnProperty.call(e,"account")&&t.uint32(10).string(e.account),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(18).string(e.langCode),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(26).string(e.code),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeVerifyReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.account=e.string();break;case 2:n.langCode=e.string();break;case 3:n.code=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeVerifyReq"},e})(),Za=Ka.ClickOKToWebResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.noNickName&&Object.hasOwnProperty.call(e,"noNickName")&&t.uint32(40).bool(e.noNickName),null!=e.noEmail&&Object.hasOwnProperty.call(e,"noEmail")&&t.uint32(48).bool(e.noEmail),null!=e.cert&&Object.hasOwnProperty.call(e,"cert")&&t.uint32(58).string(e.cert),null!=e.userFileDomain&&Object.hasOwnProperty.call(e,"userFileDomain")&&t.uint32(74).string(e.userFileDomain),null!=e.dialogFileDomain&&Object.hasOwnProperty.call(e,"dialogFileDomain")&&t.uint32(82).string(e.dialogFileDomain),null!=e.user&&Object.hasOwnProperty.call(e,"user")&&Ka.User.encode(e.user,t.uint32(90).fork()).ldelim(),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.ClickOKToWebResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Ka.User.decode(e,e.uint32());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ClickOKToWebResp"},e})();let Xa;const Ya=async(t,r,n)=>{if(r instanceof es==!1)return As.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:e.ErrorCode.PARAMETER_ERROR};Fs("conversation",t,Us,!0),Qa(t);const o=await Xa.sendMessage(t,r,n);return ec(t,o.code),o},Qa=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+t)},ec=(t,r)=>{if(r!==e.ErrorCode.SUCCESS){const e="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.warn("send message fail ->"+r+":"+n(r)+","+e)}};e.ChatRecordMessage=ls,e.ContactMessage=us,e.ErrorDesc=n,e.FileMessage=is,e.GIFMessage=os,e.GroupCloseBurnAfterReadingMessage=Ss,e.GroupOpenBurnAfterReadingMessage=Os,e.HQVoiceMessage=ss,e.ImageMessage=ns,e.InvitationMessage=ds,e.LinkMessage=fs,e.LocationMessage=cs,e.MessageTypes=bo,e.NotiMessageTypes=Co,e.PrivateCloseBurnAfterReadingMessage=Cs,e.PrivateOpenBurnAfterReadingMessage=bs,e.RecallCommandMessage=Is,e.RedEnvelopeMessage=gs,e.TextMessage=rs,e.TransferMessage=ps,e.VideoMessage=as,e.addEventListener=(e,t,r)=>{Xa.on(e,t,r)},e.clearAllMessagesUnreadStatus=()=>(As.debug("clear allMessagesUnreadStatus"),Xa.clearAllConversationsUnreadCount(),Promise.resolve({code:e.ErrorCode.SUCCESS})),e.clearBurnAfterReadingExpiredMessages=async t=>{Fs("conversation",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("clear burn after reading expired messages ->"+r);const n=await Xa.clearBurnAfterReadingExpiredMessages(t);return n.length>0&&As.debug(`已清除会话 ${r} 中的 ${n.length} 条阅后即焚过期消息`),Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.clearHistoryMessages=async t=>{Fs("conversation",t,Us);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("clear message ->"+r);const o=await Xa.deleteHistoryMessages(t);return o!==e.ErrorCode.SUCCESS?(As.warn("clear message ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:e.ErrorCode.SUCCESS}},e.clearMessagesUnreadStatus=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("clear unreadMsgNum ->"+r),Xa.clearConversationUnreadCount(t),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.clearTextMessageDraft=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("delete draft ->"+r),Xa.clearConversationMessageDraft(t),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.connect=async()=>{console.log("imlib-web connect ->");const t=await Xa.connect();return t.code===e.ErrorCode.SUCCESS?{code:t.code}:{code:t.code,msg:n(t.code)}},e.deleteMessages=async(t,r)=>{Fs("messages",r,e=>ct(e)&&!!e.length,!0),r.forEach(e=>{Fs("messages.messageUId",e.messageUId,Ms,!0),Fs("messages.sentTime",e.sentTime,Ns,!1),Fs("messages.messageDirection",e.messageDirection,e=>1===e||2===e,!1)}),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("delete messages ->"+o);const s=await Xa.deleteRemoteMessage(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("delete message fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:e.ErrorCode.SUCCESS}},e.disconnect=()=>Xa.disconnect(),e.encodeReceivedMessage2ChatRecordMsgDetail=e=>Fo.encodeReceivedMessage2ChatRecordMsgDetail(e),e.getAllConversationState=()=>{As.debug("getAllConversationState");const t=Xa.getAllConversationState();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},e.getAllUnreadMentionedCount=()=>{As.debug("getAllUnreadMentionedCount");const t=Xa.getAllUnreadMentionedCount();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},e.getBlockedConversationList=()=>Xa.getBlockConversationList(),e.getConnectionStatus=()=>Xa.getConnectionStatus(),e.getConversation=async t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get conversation ->"+r);const{code:o,data:s}=await Xa.getConversation(t);return o!==e.ErrorCode.SUCCESS?(As.warn("get conversation fail ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:o,data:s}},e.getConversationList=async t=>{As.debug("get conversation list ->");const{code:r,data:o}=await Xa.getConversationList(t?.count??20,null,t?.startTime??0,t?.order??0);return r!==e.ErrorCode.SUCCESS&&As.warn("get conversation list fail ->"+r+":"+n(r)),{code:r,msg:n(r),data:o}},e.getConversationNotificationLevel=t=>{Fs("options",t,Us,!0),As.info("getConversationNotificationLevel ->targetId:"+t.targetId+",conversationType:"+t.conversationType);const r=Xa.getConversationNotificationLevel(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},e.getConversationNotificationStatus=t=>{Fs("options",t,Us,!0),As.info("getConversationNotificationStatus ->targetId:"+t.targetId+",conversationType:"+t.conversationType);const r=Xa.getConversationNotificationStatus(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},e.getConversationState=e=>(As.debug("getConversationState"),Xa.getConversationState(e)),e.getMessageById=async t=>{const r=await Xa.getMessageById(t);return{code:e.ErrorCode.SUCCESS,data:r}},e.getMessageByUId=async t=>{const r=await Xa.getMessageByUId(t);return{code:e.ErrorCode.SUCCESS,data:r}},e.getRemoteHistoryMessages=async(t,r)=>{Fs("options.count",r.count??0,Ns),Fs("options.order",r.order??0,e=>0===e||1===e),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;let s;return As.debug("get remote history message ->"+o),rt(r.timestamp)&&(r.timestamp=r.timestamp.toString()),s=r.order?await Xa.getRemoteHistoryMessages(t,r):await Xa.getPreviousHistoryMessages(t,r.timestamp,r.count),s.code!==e.ErrorCode.SUCCESS&&As.warn("get remote history message fail ->"+s.code+":"+n(s.code)+","+o),s},e.getServerTime=()=>Xa.getServerTime(),e.getTextMessageDraft=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get draft ->"+r);const n=Xa.getConversationMessageDraft(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getTopConversationList=()=>Xa.getTopConversationList(),e.getTotalUnreadCount=(t,r)=>{if(As.debug("get total unread count -> ConversationType:"+JSON.stringify(r)+" includeMuted:"+t),Fs("includeMuted",t,Ps,!1),Fs("conversationTypes",r,Ds,!1),r)for(const e of r)Fs("conversationType",e,js,!0);const n=Xa.getAllConversationUnreadCount(r??[],t??!1);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getUnreadCount=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get unreadCount ->"+r);const n=Xa.getConversationUnreadCount(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getUnreadMentionedCount=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("get unreadMentionedCount ->"+r),Promise.resolve({code:e.ErrorCode.SUCCESS,data:Xa.getUnreadMentionedCount(t)})},e.init=e=>{Xa=Xa||new xa(e)},e.insertMessage=async(e,t,r)=>Xa.insertMessage(e,t,r),e.logOut=()=>{Xa.logOut()},e.mockGetLoginCode=e=>(e=>ln.request(805404721,{langCode:e.langCode,account:e.phone},{encoder:$a,decoder:Wa}))(e),e.mockLogin=e=>(e=>ln.request(805376017,{langCode:e.langCode,phoneNum:e.phone,password:et.SHA256(e.password).toString(),deviceType:7,imei:"59bc678b-fe6d-4e67-87c6-b0692205134b",brand:"Chrome",model:"Mozilla",appVersion:"1.0.0",osVersion:"1.0.0"},{encoder:Ha,decoder:za}))(e),e.mockVerifyLoginCode=e=>(e=>ln.request(805404723,{langCode:e.country,account:e.phone,code:e.code},{encoder:Ja,decoder:Za}))(e),e.onceEventListener=function(e,t,r){Xa.once(e,t,r)},e.parseChatRecordMsgDetails=(e,t)=>Fo.decodeChatRecordMsgDetails2ReceivedMessages(e,t),e.recallMessage=async(t,r)=>{Fs("options.messageUId",r.messageUId,Ms,!0),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId+",messageUId:"+r.messageUId;As.debug("recall message ->"+o);const s=await Xa.recallMsg(t,r);return s.code!==e.ErrorCode.SUCCESS&&As.warn("recall message fail ->"+s.code+":"+n(s.code)+","+o),s},e.registerMessageType=(e,t,r,n)=>{let o=function(o){return new es(e,o,t,r,n)};return lo(e,o),o},e.removeConversation=async t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("remove conversation ->"+r);const o=await Xa.removeConversation(t);return o!==e.ErrorCode.SUCCESS?(As.warn("remove conversation fail ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:o}},e.removeEventListener=(e,t,r)=>{Xa?.off(e,t,r)},e.request=(e,t,r,n=3e4)=>(console.log("imlib-web request ->",e,t,r,n),ln.request(e,t,r,n)),e.saveTextMessageDraft=(t,r)=>{Fs("options",t,Us,!0),Fs("draft",r,Ms,!0);const n="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("set draft ->"+n),Xa.saveConversationMessageDraft(t,r),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.sendFileMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendFileMessage(e,t,r,n);return ec(e,s.code),s},e.sendGIFMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&e.type.endsWith("image/gif"),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendGIFMessage(e,t,r,n);return ec(e,s.code),s},e.sendHQVoiceMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob,!0),Qa(e);const o=await Xa.sendHQVoiceMessage(e,t,r,n);return ec(e,o.code),o},e.sendImageMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("image/"),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendImageMessage(e,t,r,n);return ec(e,s.code),s},e.sendMessage=Ya,e.sendQuoteReplyMessage=async(e,t,r)=>await Xa.sendQuoteReplyMessage(e,t,r),e.sendReadReceipts=async t=>{try{return await Xa.sendReadReceipts(t),{code:e.ErrorCode.SUCCESS}}catch(t){return{code:e.ErrorCode.UNKNOWN}}},e.sendSightMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&"video/mp4"===e.type,!0),Qa(e);const o=await Xa.sendSightMessage(e,t,r,n);return ec(e,o.code),o},e.sendTextMessage=(e,t,r)=>{const n=new rs(t);return Ya(e,n,r)},e.setConversationNotificationStatus=async(t,r)=>{Fs("options",t,Us,!0),Fs("notificationStatus",r,e=>1===e||2===e,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("set conversation status ->"+o);const s=await Xa.setConversationNotificationStatus(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("set conversation status fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:s}},e.setConversationToTop=async(t,r=!0)=>{Fs("options",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("set conversation status ->"+o);const s=await Xa.setConversationToTop(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("set conversation status fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:s}},e.setUserLogged=e=>{Xa.setUserLogged(e)}});
37
+ */var Nr=null;try{Nr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function Pr(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function Lr(e){return!0===(e&&e.__isLong__)}function Dr(e){var t=Math.clz32(e&-e);return e?31-t:t}Pr.prototype.__isLong__,Object.defineProperty(Pr.prototype,"__isLong__",{value:!0}),Pr.isLong=Lr;var jr={},Ur={};function Br(e,t){var r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=Ur[e])?n:(r=xr(e,0,!0),o&&(Ur[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=jr[e])?n:(r=xr(e,e<0?-1:0,!1),o&&(jr[e]=r),r)}function Fr(e,t){if(isNaN(e))return t?Jr:Wr;if(t){if(e<0)return Jr;if(e>=Hr)return en}else{if(e<=-zr)return tn;if(e+1>=zr)return Qr}return e<0?Fr(-e,t).neg():xr(e%Kr|0,e/Kr|0,t)}function xr(e,t,r){return new Pr(e,t,r)}Pr.fromInt=Br,Pr.fromNumber=Fr,Pr.fromBits=xr;var Gr=Math.pow;function qr(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Jr:Wr;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return qr(e.substring(1),t,r).neg();for(var o=Fr(Gr(r,8)),s=Wr,i=0;i<e.length;i+=8){var a=Math.min(8,e.length-i),c=parseInt(e.substring(i,i+a),r);if(a<8){var l=Fr(Gr(r,a));s=s.mul(l).add(Fr(c))}else s=(s=s.mul(o)).add(Fr(c))}return s.unsigned=t,s}function Vr(e,t){return"number"==typeof e?Fr(e,t):"string"==typeof e?qr(e,t):xr(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Pr.fromString=qr,Pr.fromValue=Vr;var Kr=4294967296,Hr=Kr*Kr,zr=Hr/2,$r=Br(1<<24),Wr=Br(0);Pr.ZERO=Wr;var Jr=Br(0,!0);Pr.UZERO=Jr;var Zr=Br(1);Pr.ONE=Zr;var Xr=Br(1,!0);Pr.UONE=Xr;var Yr=Br(-1);Pr.NEG_ONE=Yr;var Qr=xr(-1,2147483647,!1);Pr.MAX_VALUE=Qr;var en=xr(-1,-1,!0);Pr.MAX_UNSIGNED_VALUE=en;var tn=xr(0,-2147483648,!1);Pr.MIN_VALUE=tn;var rn=Pr.prototype;rn.toInt=function(){return this.unsigned?this.low>>>0:this.low},rn.toNumber=function(){return this.unsigned?(this.high>>>0)*Kr+(this.low>>>0):this.high*Kr+(this.low>>>0)},rn.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(tn)){var t=Fr(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=Fr(Gr(e,6),this.unsigned),s=this,i="";;){var a=s.div(o),c=(s.sub(a.mul(o)).toInt()>>>0).toString(e);if((s=a).isZero())return c+i;for(;c.length<6;)c="0"+c;i=""+c+i}},rn.getHighBits=function(){return this.high},rn.getHighBitsUnsigned=function(){return this.high>>>0},rn.getLowBits=function(){return this.low},rn.getLowBitsUnsigned=function(){return this.low>>>0},rn.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tn)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<<t);t--);return 0!=this.high?t+33:t+1},rn.isZero=function(){return 0===this.high&&0===this.low},rn.eqz=rn.isZero,rn.isNegative=function(){return!this.unsigned&&this.high<0},rn.isPositive=function(){return this.unsigned||this.high>=0},rn.isOdd=function(){return!(1&~this.low)},rn.isEven=function(){return!(1&this.low)},rn.equals=function(e){return Lr(e)||(e=Vr(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},rn.eq=rn.equals,rn.notEquals=function(e){return!this.eq(e)},rn.neq=rn.notEquals,rn.ne=rn.notEquals,rn.lessThan=function(e){return this.comp(e)<0},rn.lt=rn.lessThan,rn.lessThanOrEqual=function(e){return this.comp(e)<=0},rn.lte=rn.lessThanOrEqual,rn.le=rn.lessThanOrEqual,rn.greaterThan=function(e){return this.comp(e)>0},rn.gt=rn.greaterThan,rn.greaterThanOrEqual=function(e){return this.comp(e)>=0},rn.gte=rn.greaterThanOrEqual,rn.ge=rn.greaterThanOrEqual,rn.compare=function(e){if(Lr(e)||(e=Vr(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},rn.comp=rn.compare,rn.negate=function(){return!this.unsigned&&this.eq(tn)?tn:this.not().add(Zr)},rn.neg=rn.negate,rn.add=function(e){Lr(e)||(e=Vr(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,s=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=o+(65535&e.low))>>>16,l+=(u+=n+a)>>>16,c+=(l+=r+i)>>>16,c+=t+s,xr((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},rn.subtract=function(e){return Lr(e)||(e=Vr(e)),this.add(e.neg())},rn.sub=rn.subtract,rn.multiply=function(e){if(this.isZero())return this;if(Lr(e)||(e=Vr(e)),Nr)return xr(Nr.mul(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Jr:Wr;if(this.eq(tn))return e.isOdd()?tn:Wr;if(e.eq(tn))return this.isOdd()?tn:Wr;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt($r)&&e.lt($r))return Fr(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,s=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=65535&e.low,l=0,u=0,d=0,g=0;return d+=(g+=o*c)>>>16,u+=(d+=n*c)>>>16,d&=65535,u+=(d+=o*a)>>>16,l+=(u+=r*c)>>>16,u&=65535,l+=(u+=n*a)>>>16,u&=65535,l+=(u+=o*i)>>>16,l+=t*c+r*a+n*i+o*s,xr((d&=65535)<<16|(g&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},rn.mul=rn.multiply,rn.divide=function(e){if(Lr(e)||(e=Vr(e)),e.isZero())throw Error("division by zero");var t,r,n;if(Nr)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?xr((this.unsigned?Nr.div_u:Nr.div_s)(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Jr:Wr;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Jr;if(e.gt(this.shru(1)))return Xr;n=Jr}else{if(this.eq(tn))return e.eq(Zr)||e.eq(Yr)?tn:e.eq(tn)?Zr:(t=this.shr(1).div(e).shl(1)).eq(Wr)?e.isNegative()?Zr:Yr:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(tn))return this.unsigned?Jr:Wr;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=Wr}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),s=o<=48?1:Gr(2,o-48),i=Fr(t),a=i.mul(e);a.isNegative()||a.gt(r);)a=(i=Fr(t-=s,this.unsigned)).mul(e);i.isZero()&&(i=Zr),n=n.add(i),r=r.sub(a)}return n},rn.div=rn.divide,rn.modulo=function(e){return Lr(e)||(e=Vr(e)),Nr?xr((this.unsigned?Nr.rem_u:Nr.rem_s)(this.low,this.high,e.low,e.high),Nr.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},rn.mod=rn.modulo,rn.rem=rn.modulo,rn.not=function(){return xr(~this.low,~this.high,this.unsigned)},rn.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},rn.clz=rn.countLeadingZeros,rn.countTrailingZeros=function(){return this.low?Dr(this.low):Dr(this.high)+32},rn.ctz=rn.countTrailingZeros,rn.and=function(e){return Lr(e)||(e=Vr(e)),xr(this.low&e.low,this.high&e.high,this.unsigned)},rn.or=function(e){return Lr(e)||(e=Vr(e)),xr(this.low|e.low,this.high|e.high,this.unsigned)},rn.xor=function(e){return Lr(e)||(e=Vr(e)),xr(this.low^e.low,this.high^e.high,this.unsigned)},rn.shiftLeft=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):xr(0,this.low<<e-32,this.unsigned)},rn.shl=rn.shiftLeft,rn.shiftRight=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):xr(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},rn.shr=rn.shiftRight,rn.shiftRightUnsigned=function(e){return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?xr(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):xr(32===e?this.high:this.high>>>e-32,0,this.unsigned)},rn.shru=rn.shiftRightUnsigned,rn.shr_u=rn.shiftRightUnsigned,rn.rotateLeft=function(e){var t;return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?xr(this.high,this.low,this.unsigned):e<32?(t=32-e,xr(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),xr(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},rn.rotl=rn.rotateLeft,rn.rotateRight=function(e){var t;return Lr(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?xr(this.high,this.low,this.unsigned):e<32?(t=32-e,xr(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),xr(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},rn.rotr=rn.rotateRight,rn.toSigned=function(){return this.unsigned?xr(this.low,this.high,!1):this},rn.toUnsigned=function(){return this.unsigned?this:xr(this.low,this.high,!0)},rn.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},rn.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},rn.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Pr.fromBytes=function(e,t,r){return r?Pr.fromBytesLE(e,t):Pr.fromBytesBE(e,t)},Pr.fromBytesLE=function(e,t){return new Pr(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Pr.fromBytesBE=function(e,t){return new Pr(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var nn=new class{_user;constructor(){this._user=this.createDefaultUser()}get uid(){return this.user.uid}get isActive(){return this.user.active}get user(){return this._user}setLogged(e){this._user={active:!0,uid:Pr.isLong(e.uid)?e.uid.toString():e.uid,deviceId:Pr.isLong(e.deviceId)?e.deviceId.toString():e.deviceId,sessionId:Pr.isLong(e.sessionId)?e.sessionId.toString():e.sessionId}}logOut(){this._user=this.createDefaultUser()}createDefaultUser(){return{active:!1,uid:"0",deviceId:"0",sessionId:"0",token:""}}};const on={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const sn=t=>e.ConnectionStatus[t],an=e=>{const t=new kr;return t.writeIn8(67),t.writeIn8(255),t.writeInt32(e.length+7),t.writeArr(Array.from(e)),t.writeIn8(0),new Int8Array(t.getBytesArray()).buffer},cn=e=>{const t=new Ar(new Uint8Array(e));t.readInt8(),t.readInt8();const r=t.readInt32(),n=t.readArr(r-7);if(t.readInt8(),e.byteLength!==r)throw new Error("packet resolve failed");return n};var ln=new class{url="";watcher;options;socket;status=e.ConnectionStatus.DISCONNECTED;autoReconnect=!1;isConnected=!1;responseCallbacks=new Map;failedCount=0;reconnectTimer;connectResolve;pendingMessages=[];constructor(e){this.options=Object.assign(on,e)}setServerInfo(e){this.url=e}setCallback(e){this.watcher=e}async connect(){return this.autoReconnect=!0,new Promise(t=>{this.connectResolve=t,this.open().then(r=>{t(r),r===e.ErrorCode.SUCCESS?(this.isConnected=!0,this.onConnect()):this.onDisconnect(r===e.ErrorCode.TIMEOUT?e.ConnectionStatus.NETWORK_UNAVAILABLE:e.ConnectionStatus.WEBSOCKET_UNAVAILABLE)})})}async request(t,r,n,o=this.options.signalTimeout){const{code:s,data:i}=await this.sendRawData(t,rt(r)&&rt(n.encoder)?n.encoder.encode(r).finish():new Uint8Array,o);if(0!==s)return{code:s,msg:"time out",data:null};if(!rt(i)||!rt(n.decoder))return{code:e.ErrorCode.SUCCESS,msg:""};const a=n.decoder?.decode(i);return a.errorCode?{code:a.errorCode,msg:a.errorMessage,data:null}:{data:a,code:e.ErrorCode.SUCCESS,msg:""}}async send(t,r,n,o=this.options.signalTimeout){const s=await this.request(t,r,n,o);return s.code!==e.ErrorCode.SUCCESS?{code:Mr(s.code),msg:s.msg,data:null}:{data:s.data,code:e.ErrorCode.SUCCESS,msg:s.msg}}async sendRawData(t,r,n=this.options.signalTimeout){if(!this.socket)return{code:e.ErrorCode.RC_NET_CHANNEL_INVALID};const o=this.generateMessageSeq();this.isConnected?this.doSendRawData(t,r,o):this.pendingMessages.push({cmdId:t,body:r,messageSeq:o});const s=await new Promise(e=>{this.responseCallbacks.set(o,e),setTimeout(()=>{this.responseCallbacks.get(o)&&this.responseCallbacks.delete(o),e(null)},n)});return s?{code:0,data:s}:(As.warn(`send timeout -> cmd: 0x${t.toString(16)}, messageSeq: ${o}, timeout: ${n}`),{code:e.ErrorCode.TIMEOUT})}doSendRawData(e,t,r){const n={cmdId:e,messageSeq:Pr.fromNumber(r),deviceId:Pr.fromString(nn.user.deviceId),sessionId:Pr.fromString(nn.user.sessionId),uid:Pr.fromString(nn.user.uid),protocolVersion:0,destId:"",body:t,deviceCode:Rt.getDeviceCode()??"",deviceType:Rt.getDeviceType()};e!==Tt.Heartbean&&As.info(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${r}`),this.socket?.send(an(Ir.encode(n).finish()))}close(){this.autoReconnect=!1,this.doClose(),this.setStatus(e.ConnectionStatus.DISCONNECTED),this.connectResolve?.(e.ErrorCode.RC_SOCKET_DISCONNECTED)}async open(){const t=this.url;As.info(`connect start -> ${t}`),this.setStatus(e.ConnectionStatus.CONNECTING);const r=function(e,t){const r=new WebSocket(e,t);return r.binaryType="arraybuffer",{onClose(e){r.onclose=t=>{const{code:r,reason:n}=t;e?.(r,n)}},onError(e){r.onerror=t=>{e(t)}},onMessage(e){r.onmessage=t=>{e(t.data)}},onOpen(e){r.onopen=e},send(e){r.send(e)},close(e,t){r.close(e,t)}}}(this.url);this.socket=r;return await new Promise(n=>{r.onMessage(e=>{"ArrayBuffer"===tt(e)?this.onReceiveMessage(e):As.error("Socket received invalid data:",e)}),r.onClose((t,r)=>{As.warn("websocket closed -> code:",t,"reason:",r),this.onDisconnect(e.ConnectionStatus.CONNECTION_CLOSED),n(e.ErrorCode.RC_SOCKET_DISCONNECTED)}),r.onError(t=>{As.warn("websocket error -> ",t),this.onDisconnect(e.ConnectionStatus.WEBSOCKET_ERROR),n(e.ErrorCode.RC_SOCKET_NOT_CREATED)}),r.onOpen(()=>{As.info("websocket open -> ",t),n(e.ErrorCode.SUCCESS)}),setTimeout(()=>{n(e.ErrorCode.TIMEOUT)},this.options.webSocketTimeout)})}async checkAlive(){if(!this.socket||!this.isConnected)return;As.debug("send ping ->");const t={pingId:Pr.ZERO,disconnectDelay:Pr.ZERO},{code:r}=await this.send(Tt.Heartbean,t,{encoder:Er},this.options.pingTimeout);r===e.ErrorCode.SUCCESS?(As.debug("recv pong <-"),this.failedCount=0,setTimeout(()=>this.checkAlive(),this.options.pingInterval)):(this.failedCount+=1,As.warn(`ping failed count: ${this.failedCount}, code: ${r}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,As.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.ConnectionStatus.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let r;try{const e=cn(t);r=wr.decode(e)}catch(t){return As.error("unpack payload error -> ",t),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER)}if(r.code)return As.error("on received message error -> ",r.code),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER);if(r.cmdId===Tt.SessionKilledPush)return void this.onDisconnect(e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT);if(r.cmdId===Tt.SignOutPish||r.cmdId===Tt.SignOutPish2)return As.warn("on received signoutpush -> ",r.cmdId),void this.onDisconnect(e.ConnectionStatus.DISCONNECT_BY_SERVER);if(r.cmdId===Tt.UserFrozenToLogin||r.cmdId===Tt.UserFrozenToLogin2)return void this.onDisconnect(e.ConnectionStatus.BLOCKED);const n=Pr.isLong(r.messageSeq)?r.messageSeq.toNumber():0,o=n>0?this.responseCallbacks.get(n):null;rt(o)?(r.cmdId!==Tt.HeartbeanResp&&As.info(`websocket recv ack -> messageSeq: ${n}`),o(r.body),this.responseCallbacks.delete(n)):(As.info(`websocket recv -> cmd: 0x${r.cmdId.toString(16)}`),this.watcher?.message(r.cmdId,r.body))}async try2Reconnect(){this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},5e3)}async onConnect(){for(this.setStatus(e.ConnectionStatus.CONNECTED),this.checkAlive(),rt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);this.pendingMessages.length>0;){let{cmdId:e,body:t,messageSeq:r}=this.pendingMessages.shift();this.doSendRawData(e,t,r),await new Promise(e=>setTimeout(e,200))}}onDisconnect(e){rt(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(rt(this.socket)){this.pendingMessages.length=0;const e=this.socket;this.socket=null,e.onClose(null),e.close()}rt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.isConnected=!1;for(const e of this.responseCallbacks.values())e(null);this.responseCallbacks.clear()}isConnectionAvailable(){return this.status!==e.ConnectionStatus.DISCONNECTED&&this.status!==e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.ConnectionStatus.BLOCKED&&this.status!==e.ConnectionStatus.DISCONNECT_BY_SERVER}setStatus(e){As.info(`socketServer is changing status from ${sn(this.status)} to ${sn(e)}`),this.status=e,this.watcher?.status(e)}idCount=0;generateMessageSeq(){return++this.idCount}};const un=vr.Reader,dn=vr.Writer,gn=vr.util,pn=vr.roots.default||(vr.roots.default={}),fn=pn.SendPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e})(),hn=pn.SendPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e})(),yn=pn.DeletePrivateChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeletePrivateChatDialogReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.destId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e})(),mn=pn.GetNewMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(8).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(16).int32(e.rows),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetNewMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.offset=e.int64();break;case 2:n.rows=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e})(),vn=pn.GetNewMessageResp=(()=>{function e(e){if(this.msg={},this.reference={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msg=gn.emptyObject,e.prototype.reference=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(24).int64(e.offset),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(32).int64(e.seqno),null!=e.msg&&Object.hasOwnProperty.call(e,"msg"))for(let r=Object.keys(e.msg),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.DialogMessageList.encode(e.msg[r[n]],t.uint32(18).fork()).ldelim().ldelim();if(null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let r=Object.keys(e.reference),n=0;n<r.length;++n)t.uint32(50).fork().uint32(10).string(r[n]),pn.ReferenceDialogMessage.encode(e.reference[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetNewMessageResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.offset=e.int64();break;case 4:s.seqno=e.int64();break;case 5:{s.msg===gn.emptyObject&&(s.msg={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.msg[r]=n;break}case 6:{s.reference===gn.emptyObject&&(s.reference={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.reference[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e})();pn.DialogMessageList=(()=>{function e(e){if(this.dialogMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.dialogMessage&&e.dialogMessage.length)for(let r=0;r<e.dialogMessage.length;++r)pn.DialogMessage.encode(e.dialogMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DialogMessageList;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.dialogMessage&&n.dialogMessage.length||(n.dialogMessage=[]),n.dialogMessage.push(pn.DialogMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e})(),pn.DialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.isOut=!1,e.prototype.senderCategory=0,e.prototype.msgCategory=0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.burnAfterReadingFlag=!1,e.prototype.atFlag=!1,e.prototype.replyFlag=!1,e.prototype.referenceFlag=!1,e.prototype.msgIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.replyMarkup="",e.prototype.extra="",e.prototype.msgArrival=!1,e.prototype.msgRead=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(8).int64(e.msgId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgStatus&&Object.hasOwnProperty.call(e,"msgStatus")&&t.uint32(24).int32(e.msgStatus),null!=e.srcId&&Object.hasOwnProperty.call(e,"srcId")&&t.uint32(32).int64(e.srcId),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(40).int64(e.destId),null!=e.isOut&&Object.hasOwnProperty.call(e,"isOut")&&t.uint32(48).bool(e.isOut),null!=e.senderCategory&&Object.hasOwnProperty.call(e,"senderCategory")&&t.uint32(56).int32(e.senderCategory),null!=e.msgCategory&&Object.hasOwnProperty.call(e,"msgCategory")&&t.uint32(64).int32(e.msgCategory),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(74).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(82).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(88).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(96).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(106).string(e.mediaAttribute),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(112).int64(e.msgSendTime),null!=e.burnAfterReadingFlag&&Object.hasOwnProperty.call(e,"burnAfterReadingFlag")&&t.uint32(120).bool(e.burnAfterReadingFlag),null!=e.atFlag&&Object.hasOwnProperty.call(e,"atFlag")&&t.uint32(128).bool(e.atFlag),null!=e.replyFlag&&Object.hasOwnProperty.call(e,"replyFlag")&&t.uint32(136).bool(e.replyFlag),null!=e.referenceFlag&&Object.hasOwnProperty.call(e,"referenceFlag")&&t.uint32(144).bool(e.referenceFlag),null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(152).int64(e.msgIdReferenced),null!=e.uploadFlag&&Object.hasOwnProperty.call(e,"uploadFlag")&&t.uint32(160).bool(e.uploadFlag),null!=e.burnAfterReadingTime&&Object.hasOwnProperty.call(e,"burnAfterReadingTime")&&t.uint32(168).int64(e.burnAfterReadingTime),null!=e.sharingGroupFlag&&Object.hasOwnProperty.call(e,"sharingGroupFlag")&&t.uint32(176).bool(e.sharingGroupFlag),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(184).int64(e.seqno),null!=e.replyMarkup&&Object.hasOwnProperty.call(e,"replyMarkup")&&t.uint32(194).string(e.replyMarkup),null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(202).string(e.extra),null!=e.msgArrival&&Object.hasOwnProperty.call(e,"msgArrival")&&t.uint32(208).bool(e.msgArrival),null!=e.msgRead&&Object.hasOwnProperty.call(e,"msgRead")&&t.uint32(216).bool(e.msgRead),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DialogMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.msgId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgStatus=e.int32();break;case 4:n.srcId=e.int64();break;case 5:n.destId=e.int64();break;case 6:n.isOut=e.bool();break;case 7:n.senderCategory=e.int32();break;case 8:n.msgCategory=e.int32();break;case 9:n.msgPreContent=e.string();break;case 10:n.msgPostContent=e.string();break;case 11:n.mediaFlag=e.bool();break;case 12:n.mediaConstructor=e.int32();break;case 13:n.mediaAttribute=e.string();break;case 14:n.msgSendTime=e.int64();break;case 15:n.burnAfterReadingFlag=e.bool();break;case 16:n.atFlag=e.bool();break;case 17:n.replyFlag=e.bool();break;case 18:n.referenceFlag=e.bool();break;case 19:n.msgIdReferenced=e.int64();break;case 20:n.uploadFlag=e.bool();break;case 21:n.burnAfterReadingTime=e.int64();break;case 22:n.sharingGroupFlag=e.bool();break;case 23:n.seqno=e.int64();break;case 24:n.replyMarkup=e.string();break;case 25:n.extra=e.string();break;case 26:n.msgArrival=e.bool();break;case 27:n.msgRead=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e})(),pn.ReferenceDialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.srcId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.srcName="",e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.destName="",e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(8).int64(e.msgId),null!=e.srcId&&Object.hasOwnProperty.call(e,"srcId")&&t.uint32(16).int64(e.srcId),null!=e.srcName&&Object.hasOwnProperty.call(e,"srcName")&&t.uint32(26).string(e.srcName),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(32).int64(e.destId),null!=e.destName&&Object.hasOwnProperty.call(e,"destName")&&t.uint32(42).string(e.destName),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(50).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(58).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(64).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(72).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(82).string(e.mediaAttribute),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(88).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReferenceDialogMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.msgId=e.int64();break;case 2:n.srcId=e.int64();break;case 3:n.srcName=e.string();break;case 4:n.destId=e.int64();break;case 5:n.destName=e.string();break;case 6:n.msgPreContent=e.string();break;case 7:n.msgPostContent=e.string();break;case 8:n.mediaFlag=e.bool();break;case 9:n.mediaConstructor=e.int32();break;case 10:n.mediaAttribute=e.string();break;case 11:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReferenceDialogMessage"},e})();const bn=pn.UpdatePrivateChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.UpdatePrivateChatDialogStickyConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e})(),Cn=pn.UpdatePrivateChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.UpdatePrivateChatDialogMuteConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.muteFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e})(),On=pn.DeleteChatMessageReq=(()=>{function e(e){if(this.msgIdList=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(let r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeleteChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;case 3:if(n.msgIdList&&n.msgIdList.length||(n.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgIdList.push(e.int64())}else n.msgIdList.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e})();pn.DeletePrivateChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.DeletePrivateChatHistoryReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e})();const Sn=pn.CleanHistoryMessageReq=(()=>{function e(e){if(this.msgIdList=[],this.destIdList=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gn.emptyArray,e.prototype.destIdList=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(let r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}if(null!=e.destIdList&&e.destIdList.length)for(let r=0;r<e.destIdList.length;++r)t.uint32(34).string(e.destIdList[r]);return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.CleanHistoryMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.string();break;case 2:n.msgId=e.int64();break;case 3:if(n.msgIdList&&n.msgIdList.length||(n.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgIdList.push(e.int64())}else n.msgIdList.push(e.int64());break;case 4:n.destIdList&&n.destIdList.length||(n.destIdList=[]),n.destIdList.push(e.string());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e})(),In=pn.GetBriefDialogListReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let r=0;r<e.destId.length;++r)t.int64(e.destId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetBriefDialogListReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)if(n.destId&&n.destId.length||(n.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.destId.push(e.int64())}else n.destId.push(e.int64());else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e})(),wn=pn.GetBriefDialogListResp=(()=>{function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=gn.emptyArray,e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.notExistDestId&&e.notExistDestId.length){t.uint32(26).fork();for(let r=0;r<e.notExistDestId.length;++r)t.int64(e.notExistDestId[r]);t.ldelim()}if(null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(32).int64(e.seqno),null!=e.briefDialog&&Object.hasOwnProperty.call(e,"briefDialog"))for(let r=Object.keys(e.briefDialog),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.BriefDialog.encode(e.briefDialog[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetBriefDialogListResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:if(s.notExistDestId&&s.notExistDestId.length||(s.notExistDestId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)s.notExistDestId.push(e.int64())}else s.notExistDestId.push(e.int64());break;case 4:s.seqno=e.int64();break;case 5:{s.briefDialog===gn.emptyObject&&(s.briefDialog={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.briefDialog[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e})();pn.BriefDialog=(()=>{function e(e){if(this.groupMemberSmallAvatarUrl=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.dialogTitle="",e.prototype.smallAvatarUrl="",e.prototype.backgroundImage="",e.prototype.stickyFlag=!1,e.prototype.muteFlag=!1,e.prototype.blockFlag=!1,e.prototype.burnAfterReadingFlag=!1,e.prototype.takeScreenshotFlag=!1,e.prototype.groupFlag=!1,e.prototype.totalMemberNumber=0,e.prototype.groupMemberSmallAvatarUrl=gn.emptyArray,e.prototype.burnAfterReadingTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.dialogMenuContent="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.dialogTitle&&Object.hasOwnProperty.call(e,"dialogTitle")&&t.uint32(18).string(e.dialogTitle),null!=e.smallAvatarUrl&&Object.hasOwnProperty.call(e,"smallAvatarUrl")&&t.uint32(26).string(e.smallAvatarUrl),null!=e.backgroundImage&&Object.hasOwnProperty.call(e,"backgroundImage")&&t.uint32(34).string(e.backgroundImage),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(40).bool(e.stickyFlag),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(48).bool(e.muteFlag),null!=e.blockFlag&&Object.hasOwnProperty.call(e,"blockFlag")&&t.uint32(56).bool(e.blockFlag),null!=e.burnAfterReadingFlag&&Object.hasOwnProperty.call(e,"burnAfterReadingFlag")&&t.uint32(64).bool(e.burnAfterReadingFlag),null!=e.takeScreenshotFlag&&Object.hasOwnProperty.call(e,"takeScreenshotFlag")&&t.uint32(72).bool(e.takeScreenshotFlag),null!=e.groupFlag&&Object.hasOwnProperty.call(e,"groupFlag")&&t.uint32(80).bool(e.groupFlag),null!=e.totalMemberNumber&&Object.hasOwnProperty.call(e,"totalMemberNumber")&&t.uint32(88).int32(e.totalMemberNumber),null!=e.groupMemberSmallAvatarUrl&&e.groupMemberSmallAvatarUrl.length)for(let r=0;r<e.groupMemberSmallAvatarUrl.length;++r)t.uint32(98).string(e.groupMemberSmallAvatarUrl[r]);return null!=e.burnAfterReadingTime&&Object.hasOwnProperty.call(e,"burnAfterReadingTime")&&t.uint32(104).int64(e.burnAfterReadingTime),null!=e.dialogMenuContent&&Object.hasOwnProperty.call(e,"dialogMenuContent")&&t.uint32(114).string(e.dialogMenuContent),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.BriefDialog;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.dialogTitle=e.string();break;case 3:n.smallAvatarUrl=e.string();break;case 4:n.backgroundImage=e.string();break;case 5:n.stickyFlag=e.bool();break;case 6:n.muteFlag=e.bool();break;case 7:n.blockFlag=e.bool();break;case 8:n.burnAfterReadingFlag=e.bool();break;case 9:n.takeScreenshotFlag=e.bool();break;case 10:n.groupFlag=e.bool();break;case 11:n.totalMemberNumber=e.int32();break;case 12:n.groupMemberSmallAvatarUrl&&n.groupMemberSmallAvatarUrl.length||(n.groupMemberSmallAvatarUrl=[]),n.groupMemberSmallAvatarUrl.push(e.string());break;case 13:n.burnAfterReadingTime=e.int64();break;case 14:n.dialogMenuContent=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e})();const En=pn.GetDialogKeyReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let r=0;r<e.destId.length;++r)t.int64(e.destId[r]);t.ldelim()}return null!=e.clientSign&&Object.hasOwnProperty.call(e,"clientSign")&&t.uint32(18).string(e.clientSign),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetDialogKeyReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:if(n.destId&&n.destId.length||(n.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.destId.push(e.int64())}else n.destId.push(e.int64());break;case 2:n.clientSign=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e})(),Rn=pn.GetDialogKeyResp=(()=>{function e(e){if(this.retryUid=[],this.entry={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.retryUid=gn.emptyArray,e.prototype.entry=gn.emptyObject,e.prototype.serverSign="",e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.dialogKeyVersion&&Object.hasOwnProperty.call(e,"dialogKeyVersion")&&t.uint32(24).int64(e.dialogKeyVersion),null!=e.retryUid&&e.retryUid.length){t.uint32(34).fork();for(let r=0;r<e.retryUid.length;++r)t.int64(e.retryUid[r]);t.ldelim()}if(null!=e.entry&&Object.hasOwnProperty.call(e,"entry"))for(let r=Object.keys(e.entry),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.AesKeyAndIV.encode(e.entry[r[n]],t.uint32(18).fork()).ldelim().ldelim();return null!=e.serverSign&&Object.hasOwnProperty.call(e,"serverSign")&&t.uint32(50).string(e.serverSign),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetDialogKeyResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.dialogKeyVersion=e.int64();break;case 4:if(s.retryUid&&s.retryUid.length||(s.retryUid=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)s.retryUid.push(e.int64())}else s.retryUid.push(e.int64());break;case 5:{s.entry===gn.emptyObject&&(s.entry={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.entry[r]=n;break}case 6:s.serverSign=e.string();break;default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e})();pn.AesKeyAndIV=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.encode=function(e,t){return t||(t=dn.create()),null!=e.aesKey&&Object.hasOwnProperty.call(e,"aesKey")&&t.uint32(10).string(e.aesKey),null!=e.aesIV&&Object.hasOwnProperty.call(e,"aesIV")&&t.uint32(18).string(e.aesIV),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.AesKeyAndIV;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e})();const Tn=pn.RecallPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.RecallPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e})(),_n=pn.GetHistoryMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogKeys="",e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.dialogKeys&&Object.hasOwnProperty.call(e,"dialogKeys")&&t.uint32(10).string(e.dialogKeys),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.oldOffset&&Object.hasOwnProperty.call(e,"oldOffset")&&t.uint32(24).int64(e.oldOffset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(32).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(40).bool(e.newToOld),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetHistoryMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.dialogKeys=e.string();break;case 2:n.offset=e.int64();break;case 3:n.oldOffset=e.int64();break;case 4:n.rows=e.int32();break;case 5:n.newToOld=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e})(),kn=pn.GetHistoryMessageResp=(()=>{function e(e){if(this.reference={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.prototype.reference=gn.emptyObject,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pn.DialogMessageList.encode(e.msg,t.uint32(26).fork()).ldelim(),null!=e.isEnd&&Object.hasOwnProperty.call(e,"isEnd")&&t.uint32(32).bool(e.isEnd),null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let r=Object.keys(e.reference),n=0;n<r.length;++n)t.uint32(42).fork().uint32(10).string(r[n]),pn.ReferenceDialogMessage.encode(e.reference[r[n]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetHistoryMessageResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:s.msg=pn.DialogMessageList.decode(e,e.uint32());break;case 4:s.isEnd=e.bool();break;case 5:{s.reference===gn.emptyObject&&(s.reference={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.reference[r]=n;break}default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e})(),An=pn.GetWebDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.type=0,e.prototype.offset=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dn.create()),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(24).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(32).bool(e.newToOld),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetWebDialogListReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.type=e.int32();break;case 2:n.offset=e.int64();break;case 3:n.rows=e.int32();break;case 4:n.newToOld=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e})(),Mn=pn.GetWebDialogListResp=(()=>{function e(e){if(this.fullDialog=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.fullDialog&&e.fullDialog.length)for(let r=0;r<e.fullDialog.length;++r)pn.WebFullDialog.encode(e.fullDialog[r],t.uint32(26).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetWebDialogListResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.fullDialog&&n.fullDialog.length||(n.fullDialog=[]),n.fullDialog.push(pn.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e})();pn.WebFullDialog=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialog=null,e.prototype.msg=null,e.encode=function(e,t){return t||(t=dn.create()),null!=e.dialog&&Object.hasOwnProperty.call(e,"dialog")&&pn.BriefDialog.encode(e.dialog,t.uint32(10).fork()).ldelim(),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pn.DialogMessage.encode(e.msg,t.uint32(18).fork()).ldelim(),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.WebFullDialog;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.dialog=pn.BriefDialog.decode(e,e.uint32());break;case 2:n.msg=pn.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e})();const Nn=pn.GetNewSettingDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.time=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.GetNewSettingDialogListReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.time=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e})(),Pn=pn.GetNewSettingDialogListResp=(()=>{function e(e){if(this.briefDialog={},e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=gn.emptyObject,e.prototype.setTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.briefDialog&&Object.hasOwnProperty.call(e,"briefDialog"))for(let r=Object.keys(e.briefDialog),n=0;n<r.length;++n)t.uint32(26).fork().uint32(10).string(r[n]),pn.BriefDialog.encode(e.briefDialog[r[n]],t.uint32(18).fork()).ldelim().ldelim();return null!=e.setTime&&Object.hasOwnProperty.call(e,"setTime")&&t.uint32(32).int64(e.setTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r,n,o=void 0===t?e.len:e.pos+t,s=new pn.GetNewSettingDialogListResp;for(;e.pos<o;){let t=e.uint32();switch(t>>>3){case 1:s.errorCode=e.int32();break;case 2:s.errorMessage=e.string();break;case 3:{s.briefDialog===gn.emptyObject&&(s.briefDialog={});let t=e.uint32()+e.pos;for(r="",n=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:r=e.string();break;case 2:n=pn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}s.briefDialog[r]=n;break}case 4:s.setTime=e.int64();break;default:e.skipType(7&t)}}return s},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e})(),Ln=pn.NewMessageNotificationResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(24).int64(e.seqno),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.NewMessageNotificationResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e})();pn.ChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.msgId&&e.msgId.length){t.uint32(18).fork();for(let r=0;r<e.msgId.length;++r)t.int64(e.msgId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ChatMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:if(n.msgId&&n.msgId.length||(n.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgId.push(e.int64())}else n.msgId.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ChatMessage"},e})();const Dn=pn.SendPrivateChatArrivalAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.chatMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.chatMessage&&e.chatMessage.length)for(let r=0;r<e.chatMessage.length;++r)pn.ChatMessage.encode(e.chatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatArrivalAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.chatMessage&&n.chatMessage.length||(n.chatMessage=[]),n.chatMessage.push(pn.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatArrivalAckReq"},e})(),jn=pn.SendPrivateChatReadAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.chatMessage=gn.emptyArray,e.encode=function(e,t){if(t||(t=dn.create()),null!=e.chatMessage&&e.chatMessage.length)for(let r=0;r<e.chatMessage.length;++r)pn.ChatMessage.encode(e.chatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.SendPrivateChatReadAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.chatMessage&&n.chatMessage.length||(n.chatMessage=[]),n.chatMessage.push(pn.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatReadAckReq"},e})(),Un=pn.ReplyPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContentReferenced="",e.prototype.msgPostContentReferenced="",e.prototype.mediaFlagReferenced=!1,e.prototype.mediaConstructorReferenced=0,e.prototype.mediaAttributeReferenced="",e.prototype.msgSendTimeReferenced=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(64).int64(e.msgIdReferenced),null!=e.msgSrcIdReferenced&&Object.hasOwnProperty.call(e,"msgSrcIdReferenced")&&t.uint32(72).int64(e.msgSrcIdReferenced),null!=e.msgDestIdReferenced&&Object.hasOwnProperty.call(e,"msgDestIdReferenced")&&t.uint32(80).int64(e.msgDestIdReferenced),null!=e.msgPreContentReferenced&&Object.hasOwnProperty.call(e,"msgPreContentReferenced")&&t.uint32(90).string(e.msgPreContentReferenced),null!=e.msgPostContentReferenced&&Object.hasOwnProperty.call(e,"msgPostContentReferenced")&&t.uint32(98).string(e.msgPostContentReferenced),null!=e.mediaFlagReferenced&&Object.hasOwnProperty.call(e,"mediaFlagReferenced")&&t.uint32(104).bool(e.mediaFlagReferenced),null!=e.mediaConstructorReferenced&&Object.hasOwnProperty.call(e,"mediaConstructorReferenced")&&t.uint32(112).int32(e.mediaConstructorReferenced),null!=e.mediaAttributeReferenced&&Object.hasOwnProperty.call(e,"mediaAttributeReferenced")&&t.uint32(122).string(e.mediaAttributeReferenced),null!=e.msgSendTimeReferenced&&Object.hasOwnProperty.call(e,"msgSendTimeReferenced")&&t.uint32(128).int64(e.msgSendTimeReferenced),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReplyPrivateChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.destId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:n.msgIdReferenced=e.int64();break;case 9:n.msgSrcIdReferenced=e.int64();break;case 10:n.msgDestIdReferenced=e.int64();break;case 11:n.msgPreContentReferenced=e.string();break;case 12:n.msgPostContentReferenced=e.string();break;case 13:n.mediaFlagReferenced=e.bool();break;case 14:n.mediaConstructorReferenced=e.int32();break;case 15:n.mediaAttributeReferenced=e.string();break;case 16:n.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageReq"},e})(),Bn=pn.ReplyPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=gn.Long?gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gn.Long?gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof un||(e=un.create(e));let r=void 0===t?e.len:e.pos+t,n=new pn.ReplyPrivateChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageResp"},e})(),Fn=vr.Reader,xn=vr.Writer,Gn=vr.util,qn=vr.roots.default||(vr.roots.default={}),Vn=qn.SendGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(let r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:if(n.at&&n.at.length||(n.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.at.push(e.int64())}else n.at.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e})(),Kn=qn.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.seqno=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),null!=e.seqno&&Object.hasOwnProperty.call(e,"seqno")&&t.uint32(48).int64(e.seqno),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();qn.DeleteGroupChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.DeleteGroupChatHistoryReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e})();const Hn=qn.UpdateGroupChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.UpdateGroupChatDialogStickyConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e})(),zn=qn.UpdateGroupChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.UpdateGroupChatDialogMuteConfigReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.muteFlag=e.bool();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e})(),$n=qn.RecallGroupChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.RecallGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.msgId=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e})();qn.DeleteGroupChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.DeleteGroupChatDialogReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupId=e.int64();else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e})(),qn.GroupChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.userId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.userId&&Object.hasOwnProperty.call(e,"userId")&&t.uint32(16).int64(e.userId),null!=e.msgId&&e.msgId.length){t.uint32(26).fork();for(let r=0;r<e.msgId.length;++r)t.int64(e.msgId[r]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.GroupChatMessage;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.userId=e.int64();break;case 3:if(n.msgId&&n.msgId.length||(n.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.msgId.push(e.int64())}else n.msgId.push(e.int64());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GroupChatMessage"},e})();const Wn=qn.SendGroupChatArrivalAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupChatMessage=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let r=0;r<e.groupChatMessage.length;++r)qn.GroupChatMessage.encode(e.groupChatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatArrivalAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupChatMessage&&n.groupChatMessage.length||(n.groupChatMessage=[]),n.groupChatMessage.push(qn.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatArrivalAckReq"},e})(),Jn=qn.SendGroupChatReadAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupChatMessage=Gn.emptyArray,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let r=0;r<e.groupChatMessage.length;++r)qn.GroupChatMessage.encode(e.groupChatMessage[r],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.SendGroupChatReadAckReq;for(;e.pos<r;){let t=e.uint32();if(t>>>3==1)n.groupChatMessage&&n.groupChatMessage.length||(n.groupChatMessage=[]),n.groupChatMessage.push(qn.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatReadAckReq"},e})(),Zn=qn.ReplyGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Gn.emptyArray,e.prototype.msgIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContentReferenced="",e.prototype.msgPostContentReferenced="",e.prototype.mediaFlagReferenced=!1,e.prototype.mediaConstructorReferenced=0,e.prototype.mediaAttributeReferenced="",e.prototype.msgSendTimeReferenced=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=xn.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(let r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return null!=e.msgIdReferenced&&Object.hasOwnProperty.call(e,"msgIdReferenced")&&t.uint32(72).int64(e.msgIdReferenced),null!=e.msgSrcIdReferenced&&Object.hasOwnProperty.call(e,"msgSrcIdReferenced")&&t.uint32(80).int64(e.msgSrcIdReferenced),null!=e.msgDestIdReferenced&&Object.hasOwnProperty.call(e,"msgDestIdReferenced")&&t.uint32(88).int64(e.msgDestIdReferenced),null!=e.msgPreContentReferenced&&Object.hasOwnProperty.call(e,"msgPreContentReferenced")&&t.uint32(98).string(e.msgPreContentReferenced),null!=e.msgPostContentReferenced&&Object.hasOwnProperty.call(e,"msgPostContentReferenced")&&t.uint32(106).string(e.msgPostContentReferenced),null!=e.mediaFlagReferenced&&Object.hasOwnProperty.call(e,"mediaFlagReferenced")&&t.uint32(112).bool(e.mediaFlagReferenced),null!=e.mediaConstructorReferenced&&Object.hasOwnProperty.call(e,"mediaConstructorReferenced")&&t.uint32(120).int32(e.mediaConstructorReferenced),null!=e.mediaAttributeReferenced&&Object.hasOwnProperty.call(e,"mediaAttributeReferenced")&&t.uint32(130).string(e.mediaAttributeReferenced),null!=e.msgSendTimeReferenced&&Object.hasOwnProperty.call(e,"msgSendTimeReferenced")&&t.uint32(136).int64(e.msgSendTimeReferenced),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.ReplyGroupChatMessageReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.groupId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgPreContent=e.string();break;case 4:n.msgPostContent=e.string();break;case 5:n.mediaFlag=e.bool();break;case 6:n.mediaConstructor=e.int32();break;case 7:n.mediaAttribute=e.string();break;case 8:if(n.at&&n.at.length||(n.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.at.push(e.int64())}else n.at.push(e.int64());break;case 9:n.msgIdReferenced=e.int64();break;case 10:n.msgSrcIdReferenced=e.int64();break;case 11:n.msgDestIdReferenced=e.int64();break;case 12:n.msgPreContentReferenced=e.string();break;case 13:n.msgPostContentReferenced=e.string();break;case 14:n.mediaFlagReferenced=e.bool();break;case 15:n.mediaConstructorReferenced=e.int32();break;case 16:n.mediaAttributeReferenced=e.string();break;case 17:n.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageReq"},e})(),Xn=qn.ReplyGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Gn.Long?Gn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=xn.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(24).int64(e.localId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(32).int64(e.msgId),null!=e.msgSendTime&&Object.hasOwnProperty.call(e,"msgSendTime")&&t.uint32(40).int64(e.msgSendTime),t},e.decode=function(e,t){e instanceof Fn||(e=Fn.create(e));let r=void 0===t?e.len:e.pos+t,n=new qn.ReplyGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageResp"},e})();function Yn(t){return(lt(t)?Pr.fromString(t):t).greaterThan(Pr.fromNumber(9e10))?e.ConversationType.GROUP:e.ConversationType.PRIVATE}const Qn=e=>e.targetId,eo=e=>({conversationType:Yn(e),targetId:Pr.isLong(e)?e.toString():e});let to=0;const ro=async()=>{const t=(new Date).getTime(),{code:r,data:n}=await ln.send(Tt.GetServerTime,null,{decoder:Rr});if(r===e.ErrorCode.SUCCESS){const{currentTimeMillis:e}=n;to=e.toNumber()-t}},no=()=>(new Date).getTime()+to,oo=new Set;var so={addMessage(e){oo.add(e)},remove(e){oo.delete(e)},has:e=>oo.has(e),reset(){oo.clear()}};const io=new Set;var ao={addMessage(e){io.add(e)},remove(e){io.delete(e)},has:e=>io.has(e),reset(){io.clear()}};const co=new Map;function lo(e,t){co.set(e,t)}function uo(e,t){const r=co.get(e);if(!r)return console.warn(`No message constructor found for type: ${e}`),null;try{return new r(t)}catch(t){return console.error(`Failed to decode message type ${e}:`,t),null}}var go=new class{aesKeyRecord=new Map;async getDialogAesKey(e){return ut(e)?this.aesKeyRecord.has(e)?this.aesKeyRecord.get(e):new Promise(t=>{this.getDialogAesKeyListFromRemote([e]).then(r=>{t(r.get(e))}),setTimeout(()=>{t(null)},8e3)}):null}getDialogAesKeyList(e){return new Promise(t=>{const r=new Map;this.getDialogAesKeyListInBatches(e,(n,o)=>{if(o.size)for(const[e,t]of o)r.set(e,t);(r.size===e.length||n)&&t(r)})})}getDialogAesKeyListInBatches(e,t){const r=new Map,n=[];e.forEach(e=>{if(!ut(e))return;const t=this.getDialogAesKeyFromLocal(e);t?r.set(e,t):n.push(e)}),t(!1,r),n.length&&this.getDialogAesKeyListFromRemote(n).then(e=>{t(!0,e)})}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(t){if(!t.length)return new Map;try{const{code:n,data:o}=await(r=t.map(e=>Pr.fromString(e)),ln.send(Tt.GetDialogKey,{destId:r,clientSign:""},{encoder:En,decoder:Rn}));if(n===e.ErrorCode.SUCCESS){const e=new Map;for(const t in o.entry){const r=o.entry[t];if(r.aesKey?.length&&r.aesIV?.length){const n={key:r.aesKey,iv:r.aesIV};e.set(t,n),this.aesKeyRecord.set(t,n)}}return e}}catch(e){As.error("getDialogAesKeyListFromRemote error",e)}var r;return new Map}getDialogAesKeyFromLocal(e){return ut(e)?this.aesKeyRecord.get(e):null}};const po="time",fo=(e,t)=>[e,t,po].join("_");class ho{appkey;userId;inBoxOffset=Pr.ZERO;constructor(e,t){this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=fo(this.appkey,this.userId);Ct.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=fo(this.appkey,this.userId);this.inBoxOffset=Pr.fromString(Ct.get(e)??"0")}return this.inBoxOffset}}const yo=(e,t)=>{if(!ut(e))return"";const r=et.AES.encrypt(e,et.enc.Utf8.parse(t.key),{iv:rt(t.iv)?et.enc.Utf8.parse(t.iv):void 0});return Array.from(vo(r.ciphertext.words)).map(e=>e.toString(16).padStart(2,"0")).join("")},mo=(e,t)=>{const r=new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))||[]),n=window.btoa(String.fromCharCode(...r));return et.AES.decrypt(n,et.enc.Utf8.parse(t.key),{iv:rt(t.iv)?et.enc.Utf8.parse(t.iv):void 0}).toString(et.enc.Utf8)},vo=e=>{const t=[];let r,n,o;for(n=0;n<e.length;++n)for(r=e[n],o=3;o>=0;--o)t.push(r>>8*o&255);return new Uint8Array(t)},bo={TEXT:0,IMAGE:805310464,GIF:805310475,FILE:805310490,AUDIO:805310481,VIDEO:805310470,RECALL:1610678301,LOCATION:805310469,CHAT_RECORD:805310489,CONTACT:268439554,GROUP_INVITATION:805310467,REDPACKET:268439616,TRANSFER:268439600,LINK:268439556},Co={GROUP_ARRIVAL_RECEIPT:1610743844,GROUP_READ_RECEIPT:1610743845,PRIVATE_ARRIVAL_RECEIPT:1610678284,PRIVATE_READ_RECEIPT:1610678285,PRIVATE_OPEN_BURNAFTERREADING:1610678274,PRIVATE_CLOSE_BURNAFTERREADING:1610678275,GROUP_OPEN_BURNAFTERREADING:1610743816,GROUP_CLOSE_BURNAFTERREADING:1610743817};function Oo(e){if(!rt(e))return e;if(Array.isArray(e))return e.map(e=>Oo(e));if(at(e)){const t={};return Object.keys(e).forEach(r=>{t[r]=Oo(e[r])}),t}return e}const So={unreadMessageCount:{keyName:"c",defaultVal:0},lastUnreadTime:{keyName:"lt",defaultVal:0},notificationStatus:{keyName:"nc",defaultVal:2},notificationLevel:{keyName:"nl",defaultVal:0},isTop:{keyName:"it",defaultVal:!1},mentionedUIds:{keyName:"mu",defaultVal:null},dialogTitle:{keyName:"dt",defaultVal:null},smallAvatarUrl:{keyName:"sa",defaultVal:null},burnAfterReadingFlag:{keyName:"brf",defaultVal:!1},burnAfterReadingTime:{keyName:"brt",defaultVal:0},updateTime:{keyName:"ut",defaultVal:0}};class Io{localStore;constructor(e,t){const r=`con-${e}-${t}`;this.localStore=new St(r)}getStoreKey(e){return`${e.conversationType}_${e.targetId}\n }`}getConOptionByKey(t){const r=(t=t||"").split("_");if(r.length>=2){const e=r.shift(),t=r.shift();return{conversationType:Number(e),targetId:t}}return{conversationType:e.ConversationType.PRIVATE,targetId:"0"}}updateUnreadCount(t){const{conversationType:r,targetId:n,content:o,messageType:s,sentTime:i,isCounted:a,messageDirection:c}=t,l=c===e.MessageDirection.SEND,u=s===bo.RECALL,d=at(o),g={conversationType:r,targetId:n},p=this.get(g)||{},f=p.lastUnreadTime||Pr.ZERO,h=p.unreadMessageCount||0;if(!(i<=f)&&!l){if(a&&(p.unreadMessageCount=h+1,f||(p.lastUnreadTime=i)),u&&d){o.sentTime>=f&&h&&(p.unreadMessageCount=h-1)}this.set(g,p)}}updateMentionedData(t){const{conversationType:r,targetId:n,messageUId:o,messageType:s,isMentioned:i,messageDirection:a,content:c}=t;if(!o||a===e.MessageDirection.SEND||!i&&s!==bo.RECALL)return;const l=this.getStoreKey({conversationType:r,targetId:n}),u=this.localStore.get(l)||{},d=So.mentionedUIds.keyName,g=u[d]||[];if(i&&r===e.ConversationType.GROUP&&(g.includes(o.toString())||g.push(o.toString())),s===bo.RECALL&&r===e.ConversationType.GROUP){const e=c,t=g.indexOf(e.messageUId?.toString()??"");t>=0&&g.splice(t,1)}g.length?u[d]=g:delete u[d],dt(u)?this.localStore.set(l,u):this.localStore.remove(l)}updateUpdateTime(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};n[So.updateTime.keyName]=t,this.localStore.set(r,n)}set(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};for(const e of pt(t)){const r=So[e],o=t[e];if(st(r?.keyName)||st(o))continue;o===r.defaultVal?delete n[r.keyName]:n[r.keyName]=o,n[So.unreadMessageCount.keyName]||(delete n[So.lastUnreadTime.keyName],delete n[So.mentionedUIds.keyName])}dt(n)?this.localStore.set(r,n):this.localStore.remove(r)}remove(e){const t=this.getStoreKey(e);this.localStore.remove(t)}get(e){const t=this.getStoreKey(e),r=this.localStore.get(t)||{},n={};for(const e of pt(So)){const{keyName:t,defaultVal:o}=So[e];"mentionedUIds"===e?(n.unreadMentionedCount=r[t]?.length??0,n.hasMentioned=!!n.unreadMentionedCount):n[e]=r[t]||Oo(o)}return n}getAll(){const e=this.localStore.getCache()||{},t=[];for(const r in e){const n=this.getConOptionByKey(r),o=e[r];for(const e of pt(So)){const{keyName:t,defaultVal:r}=So[e];"mentionedUIds"!==e&&(n[e]=o[t]||Oo(r))}t.push(n)}return t}}const wo=t=>{const r=t.destId??"",n=eo(r);if(!n)return;t.dialogTitle,t.smallAvatarUrl;return{...n,unreadMessageCount:0,notificationStatus:t.muteFlag?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,notificationLevel:t.muteFlag?e.NotificationLevel.NOT_MESSAGE_NOTIFICATION:e.NotificationLevel.ALL_MESSAGE,isTop:!!t.stickyFlag,dialogTitle:t.dialogTitle,smallAvatarUrl:t.smallAvatarUrl,lastUnreadTime:"0",burnAfterReadingFlag:!!t.burnAfterReadingFlag,burnAfterReadingTime:t.burnAfterReadingTime&&t.burnAfterReadingTime.toNumber()}};class Eo{events={};on(e,t,r){const n=this.events[e]||(this.events[e]=[]);n.some(e=>e.listener===t&&e.target===r)||n.push({listener:t,target:r})}emit(e,...t){const r=this.events[e];r?.length&&r.map(e=>{const{target:r,listener:n}=e;try{n.call(r,...t)}catch(e){}})}off(e,t,r){let n=this.events[e];n?.length&&(n=n.filter(e=>e.listener!==t||e.target!==r),n.length?this.events[e]=n:delete this.events[e])}once(e,t,r){const n=(...o)=>{t.call(r,...o),this.off(e,n,r)};return this.on(e,n,r),this}}const Ro="STATUS_CHANGED";class To{storageKey;eventEmitter;isPulling=!1;constructor(e,t){this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new Eo}async pull(){if(this.isPulling)return;let t;this.isPulling=!0;const r=Ct.get(this.storageKey);t=nt(r)&&r>0?r:no()-1e4;let{code:n,data:o}=await(e=>ln.send(Tt.GetDialogChangedStatus,{time:Pr.fromNumber(e)},{encoder:Nn,decoder:Pn}))(t);n===e.ErrorCode.SUCCESS&&(Pr.isLong(o.setTime)&&o.setTime.toNumber()>0&&Ct.set(this.storageKey,o.setTime.toNumber()),o.briefDialog&&pt(o.briefDialog).forEach(e=>{const t=o.briefDialog[e],r=wo(t);r&&this.eventEmitter.emit(Ro,r)})),this.isPulling=!1}watch(e){this.eventEmitter.on(Ro,t=>{e(t)})}}class _o{updatedConversationFunc;store;draftMap=new Map;localConversationSet=new Set;updatedConversations=[];notify;statusManager;constructor(e,t,r){this.updatedConversationFunc=r,this.store=new Io(e,t),this.notify=ht(this.notifyConversationChanged.bind(this),0),this.statusManager=new To(e,t),this.statusManager.watch(e=>{this.addStatus(e,!0)})}getConversationKey(e){return`${e.conversationType}_${e.targetId}\n }`}setUpdatedConversation(e){const t=this.updatedConversations.findIndex(t=>this.getConversationKey(e.conversation)===this.getConversationKey(t.conversation));t>=0?(e={conversation:Object.assign(this.updatedConversations[t].conversation,e.conversation),updatedItems:Object.assign(this.updatedConversations[t].updatedItems,e.updatedItems)},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){const e=this.updatedConversations.map(e=>({conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems}));this.updatedConversations=[],this.updatedConversationFunc?.(e)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(t){if(!t?.length)return;const r=t.filter(e=>!this.localConversationSet.has(this.getConversationKey(e)));if(!r.length)return;const n=r.map(Qn);if(!n.length)return;const{code:o,data:s}=await(e=>ln.send(Tt.GetBriefDialogList,{destId:e.map(e=>Pr.fromString(e))},{encoder:In,decoder:wn}))(n);o===e.ErrorCode.SUCCESS&&pt(s.briefDialog).forEach(e=>{const t=s.briefDialog[e],r=wo(t);r&&(this.localConversationSet.add(this.getConversationKey(r)),this.addStatus(r,!0))})}addLocalConversation(e){const{conversationType:t,targetId:r,isTop:n,notificationStatus:o,notificationLevel:s,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:r,isTop:n,notificationStatus:o,notificationLevel:s,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u},!1)}addStatus(e,t=!1){const{conversationType:r,targetId:n,notificationStatus:o,notificationLevel:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}=e,g={conversationType:r,targetId:n},p=no(),f=this.store.get(g),h={};rt(s)&&f.notificationLevel!==s&&(h.notificationLevel={time:p,val:s}),rt(o)&&f.notificationStatus!==o&&(h.notificationStatus={time:p,val:o}),rt(i)&&f.isTop!==i&&(h.isTop={time:p,val:i}),rt(a)&&f.dialogTitle!==a&&(h.dialogTitle={time:p,val:a}),rt(c)&&f.smallAvatarUrl!==c&&(h.smallAvatarUrl={time:p,val:c}),rt(l)&&f.burnAfterReadingFlag!==l&&(h.burnAfterReadingFlag={time:p,val:l}),rt(u)&&f.burnAfterReadingTime!==u&&(h.burnAfterReadingTime={time:p,val:u}),this.store.set(g,{notificationStatus:o,isTop:i,notificationLevel:s,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}),Object.keys(h).length&&t&&this.setUpdatedConversation({conversation:g,updatedItems:h})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:r,targetId:n}=e;if(!r)return;const o={conversationType:t,targetId:n},s={conversation:o,updatedItems:{}},i=Oo(this.get(o));this.store.updateUnreadCount(e),this.store.updateMentionedData(e),this.store.updateUpdateTime(o,parseInt(e.sentTime));const a=this.get(o);i.unreadMessageCount!==a.unreadMessageCount&&(s.updatedItems.unreadMessageCount={time:parseInt(e.sentTime),val:a.unreadMessageCount}),i.hasMentioned!==a.hasMentioned&&(s.updatedItems.hasMentioned={time:parseInt(e.sentTime),val:a.hasMentioned}),i.unreadMentionedCount!==a.unreadMentionedCount&&(s.updatedItems.unreadMentionedCount={time:parseInt(e.sentTime),val:a.unreadMentionedCount}),Object.keys(s.updatedItems).length&&this.setUpdatedConversation(s)}get(e){return this.store.get(e)}getAllUnreadCount(t,r){const n=this.store.getAll();let o=0;return n.forEach(({unreadMessageCount:n,notificationStatus:s,notificationLevel:i,conversationType:a})=>{n=n||0;const c=s===e.NotificationStatus.OPEN||i>0;!r&&c||(t.length>0?t.includes(+a)&&(o+=+n):o+=+n)}),o}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:r,unreadMentionedCount:n}=t;(r||n)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const o={};r&&(o.unreadMessageCount={val:0,time:no()}),n&&(o.hasMentioned={val:!1,time:no()},o.unreadMentionedCount={val:0,time:no()}),Object.keys(o).length&&this.setUpdatedConversation({conversation:e,updatedItems:o})}clearAllUnreadCount(){this.store.getAll().forEach(e=>this.clearUnreadCount(e))}getNotificationLevel(e){return this.store.get(e).notificationLevel}getNotificationStatus(e){return this.store.get(e).notificationStatus||2}setDraft(e,t){this.draftMap.set(this.getConversationKey(e),t)}getDraft(e){return this.draftMap.get(this.getConversationKey(e))??""}clearDraft(e){this.draftMap.delete(this.getConversationKey(e))}getBlockConversationList(){return this.store.getAll().filter(t=>t.notificationStatus===e.NotificationStatus.OPEN||t.notificationLevel>0).map(e=>({conversationType:e.conversationType,targetId:e.targetId}))}getTopConversationList(){return(this.store.getAll()||{}).filter(e=>e.isTop).map(e=>({conversationType:e.conversationType,targetId:e.targetId}))}getUnreadMentionedCount(e){return this.get(e).unreadMentionedCount||0}getAllUnreadMentionedCount(){const e=this.store.getAll();let t=0;return e.forEach(({unreadMentionedCount:e})=>{e=e||0,t+=Number(e)}),t}getConversationState(e){let t=this.get(e);if(t){let{unreadMessageCount:r,unreadMentionedCount:n,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}=t;return{...e,unreadCount:r,unreadMentionedCount:n??0,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}}return null}getAllConversationState(){return this.store.getAll().map(({conversationType:e,targetId:t,unreadMessageCount:r,unreadMentionedCount:n,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l})=>({conversationType:e,targetId:t,unreadCount:r,unreadMentionedCount:n??0,notificationLevel:o,notificationStatus:s,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}))}remove(e){this.store.remove(e),this.localConversationSet.delete(this.getConversationKey(e))}clearHistoryMessages(e){this.clearUnreadCount(e);const t={conversation:e,updatedItems:{}};t.conversation.latestMessage=void 0,t.updatedItems.latestMessage={val:null,time:no()},this.setUpdatedConversation(t)}updateLatestMessage(e,t){rt(t)&&this.store.set(e,{updateTime:parseInt(t.sentTime)});const r={conversation:e,updatedItems:{}};rt(t)&&(r.conversation.updateTime=parseInt(t.sentTime)),r.conversation.latestMessage=t,r.updatedItems.latestMessage={val:t,time:no()},this.setUpdatedConversation(r)}destroyed(){this.updatedConversationFunc=void 0}}const ko={addStatus:function(e,t){},setConversationCacheByMessage:function(e){},updateLatestMessage:function(e,t){},get:function(e){return null},getAllUnreadCount:function(e,t){return 0},getUnreadCount:function(e){return 0},clearUnreadCount:function(e){},clearAllUnreadCount(){},getNotificationLevel:function(t){return e.NotificationLevel.NOT_SET},getNotificationStatus:function(t){return e.NotificationStatus.CLOSE},setDraft:function(e,t){},getDraft:function(e){return""},clearDraft:function(e){},getBlockConversationList:function(){return[]},getTopConversationList:function(){return[]},getUnreadMentionedCount:function(e){return 0},getAllUnreadMentionedCount:function(){return 0},getConversationState:e=>null,getAllConversationState:function(){return[]},addLocalConversation:function(e){},loadConvsationsIfNotExist:function(e){return Promise.resolve()},destroyed(){},syncConversationStatus:function(){},remove:function(e){},clearHistoryMessages:function(e){}};let Ao;var Mo={create(e,t,r){Ao=new _o(e,t,r)},get:()=>Ao??ko};const No=(t,r,n=e.SentStatus.SENDING)=>{const o=Mo.get().get(r.conversation);return{conversationType:r.conversation.conversationType,targetId:r.conversation.targetId,senderUserId:r.senderUserId,messageDirection:e.MessageDirection.SEND,isCounted:t.isCounted,isMentioned:!1,content:Oo(t.content),messageType:t.messageType,isOffLineMessage:!1,isPersited:t.isPersited,messageId:r.messageId,messageUId:"local"+r.sentTime,sentTime:r.sentTime,sentStatus:n,receivedTime:r.sentTime,isStatusMessage:t.isStatusMessage,receivedStatus:e.ReceivedStatus.IDLE,disableNotification:!0,burnAfterReadingFlag:o?.burnAfterReadingFlag??!1,burnAfterReadingTime:o?.burnAfterReadingTime??0}};function Po(e){const t={...e};return"content"in t&&delete t.content,"quotedReply"in t&&delete t.quotedReply,"msgPreContent"in t&&delete t.msgPreContent,"msgPostContent"in t&&delete t.msgPostContent,t}const Lo=(e,t,r,n)=>{const o=new Map;return e.forEach(e=>{const s=Do(e,t.get(e),r.get(e),n);s.length&&o.set(e,s)}),o},Do=(t,r,n,o)=>{const s=eo(t);if(!s)return[];const i=Mo.get().get(s);let a=[];return r.forEach(t=>{const r=t;let c=r.mediaConstructor,l=jo(r,n);if(!l)return;if(1610678290===c||1610743841===c){const{msgId:e}=l;c=bo.RECALL,l={messageUId:e}}const u=uo(c,l);if(rt(u)){const c={...s,senderUserId:r.srcId.toString(),messageDirection:r.isOut?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:u.isCounted,isMentioned:r.atFlag,content:u.content,messageType:u.messageType,isOffLineMessage:!1,isPersited:u.isPersited,messageId:Pr.isLong(r.localId)?r.localId.toNumber():0,messageUId:r.msgId.toString(),sentTime:r.seqno.toString(),sentStatus:e.SentStatus.SENT,receivedTime:no().toString(),isStatusMessage:u.isStatusMessage,receivedStatus:r.msgRead?e.ReceivedStatus.READ:r.msgArrival?e.ReceivedStatus.RECEIVED:e.ReceivedStatus.IDLE,disableNotification:i?.notificationStatus===e.NotificationStatus.OPEN||r.srcId.toString()==nn.uid,burnAfterReadingFlag:r.burnAfterReadingFlag,burnAfterReadingTime:r.burnAfterReadingTime&&r.burnAfterReadingTime.toNumber()};if(c.isStatusMessage&&Pr.fromNumber(no()).subtract(c.sentTime).greaterThan(6e3))return;if(r.msgIdReferenced&&Pr.isLong(r.msgIdReferenced)){const t=o[r.msgIdReferenced.toString()];if(t){let r=jo({mediaAttribute:t.mediaAttribute,msgPreContent:t.msgPreContent,msgPostContent:t.msgPostContent,mediaConstructor:t.mediaConstructor??0,msgId:t.msgId??Pr.fromNumber(0)},n);if(r){const n=uo(t.mediaConstructor??0,r);rt(n)&&(c.quotedReply=((t,r,n)=>({conversationType:n.conversationType,targetId:t.destId.toString(),senderUserId:t.srcId.toString(),messageDirection:t.srcId.toString()===nn.uid?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:r.isCounted,isMentioned:!1,content:Oo(r.content),messageType:r.messageType,isOffLineMessage:!1,isPersited:r.isPersited,messageId:1,messageUId:t.msgId.toString(),sentTime:t.msgSendTime.toString(),sentStatus:e.SentStatus.SENT,receivedTime:t.msgSendTime.toString(),isStatusMessage:r.isStatusMessage,receivedStatus:e.ReceivedStatus.RECEIVED,disableNotification:!0,burnAfterReadingFlag:!1,burnAfterReadingTime:0,senderUserName:t.srcName}))(t,n,s))}}}ut(c.messageUId)?a.push(c):As.error("message is invalid",Po(t))}}),a},jo=(e,t)=>{try{let r,n;return r=e.mediaAttribute?.length?mo(e.mediaAttribute,t):e.msgPreContent??"",e.msgPostContent?.length&&(n=mo(e.msgPostContent,t)),Uo(e.mediaConstructor,r,n)}catch(t){return As.error("decode message content fail",e,t),null}},Uo=(e,t,r)=>{let n={};if(e==bo.TEXT&&r)n.content=r;else if(t?.length){const e=Bo(t);n=JSON.parse(e)}return n},Bo=e=>{let t=e.replace(/("[\w\d_]+"\s*:\s*)(?<!\d\.)(\d{15,})(?!\.\d*)([\s,}\]])/g,'$1"$2"$3');return t=t.replace(/(\[\s*|,\s*)(?<!\d\.)(\d{15,})(?!\.\d*)([\s,\]])/g,'$1"$2"$3'),t};var Fo={parse:function(e,t,r){const n=new Map;if(Object.keys(e).forEach(t=>{const r=e[t].dialogMessage?.filter(e=>!e.sharingGroupFlag);r?.length&&n.set(t,r)}),!n.size)return void r(!0,new Map);const o=new Set([...n.keys()]);go.getDialogAesKeyListInBatches([...n.keys()],(e,s)=>{try{if(s.size){const e=[...s.keys()];for(const t of e)o.delete(t);r(!o.size,Lo(e,n,s,t))}o.size&&e&&r(!0,new Map)}catch(t){As.error("parseDialogsMessages error",t),o.size&&e&&r(!0,new Map)}})},parseSingleDialogMessages:Do,decodeChatRecordMsgDetails2ReceivedMessages:(t,r)=>{let n=[];return r.forEach(r=>{const o=Uo(r.mediaConstructor,r.mediaAttribute,r.msgPostContent);if(!o)return;const s=uo(r.mediaConstructor,o);if(rt(s)){const o={...t,senderUserId:r.srcId.toString(),messageDirection:r.srcId==nn.uid?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isCounted:s.isCounted,isMentioned:!1,content:s.content,messageType:s.messageType,isOffLineMessage:!1,isPersited:s.isPersited,messageId:0,messageUId:r.msgId+"",sentTime:r.msgSendTime+"",sentStatus:e.SentStatus.SENT,receivedTime:r.msgSendTime+"",isStatusMessage:s.isStatusMessage,receivedStatus:e.ReceivedStatus.READ,disableNotification:!1};n.push(o)}}),n},encodeReceivedMessage2ChatRecordMsgDetail:e=>{const t=uo(e.messageType,e.content);if(!t)return null;const r=JSON.stringify(t.content),n=e.messageType===bo.TEXT?t.content.content:void 0;return{senderNickname:e.senderNickname,senderAvatar:e.senderAvatar||void 0,msgId:e.messageUId,srcId:e.senderUserId,destId:e.targetId,mediaConstructor:e.messageType,mediaAttribute:r,msgPostContent:n,msgSendTime:e.sentTime}}};const xo="unreadMessageUids";class Go{localStore;constructor(e,t){const r=`receipt-v2-${e}-${t}`;this.localStore=new St(r)}storeUnreadMessageUids(t){const r=t.filter(t=>t.isCounted&&t.messageDirection!==e.MessageDirection.SEND).map(e=>({uid:e.messageUId,timestamp:Date.now()})),n=[...this.localStore.get(xo)||[],...r];this.localStore.set(xo,n)}cleanExpiredMessages(){const e=this.localStore.get(xo)||[],t=Date.now(),r=e.filter(e=>t-e.timestamp<=1728e5);this.localStore.set(xo,r)}formatReceiptMessages(t){const r=[],n=[];t.forEach(t=>{t.conversationType===e.ConversationType.PRIVATE?r.push(t):n.push(t)});return{privateReceiptMessages:Object.entries(r.reduce((e,t)=>(e[t.targetId]||(e[t.targetId]=[]),e[t.targetId].push(t.messageUId),e),{})).map(([e,t])=>({destId:Pr.fromString(e),msgId:t.map(e=>Pr.fromString(e))})),groupReceiptMessages:n.reduce((e,t)=>{const r=e.find(e=>e.groupId.equals(Pr.fromString(t.targetId))&&e.userId.equals(Pr.fromString(t.senderUserId)));return r?r.msgId.push(Pr.fromString(t.messageUId)):e.push({groupId:Pr.fromString(t.targetId),userId:Pr.fromString(t.senderUserId),msgId:[Pr.fromString(t.messageUId)]}),e},[])}}filterValidMessages(t){return t.filter(t=>t.isCounted&&t.messageDirection!==e.MessageDirection.SEND)}async sendArrivalReceipts(e){this.storeUnreadMessageUids(e);const t=this.filterValidMessages(e),{privateReceiptMessages:r,groupReceiptMessages:n}=this.formatReceiptMessages(t);var o;r.length&&await(o={chatMessage:r},ln.send(Tt.SendPrivateChatArrivalAck,o,{encoder:Dn,decoder:Tr})),n.length&&await(e=>ln.send(Tt.SendGroupChatReadAck,e,{encoder:Jn,decoder:Tr}))({groupChatMessage:n})}async sendReadReceipts(e){const t=this.localStore.get(xo)||[],r=this.filterValidMessages(e).filter(e=>t.some(t=>t.uid===e.messageUId));try{const{privateReceiptMessages:e,groupReceiptMessages:t}=this.formatReceiptMessages(r);e.length&&await(n={chatMessage:e},ln.send(Tt.SendPrivateChatReadAck,n,{encoder:jn,decoder:Tr})),t.length&&await(e=>ln.send(Tt.SendGroupChatArrivalAck,e,{encoder:Wn,decoder:Tr}))({groupChatMessage:t});const o=this.localStore.get(xo)||[],s=r.map(e=>e.messageUId),i=o.filter(e=>!s.includes(e.uid));this.localStore.set(xo,i)}catch(e){throw console.error("发送已读回执失败:",e),e}var n}}let qo;var Vo={create(e,t){qo=new Go(e,t),qo.cleanExpiredMessages()},get:()=>qo};let Ko=0,Ho=0;function zo(e,t){Ko=e+100,Ho=t+100}function $o(){return Ho++,Ho}function Wo(){return Ko--,Ko}function Jo(){return Ho}class Zo{loadedEndMap=new Map;db=null;currentAppKey="";currentUserId="";APP_INFO_KEY="im_app_info";DB_NAME_PREFIX="im_message_cache_1";DB_VERSION=2;STORE_NAME="messages_new";DIALOG_STATE_STORE="dialogStates_new";encryptKey={key:""};SALT_PREFIX="im_message_cache_salt_prefix";SALT_SUFFIX="im_message_cache_salt_suffix";constructor(e,t){this.generateEncryptKey(e,t),this.currentAppKey=e,this.currentUserId=t}generateEncryptKey(e,t){const r=`${this.SALT_PREFIX}${e}_${t}${this.SALT_SUFFIX}`,n=et.SHA256(r).toString(),o=n.substring(0,16),s=n.substring(16,48),i=et.SHA256(`${o}:${this.SALT_PREFIX}:${t}:${e}`).toString().substring(0,8),a=et.PBKDF2(s,i,{keySize:8,iterations:1e3,hasher:et.algo.SHA256}).toString();this.encryptKey={key:a.substring(0,32),iv:o}}async initDB(){await this.checkAndResetDatabase(),await this.initDatabase()}async checkAndResetDatabase(){const e=bt.get(this.APP_INFO_KEY);if(e)try{const t=JSON.parse(e);t.appKey===this.currentAppKey&&t.userId===this.currentUserId||await this.deleteDatabase()}catch(e){As.error("Failed to parse stored AppKey and UserId",e),await this.deleteDatabase()}bt.set(this.APP_INFO_KEY,JSON.stringify({appKey:this.currentAppKey,userId:this.currentUserId,timestamp:Date.now()}))}async deleteDatabase(){return this.db&&(this.db.close(),this.db=null),this.loadedEndMap.clear(),new Promise((e,t)=>{const r=this.getDBName(),n=indexedDB.deleteDatabase(r);n.onsuccess=()=>{As.info(`Database ${r} successfully deleted`),e()},n.onerror=t=>{As.error(`Failed to delete database ${r}`,t),e()}})}getDBName(){return`${this.DB_NAME_PREFIX}_${this.currentAppKey}_${this.currentUserId}`}initDatabase(){return new Promise((e,t)=>{const r=this.getDBName(),n=indexedDB.open(r,this.DB_VERSION);n.onerror=e=>{As.error("Failed to open database",e),t(new Error("Failed to open database"))},n.onsuccess=t=>{this.db=t.target.result,this.loadAllDialogStates().then(()=>{e()}).catch(t=>{As.error("Failed to load conversation states",t),e()})},n.onupgradeneeded=e=>{const t=e.target.result;if(!t.objectStoreNames.contains(this.STORE_NAME)){const e=t.createObjectStore(this.STORE_NAME,{keyPath:"messageId"});e.createIndex("messageUId","messageUId",{unique:!0}),e.createIndex("dialogId","dialogId",{unique:!1}),e.createIndex("dialogId_sentTime",["dialogId","sentTime"],{unique:!1}),e.createIndex("receivedStatus","receivedStatus",{unique:!1}),e.createIndex("burnAfterReadingFlag","burnAfterReadingFlag",{unique:!1}),e.createIndex("dialogId_receivedStatus",["dialogId","receivedStatus"],{unique:!1})}t.objectStoreNames.contains(this.DIALOG_STATE_STORE)||t.createObjectStore(this.DIALOG_STATE_STORE,{keyPath:"dialogId"})}})}async loadAllDialogStates(){if(this.db)return new Promise((e,t)=>{const r=this.db.transaction(this.DIALOG_STATE_STORE,"readonly").objectStore(this.DIALOG_STATE_STORE).getAll();r.onsuccess=()=>{const t=r.result;this.loadedEndMap.clear(),t.forEach(e=>{this.loadedEndMap.set(e.dialogId,e.isEnd)}),e()},r.onerror=e=>{t(new Error("Failed to load conversation states"))}})}async updateDialogState(e,t){if(this.db)return this.loadedEndMap.set(e,t),new Promise((r,n)=>{const o=this.db.transaction(this.DIALOG_STATE_STORE,"readwrite").objectStore(this.DIALOG_STATE_STORE).put({dialogId:e,isEnd:t,updateTime:Date.now()});o.onsuccess=()=>{r()},o.onerror=e=>{As.error("Failed to update conversation state",e),n(new Error("Failed to update conversation state"))}})}encryptContent(e){if(!e)return"";try{const t=JSON.stringify(e);return yo(t,this.encryptKey)}catch(e){return As.error("Failed to encrypt message content",e),""}}decryptContent(e){if(!e)return null;try{const t=mo(e,this.encryptKey);return JSON.parse(t)}catch(e){return As.error("Failed to decrypt message content",e),null}}decryptMessage(e){const t={...e};if("string"==typeof t.content&&t.content)try{t.content=this.decryptContent(t.content)}catch(e){As.error("Failed to decrypt message content",e),t.content=null}if(t.quotedReply&&"string"==typeof t.quotedReply.content&&t.quotedReply.content)try{t.quotedReply.content=this.decryptContent(t.quotedReply.content)}catch(e){As.error("Failed to decrypt quoted message content",e),t.quotedReply.content=null}return t}async addMessages(e,t,r=void 0){let n=e?.filter(e=>e.isPersited);if(!n||0===n.length||!this.db){if(rt(r)){const e=Qn(t);await this.updateDialogState(e,r)}return}const o=Qn(t);return new Promise(e=>{try{const t=this.db.transaction(this.STORE_NAME,"readwrite"),s=t.objectStore(this.STORE_NAME);t.oncomplete=async()=>{if(rt(r))try{await this.updateDialogState(o,r)}catch(e){As.error("Failed to update dialog state:",e)}e()},t.onerror=s=>{As.error("Transaction failed in addMessages:",function(e){return e.map(Po)}(n),t.error),rt(r)?this.updateDialogState(o,r).catch(e=>As.error("Failed to update dialog state after transaction error:",e)).finally(()=>e()):e()};for(const e of n)try{const t={...Oo(e),dialogId:o};t.content&&(t.content=this.encryptContent(t.content)),t.quotedReply?.content&&(t.quotedReply.content=this.encryptContent(t.quotedReply.content)),s.put(t)}catch(t){As.error("Error processing message:",Po(e),t)}}catch(t){As.error("Failed to start transaction:",t),rt(r)?this.updateDialogState(o,r).catch(e=>As.error("Failed to update dialog state:",e)).finally(()=>e()):e()}})}async getPreviousMessages(e,t="0",r=20){const n=Qn(e);if(!this.db)return{messages:[],hasMore:!1};const o=await this.getDialogLoadedState(n);return new Promise((e,s)=>{const i=this.db.transaction(this.STORE_NAME,"readonly"),a=i.objectStore(this.STORE_NAME).index("dialogId_sentTime");let c;c="0"===t?IDBKeyRange.bound([n,""],[n,"￿"]):IDBKeyRange.bound([n,""],[n,t]);const l=[];let u=!1,d=0;const g=a.count(c);g.onsuccess=()=>{const t=g.result;a.openCursor(c,"prev").onsuccess=e=>{const t=e.target.result;if(t)if(d<r){const e=this.decryptMessage(t.value);l.push(e),d++,t.continue()}else u=!0,n();else n()};const n=()=>{l.sort((e,t)=>Pr.fromString(e.sentTime).compare(Pr.fromString(t.sentTime))),e({messages:l,hasMore:u||t>r||!o})}},i.onerror=e=>{As.error("Failed to query message",e),s(new Error("Failed to query message"))}})}async clearConversationCache(e){const t=Qn(e);if(!this.db)return void this.loadedEndMap.set(t,!0);const r=new Promise((e,r)=>{const n=this.db.transaction(this.STORE_NAME,"readwrite");n.objectStore(this.STORE_NAME).index("dialogId").openCursor(IDBKeyRange.only(t)).onsuccess=e=>{const t=e.target.result;t&&(t.delete(),t.continue())},n.oncomplete=()=>{e()},n.onerror=e=>{As.error("Failed to clear conversation messages"),r(new Error("Failed to clear conversation messages"))}});await Promise.all([r,this.updateDialogState(t,!0)])}async clearAllCache(){if(!this.db)return void this.loadedEndMap.clear();const e=new Promise((e,t)=>{const r=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME).clear();r.onsuccess=()=>{e()},r.onerror=e=>{As.error("Failed to clear all messages"),t(new Error("Failed to clear all messages"))}}),t=new Promise((e,t)=>{const r=this.db.transaction(this.DIALOG_STATE_STORE,"readwrite").objectStore(this.DIALOG_STATE_STORE).clear();r.onsuccess=()=>{this.loadedEndMap.clear(),e()},r.onerror=e=>{As.error("Failed to clear all conversation states"),t(new Error("Failed to clear all conversation states"))}});await Promise.all([e,t])}async getDialogLoadedState(e){return this.loadedEndMap.has(e)?this.loadedEndMap.get(e):!!this.db&&new Promise((t,r)=>{const n=this.db.transaction(this.DIALOG_STATE_STORE,"readonly").objectStore(this.DIALOG_STATE_STORE).get(e);n.onsuccess=()=>{const r=n.result;r?(this.loadedEndMap.set(e,r.isEnd),t(r.isEnd)):t(!1)},n.onerror=e=>{t(!1)}})}async removeMessagesByUId(e){if(!e||0===e.length||!this.db)return;const t=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME),r=t.index("messageUId");e.forEach(e=>{const n=r.get(e);n.onsuccess=()=>{const e=n.result;e&&t.delete(e.messageId)}})}async updateMessageReceiptStatus(t,r){if(!t||!t.messageUIdList||0===t.messageUIdList.length||!this.db)return;const n=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME),o=n.index("messageUId");t.messageUIdList.forEach(t=>{const s=o.get(t);s.onsuccess=()=>{const t=s.result;if(t){let o=!1;0===r&&t.receivedStatus<e.ReceivedStatus.RECEIVED?(t.receivedStatus=e.ReceivedStatus.RECEIVED,o=!0):1===r&&t.receivedStatus<e.ReceivedStatus.READ&&(t.receivedStatus=e.ReceivedStatus.READ,o=!0),o&&n.put(t)}}})}async clearBurnAfterReadingExpiredMessages(e){const t=Qn(e);if(!this.db)return[];const r=Date.now();return new Promise((e,n)=>{const o=this.db.transaction(this.STORE_NAME,"readwrite").objectStore(this.STORE_NAME).index("dialogId"),s=[],i=o.openCursor(IDBKeyRange.only(t));i.onsuccess=t=>{const n=t.target.result;if(n){const e=n.value;if(e.burnAfterReadingFlag){const t=e.burnAfterReadingTime||0;let o=0===t;if(!o&&t>0){const n=Pr.fromString(e.sentTime),s=Pr.fromNumber(r),i=Pr.fromNumber(t),a=n.add(i);o=s.greaterThan(a)}o&&(s.push(e.messageUId),n.delete())}n.continue()}else e(s)},i.onerror=e=>{As.error("Failed to clear expired messages",e),n(new Error("Failed to clear expired messages"))}})}async getLatestMessage(e){const t=Qn(e);return this.db?new Promise((e,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).index("dialogId_sentTime"),o=IDBKeyRange.bound([t,""],[t,"￿"]),s=n.openCursor(o,"prev");s.onsuccess=t=>{const r=t.target.result;if(r){const t=this.decryptMessage(r.value);e(t)}else e(null)},s.onerror=t=>{As.error("Failed to get latest message",t),e(null)}}):null}async upsertMessage(e){this.addMessages([e],e)}async getMessageById(e){return this.db?new Promise((t,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).get(e);n.onsuccess=()=>{const e=n.result;if(e){const r=this.decryptMessage(e);t(r)}else t(null)},n.onerror=e=>{As.error("Failed to query message",e),t(null)}}):null}async getMessageIdRange(){return this.db?new Promise((e,t)=>{const r=this.db.transaction(this.STORE_NAME,"readonly"),n=r.objectStore(this.STORE_NAME);let o=null,s=null;n.openCursor().onsuccess=t=>{const r=t.target.result;if(r){s=r.value.messageId;n.openCursor(null,"prev").onsuccess=t=>{const r=t.target.result;r?(o=r.value.messageId,e(o&&s?{newest:o,oldest:s}:null)):e(null)}}else e(null)},r.onerror=t=>{e(null)}}):null}async convertToRecallMessages(e){if(e&&0!==e.length&&this.db)return new Promise(t=>{const r=this.db.transaction(this.STORE_NAME,"readwrite"),n=r.objectStore(this.STORE_NAME),o=n.index("messageUId");let s=e.length;for(const t of e){if(!t){i();continue}const e=o.get(t);e.onsuccess=()=>{const r=e.result;if(r){const e={messageUId:t},o={...r,messageType:bo.RECALL,content:this.encryptContent(e),isPersited:!0,isCounted:!1,isMentioned:!1,disableNotification:!0},s=n.put(o);s.onerror=()=>{i()},s.onsuccess=()=>{i()}}else i()},e.onerror=()=>{i()}}function i(){s--,0===s&&t()}r.oncomplete=()=>{t()},r.onerror=()=>{t()}})}async getMessageByUId(e){return this.db?new Promise((t,r)=>{const n=this.db.transaction(this.STORE_NAME,"readonly").objectStore(this.STORE_NAME).index("messageUId").get(e);n.onsuccess=()=>{const e=n.result;if(e){const r=this.decryptMessage(e);t(r)}else t(null)},n.onerror=e=>{As.error("Failed to query message",e),t(null)}}):null}}let Xo=null;var Yo={create(e,t){Xo=new Zo(e,t)},get:()=>Xo};class Qo{watcher;pullingMsg=!1;letterbox;serverMsgSeqno=Pr.ZERO;pullOfflineFinished=!1;intervalTimer;retryTimer;latestSyncTimestamp=0;started=!1;constructor(e,t){this.watcher=e,this.letterbox=new ho(t.appkey,nn.uid.toString())}start(){this.started=!0,this.pullOfflineFinished=!1,this.startPullInterval()}stop(){this.started=!1,this.stopPullInterval(),this.cancelRetryTask()}syncMsg(e){this.serverMsgSeqno=e,this.pullMsg()}startPullInterval(){this.stopPullInterval();this.intervalTimer=setInterval(()=>{Date.now()-this.latestSyncTimestamp>=18e4&&this.pullMsg()},3e4),this.latestSyncTimestamp=Date.now(),this.pullMsg()}stopPullInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}try2RePullMsg(){this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.pullMsg()},1e3)}cancelRetryTask(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}async pullMsg(){if(this.pullingMsg)return;if(!this.started)return;this.cancelRetryTask(),this.pullingMsg=!0;const t=this.letterbox.getInboxOffset();As.info(`pullMsg -> time: ${t}`),this.latestSyncTimestamp=Date.now();const{code:r,data:n}=await((e,t)=>ln.send(Tt.GetNewMessage,{offset:e,rows:t},{encoder:mn,decoder:vn}))(t,60);if(r!==e.ErrorCode.SUCCESS)return As.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void(ws.loader?.getConnectionStatus()==e.ConnectionStatus.CONNECTED&&this.try2RePullMsg());const{offset:o,seqno:s,msg:i,reference:a}=n,c=Object.keys(i).map(e=>({conversationType:Yn(Pr.fromString(e)),targetId:e}));await Mo.get().loadConvsationsIfNotExist(c),Fo.parse(i,a,async(e,t)=>{try{for(const[e,r]of t.entries()){if(0===r.length)return;await this.processMessages(r,!this.pullOfflineFinished)}}catch(e){As.error("processMessages error -> ",e)}if(e)try{let e;s&&(Pr.isLong(s)?e=s:"string"==typeof s?e=Pr.fromString(s):"number"==typeof s&&(e=Pr.fromNumber(s))),e&&Pr.isLong(e)&&e.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=e);const t=this.serverMsgSeqno.lessThanOrEqual(o);As.info(`pullMsg success -> syncTime: ${o}, finished: ${t}`),this.letterbox?.setInboxOffset(o),this.pullingMsg=!1,t&&!this.pullOfflineFinished&&(this.pullOfflineFinished=!0,this.watcher.pullFinished&&this.watcher.pullFinished()),t||this.pullMsg()}catch(e){As.error("setPullMsgDone error",e),this.pullingMsg=!1}})}async processMessages(e,t){const r={conversationType:e[0].conversationType,targetId:e[0].targetId};let n=[];const o=[];let s=[];e.forEach(e=>{e.messageType===bo.RECALL&&ao.has(e.content.messageUId)?e.content.messageUId?(ao.remove(e.content.messageUId),s.push(e.content.messageUId)):As.error("recallMessage's messageUId is undefined",Po(e)):e.messageUId?(e.isOffLineMessage=t,(!e.messageId||e.messageId>Jo())&&(e.messageId=$o()),Mo.get().setConversationCacheByMessage(e),n.push(e),e.messageType===bo.RECALL&&o.push(n.length-1),[Co.PRIVATE_OPEN_BURNAFTERREADING,Co.GROUP_OPEN_BURNAFTERREADING,Co.PRIVATE_CLOSE_BURNAFTERREADING,Co.GROUP_CLOSE_BURNAFTERREADING].includes(e.messageType)&&this.handleBurnAfterReadingMessage(e)):As.error("message's messageUId is undefined",Po(e))});let i=[];for(let e=o.length-1;e>=0;e--){const t=o[e],r=n[t],a=r.content,c=n.findIndex(e=>e.messageUId===a.messageUId);if(-1!==c){const e=n[c];r.messageId=e.messageId,r.sentTime=e.sentTime,n[c]=r,n[t]=e,i.push(t)}else s.push(a.messageUId),i.push(t)}if(i.length){let e=[];n.forEach((t,r)=>{i.includes(r)||e.push(t)}),n=e}let a=this.handleReceiptMessages(n);a.length&&(await(Yo.get()?.addMessages(a,{conversationType:a[0].conversationType,targetId:a[0].targetId})),this.handleBatchMessages(a),Vo.get()?.sendArrivalReceipts(a)),s.length&&(await(Yo.get()?.convertToRecallMessages(s)),this.watcher.onRecall?.(s));if(n.some(e=>e.isPersited)){const e=await(Yo.get()?.getLatestMessage(r));Mo.get().updateLatestMessage(r,e)}}handleBurnAfterReadingMessage(e){const t=e.content,r=e.conversationType,n=e.targetId,{templateId:o,burnAfterReadingTime:s}=t,i=60010010===o||60010011===o;Mo.get().addStatus({conversationType:r,targetId:n,burnAfterReadingFlag:i,burnAfterReadingTime:i?s:null},!0)}handleReceiptMessages(t){try{const r=[],n=[];t.forEach(e=>{e.messageType===Co.GROUP_ARRIVAL_RECEIPT||e.messageType===Co.GROUP_READ_RECEIPT||e.messageType===Co.PRIVATE_ARRIVAL_RECEIPT||e.messageType===Co.PRIVATE_READ_RECEIPT?n.push(e):r.push(e)});const o=r.filter(t=>t.messageDirection===e.MessageDirection.SEND);return n.forEach(t=>{const r=t.content,n=t.messageType===Co.GROUP_ARRIVAL_RECEIPT||t.messageType===Co.PRIVATE_ARRIVAL_RECEIPT;o.forEach(t=>{r.msgIdList.includes(t.messageUId)&&(t.receivedStatus=n?e.ReceivedStatus.RECEIVED:e.ReceivedStatus.READ)}),this.watcher.onReceiptReceived?.({conversation:{conversationType:t.conversationType,targetId:t.targetId},messageUIdList:r.msgIdList.map(e=>e.toString())},t.messageType===Co.GROUP_ARRIVAL_RECEIPT||t.messageType===Co.PRIVATE_ARRIVAL_RECEIPT?0:1)}),r}catch(e){return As.error("handleReceiptMessages error",e),[]}}async handleBatchMessages(t){const r=t.filter(t=>t.messageDirection!==e.MessageDirection.SEND||!t.messageId||!so.has(t.messageId)||(so.remove(t.messageId),!1));r.length&&this.watcher.batchMessage?.(r)}}class es{messageType;content;isPersited;isCounted;isStatusMessage;constructor(e,t,r=!0,n=!0,o=!1){this.messageType=e,this.content=t,o?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=r,this.isCounted=n),this.isStatusMessage=o}}const ts=(e,t,r,n)=>function(o){return new es(e,o,t,r,n)},rs=ts(bo.TEXT,!0,!0,!1),ns=ts(bo.IMAGE,!0,!0,!1),os=ts(bo.GIF,!0,!0,!1),ss=ts(bo.AUDIO,!0,!0,!1),is=ts(bo.FILE,!0,!0,!1),as=ts(bo.VIDEO,!0,!0,!1);let cs=ts(bo.LOCATION,!0,!0,!1),ls=ts(bo.CHAT_RECORD,!0,!0,!1),us=ts(bo.CONTACT,!0,!0,!1),ds=ts(bo.GROUP_INVITATION,!0,!0,!1),gs=ts(bo.REDPACKET,!0,!0,!1),ps=ts(bo.TRANSFER,!0,!0,!1),fs=ts(bo.LINK,!0,!0,!1);const hs=ts(Co.GROUP_ARRIVAL_RECEIPT,!1,!1,!1),ys=ts(Co.GROUP_READ_RECEIPT,!1,!1,!1),ms=ts(Co.PRIVATE_ARRIVAL_RECEIPT,!1,!1,!1),vs=ts(Co.PRIVATE_READ_RECEIPT,!1,!1,!1),bs=ts(Co.PRIVATE_OPEN_BURNAFTERREADING,!1,!1,!1),Cs=ts(Co.PRIVATE_CLOSE_BURNAFTERREADING,!1,!1,!1),Os=ts(Co.GROUP_OPEN_BURNAFTERREADING,!1,!1,!1),Ss=ts(Co.GROUP_CLOSE_BURNAFTERREADING,!1,!1,!1),Is=ts(bo.RECALL,!0,!1,!1);class ws{options;connectionStatus=e.ConnectionStatus.DISCONNECTED;isInternalConnected=!1;watcher;messageLoader;static _loader;static init(e){return this._loader||(this._loader=new ws(e)),this._loader}static get loader(){return this._loader}constructor(e){this.options=e,this.watcher={onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,pullFinished:void 0,batchMessage:void 0,conversationState:void 0,onPush:void 0,onRecall:void 0,onReceiptReceived:void 0},ln.setServerInfo(this.getWebSocketUrl()),ln.setCallback({status:this.connectionStatusListener.bind(this),message:this.messageListener.bind(this)}),this.registerMessage()}getWebSocketUrl(){const e=this.options?.serverInfo;return ut(e)?lt(t=e)&&/wss?:\/\//.test(t)?e:"ws://"+e:"wss://test.gametalk.ai";var t}registerMessage(){lo(bo.TEXT,rs),lo(bo.IMAGE,ns),lo(bo.GIF,os),lo(bo.AUDIO,ss),lo(bo.FILE,is),lo(bo.VIDEO,as),lo(bo.RECALL,Is),lo(bo.LOCATION,cs),lo(bo.CHAT_RECORD,ls),lo(bo.CONTACT,us),lo(bo.GROUP_INVITATION,ds),lo(bo.REDPACKET,gs),lo(bo.TRANSFER,ps),lo(bo.LINK,fs),lo(Co.GROUP_ARRIVAL_RECEIPT,hs),lo(Co.GROUP_READ_RECEIPT,ys),lo(Co.PRIVATE_ARRIVAL_RECEIPT,ms),lo(Co.PRIVATE_READ_RECEIPT,vs),lo(Co.PRIVATE_OPEN_BURNAFTERREADING,bs),lo(Co.PRIVATE_CLOSE_BURNAFTERREADING,Cs),lo(Co.GROUP_OPEN_BURNAFTERREADING,Os),lo(Co.GROUP_CLOSE_BURNAFTERREADING,Ss)}async connect(){if(this.connectionStatus===e.ConnectionStatus.CONNECTED)return{code:e.ErrorCode.SUCCESS};if(this.connectionStatus===e.ConnectionStatus.CONNECTING)return{code:e.ErrorCode.BIZ_ERROR_CONNECTING};ln.close();const t=await ln.connect();return this.isInternalConnected=!0,{code:t}}reconnect(){return this.isInternalConnected?Promise.resolve({code:e.ErrorCode.CAN_NOT_RECONNECT}):this.connect()}disconnect(){return this.isInternalConnected=!1,ln.close(),Promise.resolve()}async setUserLogged(){Rs.setUserId(nn.uid.toString()),Mo.get().destroyed(),Mo.create(this.options.appkey,nn.uid.toString(),this.watcher.conversationState),Vo.create(this.options.appkey,nn.uid.toString()),this.messageLoader?.stop(),this.messageLoader=new Qo(this.watcher,this.options),so.reset(),ao.reset(),go.reset(),Yo.create(this.options.appkey,nn.uid.toString()),Yo.get().initDB().then(()=>Yo.get().getMessageIdRange()).then(e=>{if(e){const{oldest:t,newest:r}=e;zo(t,r)}else zo(1e4,1e4)}),this.getConnectionStatus()===e.ConnectionStatus.CONNECTED&&this.handleUserConnected()}setUserLogout(){this.messageLoader?.stop()}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){pt(this.watcher).forEach(t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.watcher[t]=it(r)?r:void 0}})}resetWatcher(){pt(this.watcher).forEach(e=>{this.watcher[e]=void 0})}async connectionStatusListener(t){switch(this.connectionStatus=t,t){case e.ConnectionStatus.BLOCKED:case e.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.ConnectionStatus.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.ConnectionStatus.CONNECTING:this.handleConnecting();break;case e.ConnectionStatus.CONNECTED:this.handleConnected();break;case e.ConnectionStatus.DISCONNECTED:this.handleDisconnect()}}handleConnecting(){this.watcher.onConnecting?.()}handleConnected(){nn.isActive&&(this.handleUserConnected(),ro()),this.watcher.onConnected?.(),As.cleanupOldLogs()}handleDisconnect(){this.watcher.onDisconnect?.(),this.messageLoader?.stop()}handleSuspend(){this.watcher.onSuspend?.()}handleUserConnected(){As.info("user connected -> ",nn.uid.toString()),this.messageLoader||(this.messageLoader=new Qo(this.watcher,this.options)),this.messageLoader?.start(),setTimeout(()=>{this.connectionStatus===e.ConnectionStatus.CONNECTED&&Mo.get().syncConversationStatus()},2e3)}messageListener(e,t){if(e===Tt.NewMessagePush){const e=Ln.decode(t);this.messageLoader?.syncMsg(e.seqno)}else e===Tt.DialogChangedPush?Mo.get().syncConversationStatus():this.watcher.onPush?.(e,t)}}class Es{static instance;messageQueue;config;flushTimer=null;userId=null;isFlushing=!1;constructor(e){this.config=e,this.messageQueue=new wt,this.startFlushTimer()}static getInstance(e){return Es.instance||(Es.instance=new Es(e)),Es.instance}trackEvent(e,t){const r={type:e,...this.collectAutomaticProperties(),content:t};this.messageQueue.enqueue(r),this.config.debugMode&&this.flush()}collectAutomaticProperties(){return{user_id:this.userId,os:"web",appVersion:Rt.appVersion,eventTime:Date.now()}}async flush(){if(!this.shouldFlush()||this.isFlushing)return;this.isFlushing=!0;let e=[];try{if(e=await this.messageQueue.dequeue(this.config.flushBulkSize),0===e.length)return;const t=await async function(e){const t=JSON.stringify(e),r=(new TextEncoder).encode(t);if("CompressionStream"in window){const e=new Response(r).body?.pipeThrough(new CompressionStream("gzip"));if(e){const t=await new Response(e).arrayBuffer();return btoa(String.fromCharCode(...new Uint8Array(t)))}}return btoa(t)}(e);await this.sendData(t)}catch(t){console.error("Failed to flush analytics data:",t),await this.messageQueue.requeueToEnd(e)}finally{this.isFlushing=!1}}shouldFlush(){return ws.loader?.getConnectionStatus()==e.ConnectionStatus.CONNECTED}async sendData(t){try{const r=await(e=>ln.send(Tt.PostAnalyticsLogs,{data:e},{encoder:_r,decoder:Tr}))(t);if(r.code!==e.ErrorCode.SUCCESS)throw new Error(`Socket error! status: ${r.code}`)}catch(e){throw e}}startFlushTimer(){this.config.flushInterval>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.config.flushInterval))}setUserId(e){this.userId=e}destroy(){this.flushTimer&&clearInterval(this.flushTimer),this.messageQueue.clear()}}var Rs=Es.getInstance({flushInterval:6e4,flushBulkSize:100,debugMode:!1});const Ts=Ct.get("ACIM-slf")===(new Date).getDate();const _s={[e.LogLevel.DEBUG]:console.debug.bind(console),[e.LogLevel.INFO]:console.info.bind(console),[e.LogLevel.WARN]:console.warn.bind(console),[e.LogLevel.ERROR]:console.error.bind(console),[e.LogLevel.FATAL]:console.log.bind(console),[e.LogLevel.NONE]:null},ks=e=>lt(e)||nt(e)||st(e)||ot(e)?e:e instanceof Error?JSON.stringify({name:e.name,message:e.message,stack:e.stack}):JSON.stringify(e);var As=new class{debug;info;warn;error;fatal;outLevel=e.LogLevel.WARN;tag;logStdout;constructor(t){this.tag=t,this.debug=this.log.bind(this,e.LogLevel.DEBUG),this.info=this.log.bind(this,e.LogLevel.INFO),this.warn=this.log.bind(this,e.LogLevel.WARN),this.error=this.log.bind(this,e.LogLevel.ERROR),this.fatal=this.log.bind(this,e.LogLevel.FATAL)}async addLog(t,r){const n={timestamp:(new Date).toISOString(),level:t,content:r};try{t===e.LogLevel.ERROR&&Rs.trackEvent("error_log",{timestamp:n.timestamp,content:n.content})}catch(e){console.error("Failed to add log:",e)}}defaultStdout(e,t,...r){const n=_s[e];rt(n)&&n(`${t}:`,...r)}reqInfo(...e){this.info(...e)}setLogLevel(e){this.outLevel=e}setLogStdout(e){this.logStdout=e}log(t,...r){if(Ts){const n=`${(new Date).toISOString()}[${this.tag}][${e.LogLevel[t]}]`;return this.defaultStdout(t,n,...r),void this.addLog(t,r.map(ks).join(" "))}if(t<this.outLevel)return;const n=`${(new Date).toISOString()}[${this.tag}][${e.LogLevel[t]}]`,o=`${n} - ${r.map(ks).join(" ")}`;if(this.logStdout)return this.logStdout(t,o),void this.addLog(t,r.map(ks).join(" "));this.defaultStdout(t,n,...r),this.addLog(t,r.map(ks).join(" "))}async exportLogs(){return[]}async clearLogs(){}async cleanupOldLogs(){}}("ACLog");const Ms=ut,Ns=nt,Ps=ot,Ls=at,Ds=ct,js=t=>nt(t)&&Object.prototype.hasOwnProperty.call(e.ConversationType,t),Us=t=>{if(!at(t))return!1;const{conversationType:r,targetId:n,channelId:o}=t;return nt(r)&&Object.prototype.hasOwnProperty.call(e.ConversationType,r)&&(nt(n)||ut(n)||Pr.isLong(n)&&!n.isZero())&&(!rt(o)||lt(o)&&!/_/g.test(o)&&o.length<=20)};class Bs extends Error{constructor(e){super(e),this.name="ACAssertError"}}const Fs=(e,t,r,n=!1)=>{if(!xs(e,t,r,n))throw new Bs(`'${e}' is invalid: ${JSON.stringify(t)}`)},xs=(e,t,r,n=!1)=>{const o=n&&!r(t)||!n&&rt(t)&&!r(t);return o&&As.error(`'${e}' is invalid: ${JSON.stringify(t)}`),!o};var Gs,qs,Vs,Ks,Hs={exports:{}},zs={exports:{}},$s={exports:{}};var Ws,Js={};var Zs,Xs,Ys,Qs,ei,ti,ri,ni,oi,si,ii,ai,ci,li,ui,di,gi,pi,fi,hi={};function yi(){return Zs||(Zs=1,function(e){var t=e,r=ta(),n=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,o={};for(t|=0;r<e.length;)o[n[r+t]]=e[r++];return o}t.basic=o([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=o([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",r.emptyArray,null]),t.long=o([0,0,0,1,1],7),t.mapKey=o([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=o([1,5,0,0,0,5,5,0,0,0,1,1,0])}(hi)),hi}function mi(){if(Ys)return Xs;Ys=1,Xs=i;var e=ra();((i.prototype=Object.create(e.prototype)).constructor=i).className="Field";var t,r=na(),n=yi(),o=ta(),s=/^required|optional|repeated$/;function i(t,r,i,a,c,l,u){if(o.isObject(a)?(u=c,l=a,a=c=void 0):o.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!o.isInteger(r)||r<0)throw TypeError("id must be a non-negative integer");if(!o.isString(i))throw TypeError("type must be a string");if(void 0!==a&&!s.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!o.isString(c))throw TypeError("extend must be a string");"proto3_optional"===a&&(a="optional"),this.rule=a&&"optional"!==a?a:void 0,this.type=i,this.id=r,this.extend=c||void 0,this.required="required"===a,this.optional=!this.required,this.repeated="repeated"===a,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!o.Long&&void 0!==n.long[i],this.bytes="bytes"===i,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}return i.fromJSON=function(e,t){return new i(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(i.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),i.prototype.setOption=function(t,r,n){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,r,n)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},i.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=n.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof t?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=o.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var s;o.base64.test(this.typeDefault)?o.base64.decode(this.typeDefault,s=o.newBuffer(o.base64.length(this.typeDefault)),0):o.utf8.write(this.typeDefault,s=o.newBuffer(o.utf8.length(this.typeDefault)),0),this.typeDefault=s}return this.map?this.defaultValue=o.emptyObject:this.repeated?this.defaultValue=o.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},i.d=function(e,t,r,n){return"function"==typeof t?t=o.decorateType(t).name:t&&"object"==typeof t&&(t=o.decorateEnum(t).name),function(s,a){o.decorateType(s.constructor).add(new i(a,e,t,r,{default:n}))}},i._configure=function(e){t=e},Xs}function vi(){if(ei)return Qs;ei=1,Qs=n;var e=ra();((n.prototype=Object.create(e.prototype)).constructor=n).className="OneOf";var t=mi(),r=ta();function n(t,r,n,o){if(Array.isArray(r)||(n=r,r=void 0),e.call(this,t,n),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=o}function o(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return n.fromJSON=function(e,t){return new n(e,t.oneof,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},n.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,o(this),this},n.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},n.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;r<this.oneof.length;++r){var n=t.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}o(this)},n.prototype.onRemove=function(t){for(var r,n=0;n<this.fieldsArray.length;++n)(r=this.fieldsArray[n]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},n.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,o){r.decorateType(t.constructor).add(new n(o,e)),Object.defineProperty(t,o,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},Qs}function bi(){if(ri)return ti;ri=1,ti=c;var e=ra();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,r,n,o=mi(),s=ta(),i=vi();function a(e,t){if(e&&e.length){for(var r={},n=0;n<e.length;++n)r[e[n].name]=e[n].toJSON(t);return r}}function c(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null}function l(e){return e._nestedArray=null,e}return c.fromJSON=function(e,t){return new c(e,t.options).addJSON(t.nested)},c.arrayToJSON=a,c.isReservedId=function(e,t){if(e)for(var r=0;r<e.length;++r)if("string"!=typeof e[r]&&e[r][0]<=t&&e[r][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=s.toArray(this.nested))}}),c.prototype.toJSON=function(e){return s.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var s,i=Object.keys(e),a=0;a<i.length;++a)s=e[i[a]],this.add((void 0!==s.fields?t.fromJSON:void 0!==s.values?n.fromJSON:void 0!==s.methods?r.fromJSON:void 0!==s.id?o.fromJSON:c.fromJSON)(i[a],s));return this},c.prototype.get=function(e){return this.nested&&this.nested[e]||null},c.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof n)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof o&&void 0!==e.extend||e instanceof t||e instanceof i||e instanceof n||e instanceof r||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var s=this.get(e.name);if(s){if(!(s instanceof c&&e instanceof c)||s instanceof t||s instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=s.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(s),this.nested||(this.nested={}),e.setOptions(s.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),l(this)},c.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),l(this)},c.prototype.define=function(e,t){if(s.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof c))throw Error("path conflicts with non-namespace objects")}else r.add(r=new c(n))}return t&&r.addJSON(t),r},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof c?e[t++].resolveAll():e[t++].resolve();return this.resolve()},c.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),s.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.get(e[0]);if(n){if(1===e.length){if(!t||t.indexOf(n.constructor)>-1)return n}else if(n instanceof c&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof c&&(n=this._nestedArray[o].lookup(e,t,!0)))return n;return null===this.parent||r?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,n]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},c.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,o,s){t=e,r=o,n=s},ti}function Ci(){if(oi)return ni;oi=1,ni=n;var e=mi();((n.prototype=Object.create(e.prototype)).constructor=n).className="MapField";var t=yi(),r=ta();function n(t,n,o,s,i,a){if(e.call(this,t,n,s,void 0,void 0,i,a),!r.isString(o))throw TypeError("keyType must be a string");this.keyType=o,this.resolvedKeyType=null,this.map=!0}return n.fromJSON=function(e,t){return new n(e,t.id,t.keyType,t.type,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},n.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},n.d=function(e,t,o){return"function"==typeof o?o=r.decorateType(o).name:o&&"object"==typeof o&&(o=r.decorateEnum(o).name),function(s,i){r.decorateType(s.constructor).add(new n(i,e,t,o))}},ni}function Oi(){if(ii)return si;ii=1,si=r;var e=ra();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=ta();function r(r,n,o,s,i,a,c,l,u){if(t.isObject(i)?(c=i,i=a=void 0):t.isObject(a)&&(c=a,a=void 0),void 0!==n&&!t.isString(n))throw TypeError("type must be a string");if(!t.isString(o))throw TypeError("requestType must be a string");if(!t.isString(s))throw TypeError("responseType must be a string");e.call(this,r,c),this.type=n||"rpc",this.requestType=o,this.requestStream=!!i||void 0,this.responseType=s,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){var r=!!e&&Boolean(e.keepComments);return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",r?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},si}function Si(){if(ci)return ai;ci=1,ai=o;var e=bi();((o.prototype=Object.create(e.prototype)).constructor=o).className="Service";var t=Oi(),r=ta(),n=hr();function o(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function s(e){return e._methodsArray=null,e}return o.fromJSON=function(e,r){var n=new o(e,r.options);if(r.methods)for(var s=Object.keys(r.methods),i=0;i<s.length;++i)n.add(t.fromJSON(s[i],r.methods[s[i]]));return r.nested&&n.addJSON(r.nested),n.comment=r.comment,n},o.prototype.toJSON=function(t){var n=e.prototype.toJSON.call(this,t),o=!!t&&Boolean(t.keepComments);return r.toObject(["options",n&&n.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",n&&n.nested||void 0,"comment",o?this.comment:void 0])},Object.defineProperty(o.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),o.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},o.prototype.resolveAll=function(){for(var t=this.methodsArray,r=0;r<t.length;++r)t[r].resolve();return e.prototype.resolve.call(this)},o.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,s(this)):e.prototype.add.call(this,r)},o.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,s(this)}return e.prototype.remove.call(this,r)},o.prototype.create=function(e,t,o){for(var s,i=new n.Service(e,t,o),a=0;a<this.methodsArray.length;++a){var c=r.lcFirst((s=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");i[c]=r.codegen(["r","c"],r.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:s,q:s.resolvedRequestType.ctor,s:s.resolvedResponseType.ctor})}return i},ai}function Ii(){if(ui)return li;ui=1,li=t;var e=nr();function t(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)this[t[r]]=e[t[r]]}return t.create=function(e){return this.$type.create(e)},t.encode=function(e,t){return this.$type.encode(e,t)},t.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},t.decode=function(e){return this.$type.decode(e)},t.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},t.verify=function(e){return this.$type.verify(e)},t.fromObject=function(e){return this.$type.fromObject(e)},t.toObject=function(e,t){return this.$type.toObject(e,t)},t.prototype.toJSON=function(){return this.$type.toObject(this,e.toJSONOptions)},li}function wi(){if(gi)return di;gi=1,di=function(o){var s=r.codegen(["r","l"],o.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(o.fieldsArray.filter(function(e){return e.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");o.group&&s("if((t&7)===4)")("break");s("switch(t>>>3){");for(var i=0;i<o.fieldsArray.length;++i){var a=o._fieldsArray[i].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+r.safeProp(a.name);s("case %i: {",a.id),a.map?(s("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?s("k=%j",t.defaults[a.keyType]):s("k=null"),void 0!==t.defaults[c]?s("value=%j",t.defaults[c]):s("value=null"),s("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===t.basic[c]?s("value=types[%i].decode(r,r.uint32())",i):s("value=r.%s()",c),s("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?s('%s[typeof k==="object"?util.longToHash(k):k]=value',l):s("%s[k]=value",l)):a.repeated?(s("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&s("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",l,c)("}else"),void 0===t.basic[c]?s(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,i):s("%s.push(r.%s())",l,c)):void 0===t.basic[c]?s(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,i):s("%s=r.%s()",l,c),s("break")("}")}for(s("default:")("r.skipType(t&7)")("break")("}")("}"),i=0;i<o._fieldsArray.length;++i){var u=o._fieldsArray[i];u.required&&s("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",n(u))}return s("return m")};var e=na(),t=yi(),r=ta();function n(e){return"missing required '"+e.name+"'"}return di}function Ei(){if(fi)return pi;fi=1,pi=function(e){var s=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),i=e.oneofsArray,a={};i.length&&s("var p={}");for(var c=0;c<e.fieldsArray.length;++c){var l=e._fieldsArray[c].resolve(),u="m"+t.safeProp(l.name);if(l.optional&&s("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)s("if(!util.isObject(%s))",u)("return%j",r(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),o(s,l,"k[i]"),n(s,l,c,u+"[k[i]]")("}");else if(l.repeated)s("if(!Array.isArray(%s))",u)("return%j",r(l,"array"))("for(var i=0;i<%s.length;++i){",u),n(s,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&s("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,s("p%s=1",d)}n(s,l,c,u)}l.optional&&s("}")}return s("return null")};var e=na(),t=ta();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function n(t,n,o,s){if(n.resolvedType)if(n.resolvedType instanceof e){t("switch(%s){",s)("default:")("return%j",r(n,"enum value"));for(var i=Object.keys(n.resolvedType.values),a=0;a<i.length;++a)t("case %i:",n.resolvedType.values[i[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",o,s)("if(e)")("return%j+e",n.name+".")("}");else switch(n.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",s)("return%j",r(n,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",s,s,s,s)("return%j",r(n,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',s)("return%j",r(n,"number"));break;case"bool":t('if(typeof %s!=="boolean")',s)("return%j",r(n,"boolean"));break;case"string":t("if(!util.isString(%s))",s)("return%j",r(n,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',s,s,s)("return%j",r(n,"buffer"))}return t}function o(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",r(t,"boolean key"))}return e}return pi}var Ri,Ti={};function _i(){return Ri||(Ri=1,function(e){var t=e,r=na(),n=ta();function o(e,t,n,o){var s=!1;if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(d%s){",o);for(var i=t.resolvedType.values,a=Object.keys(i),c=0;c<a.length;++c)i[a[c]]!==t.typeDefault||s||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',o,o,o),t.repeated||e("break"),s=!0),e("case%j:",a[c])("case %i:",i[a[c]])("m%s=%j",o,i[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',o)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",o,n,o);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",o,o);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",o,o);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",o,o);break;case"uint64":l=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",o,o,l)('else if(typeof d%s==="string")',o)("m%s=parseInt(d%s,10)",o,o)('else if(typeof d%s==="number")',o)("m%s=d%s",o,o)('else if(typeof d%s==="object")',o)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",o,o,o,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',o)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",o,o,o)("else if(d%s.length >= 0)",o)("m%s=d%s",o,o);break;case"string":e("m%s=String(d%s)",o,o);break;case"bool":e("m%s=Boolean(d%s)",o,o)}}return e}function s(e,t,n,o){if(t.resolvedType)t.resolvedType instanceof r?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",o,n,o,o,n,o,o):e("d%s=types[%i].toObject(m%s,o)",o,n,o);else{var s=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",o,o,o,o);break;case"uint64":s=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',o)("d%s=o.longs===String?String(m%s):m%s",o,o,o)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",o,o,o,o,s?"true":"",o);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",o,o,o,o,o);break;default:e("d%s=m%s",o,o)}}return e}t.fromObject=function(e){var t=e.fieldsArray,s=n.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return s("return new this.ctor");s("var m=new this.ctor");for(var i=0;i<t.length;++i){var a=t[i].resolve(),c=n.safeProp(a.name);a.map?(s("if(d%s){",c)('if(typeof d%s!=="object")',c)("throw TypeError(%j)",a.fullName+": object expected")("m%s={}",c)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",c),o(s,a,i,c+"[ks[i]]")("}")("}")):a.repeated?(s("if(d%s){",c)("if(!Array.isArray(d%s))",c)("throw TypeError(%j)",a.fullName+": array expected")("m%s=[]",c)("for(var i=0;i<d%s.length;++i){",c),o(s,a,i,c+"[i]")("}")("}")):(a.resolvedType instanceof r||s("if(d%s!=null){",c),o(s,a,i,c),a.resolvedType instanceof r||s("}"))}return s("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(n.compareFieldsById);if(!t.length)return n.codegen()("return {}");for(var o=n.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),i=[],a=[],c=[],l=0;l<t.length;++l)t[l].partOf||(t[l].resolve().repeated?i:t[l].map?a:c).push(t[l]);if(i.length){for(o("if(o.arrays||o.defaults){"),l=0;l<i.length;++l)o("d%s=[]",n.safeProp(i[l].name));o("}")}if(a.length){for(o("if(o.objects||o.defaults){"),l=0;l<a.length;++l)o("d%s={}",n.safeProp(a[l].name));o("}")}if(c.length){for(o("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=n.safeProp(u.name);if(u.resolvedType instanceof r)o("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)o("if(util.Long){")("var n=new util.Long(%i,%i,%j)",u.typeDefault.low,u.typeDefault.high,u.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",d)("}else")("d%s=o.longs===String?%j:%i",d,u.typeDefault.toString(),u.typeDefault.toNumber());else if(u.bytes){var g="["+Array.prototype.slice.call(u.typeDefault).join(",")+"]";o("if(o.bytes===String)d%s=%j",d,String.fromCharCode.apply(String,u.typeDefault))("else{")("d%s=%s",d,g)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",d,d)("}")}else o("d%s=%j",d,u.typeDefault)}o("}")}var p=!1;for(l=0;l<t.length;++l){u=t[l];var f=e._fieldsArray.indexOf(u);d=n.safeProp(u.name);u.map?(p||(p=!0,o("var ks2")),o("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),s(o,u,f,d+"[ks2[j]]")("}")):u.repeated?(o("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),s(o,u,f,d+"[j]")("}")):(o("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),s(o,u,f,d),u.partOf&&o("if(o.oneofs)")("d%s=%j",n.safeProp(u.partOf.name),u.name)),o("}")}return o("return d")}}(Ti)),Ti}var ki,Ai,Mi,Ni,Pi,Li,Di,ji,Ui,Bi,Fi,xi,Gi,qi,Vi,Ki,Hi,zi,$i,Wi,Ji,Zi,Xi={};function Yi(){return ki||(ki=1,function(e){var t=e,r=Ii();t[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var n="",o="";if(t&&t.json&&e.type_url&&e.value){o=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var s=this.lookup(o);s&&(e=s.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof r){var i=e.$type.toObject(e,t);return""===n&&(n="type.googleapis.com/"),o=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),i["@type"]=o,i}return this.toObject(e,t)}}}(Xi)),Xi}function Qi(){if(Mi)return Ai;Mi=1,Ai=h;var e=bi();((h.prototype=Object.create(e.prototype)).constructor=h).className="Type";var t=na(),r=vi(),n=mi(),o=Ci(),s=Si(),i=Ii(),a=sr(),c=or(),l=ta(),u=oa(),d=wi(),g=Ei(),p=_i(),f=Yi();function h(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function y(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(h.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var r=this.fields[e[t]],n=r.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=l.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=l.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=h.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof i||((e.prototype=new i).constructor=e,l.merge(e.prototype,t)),e.$type=e.prototype.$type=this,l.merge(e,i,!0),this._ctor=e;for(var r=0;r<this.fieldsArray.length;++r)this._fieldsArray[r].resolve();var n={};for(r=0;r<this.oneofsArray.length;++r)n[this._oneofsArray[r].resolve().name]={get:l.oneOfGetter(this._oneofsArray[r].oneof),set:l.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,n)}}}),h.generateConstructor=function(e){for(var t,r=l.codegen(["p"],e.name),n=0;n<e.fieldsArray.length;++n)(t=e._fieldsArray[n]).map?r("this%s={}",l.safeProp(t.name)):t.repeated&&r("this%s=[]",l.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},h.fromJSON=function(i,a){var c=new h(i,a.options);c.extensions=a.extensions,c.reserved=a.reserved;for(var l=Object.keys(a.fields),u=0;u<l.length;++u)c.add((void 0!==a.fields[l[u]].keyType?o.fromJSON:n.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(r.fromJSON(l[u],a.oneofs[l[u]]));if(a.nested)for(l=Object.keys(a.nested),u=0;u<l.length;++u){var d=a.nested[l[u]];c.add((void 0!==d.id?n.fromJSON:void 0!==d.fields?h.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?s.fromJSON:e.fromJSON)(l[u],d))}return a.extensions&&a.extensions.length&&(c.extensions=a.extensions),a.reserved&&a.reserved.length&&(c.reserved=a.reserved),a.group&&(c.group=!0),a.comment&&(c.comment=a.comment),c},h.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),n=!!t&&Boolean(t.keepComments);return l.toObject(["options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter(function(e){return!e.declaringField}),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",n?this.comment:void 0])},h.prototype.resolveAll=function(){for(var t=this.fieldsArray,r=0;r<t.length;)t[r++].resolve();var n=this.oneofsArray;for(r=0;r<n.length;)n[r++].resolve();return e.prototype.resolveAll.call(this)},h.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},h.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof n&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),y(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),y(this)):e.prototype.add.call(this,t)},h.prototype.remove=function(t){if(t instanceof n&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),y(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),y(this)}return e.prototype.remove.call(this,t)},h.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},h.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},h.prototype.create=function(e){return new this.ctor(e)},h.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;r<this.fieldsArray.length;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=u(this)({Writer:c,types:t,util:l}),this.decode=d(this)({Reader:a,types:t,util:l}),this.verify=g(this)({types:t,util:l}),this.fromObject=p.fromObject(this)({types:t,util:l}),this.toObject=p.toObject(this)({types:t,util:l});var n=f[e];if(n){var o=Object.create(this);o.fromObject=this.fromObject,this.fromObject=n.fromObject.bind(o),o.toObject=this.toObject,this.toObject=n.toObject.bind(o)}return this},h.prototype.encode=function(e,t){return this.setup().encode(e,t)},h.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},h.prototype.decode=function(e,t){return this.setup().decode(e,t)},h.prototype.decodeDelimited=function(e){return e instanceof a||(e=a.create(e)),this.decode(e,e.uint32())},h.prototype.verify=function(e){return this.setup().verify(e)},h.prototype.fromObject=function(e){return this.setup().fromObject(e)},h.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},h.d=function(e){return function(t){l.decorateType(t,e)}},Ai}function ea(){if(Pi)return Ni;Pi=1,Ni=c;var e=bi();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,r,n,o=mi(),s=na(),i=vi(),a=ta();function c(t){e.call(this,"",t),this.deferred=[],this.files=[]}function l(){}c.fromJSON=function(e,t){return t||(t=new c),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},c.prototype.resolvePath=a.path.resolve,c.prototype.fetch=a.fetch,c.prototype.load=function e(t,o,s){"function"==typeof o&&(s=o,o=void 0);var i=this;if(!s)return a.asPromise(e,i,t,o);var c=s===l;function u(e,t){if(s){if(c)throw e;var r=s;s=null,r(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in n)return r}return null}function g(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){r.filename=e;var n,s=r(t,i,o),l=0;if(s.imports)for(;l<s.imports.length;++l)(n=d(s.imports[l])||i.resolvePath(e,s.imports[l]))&&p(n);if(s.weakImports)for(l=0;l<s.weakImports.length;++l)(n=d(s.weakImports[l])||i.resolvePath(e,s.weakImports[l]))&&p(n,!0)}else i.setOptions(t.options).addJSON(t.nested)}catch(e){u(e)}c||f||u(null,i)}function p(e,t){if(e=d(e)||e,!(i.files.indexOf(e)>-1))if(i.files.push(e),e in n)c?g(e,n[e]):(++f,setTimeout(function(){--f,g(e,n[e])}));else if(c){var r;try{r=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}g(e,r)}else++f,i.fetch(e,function(r,n){--f,s&&(r?t?f||u(null,i):u(r):g(e,n))})}var f=0;a.isString(t)&&(t=[t]);for(var h,y=0;y<t.length;++y)(h=i.resolvePath("",t[y]))&&p(h);if(c)return i;f||u(null,i)},c.prototype.loadSync=function(e,t){if(!a.isNode)throw Error("not supported");return this.load(e,t,l)},c.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(e){return"'extend "+e.extend+"' in "+e.parent.fullName}).join(", "));return e.prototype.resolveAll.call(this)};var u=/^[A-Z]/;function d(e,t){var r=t.parent.lookup(t.extend);if(r){var n=new o(t.fullName,t.id,t.type,t.rule,void 0,t.options);return r.get(n.name)||(n.declaringField=t,t.extensionField=n,r.add(n)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof o)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof s)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof i)){if(e instanceof t)for(var r=0;r<this.deferred.length;)d(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof o){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof s)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var n=0;n<t.nestedArray.length;++n)this._handleRemove(t._nestedArray[n]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,o,s){t=e,r=o,n=s},Ni}function ta(){if(Li)return $s.exports;Li=1;var e,t,r=$s.exports=nr(),n=yr();r.codegen=function(){if(qs)return Gs;function e(t,r){"string"==typeof t&&(r=t,t=void 0);var n=[];function o(t){if("string"!=typeof t){var r=s();if(e.verbose&&console.log("codegen: "+r),r="return "+r,t){for(var i=Object.keys(t),a=new Array(i.length+1),c=new Array(i.length),l=0;l<i.length;)a[l]=i[l],c[l]=t[i[l++]];return a[l]=r,Function.apply(null,a).apply(null,c)}return Function(r)()}for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d]=arguments[++d];if(d=0,t=t.replace(/%([%dfijs])/g,function(e,t){var r=u[d++];switch(t){case"d":case"f":return String(Number(r));case"i":return String(Math.floor(r));case"j":return JSON.stringify(r);case"s":return String(r)}return"%"}),d!==u.length)throw Error("parameter count mismatch");return n.push(t),o}function s(e){return"function "+(e||r||"")+"("+(t&&t.join(",")||"")+"){\n "+n.join("\n ")+"\n}"}return o.toString=s,o}return qs=1,Gs=e,e.verbose=!1,Gs}(),r.fetch=function(){if(Ks)return Vs;Ks=1,Vs=r;var e=Nt(),t=Gt()("fs");function r(n,o,s){return"function"==typeof o?(s=o,o={}):o||(o={}),s?!o.xhr&&t&&t.readFile?t.readFile(n,function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?r.xhr(n,o,s):e?s(e):s(null,o.binary?t:t.toString("utf8"))}):r.xhr(n,o,s):e(r,this,n,o)}return r.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var o=0;o<n.responseText.length;++o)e.push(255&n.responseText.charCodeAt(o))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,n.responseText)}},t.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()},Vs}(),r.path=(Ws||(Ws=1,function(e){var t=e,r=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),o="";n&&(o=t.shift()+"/");for(var s=0;s<t.length;)".."===t[s]?s>0&&".."!==t[s-1]?t.splice(--s,2):n?t.splice(s,1):++s:"."===t[s]?t.splice(s,1):++s;return o+t.join("/")};t.resolve=function(e,t,o){return o||(t=n(t)),r(t)?t:(o||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}}(Js)),Js),r.fs=r.inquire("fs"),r.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n<t.length;)r[n]=e[t[n++]];return r}return[]},r.toObject=function(e){for(var t={},r=0;r<e.length;){var n=e[r++],o=e[r++];void 0!==o&&(t[n]=o)}return t};var o=/\\/g,s=/"/g;r.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},r.safeProp=function(e){return!/^[$\w_]+$/.test(e)||r.isReserved(e)?'["'+e.replace(o,"\\\\").replace(s,'\\"')+'"]':"."+e},r.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var i=/_([a-z])/g;r.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(i,function(e,t){return t.toUpperCase()})},r.compareFieldsById=function(e,t){return e.id-t.id},r.decorateType=function(t,n){if(t.$type)return n&&t.$type.name!==n&&(r.decorateRoot.remove(t.$type),t.$type.name=n,r.decorateRoot.add(t.$type)),t.$type;e||(e=Qi());var o=new e(n||t.name);return r.decorateRoot.add(o),o.ctor=t,Object.defineProperty(t,"$type",{value:o,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:o,enumerable:!1}),o};var a=0;return r.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=na());var n=new t("Enum"+a++,e);return r.decorateRoot.add(n),Object.defineProperty(e,"$type",{value:n,enumerable:!1}),n},r.setProperty=function(e,t,r){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var o=r.shift();if("__proto__"===o||"prototype"===o)return t;if(r.length>0)t[o]=e(t[o]||{},r,n);else{var s=t[o];s&&(n=[].concat(s).concat(n)),t[o]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(r,"decorateRoot",{get:function(){return n.decorated||(n.decorated=new(ea()))}}),$s.exports}function ra(){if(ji)return Di;ji=1,Di=r,r.className="ReflectionObject";var e,t=ta();function r(e,r){if(!t.isString(e))throw TypeError("name must be a string");if(r&&!t.isObject(r))throw TypeError("options must be an object");this.options=r,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(r.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),r.prototype.toJSON=function(){throw Error()},r.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var r=t.root;r instanceof e&&r._handleAdd(this)},r.prototype.onRemove=function(t){var r=t.root;r instanceof e&&r._handleRemove(this),this.parent=null,this.resolved=!1},r.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},r.prototype.getOption=function(e){if(this.options)return this.options[e]},r.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},r.prototype.setParsedOption=function(e,r,n){this.parsedOptions||(this.parsedOptions=[]);var o=this.parsedOptions;if(n){var s=o.find(function(t){return Object.prototype.hasOwnProperty.call(t,e)});if(s){var i=s[e];t.setProperty(i,n,r)}else(s={})[e]=t.setProperty({},n,r),o.push(s)}else{var a={};a[e]=r,o.push(a)}return this},r.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)this.setOption(r[n],e[r[n]],t);return this},r.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},r._configure=function(t){e=t},Di}function na(){if(Bi)return Ui;Bi=1,Ui=n;var e=ra();((n.prototype=Object.create(e.prototype)).constructor=n).className="Enum";var t=bi(),r=ta();function n(t,r,n,o,s,i){if(e.call(this,t,n),r&&"object"!=typeof r)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=o,this.comments=s||{},this.valuesOptions=i,this.reserved=void 0,r)for(var a=Object.keys(r),c=0;c<a.length;++c)"number"==typeof r[a[c]]&&(this.valuesById[this.values[a[c]]=r[a[c]]]=a[c])}return n.fromJSON=function(e,t){var r=new n(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,r},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},n.prototype.add=function(e,t,n,o){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return o&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=o||null),this.comments[e]=n||null,this},n.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},n.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},n.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},Ui}function oa(){if(xi)return Fi;xi=1,Fi=function(o){for(var s,i=r.codegen(["m","w"],o.name+"$encode")("if(!w)")("w=Writer.create()"),a=o.fieldsArray.slice().sort(r.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=o._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,g=t.basic[d];s="m"+r.safeProp(l.name),l.map?(i("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",s,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",s)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(l.id<<3|2)>>>0,8|t.mapKey[l.keyType],l.keyType),void 0===g?i("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,s):i(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|g,d,s),i("}")("}")):l.repeated?(i("if(%s!=null&&%s.length){",s,s),l.packed&&void 0!==t.packed[d]?i("w.uint32(%i).fork()",(l.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",s)("w.%s(%s[i])",d,s)("w.ldelim()"):(i("for(var i=0;i<%s.length;++i)",s),void 0===g?n(i,l,u,s+"[i]"):i("w.uint32(%i).%s(%s[i])",(l.id<<3|g)>>>0,d,s)),i("}")):(l.optional&&i("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",s,l.name),void 0===g?n(i,l,u,s):i("w.uint32(%i).%s(%s)",(l.id<<3|g)>>>0,d,s))}return i("return w")};var e=na(),t=yi(),r=ta();function n(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}return Fi}function sa(){if(Vi)return qi;Vi=1,qi=u;var e=/[\s{}=;:[\],'"()<>]/g,t=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,r=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,n=/^ *[*/]+ */,o=/^\s*\*?\/*/,s=/\n/g,i=/\s/,a=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function l(e){return e.replace(a,function(e,t){switch(t){case"\\":case"":return t;default:return c[t]||""}})}function u(a,c){a=a.toString();var u=0,d=a.length,g=1,p=0,f={},h=[],y=null;function m(e){return Error("illegal "+e+" (line "+g+")")}function v(e){return a.charAt(e)}function b(e,t,r){var i,l={type:a.charAt(e++),lineEmpty:!1,leading:r},u=e-(c?2:3);do{if(--u<0||"\n"===(i=a.charAt(u))){l.lineEmpty=!0;break}}while(" "===i||"\t"===i);for(var d=a.substring(e,t).split(s),h=0;h<d.length;++h)d[h]=d[h].replace(c?o:n,"").trim();l.text=d.join("\n").trim(),f[g]=l,p=g}function C(e){var t=O(e),r=a.substring(e,t);return/^\s*\/\//.test(r)}function O(e){for(var t=e;t<d&&"\n"!==v(t);)t++;return t}function S(){if(h.length>0)return h.shift();if(y)return function(){var e="'"===y?r:t;e.lastIndex=u-1;var n=e.exec(a);if(!n)throw m("string");return u=e.lastIndex,I(y),y=null,l(n[1])}();var n,o,s,p,f,S=0===u;do{if(u===d)return null;for(n=!1;i.test(s=v(u));)if("\n"===s&&(S=!0,++g),++u===d)return null;if("/"===v(u)){if(++u===d)throw m("comment");if("/"===v(u))if(c){if(p=u,f=!1,C(u-1)){f=!0;do{if((u=O(u))===d)break;if(u++,!S)break}while(C(u))}else u=Math.min(d,O(u)+1);f&&(b(p,u,S),S=!0),g++,n=!0}else{for(f="/"===v(p=u+1);"\n"!==v(++u);)if(u===d)return null;++u,f&&(b(p,u-1,S),S=!0),++g,n=!0}else{if("*"!==(s=v(u)))return"/";p=u+1,f=c||"*"===v(p);do{if("\n"===s&&++g,++u===d)throw m("comment");o=s,s=v(u)}while("*"!==o||"/"!==s);++u,f&&(b(p,u-2,S),S=!0),n=!0}}}while(n);var w=u;if(e.lastIndex=0,!e.test(v(w++)))for(;w<d&&!e.test(v(w));)++w;var E=a.substring(u,u=w);return'"'!==E&&"'"!==E||(y=E),E}function I(e){h.push(e)}function w(){if(!h.length){var e=S();if(null===e)return null;I(e)}return h[0]}return Object.defineProperty({next:S,peek:w,push:I,skip:function(e,t){var r=w();if(r===e)return S(),!0;if(!t)throw m("token '"+r+"', '"+e+"' expected");return!1},cmnt:function(e){var t,r=null;return void 0===e?(t=f[g-1],delete f[g-1],t&&(c||"*"===t.type||t.lineEmpty)&&(r=t.leading?t.text:null)):(p<e&&w(),t=f[e],delete f[e],!t||t.lineEmpty||!c&&"/"!==t.type||(r=t.leading?null:t.text)),r}},"line",{get:function(){return g}})}return u.unescape=l,qi}function ia(){if(Hi)return Ki;Hi=1,Ki=O,O.filename=null,O.defaults={keepCase:!1};var e=sa(),t=ea(),r=Qi(),n=mi(),o=Ci(),s=vi(),i=na(),a=Si(),c=Oi(),l=yi(),u=ta(),d=/^[1-9][0-9]*$/,g=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,f=/^-?0[x][0-9a-fA-F]+$/,h=/^0[0-7]+$/,y=/^-?0[0-7]+$/,m=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,v=/^[a-zA-Z_][a-zA-Z_0-9]*$/,b=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,C=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function O(S,I,w){I instanceof t||(w=I,I=new t),w||(w=O.defaults);var E,R,T,_,k,A=w.preferTrailingComment||!1,M=e(S,w.alternateCommentMode||!1),N=M.next,P=M.push,L=M.peek,D=M.skip,j=M.cmnt,U=!0,B=!1,F=I,x=w.keepCase?function(e){return e}:u.camelCase;function G(e,t,r){var n=O.filename;return r||(O.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+M.line+")")}function q(){var e,t=[];do{if('"'!==(e=N())&&"'"!==e)throw G(e);t.push(N()),D(e),e=L()}while('"'===e||"'"===e);return t.join("")}function V(e){var t=N();switch(t){case"'":case'"':return P(t),q();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(d.test(e))return r*parseInt(e,10);if(p.test(e))return r*parseInt(e,16);if(h.test(e))return r*parseInt(e,8);if(m.test(e))return r*parseFloat(e);throw G(e,"number",t)}(t,!0)}catch(r){if(e&&b.test(t))return t;throw G(t,"value")}}function K(e,t){var r,n;do{!t||'"'!==(r=L())&&"'"!==r?e.push([n=H(N()),D("to",!0)?H(N()):n]):e.push(q())}while(D(",",!0));var o={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(o,function(e){if("option"!==e)throw G(e);ee(o,e),D(";")},function(){ne(o)})}function H(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw G(e,"id");if(g.test(e))return parseInt(e,10);if(f.test(e))return parseInt(e,16);if(y.test(e))return parseInt(e,8);throw G(e,"id")}function z(){if(void 0!==E)throw G("package");if(E=N(),!b.test(E))throw G(E,"name");F=F.define(E),D(";")}function $(){var e,t=L();switch(t){case"weak":e=T||(T=[]),N();break;case"public":N();default:e=R||(R=[])}t=q(),D(";"),e.push(t)}function W(){if(D("="),_=q(),!(B="proto3"===_)&&"proto2"!==_)throw G(_,"syntax");I.setOption("syntax",_),D(";")}function J(e,t){switch(t){case"option":return ee(e,t),D(";"),!0;case"message":return X(e,t),!0;case"enum":return Q(e,t),!0;case"service":return function(e,t){if(!v.test(t=N()))throw G(t,"service name");var r=new a(t);Z(r,function(e){if(!J(r,e)){if("rpc"!==e)throw G(e);!function(e,t){var r=j(),n=t;if(!v.test(t=N()))throw G(t,"name");var o,s,i,a,l=t;D("("),D("stream",!0)&&(s=!0);if(!b.test(t=N()))throw G(t);o=t,D(")"),D("returns"),D("("),D("stream",!0)&&(a=!0);if(!b.test(t=N()))throw G(t);i=t,D(")");var u=new c(l,n,o,i,s,a);u.comment=r,Z(u,function(e){if("option"!==e)throw G(e);ee(u,e),D(";")}),e.add(u)}(r,e)}}),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!b.test(t=N()))throw G(t,"reference");var r=t;Z(null,function(t){switch(t){case"required":case"repeated":Y(e,t,r);break;case"optional":Y(e,B?"proto3_optional":"optional",r);break;default:if(!B||!b.test(t))throw G(t);P(t),Y(e,"optional",r)}})}(e,t),!0}return!1}function Z(e,t,r){var n=M.line;if(e&&("string"!=typeof e.comment&&(e.comment=j()),e.filename=O.filename),D("{",!0)){for(var o;"}"!==(o=N());)t(o);D(";",!0)}else r&&r(),D(";"),e&&("string"!=typeof e.comment||A)&&(e.comment=j(n)||e.comment)}function X(e,t){if(!v.test(t=N()))throw G(t,"type name");var n=new r(t);Z(n,function(e){if(!J(n,e))switch(e){case"map":!function(e){D("<");var t=N();if(void 0===l.mapKey[t])throw G(t,"type");D(",");var r=N();if(!b.test(r))throw G(r,"type");D(">");var n=N();if(!v.test(n))throw G(n,"name");D("=");var s=new o(x(n),H(N()),t,r);Z(s,function(e){if("option"!==e)throw G(e);ee(s,e),D(";")},function(){ne(s)}),e.add(s)}(n);break;case"required":case"repeated":Y(n,e);break;case"optional":Y(n,B?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!v.test(t=N()))throw G(t,"name");var r=new s(x(t));Z(r,function(e){"option"===e?(ee(r,e),D(";")):(P(e),Y(r,"optional"))}),e.add(r)}(n,e);break;case"extensions":K(n.extensions||(n.extensions=[]));break;case"reserved":K(n.reserved||(n.reserved=[]),!0);break;default:if(!B||!b.test(e))throw G(e);P(e),Y(n,"optional")}}),e.add(n)}function Y(e,t,o){var i=N();if("group"!==i){for(;i.endsWith(".")||L().startsWith(".");)i+=N();if(!b.test(i))throw G(i,"type");var a=N();if(!v.test(a))throw G(a,"name");a=x(a),D("=");var c=new n(a,H(N()),i,t,o);if(Z(c,function(e){if("option"!==e)throw G(e);ee(c,e),D(";")},function(){ne(c)}),"proto3_optional"===t){var d=new s("_"+a);c.setOption("proto3_optional",!0),d.add(c),e.add(d)}else e.add(c);B||!c.repeated||void 0===l.packed[i]&&void 0!==l.basic[i]||c.setOption("packed",!1,!0)}else!function(e,t){var o=N();if(!v.test(o))throw G(o,"name");var s=u.lcFirst(o);o===s&&(o=u.ucFirst(o));D("=");var i=H(N()),a=new r(o);a.group=!0;var c=new n(s,i,o,t);c.filename=O.filename,Z(a,function(e){switch(e){case"option":ee(a,e),D(";");break;case"required":case"repeated":Y(a,e);break;case"optional":Y(a,B?"proto3_optional":"optional");break;case"message":X(a,e);break;case"enum":Q(a,e);break;default:throw G(e)}}),e.add(a).add(c)}(e,t)}function Q(e,t){if(!v.test(t=N()))throw G(t,"name");var r=new i(t);Z(r,function(e){switch(e){case"option":ee(r,e),D(";");break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!v.test(t))throw G(t,"name");D("=");var r=H(N(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(n,function(e){if("option"!==e)throw G(e);ee(n,e),D(";")},function(){ne(n)}),e.add(t,r,n.comment,n.options)}(r,e)}}),e.add(r)}function ee(e,t){var r=D("(",!0);if(!b.test(t=N()))throw G(t,"name");var n,o=t,s=o;r&&(D(")"),s=o="("+o+")",t=L(),C.test(t)&&(n=t.slice(1),o+=t,N())),D("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,s,te(e,o),n)}function te(e,t){if(D("{",!0)){for(var r={};!D("}",!0);){if(!v.test(k=N()))throw G(k,"name");if(null===k)throw G(k,"end of input");var n,o=k;if(D(":",!0),"{"===L())n=te(e,t+"."+k);else if("["===L()){var s;if(n=[],D("[",!0)){do{s=V(!0),n.push(s)}while(D(",",!0));D("]"),void 0!==s&&re(e,t+"."+k,s)}}else n=V(!0),re(e,t+"."+k,n);var i=r[o];i&&(n=[].concat(i).concat(n)),r[o]=n,D(",",!0),D(";",!0)}return r}var a=V(!0);return re(e,t,a),a}function re(e,t,r){e.setOption&&e.setOption(t,r)}function ne(e){if(D("[",!0)){do{ee(e,"option")}while(D(",",!0));D("]")}return e}for(;null!==(k=N());)switch(k){case"package":if(!U)throw G(k);z();break;case"import":if(!U)throw G(k);$();break;case"syntax":if(!U)throw G(k);W();break;case"option":ee(F,k),D(";");break;default:if(J(F,k)){U=!1;continue}throw G(k)}return O.filename=null,{package:E,imports:R,weakImports:T,syntax:_,root:I}}return Ki}function aa(){if(Wi)return Hs.exports;Wi=1;var e=Hs.exports=function(){if(Gi)return zs.exports;Gi=1;var e=zs.exports=mr();return e.build="light",e.load=function(t,r,n){return"function"==typeof r?(n=r,r=new e.Root):r||(r=new e.Root),r.load(t,n)},e.loadSync=function(t,r){return r||(r=new e.Root),r.loadSync(t)},e.encoder=oa(),e.decoder=wi(),e.verifier=Ei(),e.converter=_i(),e.ReflectionObject=ra(),e.Namespace=bi(),e.Root=ea(),e.Enum=na(),e.Type=Qi(),e.Field=mi(),e.OneOf=vi(),e.MapField=Ci(),e.Service=Si(),e.Method=Oi(),e.Message=Ii(),e.wrappers=Yi(),e.types=yi(),e.util=ta(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),zs.exports}();return e.build="full",e.tokenize=sa(),e.parse=ia(),e.common=function(){if($i)return zi;$i=1,zi=r;var e,t=/\/|\./;function r(e,n){t.test(e)||(e="google/protobuf/"+e+".proto",n={nested:{google:{nested:{protobuf:{nested:n}}}}}),r[e]=n}return r("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),r("duration",{Duration:e={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),r("timestamp",{Timestamp:e}),r("empty",{Empty:{fields:{}}}),r("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),r("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),r("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),r.get=function(e){return r[e]||null},zi}(),e.Root._configure(e.Type,e.parse,e.common),Hs.exports}var ca=f(Zi?Ji:(Zi=1,Ji=aa()));const la=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},ua=e=>{const t=e.name;return ut(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},da=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},ga=e=>{const t=e.match(/data:([^;]+)/)[1],r=e.replace(/^[^,]+,/,""),n=window.atob(r);let o=n.length;const s=new Uint8Array(n.length);for(;o--;)s[o]=n.charCodeAt(o);return new Blob([s],{type:t})},pa=1680,fa=160,ha=e=>new Promise((t,r)=>{const n=e=>{0!==e.width||0!==e.height?t(e):r()},o=new Image;if(o.addEventListener("load",e=>n(e.target)),o.addEventListener("error",r),o.src=e,o.complete)return void n(o);const s=setInterval(()=>{o.complete&&(n(o),clearInterval(s))},40)}),ya=(e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d"),o=function(e,t,r){let n=e,o=t,s=0,i=0;const a=e*t,c=r.maxWidth*r.maxHeight;if(a<=c)return s=(r.maxWidth-n)/2,i=(r.maxHeight-o)/2,{w:n,h:o,x:s,y:i};const l=Math.sqrt(c/a);return n=e*l,o=t*l,s=(r.maxWidth-n)/2,i=(r.maxHeight-o)/2,{w:n,h:o,x:s,y:i}}(e.width,e.height,t);r.width=o.w,r.height=o.h,n.fillStyle="#FFFFFF",n.fillRect(0,0,r.width,r.height),n?.drawImage(e,0,0,o.w,o.h);try{let e=r.toDataURL("image/jpeg",t.quality);return ga(e)}catch(e){throw new Error(e)}};function ma(e){const t=Math.max(0,e),r=t%60,n=Math.floor(t/60%60),o=Math.floor(t/3600);return o>0?`${o}:${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${n}:${r.toString().padStart(2,"0")}`}const va={maxHeight:500,maxWidth:500,quality:.6,scale:2.4};class ba{async create(e,t){try{const r=la(e),n=await ha(r);let o,s,i;if(da(r),t?.full)o=e,s=n.width,i=n.height;else{const t=((e,t=1,r="image/jpeg")=>{t=Math.min(1,t);const n=e.width,o=e.height;let s=n,i=o;if(t<1){const e=n<o,t=e?o/pa:n/pa;n>pa&&o>pa?e?(i=pa,s/=t):(s=pa,i/=t):n>pa&&o>fa?(s=pa,i/=t,i<fa&&(i=fa,s=n/(o/fa))):o>pa&&n>fa&&(i=pa,s/=t,s<fa&&(s=fa,i=o/(n/fa)))}s=Math.floor(s),i=Math.floor(i);const a=document.createElement("canvas");a.width=s,a.height=i;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,s,i),c.drawImage(e,0,0,n,o,0,0,s,i),r&&"image/png"!=r||(r="image/jpeg"),{imageFile:ga(a.toDataURL(r,Math.min(.92,t))),compressWidth:s,compressHeight:i}})(n,.85,e.type);o=t.imageFile,s=t.compressWidth,i=t.compressHeight}const a=ya(n,va);return{success:!0,message:new ns({thumbnailObjectKey:la(a),originalObjectKey:la(o),width:s,height:i}),files:[a,o]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n,o],encryptedKey:s}=t;return r.originalObjectKey=o,r.thumbnailObjectKey=n,r.encryptKey=s,r}}class Ca{async create(e){if(e.size>2097152)return{success:!1};try{const t=la(e),r=await ha(t);return{success:!0,message:new os({originalObjectKey:t,extension:ua(e),width:r.width,height:r.height}),files:[e]}}catch{return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.originalObjectKey=n,r.encryptKey=o,r}}let Oa;class Sa{create(e){return(t=e,gt(t.arrayBuffer)?t.arrayBuffer():new Promise((e,r)=>{const n=new FileReader;n.addEventListener("load",t=>{t.target?e(t.target.result):r("null")}),n.addEventListener("error",e=>r(e)),n.readAsArrayBuffer(t)})).then(this.getAudioInfo).then(t=>({success:!0,message:new ss({audioObjectKey:la(e),length:t.duration,extension:ua(e)}),files:[e]})).catch(()=>({success:!1}));var t}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.audioObjectKey=n,r.encryptKey=o,r}getAudioInfo(e){const t=Oa||new AudioContext;return Oa=t,new Promise((r,n)=>{t.decodeAudioData(e,function(e){r({duration:e.duration,length:e.length})},n)})}}class Ia{async create(e){return e.size>104857600?{success:!1}:{success:!0,message:new is({fileKey:"",title:e.name,extension:ua(e),size:e.size}),files:[e]}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n],encryptedKey:o}=t;return r.fileKey=n,r.encryptKey=o,r}}class wa{async create(e){try{if(e.size>104857600)return{success:!1};const t=la(e),r=document.createElement("video");r.src=t,await new Promise((e,t)=>{r.onloadedmetadata=e,r.onerror=t}),r.currentTime=.001,await new Promise(e=>{r.onseeked=e});const n=r.duration,o=r.videoWidth,s=r.videoHeight,i=Math.min(va.maxWidth/o,va.maxHeight/s,va.scale),a=Math.floor(o*i),c=Math.floor(s*i),l=document.createElement("canvas");l.width=a,l.height=c;const u=l.getContext("2d");u?.drawImage(r,0,0,a,c);const d=await new Promise(e=>{l.toBlob(t=>e(t),"image/jpeg",va.quality)});return da(t),{success:!0,message:new as({videoObjectKey:"",thumbnailObjectKey:"",during:ma(n),width:o,height:s,extension:ua(e)}),files:[e,d]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let r=Oo(e);const{urls:[n,o],encryptedKey:s}=t;return r.videoObjectKey=n,r.thumbnailObjectKey=o,r.encryptKey=s,r}}var Ea;!function(e){e[e.IMAGE=1]="IMAGE",e[e.GIF=2]="GIF",e[e.AUDIO=3]="AUDIO",e[e.FILE=4]="FILE",e[e.SIGHT=5]="SIGHT"}(Ea||(Ea={}));async function Ra(e,t,r){return Da(e,t,r)}const Ta=Pa.bind(null,Ea.IMAGE),_a=Pa.bind(null,Ea.GIF),ka=Pa.bind(null,Ea.AUDIO),Aa=Pa.bind(null,Ea.SIGHT),Ma=Pa.bind(null,Ea.FILE),Na=async(t,r)=>{const n=Qn(t);ao.addMessage(r.messageUId);const o=await((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.RecallGroupMessage,{groupId:Pr.fromString(t),msgId:Pr.fromString(r)},{encoder:$n,decoder:Tr}):ln.send(Tt.RecallPrivateMessage,{destId:Pr.fromString(t),msgId:Pr.fromString(r)},{encoder:Tn,decoder:Tr}),n})(n,r.messageUId);if(o.code!==e.ErrorCode.SUCCESS)return{code:o.code};const s=new Is({messageUId:r.messageUId}),i={conversation:t,senderUserId:nn.uid,messageId:0,sentTime:no().toString()},a=No(s,i,e.SentStatus.SENT);return a.burnAfterReadingFlag=!1,a.burnAfterReadingTime=0,Mo.get().setConversationCacheByMessage(a),{code:e.ErrorCode.SUCCESS,data:a}};async function Pa(t,r,n,o,s){const i=(e=>{let t;switch(e){case Ea.IMAGE:t=new ba;break;case Ea.AUDIO:t=new Sa;break;case Ea.GIF:t=new Ca;break;case Ea.FILE:t=new Ia;break;case Ea.SIGHT:t=new wa}return t})(t);if(!i)return{code:e.ErrorCode.NOT_SUPPORT};const{success:a,message:c,files:l}=await i.create(n.file,s);if(!a||!c||!l)return{code:e.ErrorCode.MEDIA_EXCEPTION};c.content.user=n.user,c.content.extra=n.extra;const u=Rt.getUploader();try{const e=await u.prepare(l);return c.content=i.updateMessageRemoteUrlProperty(c.content,{urls:e.items.map(e=>e.url),encryptedKey:e.encryptKey}),Da(r,c,s,{uploadItems:e,task:(e,t)=>new Promise(r=>{u.upload(t,{onProgress:e=>o?.onProgress?.(e),onError:()=>{r({finished:!1,message:e})},onCompleted:t=>{r({finished:!0,message:o?.onComplete?.(t)??e})}})})})}catch(t){return{code:e.ErrorCode.UPLOAD_FILE_FAILED}}}const La=async(t,r,n)=>{const o=await ja({conversationType:r.conversationType,targetId:r.targetId},t,r,n);if(o.code!==e.ErrorCode.SUCCESS||!o.message||!o.sentArgs)return{code:o.code};const s=No(o.message,o.sentArgs);s.quotedReply=r,await Fa(s,o.sentArgs);const i=Qn(r),a=await go.getDialogAesKey(i.toString());if(!a)return s.sentStatus=e.SentStatus.FAILED,await Fa(s,o.sentArgs),{code:e.ErrorCode.MSG_ENCRYPT_ERROR,data:s};let c,l,u,d;if(t.messageType===bo.TEXT){let e=Oo(t.content),r=e.content;delete e.content,c=yo(r,a),l=JSON.stringify(ft(e))}else l=JSON.stringify(ft(t.content));const g=yo(l,a);if(r){if(r.messageType===bo.TEXT){let e=Oo(r.content),t=e.content;delete e.content,u=yo(t,a),d=JSON.stringify(ft(e))}else d=JSON.stringify(ft(r.content));d=yo(d,a)}so.addMessage(o.sentArgs.messageId);const p={localId:Pr.fromNumber(o.sentArgs.messageId),mediaFlag:t.messageType!==bo.TEXT,mediaConstructor:t.messageType,msgPreContent:"",msgPostContent:c,mediaAttribute:g,msgIdReferenced:Pr.fromString(r.messageUId),msgSrcIdReferenced:Pr.fromString(r.senderUserId),msgDestIdReferenced:r.messageDirection==e.MessageDirection.RECEIVE?Pr.fromString(nn.uid):Pr.fromString(r.targetId),msgPostContentReferenced:u,mediaFlagReferenced:r.messageType!==bo.TEXT,mediaConstructorReferenced:r.messageType,mediaAttributeReferenced:d,msgSendTimeReferenced:Pr.fromString(r.sentTime)};let f;if(r.conversationType===e.ConversationType.GROUP){const e={...p,groupId:Pr.fromString(i)};if(rt(t.content.mentionedInfo)){const r=t.content.mentionedInfo;if(r.userList?.length){e.at=r.userList.map(e=>Pr.fromString(e.uin));const t=JSON.stringify({atInfo:JSON.stringify(r.userList)});e.msgPreContent=t}}f=await(h=e,ln.send(Tt.SendQuoteGroupChatMessage,h,{encoder:Zn,decoder:Xn}))}else{const e={...p,destId:Pr.fromString(i)};f=await(e=>ln.send(Tt.SendQuotePrivateChatMessage,e,{encoder:Un,decoder:Bn}))(e)}var h;const y=Oo(s);return f.code===e.ErrorCode.SUCCESS?(y.sentTime=f.data.msgSendTime.toString(),y.messageUId=f.data.msgId.toString(),y.sentStatus=e.SentStatus.SENT,await Fa(y,o.sentArgs)):(y.sentStatus=e.SentStatus.FAILED,await Fa(y,o.sentArgs)),{code:f.code,data:y}};async function Da(t,r,n,o){const s=await ja(t,r,null,n,o?.uploadItems);if(s.code!==e.ErrorCode.SUCCESS||!s.message||!s.sentArgs)return{code:s.code};{const e=No(s.message,s.sentArgs);await Fa(e,s.sentArgs)}let{message:i,sentArgs:a}=s;if(rt(o)){const t=await o.task(i,o.uploadItems);if(i=t.message,!t.finished){const t=No(s.message,s.sentArgs,e.SentStatus.FAILED);return await Fa(t,a),{code:e.ErrorCode.UPLOAD_FILE_FAILED,data:t}}}return async function(t,r){const n=Qn(r.conversation),o=No(t,r),s=await go.getDialogAesKey(n.toString());if(!s)return o.sentStatus=e.SentStatus.FAILED,await Fa(o,r),{code:e.ErrorCode.MSG_ENCRYPT_ERROR,data:o};let i,a;if(t.messageType===bo.TEXT){let e=Oo(t.content),r=e.content;delete e.content,i=yo(r,s),a=JSON.stringify(ft(e))}else a=JSON.stringify(ft(t.content));const c=yo(a,s);so.addMessage(r.messageId);const l={localId:Pr.fromNumber(r.messageId),mediaFlag:t.messageType!==bo.TEXT,mediaConstructor:t.messageType,msgPreContent:"",msgPostContent:i,mediaAttribute:c};let u;if(r.conversation.conversationType===e.ConversationType.GROUP){const e={...l,groupId:Pr.fromString(n)};if(rt(t.content.mentionedInfo)){const r=t.content.mentionedInfo;if(r.userList?.length){e.at=r.userList.map(e=>Pr.fromString(e.uin));const t=JSON.stringify({atInfo:JSON.stringify(r.userList)});e.msgPreContent=t}}u=await(d=e,ln.send(Tt.SendGroupChatMessage,d,{encoder:Vn,decoder:Kn}))}else{const e={...l,destId:Pr.fromString(n)};u=await(e=>ln.send(Tt.SendPrivateChatMessage,e,{encoder:fn,decoder:hn}))(e)}var d;u.code===e.ErrorCode.SUCCESS?(o.sentTime=u.data.msgSendTime.toString(),o.messageUId=u.data.msgId.toString(),o.sentStatus=e.SentStatus.SENT,await Fa(o,r)):(o.sentStatus=e.SentStatus.FAILED,await Fa(o,r));return{code:u.code,data:o}}(i,a)}async function ja(t,r,n,o,s){if(((e,t="utf-8")=>{let r=0;if("utf-16"===t)for(let t=0,n=e.length;t<n;t++)r+=e.charCodeAt(t)<=65535?2:4;else for(let t=0,n=e.length;t<n;t++){const n=e.charCodeAt(t);r+=n<127?1:n<=2047?2:n<=65535?3:4}return r})(JSON.stringify(ft(r.content)))>81920)return{code:e.ErrorCode.RC_MSG_CONTENT_EXCEED_LIMIT};r.isPersited&&await Mo.get().loadConvsationsIfNotExist([t]);const i={conversation:t,senderUserId:nn.uid,messageId:$o(),sentTime:Ba().toString(),pushConfig:o?.pushConfig};if(o?.onSendBefore){const e=No(r,i);n&&(e.quotedReply=n),o.onSendBefore(e,s)}return{code:e.ErrorCode.SUCCESS,message:r,sentArgs:i}}let Ua=1;function Ba(){Ua++;const e=no();return Ua<e&&(Ua=e),Ua}async function Fa(e,t){try{const r=Yo.get();if(e.isPersited&&r){await r.upsertMessage(e);const n=await r.getLatestMessage(t.conversation);let o=e;n&&Pr.fromString(n.sentTime).greaterThan(Pr.fromString(e.sentTime))&&(o=n),Mo.get().updateLatestMessage(t.conversation,o)}}catch(e){As.error("saveSentMessage -> ",e)}}class xa extends Eo{options;static imClient;libLoader;constructor(e){if(xa.imClient)return As.warn("Please do not perform the init method repeatedly"),xa.imClient;super(),this.options=e,this.fixedProtobuf(),rt(e.logLevel)&&As.setLogLevel(e.logLevel),rt(e.logStdout)&&As.setLogStdout(e.logStdout),As.debug("IMClient.init -> "),rt(e.uploader)&&Rt.setUploader(e.uploader),Rt.setDeviceCode(e.deviceCode),Rt.setDeviceType(e.deviceType),this.libLoader=ws.init(e),this.watch(),xa.imClient=this}fixedProtobuf(){ca.util.Long=Pr,ca.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(e.Events.CONNECTING)},onConnected:()=>{this.emit(e.Events.CONNECTED)},onDisconnect:()=>{this.emit(e.Events.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(e.Events.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:t=>{this.emit(e.Events.MESSAGES,{messages:t})},pullFinished:()=>{this.emit(e.Events.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:t=>{this.emit(e.Events.CONVERSATION,{conversations:t})},onPush:(t,r)=>{this.emit(e.Events.PUSH,{cmdId:t,body:r})},onRecall:t=>{t.forEach(t=>{this.emit(e.Events.RECALL,t)})},onReceiptReceived:(t,r)=>{Yo.get()?.updateMessageReceiptStatus(t,r),0===r?this.emit(e.Events.ARRIVAL_RECEIPT_RECEIVED,t):this.emit(e.Events.READ_RECEIPT_RECEIVED,t)}})}connect(){return this.libLoader.connect()}disconnect(){return this.libLoader.disconnect()}setUserLogged(e){e.uid!==nn.uid.toString()&&(nn.setLogged(e),this.libLoader.setUserLogged())}logOut(){nn.logOut(),this.libLoader.setUserLogout()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}getServerTime=no;async insertMessage(t,r,n){(!r.messageId||r.messageId>Jo())&&(r.messageId=$o()),Mo.get().setConversationCacheByMessage(r);try{const e=Yo.get();if(r.isPersited&&e){await e.upsertMessage(r);const t=await e.getLatestMessage(r);let n=r;t&&Pr.fromString(t.sentTime).greaterThan(Pr.fromString(r.sentTime))&&(n=t),Mo.get().updateLatestMessage(r,n)}}catch(e){As.error("insertMessage -> ",e)}return{code:e.ErrorCode.SUCCESS,data:r}}sendMessage=Ra;sendImageMessage=Ta;sendGIFMessage=_a;sendHQVoiceMessage=ka;sendFileMessage=Ma;sendSightMessage=Aa;async recallMsg(e,t){return await Na(e,t)}sendQuoteReplyMessage=La;async getRemoteHistoryMessages(t,r){const o=r.timestamp??"0",s=r.count??20,i=Qn(t);return(e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=Pr.fromString(e.offset):t.oldOffset=Pr.fromString(e.offset),ln.send(Tt.GetRemoteMessages,t,{encoder:_n,decoder:kn})})({dialogId:i,offset:o,count:s,newToOld:0===r.order}).then(({code:t,data:r})=>new Promise(o=>{t===e.ErrorCode.SUCCESS?Fo.parse({[i]:r.msg??{}},{[i]:r.reference??{}},(t,n)=>{const s=n.get(i)??[];s.sort((e,t)=>Pr.fromString(e.sentTime).lessThan(Pr.fromString(t.sentTime))?-1:1),o({code:e.ErrorCode.SUCCESS,data:{list:s,hasMore:!r.isEnd}})}):o({code:t,msg:n(t)})}))}async getPreviousHistoryMessages(t,r,n=20){const o=await Yo.get().getPreviousMessages(t,r??"0",n);if(!r&&o.messages.length&&Mo.get().updateLatestMessage(t,o.messages[o.messages.length-1]),o.messages.length>=n||!o.hasMore)return{code:e.ErrorCode.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}};const s=o.messages[0]?.sentTime??r,i=await this.getRemoteHistoryMessages(t,{timestamp:s,count:n-o.messages.length,order:0});if(i.code!==e.ErrorCode.SUCCESS)return i;const a=i.data.list;for(let e=a.length-1;e>=0;e--){const t=a[e];(!t.messageId||t.messageId>Jo())&&(t.messageId=Wo())}return s&&"0"!=s||Mo.get().updateLatestMessage(t,a[a.length-1]),Yo.get().addMessages(a,t,!i.data.hasMore),{code:e.ErrorCode.SUCCESS,data:{list:[...i.data.list,...o.messages],hasMore:i.data.hasMore}}}async deleteRemoteMessage(t,r){const n=await(o=Qn(t),s=r.map(e=>e.messageUId),ln.send(Tt.DeleteChatMessages,{destId:Pr.fromString(o),msgIdList:s.map(e=>Pr.fromString(e))},{encoder:On,decoder:Tr})).then(e=>e.code);var o,s;if(n===e.ErrorCode.SUCCESS){const e=await(Yo.get()?.getLatestMessage(t));if(await(Yo.get()?.removeMessagesByUId(r.map(e=>e.messageUId))),e&&r.some(t=>t.messageUId===e.messageUId)){const e=await(Yo.get()?.getLatestMessage(t));Mo.get().updateLatestMessage(t,e)}}return n}async deleteHistoryMessages(e){return Yo.get()?.clearConversationCache(e),Mo.get().clearHistoryMessages(e),(t=Qn(e),ln.send(Tt.ClearChatHistoryMessage,{destId:t},{encoder:Sn,decoder:Tr})).then(e=>e.code);var t}async getConversationList(t,r,n,o){const s={rows:t,type:r??0,offset:Pr.fromNumber(n),newToOld:0===o},{code:i,data:a}=await(e=>ln.send(Tt.GetDialogList,e,{encoder:An,decoder:Mn}))(s);if(i!==e.ErrorCode.SUCCESS)return{code:i};const c=a.fullDialog.map(e=>e.dialog?.destId).filter(rt);await go.getDialogAesKeyList(c.map(e=>e.toString()));let l=1e4;const u=[];for(const e of a.fullDialog){const t=this.formatConversation(e);if(!t)continue;const r={conversationType:t.conversationType,targetId:t.targetId},n=t.latestMessage;t.latestMessage=await(Yo.get()?.getLatestMessage(r));const o=Mo.get().get(r);o||Object.assign(t,o),rt(t.latestMessage)&&!t.updateTime&&(t.updateTime=parseInt(t.latestMessage.sentTime)),t.updateTime||(n?t.updateTime=parseInt(n.sentTime):(t.updateTime=l,l++)),Mo.get().addLocalConversation(t),u.push(t)}return u.sort((e,t)=>(e.updateTime??0)-(t.updateTime??0)),{code:e.ErrorCode.SUCCESS,data:u}}getBlockConversationList(){const t=Mo.get().getBlockConversationList();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})}getTopConversationList(){const t=Mo.get().getTopConversationList();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})}async getConversation(t){const r=Mo.get().get(t);if(!r)return{code:e.ErrorCode.CONVER_GET_ERROR};const n=await(Yo.get()?.getLatestMessage(t)),o={...t,...r,updateTime:rt(n?.sentTime)?parseInt(n.sentTime):void 0,latestMessage:n};return{code:e.ErrorCode.SUCCESS,data:o}}removeConversation(e){return Mo.get().remove(e),(t=Qn(e),ln.send(Tt.DeletePrivateDialog,{destId:Pr.fromString(t)},{encoder:yn,decoder:Tr})).then(e=>e.code);var t}getUnreadMentionedCount(e){return Mo.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return Mo.get().getAllUnreadMentionedCount()}getConversationState(e){return Mo.get().getConversationState(e)}getAllConversationState(){return Mo.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return Mo.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return Mo.get().getUnreadCount(e)}clearConversationUnreadCount(e){Mo.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){Mo.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return Mo.get().getNotificationLevel(e)}setConversationNotificationStatus(t,r){return((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.UpdateGroupChatMuteConfig,{groupId:Pr.fromString(t),muteFlag:r},{encoder:zn,decoder:Tr}):ln.send(Tt.UpdatePrivateChatMuteConfig,{destId:Pr.fromString(t),muteFlag:r},{encoder:Cn,decoder:Tr}),n})(Qn(t),r===e.NotificationStatus.OPEN).then(n=>(!n.code&&Mo.get().addStatus({...t,notificationStatus:r,notificationLevel:r==e.NotificationStatus.OPEN?e.NotificationLevel.AT_USER_NOTIFICATION:e.NotificationLevel.NOT_SET},!0),n.code))}getConversationNotificationStatus(e){return Mo.get().getNotificationStatus(e)}setConversationToTop(t,r){return((t,r)=>{let n;return n=Yn(t)==e.ConversationType.GROUP?ln.send(Tt.UpdateGroupChatStickyConfig,{groupId:Pr.fromString(t),stickyFlag:r},{encoder:Hn,decoder:Tr}):ln.send(Tt.UpdatePrivateChatStickyConfig,{destId:Pr.fromString(t),stickyFlag:r},{encoder:bn,decoder:Tr}),n})(Qn(t),r).then(e=>(!e.code&&Mo.get().addStatus({...t,isTop:r},!0),e.code))}saveConversationMessageDraft(e,t){Mo.get().setDraft(e,t)}getConversationMessageDraft(e){return Mo.get().getDraft(e)}clearConversationMessageDraft(e){Mo.get().clearDraft(e)}async sendReadReceipts(e){await(Vo.get()?.sendReadReceipts(e))}formatConversation(e){const{dialog:t,msg:r}=e,n=t.destId;if(!rt(n))return;const o=wo(t);if(!o)return;const s=go.getDialogAesKeyFromLocal(n.toString());if(s){if(rt(r)){const e=Fo.parseSingleDialogMessages(n.toString(),[r],s,{})[0];o.latestMessage=e}return o}}async clearBurnAfterReadingExpiredMessages(e){const t=Yo.get();if(!t)return Promise.resolve([]);const r=await t.getLatestMessage(e),n=await t.clearBurnAfterReadingExpiredMessages(e);if(r&&n.includes(r.messageUId)){const r=await t.getLatestMessage(e);Mo.get().updateLatestMessage(e,r)}return n}async getMessageById(e){return Yo.get()?.getMessageById(e)}async getMessageByUId(e){return Yo.get()?.getMessageByUId(e)}}const Ga=vr.Reader,qa=vr.Writer,Va=vr.util,Ka=vr.roots.default||(vr.roots.default={}),Ha=Ka.AuthSignIn2Req=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.langCode="",e.prototype.phoneNum="",e.prototype.password="",e.prototype.appVersionCode=0,e.prototype.deviceType=0,e.prototype.imei="",e.prototype.brand="",e.prototype.model="",e.prototype.apnsToken="",e.prototype.bandId="",e.prototype.appVersion="",e.prototype.osVersion="",e.prototype.version=0,e.encode=function(e,t){return t||(t=qa.create()),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(10).string(e.langCode),null!=e.phoneNum&&Object.hasOwnProperty.call(e,"phoneNum")&&t.uint32(18).string(e.phoneNum),null!=e.password&&Object.hasOwnProperty.call(e,"password")&&t.uint32(26).string(e.password),null!=e.appVersionCode&&Object.hasOwnProperty.call(e,"appVersionCode")&&t.uint32(32).int32(e.appVersionCode),null!=e.deviceType&&Object.hasOwnProperty.call(e,"deviceType")&&t.uint32(40).int32(e.deviceType),null!=e.imei&&Object.hasOwnProperty.call(e,"imei")&&t.uint32(50).string(e.imei),null!=e.brand&&Object.hasOwnProperty.call(e,"brand")&&t.uint32(58).string(e.brand),null!=e.model&&Object.hasOwnProperty.call(e,"model")&&t.uint32(66).string(e.model),null!=e.apnsToken&&Object.hasOwnProperty.call(e,"apnsToken")&&t.uint32(74).string(e.apnsToken),null!=e.bandId&&Object.hasOwnProperty.call(e,"bandId")&&t.uint32(82).string(e.bandId),null!=e.appVersion&&Object.hasOwnProperty.call(e,"appVersion")&&t.uint32(90).string(e.appVersion),null!=e.osVersion&&Object.hasOwnProperty.call(e,"osVersion")&&t.uint32(98).string(e.osVersion),null!=e.version&&Object.hasOwnProperty.call(e,"version")&&t.uint32(104).int32(e.version),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.AuthSignIn2Req;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.langCode=e.string();break;case 2:n.phoneNum=e.string();break;case 3:n.password=e.string();break;case 4:n.appVersionCode=e.int32();break;case 5:n.deviceType=e.int32();break;case 6:n.imei=e.string();break;case 7:n.brand=e.string();break;case 8:n.model=e.string();break;case 9:n.apnsToken=e.string();break;case 10:n.bandId=e.string();break;case 11:n.appVersion=e.string();break;case 12:n.osVersion=e.string();break;case 13:n.version=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Req"},e})(),za=Ka.AuthSignIn2Resp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.prototype.frozenDays=0,e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.noNickName&&Object.hasOwnProperty.call(e,"noNickName")&&t.uint32(40).bool(e.noNickName),null!=e.noEmail&&Object.hasOwnProperty.call(e,"noEmail")&&t.uint32(48).bool(e.noEmail),null!=e.cert&&Object.hasOwnProperty.call(e,"cert")&&t.uint32(58).string(e.cert),null!=e.userFileDomain&&Object.hasOwnProperty.call(e,"userFileDomain")&&t.uint32(74).string(e.userFileDomain),null!=e.dialogFileDomain&&Object.hasOwnProperty.call(e,"dialogFileDomain")&&t.uint32(82).string(e.dialogFileDomain),null!=e.user&&Object.hasOwnProperty.call(e,"user")&&Ka.User.encode(e.user,t.uint32(90).fork()).ldelim(),null!=e.frozenDays&&Object.hasOwnProperty.call(e,"frozenDays")&&t.uint32(104).int32(e.frozenDays),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.AuthSignIn2Resp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Ka.User.decode(e,e.uint32());break;case 13:n.frozenDays=e.int32();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Resp"},e})();Ka.User=(()=>{function e(e){if(this.aliasMobile=[],e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.uid=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.nickName="",e.prototype.langCode="",e.prototype.phone="",e.prototype.numberInPhoneBook="",e.prototype.smallAvatarUrl="",e.prototype.originalAvatarUrl="",e.prototype.email="",e.prototype.qrcodeString="",e.prototype.gender=0,e.prototype.contactStatus=0,e.prototype.alias="",e.prototype.aliasMobile=Va.emptyArray,e.prototype.aliasDesp="",e.encode=function(e,t){if(t||(t=qa.create()),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(8).int64(e.uid),null!=e.nickName&&Object.hasOwnProperty.call(e,"nickName")&&t.uint32(18).string(e.nickName),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(26).string(e.langCode),null!=e.phone&&Object.hasOwnProperty.call(e,"phone")&&t.uint32(34).string(e.phone),null!=e.numberInPhoneBook&&Object.hasOwnProperty.call(e,"numberInPhoneBook")&&t.uint32(42).string(e.numberInPhoneBook),null!=e.smallAvatarUrl&&Object.hasOwnProperty.call(e,"smallAvatarUrl")&&t.uint32(50).string(e.smallAvatarUrl),null!=e.originalAvatarUrl&&Object.hasOwnProperty.call(e,"originalAvatarUrl")&&t.uint32(58).string(e.originalAvatarUrl),null!=e.email&&Object.hasOwnProperty.call(e,"email")&&t.uint32(66).string(e.email),null!=e.qrcodeString&&Object.hasOwnProperty.call(e,"qrcodeString")&&t.uint32(74).string(e.qrcodeString),null!=e.gender&&Object.hasOwnProperty.call(e,"gender")&&t.uint32(80).int32(e.gender),null!=e.contactStatus&&Object.hasOwnProperty.call(e,"contactStatus")&&t.uint32(88).int32(e.contactStatus),null!=e.alias&&Object.hasOwnProperty.call(e,"alias")&&t.uint32(98).string(e.alias),null!=e.aliasMobile&&e.aliasMobile.length)for(let r=0;r<e.aliasMobile.length;++r)t.uint32(106).string(e.aliasMobile[r]);return null!=e.aliasDesp&&Object.hasOwnProperty.call(e,"aliasDesp")&&t.uint32(114).string(e.aliasDesp),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.User;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.uid=e.int64();break;case 2:n.nickName=e.string();break;case 3:n.langCode=e.string();break;case 4:n.phone=e.string();break;case 5:n.numberInPhoneBook=e.string();break;case 6:n.smallAvatarUrl=e.string();break;case 7:n.originalAvatarUrl=e.string();break;case 8:n.email=e.string();break;case 9:n.qrcodeString=e.string();break;case 10:n.gender=e.int32();break;case 11:n.contactStatus=e.int32();break;case 12:n.alias=e.string();break;case 13:n.aliasMobile&&n.aliasMobile.length||(n.aliasMobile=[]),n.aliasMobile.push(e.string());break;case 14:n.aliasDesp=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e})();const $a=Ka.WebGetLoginCodeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.account="",e.prototype.langCode="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.account&&Object.hasOwnProperty.call(e,"account")&&t.uint32(10).string(e.account),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(18).string(e.langCode),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.account=e.string();break;case 2:n.langCode=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeReq"},e})(),Wa=Ka.WebGetLoginCodeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeResp"},e})(),Ja=Ka.WebGetLoginCodeVerifyReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.account="",e.prototype.langCode="",e.prototype.code="",e.encode=function(e,t){return t||(t=qa.create()),null!=e.account&&Object.hasOwnProperty.call(e,"account")&&t.uint32(10).string(e.account),null!=e.langCode&&Object.hasOwnProperty.call(e,"langCode")&&t.uint32(18).string(e.langCode),null!=e.code&&Object.hasOwnProperty.call(e,"code")&&t.uint32(26).string(e.code),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.WebGetLoginCodeVerifyReq;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.account=e.string();break;case 2:n.langCode=e.string();break;case 3:n.code=e.string();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeVerifyReq"},e})(),Za=Ka.ClickOKToWebResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Va.Long?Va.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.encode=function(e,t){return t||(t=qa.create()),null!=e.errorCode&&Object.hasOwnProperty.call(e,"errorCode")&&t.uint32(8).int32(e.errorCode),null!=e.errorMessage&&Object.hasOwnProperty.call(e,"errorMessage")&&t.uint32(18).string(e.errorMessage),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.noNickName&&Object.hasOwnProperty.call(e,"noNickName")&&t.uint32(40).bool(e.noNickName),null!=e.noEmail&&Object.hasOwnProperty.call(e,"noEmail")&&t.uint32(48).bool(e.noEmail),null!=e.cert&&Object.hasOwnProperty.call(e,"cert")&&t.uint32(58).string(e.cert),null!=e.userFileDomain&&Object.hasOwnProperty.call(e,"userFileDomain")&&t.uint32(74).string(e.userFileDomain),null!=e.dialogFileDomain&&Object.hasOwnProperty.call(e,"dialogFileDomain")&&t.uint32(82).string(e.dialogFileDomain),null!=e.user&&Object.hasOwnProperty.call(e,"user")&&Ka.User.encode(e.user,t.uint32(90).fork()).ldelim(),t},e.decode=function(e,t){e instanceof Ga||(e=Ga.create(e));let r=void 0===t?e.len:e.pos+t,n=new Ka.ClickOKToWebResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Ka.User.decode(e,e.uint32());break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ClickOKToWebResp"},e})();let Xa;const Ya=async(t,r,n)=>{if(r instanceof es==!1)return As.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:e.ErrorCode.PARAMETER_ERROR};Fs("conversation",t,Us,!0),Qa(t);const o=await Xa.sendMessage(t,r,n);return ec(t,o.code),o},Qa=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+t)},ec=(t,r)=>{if(r!==e.ErrorCode.SUCCESS){const e="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.warn("send message fail ->"+r+":"+n(r)+","+e)}};e.ChatRecordMessage=ls,e.ContactMessage=us,e.ErrorDesc=n,e.FileMessage=is,e.GIFMessage=os,e.GroupCloseBurnAfterReadingMessage=Ss,e.GroupOpenBurnAfterReadingMessage=Os,e.HQVoiceMessage=ss,e.ImageMessage=ns,e.InvitationMessage=ds,e.LinkMessage=fs,e.LocationMessage=cs,e.MessageTypes=bo,e.NotiMessageTypes=Co,e.PrivateCloseBurnAfterReadingMessage=Cs,e.PrivateOpenBurnAfterReadingMessage=bs,e.RecallCommandMessage=Is,e.RedEnvelopeMessage=gs,e.TextMessage=rs,e.TransferMessage=ps,e.VideoMessage=as,e.addEventListener=(e,t,r)=>{Xa.on(e,t,r)},e.clearAllMessagesUnreadStatus=()=>(As.debug("clear allMessagesUnreadStatus"),Xa.clearAllConversationsUnreadCount(),Promise.resolve({code:e.ErrorCode.SUCCESS})),e.clearBurnAfterReadingExpiredMessages=async t=>{Fs("conversation",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("clear burn after reading expired messages ->"+r);const n=await Xa.clearBurnAfterReadingExpiredMessages(t);return n.length>0&&As.debug(`已清除会话 ${r} 中的 ${n.length} 条阅后即焚过期消息`),Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.clearHistoryMessages=async t=>{Fs("conversation",t,Us);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("clear message ->"+r);const o=await Xa.deleteHistoryMessages(t);return o!==e.ErrorCode.SUCCESS?(As.warn("clear message ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:e.ErrorCode.SUCCESS}},e.clearMessagesUnreadStatus=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("clear unreadMsgNum ->"+r),Xa.clearConversationUnreadCount(t),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.clearTextMessageDraft=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("delete draft ->"+r),Xa.clearConversationMessageDraft(t),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.connect=async()=>{const t=await Xa.connect();return t.code===e.ErrorCode.SUCCESS?{code:t.code}:{code:t.code,msg:n(t.code)}},e.deleteMessages=async(t,r)=>{Fs("messages",r,e=>ct(e)&&!!e.length,!0),r.forEach(e=>{Fs("messages.messageUId",e.messageUId,Ms,!0),Fs("messages.sentTime",e.sentTime,Ns,!1),Fs("messages.messageDirection",e.messageDirection,e=>1===e||2===e,!1)}),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("delete messages ->"+o);const s=await Xa.deleteRemoteMessage(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("delete message fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:e.ErrorCode.SUCCESS}},e.disconnect=()=>Xa.disconnect(),e.encodeReceivedMessage2ChatRecordMsgDetail=e=>Fo.encodeReceivedMessage2ChatRecordMsgDetail(e),e.getAllConversationState=()=>{As.debug("getAllConversationState");const t=Xa.getAllConversationState();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},e.getAllUnreadMentionedCount=()=>{As.debug("getAllUnreadMentionedCount");const t=Xa.getAllUnreadMentionedCount();return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},e.getBlockedConversationList=()=>Xa.getBlockConversationList(),e.getConnectionStatus=()=>Xa.getConnectionStatus(),e.getConversation=async t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get conversation ->"+r);const{code:o,data:s}=await Xa.getConversation(t);return o!==e.ErrorCode.SUCCESS?(As.warn("get conversation fail ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:o,data:s}},e.getConversationList=async t=>{As.debug("get conversation list ->");const{code:r,data:o}=await Xa.getConversationList(t?.count??20,null,t?.startTime??0,t?.order??0);return r!==e.ErrorCode.SUCCESS&&As.warn("get conversation list fail ->"+r+":"+n(r)),{code:r,msg:n(r),data:o}},e.getConversationNotificationLevel=t=>{Fs("options",t,Us,!0),As.info("getConversationNotificationLevel ->targetId:"+t.targetId+",conversationType:"+t.conversationType);const r=Xa.getConversationNotificationLevel(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},e.getConversationNotificationStatus=t=>{Fs("options",t,Us,!0),As.info("getConversationNotificationStatus ->targetId:"+t.targetId+",conversationType:"+t.conversationType);const r=Xa.getConversationNotificationStatus(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},e.getConversationState=e=>(As.debug("getConversationState"),Xa.getConversationState(e)),e.getMessageById=async t=>{const r=await Xa.getMessageById(t);return{code:e.ErrorCode.SUCCESS,data:r}},e.getMessageByUId=async t=>{const r=await Xa.getMessageByUId(t);return{code:e.ErrorCode.SUCCESS,data:r}},e.getRemoteHistoryMessages=async(t,r)=>{Fs("options.count",r.count??0,Ns),Fs("options.order",r.order??0,e=>0===e||1===e),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;let s;return As.debug("get remote history message ->"+o),rt(r.timestamp)&&(r.timestamp=r.timestamp.toString()),s=r.order?await Xa.getRemoteHistoryMessages(t,r):await Xa.getPreviousHistoryMessages(t,r.timestamp,r.count),s.code!==e.ErrorCode.SUCCESS&&As.warn("get remote history message fail ->"+s.code+":"+n(s.code)+","+o),s},e.getServerTime=()=>Xa.getServerTime(),e.getTextMessageDraft=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get draft ->"+r);const n=Xa.getConversationMessageDraft(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getTopConversationList=()=>Xa.getTopConversationList(),e.getTotalUnreadCount=(t,r)=>{if(As.debug("get total unread count -> ConversationType:"+JSON.stringify(r)+" includeMuted:"+t),Fs("includeMuted",t,Ps,!1),Fs("conversationTypes",r,Ds,!1),r)for(const e of r)Fs("conversationType",e,js,!0);const n=Xa.getAllConversationUnreadCount(r??[],t??!1);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getUnreadCount=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("get unreadCount ->"+r);const n=Xa.getConversationUnreadCount(t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},e.getUnreadMentionedCount=t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("get unreadMentionedCount ->"+r),Promise.resolve({code:e.ErrorCode.SUCCESS,data:Xa.getUnreadMentionedCount(t)})},e.init=e=>{Xa=Xa||new xa(e)},e.insertMessage=async(e,t,r)=>Xa.insertMessage(e,t,r),e.logOut=()=>{Xa.logOut()},e.mockGetLoginCode=e=>(e=>ln.request(805404721,{langCode:e.langCode,account:e.phone},{encoder:$a,decoder:Wa}))(e),e.mockLogin=e=>(e=>ln.request(805376017,{langCode:e.langCode,phoneNum:e.phone,password:et.SHA256(e.password).toString(),deviceType:7,imei:"59bc678b-fe6d-4e67-87c6-b0692205134b",brand:"Chrome",model:"Mozilla",appVersion:"1.0.0",osVersion:"1.0.0"},{encoder:Ha,decoder:za}))(e),e.mockVerifyLoginCode=e=>(e=>ln.request(805404723,{langCode:e.country,account:e.phone,code:e.code},{encoder:Ja,decoder:Za}))(e),e.onceEventListener=function(e,t,r){Xa.once(e,t,r)},e.parseChatRecordMsgDetails=(e,t)=>Fo.decodeChatRecordMsgDetails2ReceivedMessages(e,t),e.recallMessage=async(t,r)=>{Fs("options.messageUId",r.messageUId,Ms,!0),Fs("conversation",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId+",messageUId:"+r.messageUId;As.debug("recall message ->"+o);const s=await Xa.recallMsg(t,r);return s.code!==e.ErrorCode.SUCCESS&&As.warn("recall message fail ->"+s.code+":"+n(s.code)+","+o),s},e.registerMessageType=(e,t,r,n)=>{let o=function(o){return new es(e,o,t,r,n)};return lo(e,o),o},e.removeConversation=async t=>{Fs("options",t,Us,!0);const r="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("remove conversation ->"+r);const o=await Xa.removeConversation(t);return o!==e.ErrorCode.SUCCESS?(As.warn("remove conversation fail ->"+o+":"+n(o)+","+r),{code:o,msg:n(o)}):{code:o}},e.removeEventListener=(e,t,r)=>{Xa?.off(e,t,r)},e.request=(e,t,r,n=3e4)=>ln.request(e,t,r,n),e.saveTextMessageDraft=(t,r)=>{Fs("options",t,Us,!0),Fs("draft",r,Ms,!0);const n="conversationType:"+t.conversationType+",targetId:"+t.targetId;return As.debug("set draft ->"+n),Xa.saveConversationMessageDraft(t,r),Promise.resolve({code:e.ErrorCode.SUCCESS})},e.sendFileMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendFileMessage(e,t,r,n);return ec(e,s.code),s},e.sendGIFMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&e.type.endsWith("image/gif"),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendGIFMessage(e,t,r,n);return ec(e,s.code),s},e.sendHQVoiceMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob,!0),Qa(e);const o=await Xa.sendHQVoiceMessage(e,t,r,n);return ec(e,o.code),o},e.sendImageMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("image/"),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;As.debug("send message ->"+o),Qa(e);const s=await Xa.sendImageMessage(e,t,r,n);return ec(e,s.code),s},e.sendMessage=Ya,e.sendQuoteReplyMessage=async(e,t,r)=>await Xa.sendQuoteReplyMessage(e,t,r),e.sendReadReceipts=async t=>{try{return await Xa.sendReadReceipts(t),{code:e.ErrorCode.SUCCESS}}catch(t){return{code:e.ErrorCode.UNKNOWN}}},e.sendSightMessage=async(e,t,r,n)=>{Fs("conversation",e,Us,!0),Fs("uploader",Rt.getUploader(),Ls,!0),Fs("msgBody.file",t.file,e=>e instanceof Blob&&"video/mp4"===e.type,!0),Qa(e);const o=await Xa.sendSightMessage(e,t,r,n);return ec(e,o.code),o},e.sendTextMessage=(e,t,r)=>{const n=new rs(t);return Ya(e,n,r)},e.setConversationNotificationStatus=async(t,r)=>{Fs("options",t,Us,!0),Fs("notificationStatus",r,e=>1===e||2===e,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("set conversation status ->"+o);const s=await Xa.setConversationNotificationStatus(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("set conversation status fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:s}},e.setConversationToTop=async(t,r=!0)=>{Fs("options",t,Us,!0);const o="conversationType:"+t.conversationType+",targetId:"+t.targetId;As.debug("set conversation status ->"+o);const s=await Xa.setConversationToTop(t,r);return s!==e.ErrorCode.SUCCESS?(As.warn("set conversation status fail ->"+s+":"+n(s)+","+o),{code:s,msg:n(s)}):{code:s}},e.setUserLogged=e=>{Xa.setUserLogged(e)}});