@onyx-p/imlib-web 3.0.6 → 3.0.8
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.esm.js +1 -1
- package/index.umd.js +1 -1
- package/package.json +1 -1
- package/types/model/messages/voiceMessage.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -34,4 +34,4 @@ return function(){var t=e,n=t.lib,r=n.WordArray,s=n.Hasher,o=t.algo,i=r.create([
|
|
|
34
34
|
* limitations under the License.
|
|
35
35
|
*
|
|
36
36
|
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
-
*/var Nn=null;try{Nn=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 Ln(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Dn(e){return!0===(e&&e.__isLong__)}function Un(e){var t=Math.clz32(e&-e);return e?31-t:t}Ln.prototype.__isLong__,Object.defineProperty(Ln.prototype,"__isLong__",{value:!0}),Ln.isLong=Dn;var jn={},Bn={};function Fn(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=Bn[e])?r:(n=Gn(e,0,!0),s&&(Bn[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=jn[e])?r:(n=Gn(e,e<0?-1:0,!1),s&&(jn[e]=n),n)}function xn(e,t){if(isNaN(e))return t?Zn:Jn;if(t){if(e<0)return Zn;if(e>=zn)return tr}else{if(e<=-$n)return nr;if(e+1>=$n)return er}return e<0?xn(-e,t).neg():Gn(e%Hn|0,e/Hn|0,t)}function Gn(e,t,n){return new Ln(e,t,n)}Ln.fromInt=Fn,Ln.fromNumber=xn,Ln.fromBits=Gn;var qn=Math.pow;function Vn(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Zn:Jn;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Vn(e.substring(1),t,n).neg();for(var s=xn(qn(n,8)),o=Jn,i=0;i<e.length;i+=8){var a=Math.min(8,e.length-i),c=parseInt(e.substring(i,i+a),n);if(a<8){var l=xn(qn(n,a));o=o.mul(l).add(xn(c))}else o=(o=o.mul(s)).add(xn(c))}return o.unsigned=t,o}function Kn(e,t){return"number"==typeof e?xn(e,t):"string"==typeof e?Vn(e,t):Gn(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Ln.fromString=Vn,Ln.fromValue=Kn;var Hn=4294967296,zn=Hn*Hn,$n=zn/2,Wn=Fn(1<<24),Jn=Fn(0);Ln.ZERO=Jn;var Zn=Fn(0,!0);Ln.UZERO=Zn;var Xn=Fn(1);Ln.ONE=Xn;var Yn=Fn(1,!0);Ln.UONE=Yn;var Qn=Fn(-1);Ln.NEG_ONE=Qn;var er=Gn(-1,2147483647,!1);Ln.MAX_VALUE=er;var tr=Gn(-1,-1,!0);Ln.MAX_UNSIGNED_VALUE=tr;var nr=Gn(0,-2147483648,!1);Ln.MIN_VALUE=nr;var rr=Ln.prototype;rr.toInt=function(){return this.unsigned?this.low>>>0:this.low},rr.toNumber=function(){return this.unsigned?(this.high>>>0)*Hn+(this.low>>>0):this.high*Hn+(this.low>>>0)},rr.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(nr)){var t=xn(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var s=xn(qn(e,6),this.unsigned),o=this,i="";;){var a=o.div(s),c=(o.sub(a.mul(s)).toInt()>>>0).toString(e);if((o=a).isZero())return c+i;for(;c.length<6;)c="0"+c;i=""+c+i}},rr.getHighBits=function(){return this.high},rr.getHighBitsUnsigned=function(){return this.high>>>0},rr.getLowBits=function(){return this.low},rr.getLowBitsUnsigned=function(){return this.low>>>0},rr.getNumBitsAbs=function(){if(this.isNegative())return this.eq(nr)?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},rr.isZero=function(){return 0===this.high&&0===this.low},rr.eqz=rr.isZero,rr.isNegative=function(){return!this.unsigned&&this.high<0},rr.isPositive=function(){return this.unsigned||this.high>=0},rr.isOdd=function(){return!(1&~this.low)},rr.isEven=function(){return!(1&this.low)},rr.equals=function(e){return Dn(e)||(e=Kn(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},rr.eq=rr.equals,rr.notEquals=function(e){return!this.eq(e)},rr.neq=rr.notEquals,rr.ne=rr.notEquals,rr.lessThan=function(e){return this.comp(e)<0},rr.lt=rr.lessThan,rr.lessThanOrEqual=function(e){return this.comp(e)<=0},rr.lte=rr.lessThanOrEqual,rr.le=rr.lessThanOrEqual,rr.greaterThan=function(e){return this.comp(e)>0},rr.gt=rr.greaterThan,rr.greaterThanOrEqual=function(e){return this.comp(e)>=0},rr.gte=rr.greaterThanOrEqual,rr.ge=rr.greaterThanOrEqual,rr.compare=function(e){if(Dn(e)||(e=Kn(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},rr.comp=rr.compare,rr.negate=function(){return!this.unsigned&&this.eq(nr)?nr:this.not().add(Xn)},rr.neg=rr.negate,rr.add=function(e){Dn(e)||(e=Kn(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=s+(65535&e.low))>>>16,l+=(u+=r+a)>>>16,c+=(l+=n+i)>>>16,c+=t+o,Gn((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},rr.subtract=function(e){return Dn(e)||(e=Kn(e)),this.add(e.neg())},rr.sub=rr.subtract,rr.multiply=function(e){if(this.isZero())return this;if(Dn(e)||(e=Kn(e)),Nn)return Gn(Nn.mul(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Zn:Jn;if(this.eq(nr))return e.isOdd()?nr:Jn;if(e.eq(nr))return this.isOdd()?nr:Jn;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(Wn)&&e.lt(Wn))return xn(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,s=65535&this.low,o=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+=s*c)>>>16,u+=(d+=r*c)>>>16,d&=65535,u+=(d+=s*a)>>>16,l+=(u+=n*c)>>>16,u&=65535,l+=(u+=r*a)>>>16,u&=65535,l+=(u+=s*i)>>>16,l+=t*c+n*a+r*i+s*o,Gn((d&=65535)<<16|(g&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},rr.mul=rr.multiply,rr.divide=function(e){if(Dn(e)||(e=Kn(e)),e.isZero())throw Error("division by zero");var t,n,r;if(Nn)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Gn((this.unsigned?Nn.div_u:Nn.div_s)(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Zn:Jn;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Zn;if(e.gt(this.shru(1)))return Yn;r=Zn}else{if(this.eq(nr))return e.eq(Xn)||e.eq(Qn)?nr:e.eq(nr)?Xn:(t=this.shr(1).div(e).shl(1)).eq(Jn)?e.isNegative()?Xn:Qn:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(nr))return this.unsigned?Zn:Jn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=Jn}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),o=s<=48?1:qn(2,s-48),i=xn(t),a=i.mul(e);a.isNegative()||a.gt(n);)a=(i=xn(t-=o,this.unsigned)).mul(e);i.isZero()&&(i=Xn),r=r.add(i),n=n.sub(a)}return r},rr.div=rr.divide,rr.modulo=function(e){return Dn(e)||(e=Kn(e)),Nn?Gn((this.unsigned?Nn.rem_u:Nn.rem_s)(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},rr.mod=rr.modulo,rr.rem=rr.modulo,rr.not=function(){return Gn(~this.low,~this.high,this.unsigned)},rr.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},rr.clz=rr.countLeadingZeros,rr.countTrailingZeros=function(){return this.low?Un(this.low):Un(this.high)+32},rr.ctz=rr.countTrailingZeros,rr.and=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low&e.low,this.high&e.high,this.unsigned)},rr.or=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low|e.low,this.high|e.high,this.unsigned)},rr.xor=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low^e.low,this.high^e.high,this.unsigned)},rr.shiftLeft=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Gn(0,this.low<<e-32,this.unsigned)},rr.shl=rr.shiftLeft,rr.shiftRight=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Gn(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},rr.shr=rr.shiftRight,rr.shiftRightUnsigned=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Gn(32===e?this.high:this.high>>>e-32,0,this.unsigned)},rr.shru=rr.shiftRightUnsigned,rr.shr_u=rr.shiftRightUnsigned,rr.rotateLeft=function(e){var t;return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Gn(this.high,this.low,this.unsigned):e<32?(t=32-e,Gn(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),Gn(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},rr.rotl=rr.rotateLeft,rr.rotateRight=function(e){var t;return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Gn(this.high,this.low,this.unsigned):e<32?(t=32-e,Gn(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),Gn(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},rr.rotr=rr.rotateRight,rr.toSigned=function(){return this.unsigned?Gn(this.low,this.high,!1):this},rr.toUnsigned=function(){return this.unsigned?this:Gn(this.low,this.high,!0)},rr.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},rr.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]},rr.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]},Ln.fromBytes=function(e,t,n){return n?Ln.fromBytesLE(e,t):Ln.fromBytesBE(e,t)},Ln.fromBytesLE=function(e,t){return new Ln(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Ln.fromBytesBE=function(e,t){return new Ln(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var sr=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:Ln.isLong(e.uid)?e.uid.toString():e.uid,deviceId:Ln.isLong(e.deviceId)?e.deviceId.toString():e.deviceId,sessionId:Ln.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 or={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const ir=t=>e[t],ar=e=>{const t=new kn;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},cr=e=>{const t=new Mn(new Uint8Array(e));t.readInt8(),t.readInt8();const n=t.readInt32(),r=t.readArr(n-7);if(t.readInt8(),e.byteLength!==n)throw new Error("packet resolve failed");return r};var lr=new class{url="";watcher;options;socket;status=e.DISCONNECTED;autoReconnect=!1;isConnected=!1;responseCallbacks=new Map;failedCount=0;reconnectTimer;connectResolve;pendingMessages=[];constructor(e){this.options=Object.assign(or,e)}setServerInfo(e){this.url=e}setCallback(e){this.watcher=e}async connect(){return this.autoReconnect=!0,new Promise(n=>{this.connectResolve=n,this.open().then(r=>{n(r),r===t.SUCCESS?(this.isConnected=!0,this.onConnect()):this.onDisconnect(r===t.TIMEOUT?e.NETWORK_UNAVAILABLE:e.WEBSOCKET_UNAVAILABLE)})})}async request(e,n,r,s=this.options.signalTimeout){const{code:o,data:i}=await this.sendRawData(e,nt(n)&&nt(r.encoder)?r.encoder.encode(n).finish():new Uint8Array,s);if(0!==o)return{code:o,msg:"time out",data:null};if(!nt(i)||!nt(r.decoder))return{code:t.SUCCESS,msg:""};const a=r.decoder?.decode(i);return a.errorCode?{code:a.errorCode,msg:a.errorMessage,data:null}:{data:a,code:t.SUCCESS,msg:""}}async send(e,n,r,s=this.options.signalTimeout){const o=await this.request(e,n,r,s);return o.code!==t.SUCCESS?{code:Pn(o.code),msg:o.msg,data:null}:{data:o.data,code:t.SUCCESS,msg:o.msg}}async sendRawData(e,n,r=this.options.signalTimeout){if(!this.socket)return{code:t.RC_NET_CHANNEL_INVALID};const s=this.generateMessageSeq();this.isConnected?this.doSendRawData(e,n,s):this.pendingMessages.push({cmdId:e,body:n,messageSeq:s});const o=await new Promise(e=>{this.responseCallbacks.set(s,e),setTimeout(()=>{this.responseCallbacks.get(s)&&this.responseCallbacks.delete(s),e(null)},r)});return o?{code:0,data:o}:(Xi.warn(`send timeout -> cmd: 0x${e.toString(16)}, messageSeq: ${s}, timeout: ${r}`),{code:t.TIMEOUT})}doSendRawData(e,t,n){const r={cmdId:e,messageSeq:Ln.fromNumber(n),deviceId:Ln.fromString(sr.user.deviceId),sessionId:Ln.fromString(sr.user.sessionId),uid:Ln.fromString(sr.user.uid),protocolVersion:0,destId:"",body:t,deviceCode:Et.getDeviceCode()??"",deviceType:Et.getDeviceType()};e!==Tt.Heartbean&&Xi.info(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${n}`),this.socket?.send(ar(Sn.encode(r).finish()))}close(){this.autoReconnect=!1,this.doClose(),this.setStatus(e.DISCONNECTED),this.connectResolve?.(t.RC_SOCKET_DISCONNECTED)}async open(){const n=this.url;Xi.info(`connect start -> ${n}`),this.setStatus(e.CONNECTING);const r=function(e,t){const n=new WebSocket(e,t);return n.binaryType="arraybuffer",{onClose(e){n.onclose=t=>{const{code:n,reason:r}=t;e?.(n,r)}},onError(e){n.onerror=t=>{e(t)}},onMessage(e){n.onmessage=t=>{e(t.data)}},onOpen(e){n.onopen=e},send(e){n.send(e)},close(e,t){n.close(e,t)}}}(this.url);this.socket=r;return await new Promise(s=>{r.onMessage(e=>{"ArrayBuffer"===tt(e)?this.onReceiveMessage(e):Xi.error("Socket received invalid data:",e)}),r.onClose((n,r)=>{Xi.warn("websocket closed -> code:",n,"reason:",r),this.onDisconnect(e.CONNECTION_CLOSED),s(t.RC_SOCKET_DISCONNECTED)}),r.onError(n=>{Xi.warn("websocket error -> ",n),this.onDisconnect(e.WEBSOCKET_ERROR),s(t.RC_SOCKET_NOT_CREATED)}),r.onOpen(()=>{Xi.info("websocket open -> ",n),s(t.SUCCESS)}),setTimeout(()=>{s(t.TIMEOUT)},this.options.webSocketTimeout)})}async checkAlive(){if(!this.socket||!this.isConnected)return;Xi.debug("send ping ->");const n={pingId:Ln.ZERO,disconnectDelay:Ln.ZERO},{code:r}=await this.send(Tt.Heartbean,n,{encoder:En},this.options.pingTimeout);r===t.SUCCESS?(Xi.debug("recv pong <-"),this.failedCount=0,setTimeout(()=>this.checkAlive(),this.options.pingInterval)):(this.failedCount+=1,Xi.warn(`ping failed count: ${this.failedCount}, code: ${r}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,Xi.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let n;try{const e=cr(t);n=Rn.decode(e)}catch(t){return Xi.error("unpack payload error -> ",t),void this.onDisconnect(e.DISCONNECT_BY_SERVER)}if(n.code)return Xi.error("on received message error -> ",n.code),void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(n.cmdId===Tt.SessionKilledPush)return void this.onDisconnect(e.KICKED_OFFLINE_BY_OTHER_CLIENT);if(n.cmdId===Tt.SignOutPish||n.cmdId===Tt.SignOutPish2)return Xi.warn("on received signoutpush -> ",n.cmdId),void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(n.cmdId===Tt.UserFrozenToLogin||n.cmdId===Tt.UserFrozenToLogin2)return void this.onDisconnect(e.BLOCKED);const r=Ln.isLong(n.messageSeq)?n.messageSeq.toNumber():0,s=r>0?this.responseCallbacks.get(r):null;nt(s)?(n.cmdId!==Tt.HeartbeanResp&&Xi.info(`websocket recv ack -> messageSeq: ${r}`),s(n.body),this.responseCallbacks.delete(r)):(Xi.info(`websocket recv -> cmd: 0x${n.cmdId.toString(16)}`),this.watcher?.message(n.cmdId,n.body))}async try2Reconnect(){this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},5e3)}async onConnect(){for(this.setStatus(e.CONNECTED),this.checkAlive(),nt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);this.pendingMessages.length>0;){let{cmdId:e,body:t,messageSeq:n}=this.pendingMessages.shift();this.doSendRawData(e,t,n),await new Promise(e=>setTimeout(e,200))}}onDisconnect(e){nt(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(nt(this.socket)){this.pendingMessages.length=0;const e=this.socket;this.socket=null,e.onClose(null),e.close()}nt(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.DISCONNECTED&&this.status!==e.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.BLOCKED&&this.status!==e.DISCONNECT_BY_SERVER}setStatus(e){Xi.info(`socketServer is changing status from ${ir(this.status)} to ${ir(e)}`),this.status=e,this.watcher?.status(e)}idCount=0;generateMessageSeq(){return++this.idCount}};const ur=bn.Reader,dr=bn.Writer,gr=bn.util,pr=bn.roots.default||(bn.roots.default={}),fr=pr.SendPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.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=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e})(),hr=pr.SendPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e})(),yr=pr.DeletePrivateChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeletePrivateChatDialogReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.destId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e})(),mr=pr.GetNewMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetNewMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.offset=e.int64();break;case 2:r.rows=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e})(),vr=pr.GetNewMessageResp=(()=>{function e(e){if(this.msg={},this.reference={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msg=gr.emptyObject,e.prototype.reference=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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 n=Object.keys(e.msg),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.DialogMessageList.encode(e.msg[n[r]],t.uint32(18).fork()).ldelim().ldelim();if(null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let n=Object.keys(e.reference),r=0;r<n.length;++r)t.uint32(50).fork().uint32(10).string(n[r]),pr.ReferenceDialogMessage.encode(e.reference[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetNewMessageResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.offset=e.int64();break;case 4:o.seqno=e.int64();break;case 5:{o.msg===gr.emptyObject&&(o.msg={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.msg[n]=r;break}case 6:{o.reference===gr.emptyObject&&(o.reference={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.reference[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e})();pr.DialogMessageList=(()=>{function e(e){if(this.dialogMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialogMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.dialogMessage&&e.dialogMessage.length)for(let n=0;n<e.dialogMessage.length;++n)pr.DialogMessage.encode(e.dialogMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DialogMessageList;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.dialogMessage&&r.dialogMessage.length||(r.dialogMessage=[]),r.dialogMessage.push(pr.DialogMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e})(),pr.DialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.destId=gr.Long?gr.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=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=gr.Long?gr.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=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DialogMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.msgId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgStatus=e.int32();break;case 4:r.srcId=e.int64();break;case 5:r.destId=e.int64();break;case 6:r.isOut=e.bool();break;case 7:r.senderCategory=e.int32();break;case 8:r.msgCategory=e.int32();break;case 9:r.msgPreContent=e.string();break;case 10:r.msgPostContent=e.string();break;case 11:r.mediaFlag=e.bool();break;case 12:r.mediaConstructor=e.int32();break;case 13:r.mediaAttribute=e.string();break;case 14:r.msgSendTime=e.int64();break;case 15:r.burnAfterReadingFlag=e.bool();break;case 16:r.atFlag=e.bool();break;case 17:r.replyFlag=e.bool();break;case 18:r.referenceFlag=e.bool();break;case 19:r.msgIdReferenced=e.int64();break;case 20:r.uploadFlag=e.bool();break;case 21:r.burnAfterReadingTime=e.int64();break;case 22:r.sharingGroupFlag=e.bool();break;case 23:r.seqno=e.int64();break;case 24:r.replyMarkup=e.string();break;case 25:r.extra=e.string();break;case 26:r.msgArrival=e.bool();break;case 27:r.msgRead=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e})(),pr.ReferenceDialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.srcId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.srcName="",e.prototype.destId=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReferenceDialogMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.msgId=e.int64();break;case 2:r.srcId=e.int64();break;case 3:r.srcName=e.string();break;case 4:r.destId=e.int64();break;case 5:r.destName=e.string();break;case 6:r.msgPreContent=e.string();break;case 7:r.msgPostContent=e.string();break;case 8:r.mediaFlag=e.bool();break;case 9:r.mediaConstructor=e.int32();break;case 10:r.mediaAttribute=e.string();break;case 11:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReferenceDialogMessage"},e})();const br=pr.UpdatePrivateChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.UpdatePrivateChatDialogStickyConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e})(),Cr=pr.UpdatePrivateChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.UpdatePrivateChatDialogMuteConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.muteFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e})(),wr=pr.DeleteChatMessageReq=(()=>{function e(e){if(this.msgIdList=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgIdList.length;++n)t.int64(e.msgIdList[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeleteChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;case 3:if(r.msgIdList&&r.msgIdList.length||(r.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgIdList.push(e.int64())}else r.msgIdList.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e})();pr.DeletePrivateChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeletePrivateChatHistoryReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e})();const Ir=pr.CleanHistoryMessageReq=(()=>{function e(e){if(this.msgIdList=[],this.destIdList=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId="",e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gr.emptyArray,e.prototype.destIdList=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgIdList.length;++n)t.int64(e.msgIdList[n]);t.ldelim()}if(null!=e.destIdList&&e.destIdList.length)for(let n=0;n<e.destIdList.length;++n)t.uint32(34).string(e.destIdList[n]);return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.CleanHistoryMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.string();break;case 2:r.msgId=e.int64();break;case 3:if(r.msgIdList&&r.msgIdList.length||(r.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgIdList.push(e.int64())}else r.msgIdList.push(e.int64());break;case 4:r.destIdList&&r.destIdList.length||(r.destIdList=[]),r.destIdList.push(e.string());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e})(),Or=pr.GetBriefDialogListReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let n=0;n<e.destId.length;++n)t.int64(e.destId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetBriefDialogListReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)if(r.destId&&r.destId.length||(r.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.destId.push(e.int64())}else r.destId.push(e.int64());else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e})(),Sr=pr.GetBriefDialogListResp=(()=>{function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=gr.emptyArray,e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.notExistDestId.length;++n)t.int64(e.notExistDestId[n]);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 n=Object.keys(e.briefDialog),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.BriefDialog.encode(e.briefDialog[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetBriefDialogListResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:if(o.notExistDestId&&o.notExistDestId.length||(o.notExistDestId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)o.notExistDestId.push(e.int64())}else o.notExistDestId.push(e.int64());break;case 4:o.seqno=e.int64();break;case 5:{o.briefDialog===gr.emptyObject&&(o.briefDialog={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.briefDialog[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e})();pr.BriefDialog=(()=>{function e(e){if(this.groupMemberSmallAvatarUrl=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.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=gr.emptyArray,e.prototype.burnAfterReadingTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.dialogMenuContent="",e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.groupMemberSmallAvatarUrl.length;++n)t.uint32(98).string(e.groupMemberSmallAvatarUrl[n]);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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.BriefDialog;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.dialogTitle=e.string();break;case 3:r.smallAvatarUrl=e.string();break;case 4:r.backgroundImage=e.string();break;case 5:r.stickyFlag=e.bool();break;case 6:r.muteFlag=e.bool();break;case 7:r.blockFlag=e.bool();break;case 8:r.burnAfterReadingFlag=e.bool();break;case 9:r.takeScreenshotFlag=e.bool();break;case 10:r.groupFlag=e.bool();break;case 11:r.totalMemberNumber=e.int32();break;case 12:r.groupMemberSmallAvatarUrl&&r.groupMemberSmallAvatarUrl.length||(r.groupMemberSmallAvatarUrl=[]),r.groupMemberSmallAvatarUrl.push(e.string());break;case 13:r.burnAfterReadingTime=e.int64();break;case 14:r.dialogMenuContent=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e})();const Rr=pr.GetDialogKeyReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=dr.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let n=0;n<e.destId.length;++n)t.int64(e.destId[n]);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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetDialogKeyReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:if(r.destId&&r.destId.length||(r.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.destId.push(e.int64())}else r.destId.push(e.int64());break;case 2:r.clientSign=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e})(),Er=pr.GetDialogKeyResp=(()=>{function e(e){if(this.retryUid=[],this.entry={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.retryUid=gr.emptyArray,e.prototype.entry=gr.emptyObject,e.prototype.serverSign="",e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.retryUid.length;++n)t.int64(e.retryUid[n]);t.ldelim()}if(null!=e.entry&&Object.hasOwnProperty.call(e,"entry"))for(let n=Object.keys(e.entry),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.AesKeyAndIV.encode(e.entry[n[r]],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 ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetDialogKeyResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.dialogKeyVersion=e.int64();break;case 4:if(o.retryUid&&o.retryUid.length||(o.retryUid=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)o.retryUid.push(e.int64())}else o.retryUid.push(e.int64());break;case 5:{o.entry===gr.emptyObject&&(o.entry={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.entry[n]=r;break}case 6:o.serverSign=e.string();break;default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e})();pr.AesKeyAndIV=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.AesKeyAndIV;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.aesKey=e.string();break;case 2:r.aesIV=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e})();const Tr=pr.RecallPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.RecallPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e})(),_r=pr.GetHistoryMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialogKeys="",e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetHistoryMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.dialogKeys=e.string();break;case 2:r.offset=e.int64();break;case 3:r.oldOffset=e.int64();break;case 4:r.rows=e.int32();break;case 5:r.newToOld=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e})(),Ar=pr.GetHistoryMessageResp=(()=>{function e(e){if(this.reference={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.prototype.reference=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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")&&pr.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 n=Object.keys(e.reference),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.ReferenceDialogMessage.encode(e.reference[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetHistoryMessageResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.msg=pr.DialogMessageList.decode(e,e.uint32());break;case 4:o.isEnd=e.bool();break;case 5:{o.reference===gr.emptyObject&&(o.reference={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.reference[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e})(),kr=pr.GetWebDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.type=0,e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetWebDialogListReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.type=e.int32();break;case 2:r.offset=e.int64();break;case 3:r.rows=e.int32();break;case 4:r.newToOld=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e})(),Mr=pr.GetWebDialogListResp=(()=>{function e(e){if(this.fullDialog=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.fullDialog.length;++n)pr.WebFullDialog.encode(e.fullDialog[n],t.uint32(26).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetWebDialogListResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.fullDialog&&r.fullDialog.length||(r.fullDialog=[]),r.fullDialog.push(pr.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e})();pr.WebFullDialog=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialog=null,e.prototype.msg=null,e.encode=function(e,t){return t||(t=dr.create()),null!=e.dialog&&Object.hasOwnProperty.call(e,"dialog")&&pr.BriefDialog.encode(e.dialog,t.uint32(10).fork()).ldelim(),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pr.DialogMessage.encode(e.msg,t.uint32(18).fork()).ldelim(),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.WebFullDialog;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.dialog=pr.BriefDialog.decode(e,e.uint32());break;case 2:r.msg=pr.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e})();const Pr=pr.GetNewSettingDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.time=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetNewSettingDialogListReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.time=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e})(),Nr=pr.GetNewSettingDialogListResp=(()=>{function e(e){if(this.briefDialog={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=gr.emptyObject,e.prototype.setTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=dr.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 n=Object.keys(e.briefDialog),r=0;r<n.length;++r)t.uint32(26).fork().uint32(10).string(n[r]),pr.BriefDialog.encode(e.briefDialog[n[r]],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 ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetNewSettingDialogListResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:{o.briefDialog===gr.emptyObject&&(o.briefDialog={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.briefDialog[n]=r;break}case 4:o.setTime=e.int64();break;default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e})(),Lr=pr.NewMessageNotificationResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.NewMessageNotificationResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.seqno=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e})();pr.ChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgId.length;++n)t.int64(e.msgId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ChatMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:if(r.msgId&&r.msgId.length||(r.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgId.push(e.int64())}else r.msgId.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ChatMessage"},e})();const Dr=pr.SendPrivateChatArrivalAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.chatMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.chatMessage&&e.chatMessage.length)for(let n=0;n<e.chatMessage.length;++n)pr.ChatMessage.encode(e.chatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatArrivalAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.chatMessage&&r.chatMessage.length||(r.chatMessage=[]),r.chatMessage.push(pr.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatArrivalAckReq"},e})(),Ur=pr.SendPrivateChatReadAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.chatMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.chatMessage&&e.chatMessage.length)for(let n=0;n<e.chatMessage.length;++n)pr.ChatMessage.encode(e.chatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatReadAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.chatMessage&&r.chatMessage.length||(r.chatMessage=[]),r.chatMessage.push(pr.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatReadAckReq"},e})(),jr=pr.ReplyPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReplyPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:r.msgIdReferenced=e.int64();break;case 9:r.msgSrcIdReferenced=e.int64();break;case 10:r.msgDestIdReferenced=e.int64();break;case 11:r.msgPreContentReferenced=e.string();break;case 12:r.msgPostContentReferenced=e.string();break;case 13:r.mediaFlagReferenced=e.bool();break;case 14:r.mediaConstructorReferenced=e.int32();break;case 15:r.mediaAttributeReferenced=e.string();break;case 16:r.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageReq"},e})(),Br=pr.ReplyPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReplyPrivateChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageResp"},e})(),Fr=pr.MessageReadedNoticeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.MessageReadedNoticeReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.destId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/MessageReadedNoticeReq"},e})(),xr=pr.MessageReadedNoticeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.MessageReadedNoticeResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/MessageReadedNoticeResp"},e})(),Gr=bn.Reader,qr=bn.Writer,Vr=bn.util,Kr=bn.roots.default||(bn.roots.default={}),Hr=Kr.SendGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.localId=Vr.Long?Vr.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=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.at.length;++n)t.int64(e.at[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:if(r.at&&r.at.length||(r.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.at.push(e.int64())}else r.at.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e})(),zr=Kr.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.seqno=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;case 6:r.seqno=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();Kr.DeleteGroupChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.DeleteGroupChatHistoryReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e})();const $r=Kr.UpdateGroupChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.UpdateGroupChatDialogStickyConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e})(),Wr=Kr.UpdateGroupChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.UpdateGroupChatDialogMuteConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.muteFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e})(),Jr=Kr.RecallGroupChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.RecallGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e})();Kr.DeleteGroupChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.DeleteGroupChatDialogReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e})(),Kr.GroupChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.userId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.msgId.length;++n)t.int64(e.msgId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.GroupChatMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.userId=e.int64();break;case 3:if(r.msgId&&r.msgId.length||(r.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgId.push(e.int64())}else r.msgId.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GroupChatMessage"},e})();const Zr=Kr.SendGroupChatArrivalAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupChatMessage=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let n=0;n<e.groupChatMessage.length;++n)Kr.GroupChatMessage.encode(e.groupChatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatArrivalAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupChatMessage&&r.groupChatMessage.length||(r.groupChatMessage=[]),r.groupChatMessage.push(Kr.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatArrivalAckReq"},e})(),Xr=Kr.SendGroupChatReadAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupChatMessage=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let n=0;n<e.groupChatMessage.length;++n)Kr.GroupChatMessage.encode(e.groupChatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatReadAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupChatMessage&&r.groupChatMessage.length||(r.groupChatMessage=[]),r.groupChatMessage.push(Kr.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatReadAckReq"},e})(),Yr=Kr.ReplyGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.localId=Vr.Long?Vr.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=Vr.emptyArray,e.prototype.msgIdReferenced=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=Vr.Long?Vr.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=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.at.length;++n)t.int64(e.at[n]);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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.ReplyGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:if(r.at&&r.at.length||(r.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.at.push(e.int64())}else r.at.push(e.int64());break;case 9:r.msgIdReferenced=e.int64();break;case 10:r.msgSrcIdReferenced=e.int64();break;case 11:r.msgDestIdReferenced=e.int64();break;case 12:r.msgPreContentReferenced=e.string();break;case 13:r.msgPostContentReferenced=e.string();break;case 14:r.mediaFlagReferenced=e.bool();break;case 15:r.mediaConstructorReferenced=e.int32();break;case 16:r.mediaAttributeReferenced=e.string();break;case 17:r.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageReq"},e})(),Qr=Kr.ReplyGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.ReplyGroupChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageResp"},e})();function es(e){return(lt(e)?Ln.fromString(e):e).greaterThan(Ln.fromNumber(9e10))?r.GROUP:r.PRIVATE}const ts=e=>e.targetId,ns=e=>({conversationType:es(e),targetId:Ln.isLong(e)?e.toString():e});function rs(e,t,n){return e&&n.uint32(8).int64(e),n.uint32(16).int32(t.pinned),n.uint32(24).int64(t.msgId),n}class ss{static encode(e,t=bn.Writer.create()){return rs(e.destId,e,t)}}class os{static encode(e,t=bn.Writer.create()){return rs(e.groupId,e,t)}}class is{static encode(e,t=bn.Writer.create()){return t.uint32(8).int64(e.msgId),t.uint32(16).int64(e.destId),e.content&&t.uint32(26).string(e.content),t}}class as{static encode(e,t=bn.Writer.create()){return t.uint32(8).int64(e.msgId),t.uint32(16).int64(e.groupId),e.content&&t.uint32(26).string(e.content),t}}function cs(e,t,n){return e&&n.uint32(8).int64(e),n.uint32(16).bool(t.burnAfterReadingFlag),n.uint32(24).int64(t.burnAfterReadingTime),n}class ls{static encode(e,t=bn.Writer.create()){return cs(e.destId,e,t)}}class us{static encode(e,t=bn.Writer.create()){return cs(e.groupId,e,t)}}function ds(e){return String(e)}function gs(e,t){const n=e.pos+t,r=[];for(;e.pos<n;)r.push(ds(e.int64()));return r}function ps(e,t){const n=void 0===t?e.len:e.pos+t,r={id:"0",title:"",colorId:-1,categories:0,excludeMuted:!1,excludeRead:!1,sortIndex:0,includeDestIds:[],excludeDestIds:[],excludeFolded:!1};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.id=ds(e.int64());break;case 2:r.title=e.string();break;case 3:r.colorId=e.int32();break;case 4:r.categories=e.int32();break;case 5:r.excludeMuted=e.bool();break;case 6:r.excludeRead=e.bool();break;case 7:r.sortIndex=e.int32();break;case 8:2==(7&t)?r.includeDestIds.push(...gs(e,e.uint32())):r.includeDestIds.push(ds(e.int64()));break;case 9:2==(7&t)?r.excludeDestIds.push(...gs(e,e.uint32())):r.excludeDestIds.push(ds(e.int64()));break;case 10:r.excludeFolded=e.bool();break;default:e.skipType(7&t)}}return r}function fs(e,t){const n=void 0===t?e.len:e.pos+t,r={filters:[],displayTags:!1};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.filters.push(ps(e,e.uint32()));break;case 2:r.displayTags=e.bool();break;default:e.skipType(7&t)}}return r}class hs{static encode(e={},t=bn.Writer.create()){return t}}class ys{errorCode=0;errorMessage="";config={filters:[],displayTags:!1};static decode(e,t){const n=e instanceof bn.Reader?e:bn.Reader.create(e),r=void 0===t?n.len:n.pos+t,s=new ys;for(;n.pos<r;){const e=n.uint32();switch(e>>>3){case 1:s.errorCode=n.int32();break;case 2:s.errorMessage=n.string();break;case 3:s.config=fs(n,n.uint32());break;default:n.skipType(7&e)}}return s}}const ms=()=>lr.send(Tt.GetServerTime,null,{decoder:Tn}),vs=e=>lr.send(Tt.GetDialogKey,{destId:e,clientSign:""},{encoder:Rr,decoder:Er}),bs=e=>lr.send(Tt.SendPrivateChatMessage,e,{encoder:fr,decoder:hr}),Cs=e=>lr.send(Tt.SendQuotePrivateChatMessage,e,{encoder:jr,decoder:Br}),ws=e=>lr.send(Tt.SendGroupChatMessage,e,{encoder:Hr,decoder:zr}),Is=e=>lr.send(Tt.SendQuoteGroupChatMessage,e,{encoder:Yr,decoder:Qr}),Os=(e,t)=>lr.send(Tt.GetNewMessage,{offset:e,rows:t},{encoder:mr,decoder:vr}),Ss=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.RecallGroupMessage,{groupId:Ln.fromString(e),msgId:Ln.fromString(t)},{encoder:Jr,decoder:_n}):lr.send(Tt.RecallPrivateMessage,{destId:Ln.fromString(e),msgId:Ln.fromString(t)},{encoder:Tr,decoder:_n}),n},Rs=(e,t,n)=>{const s=Ln.fromString(t);return es(e)===r.GROUP?lr.send(Tt.PostGroupChatComment,{groupId:Ln.fromString(e),msgId:s,content:n},{encoder:as,decoder:_n}):lr.send(Tt.PostPrivateChatComment,{destId:Ln.fromString(e),msgId:s,content:n},{encoder:is,decoder:_n})},Es=(e,t,n)=>{const s=Ln.fromString(t);return es(e)===r.GROUP?lr.send(Tt.PinnedGroupMessage,{groupId:Ln.fromString(e),pinned:n,msgId:s},{encoder:os,decoder:_n}):lr.send(Tt.PinnedPrivateMessage,{destId:Ln.fromString(e),pinned:n,msgId:s},{encoder:ss,decoder:_n})},Ts=e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=Ln.fromString(e.offset):t.oldOffset=Ln.fromString(e.offset),lr.send(Tt.GetRemoteMessages,t,{encoder:_r,decoder:Ar})},_s=(e,t)=>lr.send(Tt.DeleteChatMessages,{destId:Ln.fromString(e),msgIdList:t.map(e=>Ln.fromString(e))},{encoder:wr,decoder:_n}),As=e=>lr.send(Tt.ClearChatHistoryMessage,{destId:e},{encoder:Ir,decoder:_n}),ks=e=>lr.send(Tt.GetDialogList,e,{encoder:kr,decoder:Mr}),Ms=e=>lr.send(Tt.GetBriefDialogList,{destId:e.map(e=>Ln.fromString(e))},{encoder:Or,decoder:Sr}),Ps=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.UpdateGroupChatMuteConfig,{groupId:Ln.fromString(e),muteFlag:t},{encoder:Wr,decoder:_n}):lr.send(Tt.UpdatePrivateChatMuteConfig,{destId:Ln.fromString(e),muteFlag:t},{encoder:Cr,decoder:_n}),n},Ns=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.UpdateGroupChatStickyConfig,{groupId:Ln.fromString(e),stickyFlag:t},{encoder:$r,decoder:_n}):lr.send(Tt.UpdatePrivateChatStickyConfig,{destId:Ln.fromString(e),stickyFlag:t},{encoder:br,decoder:_n}),n},Ls=(e,t,n)=>{const s=Ln.fromString(e),o=Ln.fromNumber(n);return es(e)===r.GROUP?lr.send(Tt.UpdateGroupChatBurnAfterReadingConfig,{groupId:s,burnAfterReadingFlag:t,burnAfterReadingTime:o},{encoder:us,decoder:_n}):lr.send(Tt.UpdatePrivateChatBurnAfterReadingConfig,{destId:s,burnAfterReadingFlag:t,burnAfterReadingTime:o},{encoder:ls,decoder:_n})},Ds=e=>lr.send(Tt.DeletePrivateDialog,{destId:Ln.fromString(e)},{encoder:yr,decoder:_n}),Us=e=>lr.send(Tt.GetDialogChangedStatus,{time:Ln.fromNumber(e)},{encoder:Pr,decoder:Nr}),js=e=>lr.send(Tt.PostAnalyticsLogs,{data:e},{encoder:An,decoder:_n}),Bs=()=>lr.send(Tt.GetDialogFilterConfig,{},{encoder:hs,decoder:ys}),Fs=e=>lr.send(Tt.SYNC_CONVERSATION_READ_STATUS,{destId:Ln.fromString(e)},{encoder:Fr,decoder:xr});var xs=Object.freeze({__proto__:null,clearHistoryMessage:As,commentChatMessage:Rs,deleteDialog:Ds,deleteMessages:_s,getBriefDialogList:Ms,getDialogChangedStatus:Us,getDialogFilterConfig:Bs,getDialogKey:vs,getDialogList:ks,getNewMessages:Os,getRemoteMessages:Ts,getServerTime:ms,postAnalyticsLogs:js,recallChatMessage:Ss,sendGroupChatArrivalAck:e=>lr.send(Tt.SendGroupChatArrivalAck,e,{encoder:Zr,decoder:_n}),sendGroupChatMessage:ws,sendGroupChatReadAck:e=>lr.send(Tt.SendGroupChatReadAck,e,{encoder:Xr,decoder:_n}),sendPrivateChatArrivalAck:e=>lr.send(Tt.SendPrivateChatArrivalAck,e,{encoder:Dr,decoder:_n}),sendPrivateChatMessage:bs,sendPrivateChatReadAck:e=>lr.send(Tt.SendPrivateChatReadAck,e,{encoder:Ur,decoder:_n}),sendQuoteGroupChatMessage:Is,sendQuotePrivateChatMessage:Cs,syncConversationReadStatus:Fs,updateChatBurnAfterReadingConfig:Ls,updateChatMuteConfig:Ps,updateChatStickyConfig:Ns,updateMessagePinned:Es});let Gs=0;const qs=()=>(new Date).getTime()+Gs,Vs=new Set;var Ks={addMessage(e){Vs.add(e)},remove(e){Vs.delete(e)},has:e=>Vs.has(e),reset(){Vs.clear()}};const Hs=new Set;var zs={addMessage(e){Hs.add(e)},remove(e){Hs.delete(e)},has:e=>Hs.has(e),reset(){Hs.clear()}};const $s=new Map;function Ws(e,t){$s.set(e,t)}function Js(e,t){const n=$s.get(e);if(!n)return console.warn(`No message constructor found for type: ${e}`),null;try{return new n(t)}catch(t){return console.error(`Failed to decode message type ${e}:`,t),null}}var Zs=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(n=>{t(n.get(e))}),setTimeout(()=>{t(null)},8e3)}):null}getDialogAesKeyList(e){return new Promise(t=>{const n=new Map;this.getDialogAesKeyListInBatches(e,(r,s)=>{if(s.size)for(const[e,t]of s)n.set(e,t);(n.size===e.length||r)&&t(n)})})}getDialogAesKeyListInBatches(e,t){const n=new Map,r=[];e.forEach(e=>{if(!ut(e))return;const t=this.getDialogAesKeyFromLocal(e);t?n.set(e,t):r.push(e)}),t(!1,n),r.length&&this.getDialogAesKeyListFromRemote(r).then(e=>{t(!0,e)})}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(e){if(!e.length)return new Map;try{const{code:n,data:r}=await vs(e.map(e=>Ln.fromString(e)));if(n===t.SUCCESS){const e=new Map;for(const t in r.entry){const n=r.entry[t];if(n.aesKey?.length&&n.aesIV?.length){const r={key:n.aesKey,iv:n.aesIV};e.set(t,r),this.aesKeyRecord.set(t,r)}}return e}}catch(e){Xi.error("getDialogAesKeyListFromRemote error",e)}return new Map}getDialogAesKeyFromLocal(e){return ut(e)?this.aesKeyRecord.get(e):null}};const Xs="time",Ys=(e,t)=>[e,t,Xs].join("_");class Qs{appkey;userId;inBoxOffset=Ln.ZERO;constructor(e,t){this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=Ys(this.appkey,this.userId);Ct.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=Ys(this.appkey,this.userId);this.inBoxOffset=Ln.fromString(Ct.get(e)??"0")}return this.inBoxOffset}}const eo=(e,t)=>{if(!ut(e))return"";const n=et.AES.encrypt(e,et.enc.Utf8.parse(t.key),{iv:nt(t.iv)?et.enc.Utf8.parse(t.iv):void 0});return Array.from(no(n.ciphertext.words)).map(e=>e.toString(16).padStart(2,"0")).join("")},to=(e,t)=>{const n=new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))||[]),r=window.btoa(String.fromCharCode(...n));return et.AES.decrypt(r,et.enc.Utf8.parse(t.key),{iv:nt(t.iv)?et.enc.Utf8.parse(t.iv):void 0}).toString(et.enc.Utf8)},no=e=>{const t=[];let n,r,s;for(r=0;r<e.length;++r)for(n=e[r],s=3;s>=0;--s)t.push(n>>8*s&255);return new Uint8Array(t)},ro={TEXT:0,IMAGE:805310464,GIF:805310475,FILE:805310490,AUDIO:805310481,VIDEO:805310470,RECALL:1610678302,STORED_RECALL:1610678301,LOCATION:805310469,CHAT_RECORD:805310489,CONTACT:268439554,GROUP_INVITATION:805310467,REDPACKET:268439616,TRANSFER:268439600,LINK:268439556},so=1610678290,oo=1610743841,io={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,MESSAGE_READ:1610678295,CHANGE_GROUP_TITLE:1610743809,CHANGE_GROUP_AVATAR:1610809394,PRIVATE_MESSAGE_PINNED:1610711169,GROUP_MESSAGE_PINNED:1610776706,CHAT_COMMENT:1610678301};function ao(e){return e===ro.RECALL||e===ro.STORED_RECALL}function co(e){return e===so||e===oo?ro.RECALL:e}function lo(e){if(!nt(e))return e;if(Array.isArray(e))return e.map(e=>lo(e));if(at(e)){const t={};return Object.keys(e).forEach(n=>{t[n]=lo(e[n])}),t}return e}const uo={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 go{localStore;constructor(e,t){const n=`con-${e}-${t}`;this.localStore=new It(n)}getStoreKey(e){return`${e.conversationType}_${e.targetId}\n }`}getConOptionByKey(e){const t=(e=e||"").split("_");if(t.length>=2){const e=t.shift(),n=t.shift();return{conversationType:Number(e),targetId:n}}return{conversationType:r.PRIVATE,targetId:"0"}}updateUnreadCount(e){const{conversationType:t,targetId:n,content:r,messageType:s,sentTime:o,isCounted:a,messageDirection:c}=e,l=c===i.SEND,u=ao(s),d=at(r),g={conversationType:t,targetId:n},p=this.get(g)||{},f=p.lastUnreadTime||Ln.ZERO,h=p.unreadMessageCount||0;if(!(o<=f)&&!l){if(a&&(p.unreadMessageCount=h+1,f||(p.lastUnreadTime=o)),u&&d){r.sentTime>=f&&h&&(p.unreadMessageCount=h-1)}this.set(g,p)}}updateMentionedData(e){const{conversationType:t,targetId:n,messageUId:s,messageType:o,isMentioned:a,messageDirection:c,content:l}=e;if(!s||c===i.SEND||!a&&!ao(o))return;const u=this.getStoreKey({conversationType:t,targetId:n}),d=this.localStore.get(u)||{},g=uo.mentionedUIds.keyName,p=d[g]||[];if(a&&t===r.GROUP&&(p.includes(s.toString())||p.push(s.toString())),ao(o)&&t===r.GROUP){const e=l,t=p.indexOf(e.messageUId?.toString()??"");t>=0&&p.splice(t,1)}p.length?d[g]=p:delete d[g],dt(d)?this.localStore.set(u,d):this.localStore.remove(u)}updateUpdateTime(e,t){const n=this.getStoreKey(e),r=this.localStore.get(n)||{},s=uo.updateTime.keyName,o=Number(r[s]||0);r[s]=Math.max(o,t),this.localStore.set(n,r)}set(e,t){const n=this.getStoreKey(e),r=this.localStore.get(n)||{};for(const e of pt(t)){const n=uo[e],s=t[e];if(ot(n?.keyName)||ot(s))continue;s===n.defaultVal?delete r[n.keyName]:r[n.keyName]=s,r[uo.unreadMessageCount.keyName]||(delete r[uo.lastUnreadTime.keyName],delete r[uo.mentionedUIds.keyName])}dt(r)?this.localStore.set(n,r):this.localStore.remove(n)}remove(e){const t=this.getStoreKey(e);this.localStore.remove(t)}get(e){const t=this.getStoreKey(e),n=this.localStore.get(t)||{},r={};for(const e of pt(uo)){const{keyName:t,defaultVal:s}=uo[e];"mentionedUIds"===e?(r.unreadMentionedCount=n[t]?.length??0,r.hasMentioned=!!r.unreadMentionedCount):r[e]=n[t]||lo(s)}return r}getAll(){const e=this.localStore.getCache()||{},t=[];for(const n in e){const r=this.getConOptionByKey(n),s=e[n];for(const e of pt(uo)){const{keyName:t,defaultVal:n}=uo[e];"mentionedUIds"!==e&&(r[e]=s[t]||lo(n))}t.push(r)}return t}}const po=e=>{const t=e.destId??"",n=ns(t);if(!n)return;e.dialogTitle,e.smallAvatarUrl;return{...n,unreadMessageCount:0,notificationStatus:e.muteFlag?o.OPEN:o.CLOSE,notificationLevel:e.muteFlag?l.NOT_MESSAGE_NOTIFICATION:l.ALL_MESSAGE,isTop:!!e.stickyFlag,dialogTitle:e.dialogTitle,smallAvatarUrl:e.smallAvatarUrl,lastUnreadTime:"0",burnAfterReadingFlag:!!e.burnAfterReadingFlag,burnAfterReadingTime:e.burnAfterReadingTime&&e.burnAfterReadingTime.toNumber()}};class fo{events={};on(e,t,n){const r=this.events[e]||(this.events[e]=[]);r.some(e=>e.listener===t&&e.target===n)||r.push({listener:t,target:n})}emit(e,...t){const n=this.events[e];n?.length&&n.map(e=>{const{target:n,listener:r}=e;try{r.call(n,...t)}catch(e){}})}off(e,t,n){let r=this.events[e];r?.length&&(r=r.filter(e=>e.listener!==t||e.target!==n),r.length?this.events[e]=r:delete this.events[e])}once(e,t,n){const r=(...s)=>{t.call(n,...s),this.off(e,r,n)};return this.on(e,r,n),this}}const ho="STATUS_CHANGED";class yo{storageKey;eventEmitter;isPulling=!1;constructor(e,t){this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new fo}async pull(){if(this.isPulling)return;let e;this.isPulling=!0;const n=Ct.get(this.storageKey);e=rt(n)&&n>0?n:qs()-1e4;let{code:r,data:s}=await Us(e);r===t.SUCCESS&&(Ln.isLong(s.setTime)&&s.setTime.toNumber()>0&&Ct.set(this.storageKey,s.setTime.toNumber()),s.briefDialog&&pt(s.briefDialog).forEach(e=>{const t=s.briefDialog[e],n=po(t);n&&this.eventEmitter.emit(ho,n)})),this.isPulling=!1}watch(e){this.eventEmitter.on(ho,t=>{e(t)})}}class mo{updatedConversationFunc;store;draftMap=new Map;localConversationSet=new Set;updatedConversations=[];notify;statusManager;constructor(e,t,n){this.updatedConversationFunc=n,this.store=new go(e,t),this.notify=ht(this.notifyConversationChanged.bind(this),0),this.statusManager=new yo(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),removed:e.removed||this.updatedConversations[t].removed},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){const e=this.updatedConversations.map(e=>e.removed?{conversation:e.conversation,updatedItems:e.updatedItems,removed:!0}:{conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems});this.updatedConversations=[],this.updatedConversationFunc?.(e)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(e){if(!e?.length)return;const n=e.filter(e=>!this.localConversationSet.has(this.getConversationKey(e)));if(!n.length)return;const r=n.map(ts);if(!r.length)return;const{code:s,data:o}=await Ms(r);s===t.SUCCESS&&pt(o.briefDialog).forEach(e=>{const t=o.briefDialog[e],n=po(t);n&&(this.localConversationSet.add(this.getConversationKey(n)),this.addStatus(n,!0))})}addLocalConversation(e){const{conversationType:t,targetId:n,isTop:r,notificationStatus:s,notificationLevel:o,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:n,isTop:r,notificationStatus:s,notificationLevel:o,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u},!1)}addStatus(e,t=!1){const{conversationType:n,targetId:r,notificationStatus:s,notificationLevel:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}=e,g={conversationType:n,targetId:r},p=qs(),f=this.store.get(g),h={};nt(o)&&f.notificationLevel!==o&&(h.notificationLevel={time:p,val:o}),nt(s)&&f.notificationStatus!==s&&(h.notificationStatus={time:p,val:s}),nt(i)&&f.isTop!==i&&(h.isTop={time:p,val:i}),nt(a)&&f.dialogTitle!==a&&(h.dialogTitle={time:p,val:a}),nt(c)&&f.smallAvatarUrl!==c&&(h.smallAvatarUrl={time:p,val:c}),nt(l)&&f.burnAfterReadingFlag!==l&&(h.burnAfterReadingFlag={time:p,val:l}),nt(u)&&f.burnAfterReadingTime!==u&&(h.burnAfterReadingTime={time:p,val:u}),this.store.set(g,{notificationStatus:s,isTop:i,notificationLevel:o,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u}),nt(d)&&this.store.updateUpdateTime(g,d),Object.keys(h).length&&t&&this.setUpdatedConversation({conversation:g,updatedItems:h})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:n,targetId:r}=e;if(!n)return;const s={conversationType:t,targetId:r},o={conversation:s,updatedItems:{}},i=lo(this.get(s));this.store.updateUnreadCount(e),this.store.updateMentionedData(e),this.store.updateUpdateTime(s,parseInt(e.sentTime));const a=this.get(s);i.unreadMessageCount!==a.unreadMessageCount&&(o.updatedItems.unreadMessageCount={time:parseInt(e.sentTime),val:a.unreadMessageCount}),i.hasMentioned!==a.hasMentioned&&(o.updatedItems.hasMentioned={time:parseInt(e.sentTime),val:a.hasMentioned}),i.unreadMentionedCount!==a.unreadMentionedCount&&(o.updatedItems.unreadMentionedCount={time:parseInt(e.sentTime),val:a.unreadMentionedCount}),Object.keys(o.updatedItems).length&&this.setUpdatedConversation(o)}get(e){return this.store.get(e)}getAllUnreadCount(e,t){const n=this.store.getAll();let r=0;return n.forEach(({unreadMessageCount:n,notificationStatus:s,notificationLevel:i,conversationType:a})=>{n=n||0;const c=s===o.OPEN||i>0;!t&&c||(e.length>0?e.includes(+a)&&(r+=+n):r+=+n)}),r}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:n,unreadMentionedCount:r}=t;(n||r)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const s={};n&&(s.unreadMessageCount={val:0,time:qs()}),r&&(s.hasMentioned={val:!1,time:qs()},s.unreadMentionedCount={val:0,time:qs()}),Object.keys(s).length&&this.setUpdatedConversation({conversation:e,updatedItems:s})}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(e=>e.notificationStatus===o.OPEN||e.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:n,unreadMentionedCount:r,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}=t;return{...e,unreadCount:n,unreadMentionedCount:r??0,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}}return null}getAllConversationState(){return this.store.getAll().map(({conversationType:e,targetId:t,unreadMessageCount:n,unreadMentionedCount:r,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l})=>({conversationType:e,targetId:t,unreadCount:n,unreadMentionedCount:r??0,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}))}remove(e){this.store.remove(e),this.localConversationSet.delete(this.getConversationKey(e)),this.setUpdatedConversation({conversation:e,updatedItems:{},removed:!0})}clearHistoryMessages(e){this.clearUnreadCount(e);const t={conversation:e,updatedItems:{}};t.conversation.latestMessage=void 0,t.updatedItems.latestMessage={val:null,time:qs()},this.setUpdatedConversation(t)}updateLatestMessage(e,t){nt(t)&&this.store.updateUpdateTime(e,parseInt(t.sentTime));const n={conversation:e,updatedItems:{}};nt(t)&&(n.conversation.updateTime=parseInt(t.sentTime)),n.conversation.latestMessage=t,n.updatedItems.latestMessage={val:t,time:qs()},this.setUpdatedConversation(n)}destroyed(){this.updatedConversationFunc=void 0}}const vo={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(e){return l.NOT_SET},getNotificationStatus:function(e){return o.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 bo;var Co={create(e,t,n){bo=new mo(e,t,n)},get:()=>bo??vo};const wo=(e,t,n=a.SENDING)=>{const r=Co.get().get(t.conversation);return{conversationType:t.conversation.conversationType,targetId:t.conversation.targetId,senderUserId:t.senderUserId,messageDirection:i.SEND,isCounted:e.isCounted,isMentioned:!1,content:lo(e.content),messageType:e.messageType,isOffLineMessage:!1,isPersited:e.isPersited,messageId:t.messageId,messageUId:"local"+t.sentTime,sentTime:t.sentTime,sentStatus:n,receivedTime:t.sentTime,isStatusMessage:e.isStatusMessage,receivedStatus:c.IDLE,disableNotification:!0,burnAfterReadingFlag:r?.burnAfterReadingFlag??!1,burnAfterReadingTime:r?.burnAfterReadingTime??0,pinned:!1}};function Io(e){if(e instanceof Error){const t=e.cause;return{type:e.constructor?.name??"Error",name:e.name,message:e.message,stack:e.stack,...void 0===t?{}:{cause:Io(t)}}}let t;try{t="string"==typeof e?e:JSON.stringify(e)??String(e)}catch{t=String(e)}return{type:null===e?"null":typeof e,value:t}}function Oo(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 So=(e,t,n,r)=>{const s=new Map;return e.forEach(e=>{const o=Ro(e,t.get(e),n.get(e),r);o.length&&s.set(e,o)}),s},Ro=(e,t,n,r)=>{const s=ns(e);if(!s)return[];const l=Co.get().get(s);let u=[];return t.forEach(e=>{const t=e;let d=t.mediaConstructor,g=Eo(t,n);if(!g)return;if(d===so||d===oo){const{msgId:e}=g,t={messageUId:e};d=co(d),g=t}const p=Js(d,g);if(nt(p)){const d={...s,senderUserId:t.srcId.toString(),messageDirection:t.isOut?i.SEND:i.RECEIVE,isCounted:p.isCounted,isMentioned:t.atFlag,content:p.content,messageType:p.messageType,isOffLineMessage:!1,isPersited:p.isPersited,messageId:Ln.isLong(t.localId)?t.localId.toNumber():0,messageUId:t.msgId.toString(),sentTime:t.seqno.toString(),sentStatus:a.SENT,receivedTime:qs().toString(),isStatusMessage:p.isStatusMessage,receivedStatus:t.msgRead?c.READ:t.msgArrival?c.RECEIVED:c.IDLE,disableNotification:l?.notificationStatus===o.OPEN||t.srcId.toString()==sr.uid,burnAfterReadingFlag:t.burnAfterReadingFlag,burnAfterReadingTime:t.burnAfterReadingTime&&t.burnAfterReadingTime.toNumber(),pinned:!1};if(d.isStatusMessage&&Ln.fromNumber(qs()).subtract(d.sentTime).greaterThan(6e3))return;if(t.msgIdReferenced&&Ln.isLong(t.msgIdReferenced)){const e=r[t.msgIdReferenced.toString()];if(e){let t=Eo({mediaAttribute:e.mediaAttribute,msgPreContent:e.msgPreContent,msgPostContent:e.msgPostContent,mediaConstructor:e.mediaConstructor??0,msgId:e.msgId??Ln.fromNumber(0)},n);if(t){const n=Js(e.mediaConstructor??0,t);nt(n)&&(d.quotedReply=((e,t,n)=>({conversationType:n.conversationType,targetId:e.destId.toString(),senderUserId:e.srcId.toString(),messageDirection:e.srcId.toString()===sr.uid?i.SEND:i.RECEIVE,isCounted:t.isCounted,isMentioned:!1,content:lo(t.content),messageType:t.messageType,isOffLineMessage:!1,isPersited:t.isPersited,messageId:1,messageUId:e.msgId.toString(),sentTime:e.msgSendTime.toString(),sentStatus:a.SENT,receivedTime:e.msgSendTime.toString(),isStatusMessage:t.isStatusMessage,receivedStatus:c.RECEIVED,disableNotification:!0,burnAfterReadingFlag:!1,burnAfterReadingTime:0,pinned:!1,senderUserName:e.srcName}))(e,n,s))}}}ut(d.messageUId)?u.push(d):Xi.error("message is invalid",Oo(e))}}),u},Eo=(e,t)=>{try{let n,r;return n=e.mediaAttribute?.length?to(e.mediaAttribute,t):e.msgPreContent??"",e.msgPostContent?.length&&(r=to(e.msgPostContent,t)),To(e.mediaConstructor,n,r)}catch(t){return Xi.error("decode message content fail",e,t),null}},To=(e,t,n)=>{let r={};if(t?.length){const e=_o(t);r=JSON.parse(e,Po)}return e===ro.TEXT&&void 0!==n&&(r.content=n),r},_o=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},Ao=new Set(["destId","groupId","groupUin","msgId"]),ko=new Set(["msgIdList"]),Mo=(e,t)=>{if("string"==typeof t)return t;if("number"==typeof t&&Number.isSafeInteger(t))return t.toString();throw new TypeError(`${e} must be an Int64 string or a safe integer, received ${typeof t}`)},Po=(e,t)=>null==t?t:Ao.has(e)?Mo(e,t):ko.has(e)?Array.isArray(t)?t.map(t=>Mo(e,t)):Mo(e,t):t;var No={parse:function(e,t,n){const r=new Map;if(Object.keys(e).forEach(t=>{const n=e[t].dialogMessage?.filter(e=>!e.sharingGroupFlag);n?.length&&r.set(t,n)}),!r.size)return void n(!0,new Map);const s=new Set([...r.keys()]);Zs.getDialogAesKeyListInBatches([...r.keys()],(e,o)=>{try{if(o.size){const e=[...o.keys()];for(const t of e)s.delete(t);n(!s.size,So(e,r,o,t))}s.size&&e&&n(!0,new Map)}catch(t){Xi.error("parseDialogsMessages error",t),s.size&&e&&n(!0,new Map)}})},parseSingleDialogMessages:Ro,decodeChatRecordMsgDetails2ReceivedMessages:(e,t)=>{let n=[];return t.forEach(t=>{const r=To(t.mediaConstructor,t.mediaAttribute,t.msgPostContent);if(!r)return;const s=Js(t.mediaConstructor,r);if(nt(s)){const r={...e,senderUserId:t.srcId.toString(),messageDirection:t.srcId==sr.uid?i.SEND:i.RECEIVE,isCounted:s.isCounted,isMentioned:!1,content:s.content,messageType:s.messageType,isOffLineMessage:!1,isPersited:s.isPersited,messageId:0,messageUId:t.msgId+"",sentTime:t.msgSendTime+"",sentStatus:a.SENT,receivedTime:t.msgSendTime+"",isStatusMessage:s.isStatusMessage,receivedStatus:c.READ,disableNotification:!1};n.push(r)}}),n},encodeReceivedMessage2ChatRecordMsgDetail:e=>{const t=Js(e.messageType,e.content);if(!t)return null;const n=JSON.stringify(t.content),r=e.messageType===ro.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:n,msgPostContent:r,msgSendTime:e.sentTime}}};const Lo="unreadMessageUids";class Do{api;localStore;constructor(e,t,n=xs){this.api=n;const r=`receipt-v2-${e}-${t}`;this.localStore=new It(r)}storeUnreadMessageUids(e){const t=e.filter(e=>e.isCounted&&e.messageDirection!==i.SEND).map(e=>({uid:e.messageUId,timestamp:Date.now()})),n=[...this.localStore.get(Lo)||[],...t];this.localStore.set(Lo,n)}cleanExpiredMessages(){const e=this.localStore.get(Lo)||[],t=Date.now(),n=e.filter(e=>t-e.timestamp<=1728e5);this.localStore.set(Lo,n)}formatReceiptMessages(e){const t=[],n=[];e.forEach(e=>{e.conversationType===r.PRIVATE?t.push(e):n.push(e)});return{privateReceiptMessages:Object.entries(t.reduce((e,t)=>(e[t.targetId]||(e[t.targetId]=[]),e[t.targetId].push(t.messageUId),e),{})).map(([e,t])=>({destId:Ln.fromString(e),msgId:t.map(e=>Ln.fromString(e))})),groupReceiptMessages:n.reduce((e,t)=>{const n=e.find(e=>e.groupId.equals(Ln.fromString(t.targetId))&&e.userId.equals(Ln.fromString(t.senderUserId)));return n?n.msgId.push(Ln.fromString(t.messageUId)):e.push({groupId:Ln.fromString(t.targetId),userId:Ln.fromString(t.senderUserId),msgId:[Ln.fromString(t.messageUId)]}),e},[])}}filterValidMessages(e){return e.filter(e=>e.isCounted&&e.messageDirection!==i.SEND)}async sendArrivalReceipts(e){this.storeUnreadMessageUids(e);const t=this.filterValidMessages(e),{privateReceiptMessages:n,groupReceiptMessages:r}=this.formatReceiptMessages(t);n.length&&await this.api.sendPrivateChatArrivalAck({chatMessage:n}),r.length&&await this.api.sendGroupChatArrivalAck({groupChatMessage:r})}async sendReadReceipts(e){const t=this.localStore.get(Lo)||[],n=this.filterValidMessages(e).filter(e=>t.some(t=>t.uid===e.messageUId));try{const{privateReceiptMessages:e,groupReceiptMessages:t}=this.formatReceiptMessages(n);e.length&&await this.api.sendPrivateChatReadAck({chatMessage:e}),t.length&&await this.api.sendGroupChatReadAck({groupChatMessage:t});const r=this.localStore.get(Lo)||[],s=n.map(e=>e.messageUId),o=r.filter(e=>!s.includes(e.uid));this.localStore.set(Lo,o)}catch(e){throw console.error("发送已读回执失败:",e),e}}}let Uo;var jo={create(e,t){Uo=new Do(e,t),Uo.cleanExpiredMessages()},get:()=>Uo};let Bo=0,Fo=0;function xo(e,t){Bo=e+100,Fo=t+100}function Go(){return Fo++,Fo}function qo(){return Bo--,Bo}function Vo(){return Fo}async function Ko(e,t){const n=await e.request(t);if(n.ok)return n.value;const r=new Error(n.error.message);throw r.name=n.error.name,r.stack=n.error.stack,r}function Ho(e,t,n){if(!e)return null;if(!/^[0-9a-f]+$/i.test(e)||e.length%2!=0)return e;const r=n.lib.CipherParams.create({ciphertext:n.enc.Hex.parse(e)}),s=n.AES.decrypt(r,n.enc.Utf8.parse(t.key),{iv:n.enc.Utf8.parse(t.iv)}).toString(n.enc.Utf8);if(!s)throw new Error("Unable to decrypt a legacy message");return JSON.parse(s)}function zo(e,t,n=et){const r={...e};return"string"==typeof r.content&&(r.content=Ho(r.content,t,n)),r.quotedReply&&"string"==typeof r.quotedReply.content&&(r.quotedReply={...r.quotedReply,content:Ho(r.quotedReply.content,t,n)}),r}function $o(e,t){return new Promise((n,r)=>{const s=e.open(t);s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error??new Error("Unable to open legacy database"))})}function Wo(e,t,n,r,s){return new Promise((o,i)=>{const a=e.transaction(t,"readonly"),c=a.objectStore(t),l=void 0===n?void 0:s.lowerBound(n,!0),u=c.openCursor(l),d=[];let g;u.onsuccess=()=>{const e=u.result;!e||d.length>=r?o({values:d,lastKey:g}):(d.push(e.value),g=e.primaryKey,d.length>=r?o({values:d,lastKey:g}):e.continue())},u.onerror=()=>i(u.error??new Error(`Unable to read ${t}`)),a.onabort=()=>i(a.error??new Error(`Unable to read ${t}`))})}async function Jo(e,t){if("function"!=typeof e.databases)throw new Error("IndexedDB.databases() is required for safe legacy migration");return(await e.databases()).some(e=>e.name===t)}function Zo(e,t){return new Promise((n,r)=>{const s=e.transaction(t,"readonly"),o=s.objectStore(t).count();o.onsuccess=()=>n(o.result),o.onerror=()=>r(o.error??new Error(`Unable to count ${t}`)),s.onabort=()=>r(s.error??new Error(`Unable to count ${t}`))})}async function Xo({appKey:e,userId:t,bridge:n,indexedDBFactory:r=indexedDB,keyRange:s=IDBKeyRange,batchSize:o=200,onProgress:i}){if("complete"===await Ko(n,{type:"read",method:"getLegacyMigrationState",args:[]}))return{migrated:!1,messages:0,dialogStates:0};const a=`im_message_cache_1_${e}_${t}`;if(!await Jo(r,a))return{migrated:!1,messages:0,dialogStates:0};const c=await $o(r,a),l=function(e,t){const n="im_message_cache_salt_prefix",r=et.SHA256(`${n}${e}_${t}im_message_cache_salt_suffix`).toString(),s=r.substring(0,16),o=r.substring(16,48),i=et.SHA256(`${s}:${n}:${t}:${e}`).toString().substring(0,8);return{key:et.PBKDF2(o,i,{keySize:8,iterations:1e3,hasher:et.algo.SHA256}).toString().substring(0,32),iv:s}}(e,t);let u=0,d=0;try{if(c.objectStoreNames.contains("messages_new")){let e;for(;;){const t=await Wo(c,"messages_new",e,o,s);if(0===t.values.length)break;const r=t.values.map(e=>zo(e,l));if(await Ko(n,{type:"write",method:"importLegacyBatch",args:[{messages:r,dialogStates:[]}]}),u+=r.length,i?.({processedMessages:u,processedDialogStates:d}),e=t.lastKey,t.values.length<o)break}}if(c.objectStoreNames.contains("dialogStates_new")){let e;for(;;){const t=await Wo(c,"dialogStates_new",e,o,s);if(0===t.values.length)break;if(await Ko(n,{type:"write",method:"importLegacyBatch",args:[{messages:[],dialogStates:t.values}]}),d+=t.values.length,i?.({processedMessages:u,processedDialogStates:d}),e=t.lastKey,t.values.length<o)break}}return await Ko(n,{type:"write",method:"completeLegacyMigration",args:[]}),{migrated:!0,messages:u,dialogStates:d}}finally{c.close()}}class Yo{appKey;userId;bridge;options;initialization=null;constructor(e,t,n=function(){const e=globalThis;if(!e.acimDatabase)throw new Error("ACIM database preload bridge is unavailable; install the Electron preload entry first");return e.acimDatabase}(),r={}){this.appKey=e,this.userId=t,this.bridge=n,this.options=r}initDB(){return this.initialization||(this.initialization=Ko(this.bridge,{type:"open",options:{appKey:this.appKey,userId:this.userId}}).then(async()=>{const e=this.options.indexedDBFactory??("undefined"==typeof indexedDB?void 0:indexedDB),t=this.options.keyRange??("undefined"==typeof IDBKeyRange?void 0:IDBKeyRange);"manual"!==this.options.legacyMigrationMode&&e&&t&&await Xo(this.migrationOptions({indexedDBFactory:e,keyRange:t}))})),this.initialization}async migrateLegacyDatabase(e){return await this.initDB(),Xo(this.migrationOptions({onProgress:e}))}async getLegacyMigrationInfo(){return await this.initDB(),async function({appKey:e,userId:t,bridge:n,indexedDBFactory:r=indexedDB}){const s=await Ko(n,{type:"read",method:"getLegacyMigrationState",args:[]}),o=`im_message_cache_1_${e}_${t}`;if(!await Jo(r,o))return{state:s,exists:!1,totalMessages:0,totalDialogStates:0};const i=await $o(r,o);try{return{state:s,exists:!0,totalMessages:i.objectStoreNames.contains("messages_new")?await Zo(i,"messages_new"):0,totalDialogStates:i.objectStoreNames.contains("dialogStates_new")?await Zo(i,"dialogStates_new"):0}}finally{i.close()}}(this.migrationOptions())}async getLegacyMediaReferences(e=0,t=500){return this.read("getLegacyMediaReferences",[e,t])}async deleteLegacyDatabase(){await this.initDB(),await async function({appKey:e,userId:t,indexedDBFactory:n=indexedDB}){const r=`im_message_cache_1_${e}_${t}`;await Jo(n,r)&&await new Promise((e,t)=>{const s=n.deleteDatabase(r);s.onsuccess=()=>e(),s.onerror=()=>t(s.error??new Error("Unable to delete legacy database")),s.onblocked=()=>t(new Error("Legacy database deletion was blocked"))})}({appKey:this.appKey,userId:this.userId,indexedDBFactory:this.options.indexedDBFactory})}async close(){this.initialization&&(await this.initialization,await Ko(this.bridge,{type:"close"}),this.initialization=null)}async deleteDatabase(){await this.close(),await Ko(this.bridge,{type:"delete",options:{appKey:this.appKey,userId:this.userId}})}async addMessages(e,t,n){const r=e.filter(e=>e.isPersited);await this.write("addMessages",[r,ts(t),n])}async getMessages(e,t="0",n=20,r=!0){return this.read("getMessages",[ts(e),t,n,r])}getPreviousMessages(e,t="0",n=20){return this.getMessages(e,t,n,!0)}getMessagesByType(e,t,n="0",r=50,s=!0){return this.read("getMessagesByType",[ts(e),t,n,r,s])}getLatestMessage(e){return this.read("getLatestMessage",[ts(e)])}async getLatestMessages(e){const t=e.map(ts);return this.read("getLatestMessages",[t])}getMessageById(e){return this.read("getMessageById",[e])}getMessageByUId(e){return this.read("getMessageByUId",[e])}getPinnedMessages(e,t=50){return this.read("getPinnedMessages",[ts(e),t])}getMessageIdRange(){return this.read("getMessageIdRange",[])}getDialogLoadedState(e){return this.read("getDialogLoadedState",[e])}async clearConversationCache(e){await this.write("clearConversationCache",[ts(e)])}async clearAllCache(){await this.write("clearAllCache",[])}async removeMessagesByUId(e){await this.write("removeMessagesByUId",[e])}async updateMessageReceiptStatus(e,t){const n=0===t?c.RECEIVED:c.READ;await this.write("updateMessageReceiptStatus",[e.messageUIdList,n])}async markMessagesRead(e,t){await this.write("updateMessageReceiptStatus",[e,c.READ,t])}async setMessagePinned(e,t,n){await this.write("setMessagePinned",[ts(e),t,n])}async setMessageReactions(e,t,n){return this.write("setMessageReactions",[ts(e),t,n])}async unpinAllMessages(e){await this.write("unpinAllMessages",[ts(e)])}clearBurnAfterReadingExpiredMessages(e){return this.write("clearBurnAfterReadingExpiredMessages",[ts(e)])}async upsertMessage(e){await this.write("upsertMessage",[e,ts(e)])}async convertToRecallMessages(e){await this.write("convertToRecallMessages",[e,ro.RECALL])}searchTextMessages(e,t){return this.read("searchTextMessages",[ts(e),t])}searchMessages(e,t=500){return this.read("searchMessages",[e,void 0,t])}migrationOptions(e={}){return{appKey:this.appKey,userId:this.userId,bridge:this.bridge,indexedDBFactory:this.options.indexedDBFactory,keyRange:this.options.keyRange,...e}}async read(e,t){return await this.initDB(),Ko(this.bridge,{type:"read",method:e,args:t})}async write(e,t){return await this.initDB(),Ko(this.bridge,{type:"write",method:e,args:t})}}let Qo=null;var ei={create:(e,t,n={})=>(Qo=new Yo(e,t,void 0,n),Qo),get:()=>Qo};function ti(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e&&Number.isFinite(e))return String(e);if("object"==typeof e&&"function"==typeof e.toString){const t=e.toString;if(t!==Object.prototype.toString){const n=t.call(e);if("string"==typeof n)return n}}return""}function ni(e,t){const n=ti(t.uid),r=(e??[]).filter(e=>ti(e.uid)!==n);return t.content.trim()?[{...t,uid:n},...r]:r}class ri{handlers=new Map;register(e,t){this.handlers.set(e,t)}contains(e){return this.handlers.has(e)}async process(e,t){const n=this.handlers.get(e.messageType);return!!n&&(await n.process(e,t),n.shouldConsume?.(e)??n.consumed)}}class si{consumed;callback;constructor(e,t){this.consumed=e,this.callback=t}async process(e,t){await this.callback(e,t)}}class oi{receivedStatus;receiptType;publish;consumed=!0;constructor(e,t,n){this.receivedStatus=e,this.receiptType=t,this.publish=n}async process(e,t){const n=e.content,r=n.msgIdList;if(null==r)return;const s=(Array.isArray(r)?r:[r]).map(e=>e.toString()),o=new Set(s);for(const e of t)e.messageDirection===i.SEND&&o.has(e.messageUId)&&e.receivedStatus<this.receivedStatus&&(e.receivedStatus=this.receivedStatus);await this.publish({conversation:{conversationType:e.conversationType,targetId:n.groupId??n.destId??e.targetId},messageUIdList:s},this.receiptType)}}class ii{setMessagePinned;unpinAllMessages;publish;consumed=!1;constructor(e,t,n){this.setMessagePinned=e,this.unpinAllMessages=t,this.publish=n}shouldConsume(e){return e.content.pinned!==g.PIN}async process(e,t){const n=e.content.pinned;if(n!==g.PIN&&n!==g.UNPIN&&n!==g.UNPIN_ALL)return;const r={conversationType:e.conversationType,targetId:e.targetId},s=String(e.content.msgId??"");if(n===g.UNPIN_ALL)t.forEach(e=>{e.pinned=!1}),await this.unpinAllMessages(r);else{const e=n===g.PIN;t.forEach(t=>{t.messageUId===s&&(t.pinned=e)}),await this.setMessagePinned(r,s,e)}await this.publish({conversation:r,messageUId:n===g.UNPIN_ALL?void 0:s,operation:n})}}function ai(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e&&Number.isFinite(e))return String(e);if("object"==typeof e&&"function"==typeof e.toString){const t=e.toString;if(t!==Object.prototype.toString){const n=t.call(e);if("string"==typeof n&&"[object Object]"!==n)return n}}return""}class ci{getMessageByUId;setMessageReactions;publish;consumed=!0;constructor(e,t,n){this.getMessageByUId=e,this.setMessageReactions=t,this.publish=n}async process(e,t){const n=e.content,r=ai(n.uid);if(!r||"0"===r)return;const s=ai(n.msgId);if(!s||"0"===s)return;const o={conversationType:e.conversationType,targetId:e.targetId},i=t.find(t=>t!==e&&ai(t.messageUId)===s),a=await this.getMessageByUId(s),c=i??a;if(!c)return void Xi.warn("chat comment notification: target message not found",s);const l=c.reactions??(c===a?void 0:a?.reactions),u={uid:r,msgId:s,content:n.content??"",nickname:n.nickName??n.nickname??"",time:Number(n.time)||0},d=ni(l,u);c.reactions=d;(await this.setMessageReactions(o,s,d)||i)&&await this.publish({conversation:o,messageUId:s,reactions:d,change:u})}}class li{watcher;pullingMsg=!1;letterbox;serverMsgSeqno=Ln.ZERO;pullOfflineFinished=!1;intervalTimer;retryTimer;latestSyncTimestamp=0;started=!1;notificationProcessor=new ri;constructor(e,t){this.watcher=e,this.letterbox=new Qs(t.appkey,sr.uid.toString()),this.registerNotificationHandlers()}registerNotificationHandlers(){this.notificationProcessor.register(io.MESSAGE_READ,new si(!0,e=>{const{toPc:t,destId:n}=e.content;t&&Co.get().clearUnreadCount({conversationType:es(Ln.fromString(n)),targetId:n})})),this.notificationProcessor.register(io.CHANGE_GROUP_TITLE,new si(!1,e=>{this.handleGroupTitleChangeMessage(e)})),this.notificationProcessor.register(io.CHANGE_GROUP_AVATAR,new si(!1,e=>{this.handleGroupAvatarChangeMessage(e)}));const e=new si(!1,e=>{this.handleBurnAfterReadingMessage(e)});[io.PRIVATE_OPEN_BURNAFTERREADING,io.GROUP_OPEN_BURNAFTERREADING,io.PRIVATE_CLOSE_BURNAFTERREADING,io.GROUP_CLOSE_BURNAFTERREADING].forEach(t=>{this.notificationProcessor.register(t,e)});const t=(e,t)=>this.watcher.onReceiptReceived?.(e,t);this.notificationProcessor.register(io.GROUP_ARRIVAL_RECEIPT,new oi(c.RECEIVED,0,t)),this.notificationProcessor.register(io.PRIVATE_ARRIVAL_RECEIPT,new oi(c.RECEIVED,0,t)),this.notificationProcessor.register(io.GROUP_READ_RECEIPT,new oi(c.READ,1,t)),this.notificationProcessor.register(io.PRIVATE_READ_RECEIPT,new oi(c.READ,1,t));const n=new ii(async(e,t,n)=>{await(ei.get()?.setMessagePinned(e,t,n))},async e=>{await(ei.get()?.unpinAllMessages(e))},e=>this.watcher.onMessagePinnedChanged?.(e));this.notificationProcessor.register(io.PRIVATE_MESSAGE_PINNED,n),this.notificationProcessor.register(io.GROUP_MESSAGE_PINNED,n),this.notificationProcessor.register(io.CHAT_COMMENT,new ci(async e=>ei.get()?.getMessageByUId(e),async(e,t,n)=>await(ei.get()?.setMessageReactions(e,t,n))??!1,e=>this.watcher.onMessageReactionsChanged?.(e)))}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 n=this.letterbox.getInboxOffset();Xi.info(`pullMsg -> time: ${n}`),this.latestSyncTimestamp=Date.now();const{code:r,data:s}=await Os(n,60);if(r!==t.SUCCESS)return Xi.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void(Ki.loader?.getConnectionStatus()==e.CONNECTED&&this.try2RePullMsg());const{offset:o,seqno:i,msg:a,reference:c}=s,l=Object.keys(a).map(e=>({conversationType:es(Ln.fromString(e)),targetId:e}));await Co.get().loadConvsationsIfNotExist(l),No.parse(a,c,async(e,t)=>{let r,s=[];try{for(const[e,n]of t.entries()){if(r=e,s=n,0===n.length)return;await this.processMessages(n,!this.pullOfflineFinished)}}catch(e){Xi.error("processMessages error ->",Io(e),"context ->",{inboxTime:n,offset:o?.toString(),seqno:i?.toString(),dialogId:r,isOfflineMessage:!this.pullOfflineFinished,messageCount:s.length,messages:(a=s,a.map(Oo))})}var a;if(e)try{let e;i&&(Ln.isLong(i)?e=i:"string"==typeof i?e=Ln.fromString(i):"number"==typeof i&&(e=Ln.fromNumber(i))),e&&Ln.isLong(e)&&e.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=e);const t=this.serverMsgSeqno.lessThanOrEqual(o);Xi.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){Xi.error("setPullMsgDone error",e),this.pullingMsg=!1}})}async processMessages(e,t){const n={conversationType:e[0].conversationType,targetId:e[0].targetId};let r=[];const s=[];let o=[];for(const n of e)this.notificationProcessor.contains(n.messageType)&&await this.notificationProcessor.process(n,e)||(ao(n.messageType)&&zs.has(n.content.messageUId)?n.content.messageUId?(zs.remove(n.content.messageUId),o.push(n.content.messageUId)):Xi.error("recallMessage's messageUId is undefined",Oo(n)):n.messageUId?(n.isOffLineMessage=t,(!n.messageId||n.messageId>Vo())&&(n.messageId=Go()),Co.get().setConversationCacheByMessage(n),r.push(n),ao(n.messageType)&&s.push(r.length-1)):Xi.error("message's messageUId is undefined",Oo(n)));let i=[];for(let e=s.length-1;e>=0;e--){const t=s[e],n=r[t],a=n.content,c=r.findIndex(e=>e.messageUId===a.messageUId);if(-1!==c){const e=r[c];n.messageId=e.messageId,n.sentTime=e.sentTime,r[c]=n,r[t]=e,i.push(t)}else o.push(a.messageUId),i.push(t)}if(i.length){let e=[];r.forEach((t,n)=>{i.includes(n)||e.push(t)}),r=e}const a=r;if(a.length&&(await(ei.get()?.addMessages(a,{conversationType:a[0].conversationType,targetId:a[0].targetId})),this.handleBatchMessages(a),jo.get()?.sendArrivalReceipts(a)),o.length){await(ei.get()?.convertToRecallMessages(o)),this.watcher.onRecall?.(o);const e=await(ei.get()?.getLatestMessage(n));Co.get().updateLatestMessage(n,e)}if(r.some(e=>e.isPersited)){const e=await(ei.get()?.getLatestMessage(n));Co.get().updateLatestMessage(n,e)}}handleBurnAfterReadingMessage(e){const t=e.content,n=e.conversationType,r=e.targetId,{templateId:s,burnAfterReadingTime:o}=t,i=60010010===s||60010011===s;Co.get().addStatus({conversationType:n,targetId:r,burnAfterReadingFlag:i,burnAfterReadingTime:i?o:null},!0)}handleGroupTitleChangeMessage(e){const t=e.content,n=t.groupUin??e.targetId;Co.get().addStatus({conversationType:e.conversationType,targetId:n,dialogTitle:t.newTitle},!0)}handleGroupAvatarChangeMessage(e){const t=e.content,n=t.groupId??e.targetId;Co.get().addStatus({conversationType:e.conversationType,targetId:n,smallAvatarUrl:t.smallAvatarUrl},!0)}async handleBatchMessages(e){const t=e.filter(e=>e.messageDirection!==i.SEND||!e.messageId||!Ks.has(e.messageId)||(Ks.remove(e.messageId),!1));t.length&&this.watcher.batchMessage?.(t)}}const ui={filters:[],displayTags:!1};let di=ui,gi=0;async function pi(){const e=++gi;return(async()=>{try{const r=await Bs();return e!==gi?di:r.code!==t.SUCCESS?(Xi.warn("getDialogFilterConfig failed",r.code,r.msg),di=ui,di):(n=r.data?.config,di=n?{filters:(n.filters??[]).filter(e=>{const t=e.title?.trim(),n=e.id?.trim();if(!t||!n||"0"===n)return!1;const r=e.colorId??-1;return!(r<-1||r>7)}),displayTags:Boolean(n.displayTags)}:ui,di)}catch(t){return e!==gi||(Xi.warn("getDialogFilterConfig threw",t),di=ui),di}var n})()}class fi{messageType;content;isPersited;isCounted;isStatusMessage;constructor(e,t,n=!0,r=!0,s=!1){this.messageType=e,this.content=t,s?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=n,this.isCounted=r),this.isStatusMessage=s}}const hi=(e,t,n,r)=>function(s){return new fi(e,s,t,n,r)},yi=hi(ro.TEXT,!0,!0,!1),mi=hi(ro.IMAGE,!0,!0,!1),vi=hi(ro.GIF,!0,!0,!1),bi=hi(ro.AUDIO,!0,!0,!1),Ci=hi(ro.FILE,!0,!0,!1),wi=hi(ro.VIDEO,!0,!0,!1);let Ii=hi(ro.LOCATION,!0,!0,!1),Oi=hi(ro.CHAT_RECORD,!0,!0,!1),Si=hi(ro.CONTACT,!0,!0,!1),Ri=hi(ro.GROUP_INVITATION,!0,!0,!1),Ei=hi(ro.REDPACKET,!0,!0,!1),Ti=hi(ro.TRANSFER,!0,!0,!1),_i=hi(ro.LINK,!0,!0,!1);const Ai=hi(io.GROUP_ARRIVAL_RECEIPT,!1,!1,!1),ki=hi(io.GROUP_READ_RECEIPT,!1,!1,!1),Mi=hi(io.PRIVATE_ARRIVAL_RECEIPT,!1,!1,!1),Pi=hi(io.PRIVATE_READ_RECEIPT,!1,!1,!1),Ni=hi(io.PRIVATE_OPEN_BURNAFTERREADING,!1,!1,!1),Li=hi(io.PRIVATE_CLOSE_BURNAFTERREADING,!1,!1,!1),Di=hi(io.GROUP_OPEN_BURNAFTERREADING,!1,!1,!1),Ui=hi(io.GROUP_CLOSE_BURNAFTERREADING,!1,!1,!1),ji=hi(io.MESSAGE_READ,!1,!1,!1),Bi=hi(io.CHANGE_GROUP_TITLE,!0,!1,!1),Fi=hi(io.CHANGE_GROUP_AVATAR,!0,!1,!1),xi=hi(io.PRIVATE_MESSAGE_PINNED,!0,!1,!1),Gi=hi(io.GROUP_MESSAGE_PINNED,!0,!1,!1),qi=hi(io.CHAT_COMMENT,!1,!1,!1),Vi=hi(ro.RECALL,!0,!1,!1);class Ki{options;connectionStatus=e.DISCONNECTED;isInternalConnected=!1;watcher;messageLoader;static _loader;static init(e){return this._loader||(this._loader=new Ki(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,onMessagePinnedChanged:void 0,onMessageReactionsChanged:void 0,onDialogFilterConfig:void 0},lr.setServerInfo(this.getWebSocketUrl()),lr.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://web.sugramapp.com:3443";var t}registerMessage(){Ws(ro.TEXT,yi),Ws(ro.IMAGE,mi),Ws(ro.GIF,vi),Ws(ro.AUDIO,bi),Ws(ro.FILE,Ci),Ws(ro.VIDEO,wi),Ws(ro.RECALL,Vi),Ws(ro.LOCATION,Ii),Ws(ro.CHAT_RECORD,Oi),Ws(ro.CONTACT,Si),Ws(ro.GROUP_INVITATION,Ri),Ws(ro.REDPACKET,Ei),Ws(ro.TRANSFER,Ti),Ws(ro.LINK,_i),Ws(io.GROUP_ARRIVAL_RECEIPT,Ai),Ws(io.GROUP_READ_RECEIPT,ki),Ws(io.PRIVATE_ARRIVAL_RECEIPT,Mi),Ws(io.PRIVATE_READ_RECEIPT,Pi),Ws(io.PRIVATE_OPEN_BURNAFTERREADING,Ni),Ws(io.PRIVATE_CLOSE_BURNAFTERREADING,Li),Ws(io.GROUP_OPEN_BURNAFTERREADING,Di),Ws(io.GROUP_CLOSE_BURNAFTERREADING,Ui),Ws(io.MESSAGE_READ,ji),Ws(io.CHANGE_GROUP_TITLE,Bi),Ws(io.CHANGE_GROUP_AVATAR,Fi),Ws(io.PRIVATE_MESSAGE_PINNED,xi),Ws(io.GROUP_MESSAGE_PINNED,Gi),Ws(io.CHAT_COMMENT,qi)}async connect(){if(this.connectionStatus===e.CONNECTED)return{code:t.SUCCESS};if(this.connectionStatus===e.CONNECTING)return{code:t.BIZ_ERROR_CONNECTING};lr.close();const n=await lr.connect();return this.isInternalConnected=!0,{code:n}}reconnect(){return this.isInternalConnected?Promise.resolve({code:t.CAN_NOT_RECONNECT}):this.connect()}disconnect(){return this.isInternalConnected=!1,lr.close(),Promise.resolve()}async setUserLogged(){zi.setUserId(sr.uid.toString()),Co.get().destroyed(),Co.create(this.options.appkey,sr.uid.toString(),this.watcher.conversationState),jo.create(this.options.appkey,sr.uid.toString()),this.messageLoader?.stop(),this.messageLoader=new li(this.watcher,this.options),Ks.reset(),zs.reset(),Zs.reset();const t=ei.create(this.options.appkey,sr.uid.toString(),{legacyMigrationMode:this.options.legacyMigrationMode??"automatic"});await t.initDB();const n=await t.getMessageIdRange();if(n){const{oldest:e,newest:t}=n;xo(e,t)}else xo(1e4,1e4);this.getConnectionStatus()===e.CONNECTED&&this.handleUserConnected()}async setUserLogout(){this.messageLoader?.stop(),await(ei.get()?.close());const e=(gi+=1,di=ui,di);this.watcher.onDialogFilterConfig?.(e)}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){pt(this.watcher).forEach(t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t];this.watcher[t]=it(n)?n:void 0}})}resetWatcher(){pt(this.watcher).forEach(e=>{this.watcher[e]=void 0})}async connectionStatusListener(t){switch(this.connectionStatus=t,t){case e.BLOCKED:case e.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.CONNECTING:this.handleConnecting();break;case e.CONNECTED:this.handleConnected();break;case e.DISCONNECTED:this.handleDisconnect()}}handleConnecting(){this.watcher.onConnecting?.()}handleConnected(){sr.isActive&&(this.handleUserConnected(),(async()=>{const e=(new Date).getTime(),{code:n,data:r}=await ms();if(n===t.SUCCESS){const{currentTimeMillis:t}=r;Gs=t.toNumber()-e}})()),this.watcher.onConnected?.(),Xi.cleanupOldLogs()}handleDisconnect(){this.watcher.onDisconnect?.(),this.messageLoader?.stop()}handleSuspend(){this.watcher.onSuspend?.()}handleUserConnected(){Xi.info("user connected -> ",sr.uid.toString()),this.messageLoader||(this.messageLoader=new li(this.watcher,this.options)),this.messageLoader?.start(),pi().then(e=>{this.watcher.onDialogFilterConfig?.(e)}),setTimeout(()=>{this.connectionStatus===e.CONNECTED&&Co.get().syncConversationStatus()},2e3)}messageListener(e,t){if(e===Tt.NewMessagePush){const e=Lr.decode(t);this.messageLoader?.syncMsg(e.seqno)}else e===Tt.DialogChangedPush?Co.get().syncConversationStatus():this.watcher.onPush?.(e,t)}}class Hi{static instance;messageQueue;config;flushTimer=null;userId=null;isFlushing=!1;constructor(e){this.config=e,this.messageQueue=new St,this.startFlushTimer()}static getInstance(e){return Hi.instance||(Hi.instance=new Hi(e)),Hi.instance}trackEvent(e,t){const n={type:e,...this.collectAutomaticProperties(),content:t};this.messageQueue.enqueue(n),this.config.debugMode&&this.flush()}collectAutomaticProperties(){return{user_id:this.userId,os:"web",appVersion:Et.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),n=(new TextEncoder).encode(t);if("CompressionStream"in window){const e=new Response(n).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 Ki.loader?.getConnectionStatus()==e.CONNECTED}async sendData(e){try{const n=await js(e);if(n.code!==t.SUCCESS)throw new Error(`Socket error! status: ${n.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 zi=Hi.getInstance({flushInterval:6e4,flushBulkSize:100,debugMode:!1});const $i=Ct.get("ACIM-slf")===(new Date).getDate();const Wi={[u.DEBUG]:console.debug,[u.INFO]:console.info,[u.WARN]:console.warn,[u.ERROR]:console.error,[u.FATAL]:console.log,[u.NONE]:null},Ji={[u.DEBUG]:console.debug,[u.INFO]:console.info,[u.WARN]:console.warn,[u.ERROR]:console.error,[u.FATAL]:console.log,[u.NONE]:null},Zi=e=>lt(e)||rt(e)||ot(e)||st(e)?e:e instanceof Error?JSON.stringify({name:e.name,message:e.message,stack:e.stack}):JSON.stringify(e);var Xi=new class{debug;info;warn;error;fatal;outLevel=u.WARN;tag;logStdout;constructor(e){this.tag=e,this.debug=this.log.bind(this,u.DEBUG),this.info=this.log.bind(this,u.INFO),this.warn=this.log.bind(this,u.WARN),this.error=this.log.bind(this,u.ERROR),this.fatal=this.log.bind(this,u.FATAL)}async addLog(e,t){const n={timestamp:(new Date).toISOString(),level:e,content:t};try{e===u.ERROR&&zi.trackEvent("error_log",{timestamp:n.timestamp,content:n.content})}catch(e){console.error("Failed to add log:",e)}}getCallerLocation(){try{const e=(new Error).stack;if(!e)return null;const t=e.split("\n");for(let e=4;e<t.length;e++){const n=t[e].trim();if(n&&!n.includes("logger.ts")&&!n.includes("at Logger.")){const e=n.match(/at\s+(?:.*?\s+)?\(?(.+?):(\d+):(\d+)\)?/)||n.match(/at\s+(.+?):(\d+):(\d+)/);if(e){const t=e[1],n=e[2];return`${t.split("/").pop()||t.split("\\").pop()||t}:${n}`}}}}catch(e){}return null}defaultStdout(e,t,...n){const r=Wi[e];if(nt(r)){const s=this.getCallerLocation(),o=Ji[e];o?s?o(`${t} @ ${s}:`,...n):o(`${t}:`,...n):s?r(`${t} @ ${s}:`,...n):r(`${t}:`,...n)}}reqInfo(...e){this.info(...e)}setLogLevel(e){this.outLevel=e}setLogStdout(e){this.logStdout=e}log(e,...t){if($i){const n=`${(new Date).toISOString()}[${this.tag}][${u[e]}]`;return this.defaultStdout(e,n,...t),void this.addLog(e,t.map(Zi).join(" "))}if(e<this.outLevel)return;const n=`${(new Date).toISOString()}[${this.tag}][${u[e]}]`,r=`${n} - ${t.map(Zi).join(" ")}`;if(this.logStdout)return this.logStdout(e,r),void this.addLog(e,t.map(Zi).join(" "));this.defaultStdout(e,n,...t),this.addLog(e,t.map(Zi).join(" "))}async exportLogs(){return[]}async clearLogs(){}async cleanupOldLogs(){}}("ACLog");const Yi=ut,Qi=rt,ea=st,ta=at,na=ct,ra=e=>rt(e)&&Object.prototype.hasOwnProperty.call(r,e),sa=e=>{if(!at(e))return!1;const{conversationType:t,targetId:n,channelId:s}=e;return rt(t)&&Object.prototype.hasOwnProperty.call(r,t)&&(rt(n)||ut(n)||Ln.isLong(n)&&!n.isZero())&&(!nt(s)||lt(s)&&!/_/g.test(s)&&s.length<=20)};class oa extends Error{constructor(e){super(e),this.name="ACAssertError"}}const ia=(e,t,n,r=!1)=>{if(!aa(e,t,n,r))throw new oa(`'${e}' is invalid: ${JSON.stringify(t)}`)},aa=(e,t,n,r=!1)=>{const s=r&&!n(t)||!r&&nt(t)&&!n(t);return s&&Xi.error(`'${e}' is invalid: ${JSON.stringify(t)}`),!s};var ca,la,ua,da,ga={exports:{}},pa={exports:{}},fa={exports:{}};var ha,ya={};var ma,va,ba,Ca,wa,Ia,Oa,Sa,Ra,Ea,Ta,_a,Aa,ka,Ma,Pa,Na,La,Da,Ua={};function ja(){return ma||(ma=1,function(e){var t=e,n=Ic(),r=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function s(e,t){var n=0,s={};for(t|=0;n<e.length;)s[r[n+t]]=e[n++];return s}t.basic=s([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=s([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",n.emptyArray,null]),t.long=s([0,0,0,1,1],7),t.mapKey=s([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=s([1,5,0,0,0,5,5,0,0,0,1,1,0])}(Ua)),Ua}function Ba(){if(ba)return va;ba=1,va=i;var e=Oc();((i.prototype=Object.create(e.prototype)).constructor=i).className="Field";var t,n=Sc(),r=ja(),s=Ic(),o=/^required|optional|repeated$/;function i(t,n,i,a,c,l,u){if(s.isObject(a)?(u=c,l=a,a=c=void 0):s.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!s.isInteger(n)||n<0)throw TypeError("id must be a non-negative integer");if(!s.isString(i))throw TypeError("type must be a string");if(void 0!==a&&!o.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!s.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=n,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=!!s.Long&&void 0!==r.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,n,r){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,n,r)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return s.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=r.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 n&&"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 n)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=s.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var o;s.base64.test(this.typeDefault)?s.base64.decode(this.typeDefault,o=s.newBuffer(s.base64.length(this.typeDefault)),0):s.utf8.write(this.typeDefault,o=s.newBuffer(s.utf8.length(this.typeDefault)),0),this.typeDefault=o}return this.map?this.defaultValue=s.emptyObject:this.repeated?this.defaultValue=s.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,n,r){return"function"==typeof t?t=s.decorateType(t).name:t&&"object"==typeof t&&(t=s.decorateEnum(t).name),function(o,a){s.decorateType(o.constructor).add(new i(a,e,t,n,{default:r}))}},i._configure=function(e){t=e},va}function Fa(){if(wa)return Ca;wa=1,Ca=r;var e=Oc();((r.prototype=Object.create(e.prototype)).constructor=r).className="OneOf";var t=Ba(),n=Ic();function r(t,n,r,s){if(Array.isArray(n)||(r=n,n=void 0),e.call(this,t,r),void 0!==n&&!Array.isArray(n))throw TypeError("fieldNames must be an Array");this.oneof=n||[],this.fieldsArray=[],this.comment=s}function s(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return r.fromJSON=function(e,t){return new r(e,t.oneof,t.options,t.comment)},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},r.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,s(this),this},r.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var n=this.fieldsArray.indexOf(e);if(n<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(n,1),(n=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(n,1),e.partOf=null,this},r.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var n=0;n<this.oneof.length;++n){var r=t.get(this.oneof[n]);r&&!r.partOf&&(r.partOf=this,this.fieldsArray.push(r))}s(this)},r.prototype.onRemove=function(t){for(var n,r=0;r<this.fieldsArray.length;++r)(n=this.fieldsArray[r]).parent&&n.parent.remove(n);e.prototype.onRemove.call(this,t)},r.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,s){n.decorateType(t.constructor).add(new r(s,e)),Object.defineProperty(t,s,{get:n.oneOfGetter(e),set:n.oneOfSetter(e)})}},Ca}function xa(){if(Oa)return Ia;Oa=1,Ia=c;var e=Oc();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,n,r,s=Ba(),o=Ic(),i=Fa();function a(e,t){if(e&&e.length){for(var n={},r=0;r<e.length;++r)n[e[r].name]=e[r].toJSON(t);return n}}function c(t,n){e.call(this,t,n),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 n=0;n<e.length;++n)if("string"!=typeof e[n]&&e[n][0]<=t&&e[n][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var n=0;n<e.length;++n)if(e[n]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=o.toArray(this.nested))}}),c.prototype.toJSON=function(e){return o.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var o,i=Object.keys(e),a=0;a<i.length;++a)o=e[i[a]],this.add((void 0!==o.fields?t.fromJSON:void 0!==o.values?r.fromJSON:void 0!==o.methods?n.fromJSON:void 0!==o.id?s.fromJSON:c.fromJSON)(i[a],o));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 r)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof s&&void 0!==e.extend||e instanceof t||e instanceof i||e instanceof r||e instanceof n||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var o=this.get(e.name);if(o){if(!(o instanceof c&&e instanceof c)||o instanceof t||o instanceof n)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=o.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(o),this.nested||(this.nested={}),e.setOptions(o.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(o.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 n=this;e.length>0;){var r=e.shift();if(n.nested&&n.nested[r]){if(!((n=n.nested[r])instanceof c))throw Error("path conflicts with non-namespace objects")}else n.add(n=new c(r))}return t&&n.addJSON(t),n},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,n){if("boolean"==typeof t?(n=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),o.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 r=this.get(e[0]);if(r){if(1===e.length){if(!t||t.indexOf(r.constructor)>-1)return r}else if(r instanceof c&&(r=r.lookup(e.slice(1),t,!0)))return r}else for(var s=0;s<this.nestedArray.length;++s)if(this._nestedArray[s]instanceof c&&(r=this._nestedArray[s].lookup(e,t,!0)))return r;return null===this.parent||n?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var n=this.lookup(e,[t]);if(!n)throw Error("no such type: "+e);return n},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var n=this.lookup(e,[t,r]);if(!n)throw Error("no such Type or Enum '"+e+"' in "+this);return n},c.prototype.lookupService=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,s,o){t=e,n=s,r=o},Ia}function Ga(){if(Ra)return Sa;Ra=1,Sa=r;var e=Ba();((r.prototype=Object.create(e.prototype)).constructor=r).className="MapField";var t=ja(),n=Ic();function r(t,r,s,o,i,a){if(e.call(this,t,r,o,void 0,void 0,i,a),!n.isString(s))throw TypeError("keyType must be a string");this.keyType=s,this.resolvedKeyType=null,this.map=!0}return r.fromJSON=function(e,t){return new r(e,t.id,t.keyType,t.type,t.options,t.comment)},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},r.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)},r.d=function(e,t,s){return"function"==typeof s?s=n.decorateType(s).name:s&&"object"==typeof s&&(s=n.decorateEnum(s).name),function(o,i){n.decorateType(o.constructor).add(new r(i,e,t,s))}},Sa}function qa(){if(Ta)return Ea;Ta=1,Ea=n;var e=Oc();((n.prototype=Object.create(e.prototype)).constructor=n).className="Method";var t=Ic();function n(n,r,s,o,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!==r&&!t.isString(r))throw TypeError("type must be a string");if(!t.isString(s))throw TypeError("requestType must be a string");if(!t.isString(o))throw TypeError("responseType must be a string");e.call(this,n,c),this.type=r||"rpc",this.requestType=s,this.requestStream=!!i||void 0,this.responseType=o,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return n.fromJSON=function(e,t){return new n(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},n.prototype.toJSON=function(e){var n=!!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",n?this.comment:void 0,"parsedOptions",this.parsedOptions])},n.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))},Ea}function Va(){if(Aa)return _a;Aa=1,_a=s;var e=xa();((s.prototype=Object.create(e.prototype)).constructor=s).className="Service";var t=qa(),n=Ic(),r=yn();function s(t,n){e.call(this,t,n),this.methods={},this._methodsArray=null}function o(e){return e._methodsArray=null,e}return s.fromJSON=function(e,n){var r=new s(e,n.options);if(n.methods)for(var o=Object.keys(n.methods),i=0;i<o.length;++i)r.add(t.fromJSON(o[i],n.methods[o[i]]));return n.nested&&r.addJSON(n.nested),r.comment=n.comment,r},s.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),s=!!t&&Boolean(t.keepComments);return n.toObject(["options",r&&r.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",r&&r.nested||void 0,"comment",s?this.comment:void 0])},Object.defineProperty(s.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=n.toArray(this.methods))}}),s.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},s.prototype.resolveAll=function(){for(var t=this.methodsArray,n=0;n<t.length;++n)t[n].resolve();return e.prototype.resolve.call(this)},s.prototype.add=function(n){if(this.get(n.name))throw Error("duplicate name '"+n.name+"' in "+this);return n instanceof t?(this.methods[n.name]=n,n.parent=this,o(this)):e.prototype.add.call(this,n)},s.prototype.remove=function(n){if(n instanceof t){if(this.methods[n.name]!==n)throw Error(n+" is not a member of "+this);return delete this.methods[n.name],n.parent=null,o(this)}return e.prototype.remove.call(this,n)},s.prototype.create=function(e,t,s){for(var o,i=new r.Service(e,t,s),a=0;a<this.methodsArray.length;++a){var c=n.lcFirst((o=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");i[c]=n.codegen(["r","c"],n.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:o,q:o.resolvedRequestType.ctor,s:o.resolvedResponseType.ctor})}return i},_a}function Ka(){if(Ma)return ka;Ma=1,ka=t;var e=rn();function t(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)this[t[n]]=e[t[n]]}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)},ka}function Ha(){if(Na)return Pa;Na=1,Pa=function(s){var o=n.codegen(["r","l"],s.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(s.fieldsArray.filter(function(e){return e.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");s.group&&o("if((t&7)===4)")("break");o("switch(t>>>3){");for(var i=0;i<s.fieldsArray.length;++i){var a=s._fieldsArray[i].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+n.safeProp(a.name);o("case %i: {",a.id),a.map?(o("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?o("k=%j",t.defaults[a.keyType]):o("k=null"),void 0!==t.defaults[c]?o("value=%j",t.defaults[c]):o("value=null"),o("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]?o("value=types[%i].decode(r,r.uint32())",i):o("value=r.%s()",c),o("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?o('%s[typeof k==="object"?util.longToHash(k):k]=value',l):o("%s[k]=value",l)):a.repeated?(o("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&o("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]?o(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,i):o("%s.push(r.%s())",l,c)):void 0===t.basic[c]?o(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,i):o("%s=r.%s()",l,c),o("break")("}")}for(o("default:")("r.skipType(t&7)")("break")("}")("}"),i=0;i<s._fieldsArray.length;++i){var u=s._fieldsArray[i];u.required&&o("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",r(u))}return o("return m")};var e=Sc(),t=ja(),n=Ic();function r(e){return"missing required '"+e.name+"'"}return Pa}function za(){if(Da)return La;Da=1,La=function(e){var o=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),i=e.oneofsArray,a={};i.length&&o("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&&o("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)o("if(!util.isObject(%s))",u)("return%j",n(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),s(o,l,"k[i]"),r(o,l,c,u+"[k[i]]")("}");else if(l.repeated)o("if(!Array.isArray(%s))",u)("return%j",n(l,"array"))("for(var i=0;i<%s.length;++i){",u),r(o,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&o("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,o("p%s=1",d)}r(o,l,c,u)}l.optional&&o("}")}return o("return null")};var e=Sc(),t=Ic();function n(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function r(t,r,s,o){if(r.resolvedType)if(r.resolvedType instanceof e){t("switch(%s){",o)("default:")("return%j",n(r,"enum value"));for(var i=Object.keys(r.resolvedType.values),a=0;a<i.length;++a)t("case %i:",r.resolvedType.values[i[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",s,o)("if(e)")("return%j+e",r.name+".")("}");else switch(r.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",o)("return%j",n(r,"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)))",o,o,o,o)("return%j",n(r,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',o)("return%j",n(r,"number"));break;case"bool":t('if(typeof %s!=="boolean")',o)("return%j",n(r,"boolean"));break;case"string":t("if(!util.isString(%s))",o)("return%j",n(r,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',o,o,o)("return%j",n(r,"buffer"))}return t}function s(e,t,r){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",r)("return%j",n(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",r)("return%j",n(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",r)("return%j",n(t,"boolean key"))}return e}return La}var $a,Wa={};function Ja(){return $a||($a=1,function(e){var t=e,n=Sc(),r=Ic();function s(e,t,r,s){var o=!1;if(t.resolvedType)if(t.resolvedType instanceof n){e("switch(d%s){",s);for(var i=t.resolvedType.values,a=Object.keys(i),c=0;c<a.length;++c)i[a[c]]!==t.typeDefault||o||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',s,s,s),t.repeated||e("break"),o=!0),e("case%j:",a[c])("case %i:",i[a[c]])("m%s=%j",s,i[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',s)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",s,r,s);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",s,s);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",s,s);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",s,s);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",s,s,l)('else if(typeof d%s==="string")',s)("m%s=parseInt(d%s,10)",s,s)('else if(typeof d%s==="number")',s)("m%s=d%s",s,s)('else if(typeof d%s==="object")',s)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",s,s,s,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',s)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",s,s,s)("else if(d%s.length >= 0)",s)("m%s=d%s",s,s);break;case"string":e("m%s=String(d%s)",s,s);break;case"bool":e("m%s=Boolean(d%s)",s,s)}}return e}function o(e,t,r,s){if(t.resolvedType)t.resolvedType instanceof n?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",s,r,s,s,r,s,s):e("d%s=types[%i].toObject(m%s,o)",s,r,s);else{var o=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",s,s,s,s);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',s)("d%s=o.longs===String?String(m%s):m%s",s,s,s)("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",s,s,s,s,o?"true":"",s);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",s,s,s,s,s);break;default:e("d%s=m%s",s,s)}}return e}t.fromObject=function(e){var t=e.fieldsArray,o=r.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return o("return new this.ctor");o("var m=new this.ctor");for(var i=0;i<t.length;++i){var a=t[i].resolve(),c=r.safeProp(a.name);a.map?(o("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),s(o,a,i,c+"[ks[i]]")("}")("}")):a.repeated?(o("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),s(o,a,i,c+"[i]")("}")("}")):(a.resolvedType instanceof n||o("if(d%s!=null){",c),s(o,a,i,c),a.resolvedType instanceof n||o("}"))}return o("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(r.compareFieldsById);if(!t.length)return r.codegen()("return {}");for(var s=r.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(s("if(o.arrays||o.defaults){"),l=0;l<i.length;++l)s("d%s=[]",r.safeProp(i[l].name));s("}")}if(a.length){for(s("if(o.objects||o.defaults){"),l=0;l<a.length;++l)s("d%s={}",r.safeProp(a[l].name));s("}")}if(c.length){for(s("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=r.safeProp(u.name);if(u.resolvedType instanceof n)s("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)s("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(",")+"]";s("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 s("d%s=%j",d,u.typeDefault)}s("}")}var p=!1;for(l=0;l<t.length;++l){u=t[l];var f=e._fieldsArray.indexOf(u);d=r.safeProp(u.name);u.map?(p||(p=!0,s("var ks2")),s("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),o(s,u,f,d+"[ks2[j]]")("}")):u.repeated?(s("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),o(s,u,f,d+"[j]")("}")):(s("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),o(s,u,f,d),u.partOf&&s("if(o.oneofs)")("d%s=%j",r.safeProp(u.partOf.name),u.name)),s("}")}return s("return d")}}(Wa)),Wa}var Za,Xa,Ya,Qa,ec,tc,nc,rc,sc,oc,ic,ac,cc,lc,uc,dc,gc,pc,fc,hc,yc,mc,vc={};function bc(){return Za||(Za=1,function(e){var t=e,n=Ka();t[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),n=this.lookup(t);if(n){var r="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===r.indexOf("/")&&(r="/"+r),this.create({type_url:r,value:n.encode(n.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var r="",s="";if(t&&t.json&&e.type_url&&e.value){s=e.type_url.substring(e.type_url.lastIndexOf("/")+1),r=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var o=this.lookup(s);o&&(e=o.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof n){var i=e.$type.toObject(e,t);return""===r&&(r="type.googleapis.com/"),s=r+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),i["@type"]=s,i}return this.toObject(e,t)}}}(vc)),vc}function Cc(){if(Ya)return Xa;Ya=1,Xa=h;var e=xa();((h.prototype=Object.create(e.prototype)).constructor=h).className="Type";var t=Sc(),n=Fa(),r=Ba(),s=Ga(),o=Va(),i=Ka(),a=on(),c=sn(),l=Ic(),u=Rc(),d=Ha(),g=za(),p=Ja(),f=bc();function h(t,n){e.call(this,t,n),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 n=this.fields[e[t]],r=n.id;if(this._fieldsById[r])throw Error("duplicate id "+r+" in "+this);this._fieldsById[r]=n}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 n=0;n<this.fieldsArray.length;++n)this._fieldsArray[n].resolve();var r={};for(n=0;n<this.oneofsArray.length;++n)r[this._oneofsArray[n].resolve().name]={get:l.oneOfGetter(this._oneofsArray[n].oneof),set:l.oneOfSetter(this._oneofsArray[n].oneof)};n&&Object.defineProperties(e.prototype,r)}}}),h.generateConstructor=function(e){for(var t,n=l.codegen(["p"],e.name),r=0;r<e.fieldsArray.length;++r)(t=e._fieldsArray[r]).map?n("this%s={}",l.safeProp(t.name)):t.repeated&&n("this%s=[]",l.safeProp(t.name));return n("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?s.fromJSON:r.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(n.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?r.fromJSON:void 0!==d.fields?h.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?o.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 n=e.prototype.toJSON.call(this,t),r=!!t&&Boolean(t.keepComments);return l.toObject(["options",n&&n.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",n&&n.nested||void 0,"comment",r?this.comment:void 0])},h.prototype.resolveAll=function(){for(var t=this.fieldsArray,n=0;n<t.length;)t[n++].resolve();var r=this.oneofsArray;for(n=0;n<r.length;)r[n++].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 r&&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 n?(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 r&&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 n){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=[],n=0;n<this.fieldsArray.length;++n)t.push(this._fieldsArray[n].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 r=f[e];if(r){var s=Object.create(this);s.fromObject=this.fromObject,this.fromObject=r.fromObject.bind(s),s.toObject=this.toObject,this.toObject=r.toObject.bind(s)}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)}},Xa}function wc(){if(ec)return Qa;ec=1,Qa=c;var e=xa();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,n,r,s=Ba(),o=Sc(),i=Fa(),a=Ic();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,s,o){"function"==typeof s&&(o=s,s=void 0);var i=this;if(!o)return a.asPromise(e,i,t,s);var c=o===l;function u(e,t){if(o){if(c)throw e;var n=o;o=null,n(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var n=e.substring(t);if(n in r)return n}return null}function g(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){n.filename=e;var r,o=n(t,i,s),l=0;if(o.imports)for(;l<o.imports.length;++l)(r=d(o.imports[l])||i.resolvePath(e,o.imports[l]))&&p(r);if(o.weakImports)for(l=0;l<o.weakImports.length;++l)(r=d(o.weakImports[l])||i.resolvePath(e,o.weakImports[l]))&&p(r,!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 r)c?g(e,r[e]):(++f,setTimeout(function(){--f,g(e,r[e])}));else if(c){var n;try{n=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}g(e,n)}else++f,i.fetch(e,function(n,r){--f,o&&(n?t?f||u(null,i):u(n):g(e,r))})}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 n=t.parent.lookup(t.extend);if(n){var r=new s(t.fullName,t.id,t.type,t.rule,void 0,t.options);return n.get(r.name)||(r.declaringField=t,t.extensionField=r,n.add(r)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof s)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof o)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof i)){if(e instanceof t)for(var n=0;n<this.deferred.length;)d(0,this.deferred[n])?this.deferred.splice(n,1):++n;for(var r=0;r<e.nestedArray.length;++r)this._handleAdd(e._nestedArray[r]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof s){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var n=this.deferred.indexOf(t);n>-1&&this.deferred.splice(n,1)}}else if(t instanceof o)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var r=0;r<t.nestedArray.length;++r)this._handleRemove(t._nestedArray[r]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,s,o){t=e,n=s,r=o},Qa}function Ic(){if(tc)return fa.exports;tc=1;var e,t,n=fa.exports=rn(),r=mn();n.codegen=function(){if(la)return ca;function e(t,n){"string"==typeof t&&(n=t,t=void 0);var r=[];function s(t){if("string"!=typeof t){var n=o();if(e.verbose&&console.log("codegen: "+n),n="return "+n,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]=n,Function.apply(null,a).apply(null,c)}return Function(n)()}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 n=u[d++];switch(t){case"d":case"f":return String(Number(n));case"i":return String(Math.floor(n));case"j":return JSON.stringify(n);case"s":return String(n)}return"%"}),d!==u.length)throw Error("parameter count mismatch");return r.push(t),s}function o(e){return"function "+(e||n||"")+"("+(t&&t.join(",")||"")+"){\n "+r.join("\n ")+"\n}"}return s.toString=o,s}return la=1,ca=e,e.verbose=!1,ca}(),n.fetch=function(){if(da)return ua;da=1,ua=n;var e=Pt(),t=Gt()("fs");function n(r,s,o){return"function"==typeof s?(o=s,s={}):s||(s={}),o?!s.xhr&&t&&t.readFile?t.readFile(r,function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?n.xhr(r,s,o):e?o(e):o(null,s.binary?t:t.toString("utf8"))}):n.xhr(r,s,o):e(n,this,r,s)}return n.xhr=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(0!==r.status&&200!==r.status)return n(Error("status "+r.status));if(t.binary){var e=r.response;if(!e){e=[];for(var s=0;s<r.responseText.length;++s)e.push(255&r.responseText.charCodeAt(s))}return n(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return n(null,r.responseText)}},t.binary&&("overrideMimeType"in r&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.responseType="arraybuffer"),r.open("GET",e),r.send()},ua}(),n.path=(ha||(ha=1,function(e){var t=e,n=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},r=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=n(e),s="";r&&(s=t.shift()+"/");for(var o=0;o<t.length;)".."===t[o]?o>0&&".."!==t[o-1]?t.splice(--o,2):r?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return s+t.join("/")};t.resolve=function(e,t,s){return s||(t=r(t)),n(t)?t:(s||(e=r(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?r(e+"/"+t):t)}}(ya)),ya),n.fs=n.inquire("fs"),n.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),r=0;r<t.length;)n[r]=e[t[r++]];return n}return[]},n.toObject=function(e){for(var t={},n=0;n<e.length;){var r=e[n++],s=e[n++];void 0!==s&&(t[r]=s)}return t};var s=/\\/g,o=/"/g;n.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)},n.safeProp=function(e){return!/^[$\w_]+$/.test(e)||n.isReserved(e)?'["'+e.replace(s,"\\\\").replace(o,'\\"')+'"]':"."+e},n.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var i=/_([a-z])/g;n.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(i,function(e,t){return t.toUpperCase()})},n.compareFieldsById=function(e,t){return e.id-t.id},n.decorateType=function(t,r){if(t.$type)return r&&t.$type.name!==r&&(n.decorateRoot.remove(t.$type),t.$type.name=r,n.decorateRoot.add(t.$type)),t.$type;e||(e=Cc());var s=new e(r||t.name);return n.decorateRoot.add(s),s.ctor=t,Object.defineProperty(t,"$type",{value:s,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:s,enumerable:!1}),s};var a=0;return n.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=Sc());var r=new t("Enum"+a++,e);return n.decorateRoot.add(r),Object.defineProperty(e,"$type",{value:r,enumerable:!1}),r},n.setProperty=function(e,t,n){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,n,r){var s=n.shift();if("__proto__"===s||"prototype"===s)return t;if(n.length>0)t[s]=e(t[s]||{},n,r);else{var o=t[s];o&&(r=[].concat(o).concat(r)),t[s]=r}return t}(e,t=t.split("."),n)},Object.defineProperty(n,"decorateRoot",{get:function(){return r.decorated||(r.decorated=new(wc()))}}),fa.exports}function Oc(){if(rc)return nc;rc=1,nc=n,n.className="ReflectionObject";var e,t=Ic();function n(e,n){if(!t.isString(e))throw TypeError("name must be a string");if(n&&!t.isObject(n))throw TypeError("options must be an object");this.options=n,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(n.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(".")}}}),n.prototype.toJSON=function(){throw Error()},n.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var n=t.root;n instanceof e&&n._handleAdd(this)},n.prototype.onRemove=function(t){var n=t.root;n instanceof e&&n._handleRemove(this),this.parent=null,this.resolved=!1},n.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},n.prototype.getOption=function(e){if(this.options)return this.options[e]},n.prototype.setOption=function(e,t,n){return n&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},n.prototype.setParsedOption=function(e,n,r){this.parsedOptions||(this.parsedOptions=[]);var s=this.parsedOptions;if(r){var o=s.find(function(t){return Object.prototype.hasOwnProperty.call(t,e)});if(o){var i=o[e];t.setProperty(i,r,n)}else(o={})[e]=t.setProperty({},r,n),s.push(o)}else{var a={};a[e]=n,s.push(a)}return this},n.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),r=0;r<n.length;++r)this.setOption(n[r],e[n[r]],t);return this},n.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},n._configure=function(t){e=t},nc}function Sc(){if(oc)return sc;oc=1,sc=r;var e=Oc();((r.prototype=Object.create(e.prototype)).constructor=r).className="Enum";var t=xa(),n=Ic();function r(t,n,r,s,o,i){if(e.call(this,t,r),n&&"object"!=typeof n)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=s,this.comments=o||{},this.valuesOptions=i,this.reserved=void 0,n)for(var a=Object.keys(n),c=0;c<a.length;++c)"number"==typeof n[a[c]]&&(this.valuesById[this.values[a[c]]=n[a[c]]]=a[c])}return r.fromJSON=function(e,t){var n=new r(e,t.values,t.options,t.comment,t.comments);return n.reserved=t.reserved,n},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.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])},r.prototype.add=function(e,t,r,s){if(!n.isString(e))throw TypeError("name must be a string");if(!n.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 s&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=s||null),this.comments[e]=r||null,this},r.prototype.remove=function(e){if(!n.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},r.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},r.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},sc}function Rc(){if(ac)return ic;ac=1,ic=function(s){for(var o,i=n.codegen(["m","w"],s.name+"$encode")("if(!w)")("w=Writer.create()"),a=s.fieldsArray.slice().sort(n.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=s._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,g=t.basic[d];o="m"+n.safeProp(l.name),l.map?(i("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",o,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",o)("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,o):i(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|g,d,o),i("}")("}")):l.repeated?(i("if(%s!=null&&%s.length){",o,o),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)",o)("w.%s(%s[i])",d,o)("w.ldelim()"):(i("for(var i=0;i<%s.length;++i)",o),void 0===g?r(i,l,u,o+"[i]"):i("w.uint32(%i).%s(%s[i])",(l.id<<3|g)>>>0,d,o)),i("}")):(l.optional&&i("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",o,l.name),void 0===g?r(i,l,u,o):i("w.uint32(%i).%s(%s)",(l.id<<3|g)>>>0,d,o))}return i("return w")};var e=Sc(),t=ja(),n=Ic();function r(e,t,n,r){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(t.id<<3|2)>>>0)}return ic}function Ec(){if(uc)return lc;uc=1,lc=u;var e=/[\s{}=;:[\],'"()<>]/g,t=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,r=/^ *[*/]+ */,s=/^\s*\*?\/*/,o=/\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,n){var i,l={type:a.charAt(e++),lineEmpty:!1,leading:n},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(o),h=0;h<d.length;++h)d[h]=d[h].replace(c?s:r,"").trim();l.text=d.join("\n").trim(),f[g]=l,p=g}function C(e){var t=w(e),n=a.substring(e,t);return/^\s*\/\//.test(n)}function w(e){for(var t=e;t<d&&"\n"!==v(t);)t++;return t}function I(){if(h.length>0)return h.shift();if(y)return function(){var e="'"===y?n:t;e.lastIndex=u-1;var r=e.exec(a);if(!r)throw m("string");return u=e.lastIndex,O(y),y=null,l(r[1])}();var r,s,o,p,f,I=0===u;do{if(u===d)return null;for(r=!1;i.test(o=v(u));)if("\n"===o&&(I=!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=w(u))===d)break;if(u++,!I)break}while(C(u))}else u=Math.min(d,w(u)+1);f&&(b(p,u,I),I=!0),g++,r=!0}else{for(f="/"===v(p=u+1);"\n"!==v(++u);)if(u===d)return null;++u,f&&(b(p,u-1,I),I=!0),++g,r=!0}else{if("*"!==(o=v(u)))return"/";p=u+1,f=c||"*"===v(p);do{if("\n"===o&&++g,++u===d)throw m("comment");s=o,o=v(u)}while("*"!==s||"/"!==o);++u,f&&(b(p,u-2,I),I=!0),r=!0}}}while(r);var S=u;if(e.lastIndex=0,!e.test(v(S++)))for(;S<d&&!e.test(v(S));)++S;var R=a.substring(u,u=S);return'"'!==R&&"'"!==R||(y=R),R}function O(e){h.push(e)}function S(){if(!h.length){var e=I();if(null===e)return null;O(e)}return h[0]}return Object.defineProperty({next:I,peek:S,push:O,skip:function(e,t){var n=S();if(n===e)return I(),!0;if(!t)throw m("token '"+n+"', '"+e+"' expected");return!1},cmnt:function(e){var t,n=null;return void 0===e?(t=f[g-1],delete f[g-1],t&&(c||"*"===t.type||t.lineEmpty)&&(n=t.leading?t.text:null)):(p<e&&S(),t=f[e],delete f[e],!t||t.lineEmpty||!c&&"/"!==t.type||(n=t.leading?null:t.text)),n}},"line",{get:function(){return g}})}return u.unescape=l,lc}function Tc(){if(gc)return dc;gc=1,dc=w,w.filename=null,w.defaults={keepCase:!1};var e=Ec(),t=wc(),n=Cc(),r=Ba(),s=Ga(),o=Fa(),i=Sc(),a=Va(),c=qa(),l=ja(),u=Ic(),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 w(I,O,S){O instanceof t||(S=O,O=new t),S||(S=w.defaults);var R,E,T,_,A,k=S.preferTrailingComment||!1,M=e(I,S.alternateCommentMode||!1),P=M.next,N=M.push,L=M.peek,D=M.skip,U=M.cmnt,j=!0,B=!1,F=O,x=S.keepCase?function(e){return e}:u.camelCase;function G(e,t,n){var r=w.filename;return n||(w.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(r?r+", ":"")+"line "+M.line+")")}function q(){var e,t=[];do{if('"'!==(e=P())&&"'"!==e)throw G(e);t.push(P()),D(e),e=L()}while('"'===e||"'"===e);return t.join("")}function V(e){var t=P();switch(t){case"'":case'"':return N(t),q();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var n=1;"-"===e.charAt(0)&&(n=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return n*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(d.test(e))return n*parseInt(e,10);if(p.test(e))return n*parseInt(e,16);if(h.test(e))return n*parseInt(e,8);if(m.test(e))return n*parseFloat(e);throw G(e,"number",t)}(t,!0)}catch(n){if(e&&b.test(t))return t;throw G(t,"value")}}function K(e,t){var n,r;do{!t||'"'!==(n=L())&&"'"!==n?e.push([r=H(P()),D("to",!0)?H(P()):r]):e.push(q())}while(D(",",!0));var s={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(s,function(e){if("option"!==e)throw G(e);ee(s,e),D(";")},function(){re(s)})}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!==R)throw G("package");if(R=P(),!b.test(R))throw G(R,"name");F=F.define(R),D(";")}function $(){var e,t=L();switch(t){case"weak":e=T||(T=[]),P();break;case"public":P();default:e=E||(E=[])}t=q(),D(";"),e.push(t)}function W(){if(D("="),_=q(),!(B="proto3"===_)&&"proto2"!==_)throw G(_,"syntax");O.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=P()))throw G(t,"service name");var n=new a(t);Z(n,function(e){if(!J(n,e)){if("rpc"!==e)throw G(e);!function(e,t){var n=U(),r=t;if(!v.test(t=P()))throw G(t,"name");var s,o,i,a,l=t;D("("),D("stream",!0)&&(o=!0);if(!b.test(t=P()))throw G(t);s=t,D(")"),D("returns"),D("("),D("stream",!0)&&(a=!0);if(!b.test(t=P()))throw G(t);i=t,D(")");var u=new c(l,r,s,i,o,a);u.comment=n,Z(u,function(e){if("option"!==e)throw G(e);ee(u,e),D(";")}),e.add(u)}(n,e)}}),e.add(n)}(e,t),!0;case"extend":return function(e,t){if(!b.test(t=P()))throw G(t,"reference");var n=t;Z(null,function(t){switch(t){case"required":case"repeated":Y(e,t,n);break;case"optional":Y(e,B?"proto3_optional":"optional",n);break;default:if(!B||!b.test(t))throw G(t);N(t),Y(e,"optional",n)}})}(e,t),!0}return!1}function Z(e,t,n){var r=M.line;if(e&&("string"!=typeof e.comment&&(e.comment=U()),e.filename=w.filename),D("{",!0)){for(var s;"}"!==(s=P());)t(s);D(";",!0)}else n&&n(),D(";"),e&&("string"!=typeof e.comment||k)&&(e.comment=U(r)||e.comment)}function X(e,t){if(!v.test(t=P()))throw G(t,"type name");var r=new n(t);Z(r,function(e){if(!J(r,e))switch(e){case"map":!function(e){D("<");var t=P();if(void 0===l.mapKey[t])throw G(t,"type");D(",");var n=P();if(!b.test(n))throw G(n,"type");D(">");var r=P();if(!v.test(r))throw G(r,"name");D("=");var o=new s(x(r),H(P()),t,n);Z(o,function(e){if("option"!==e)throw G(e);ee(o,e),D(";")},function(){re(o)}),e.add(o)}(r);break;case"required":case"repeated":Y(r,e);break;case"optional":Y(r,B?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!v.test(t=P()))throw G(t,"name");var n=new o(x(t));Z(n,function(e){"option"===e?(ee(n,e),D(";")):(N(e),Y(n,"optional"))}),e.add(n)}(r,e);break;case"extensions":K(r.extensions||(r.extensions=[]));break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:if(!B||!b.test(e))throw G(e);N(e),Y(r,"optional")}}),e.add(r)}function Y(e,t,s){var i=P();if("group"!==i){for(;i.endsWith(".")||L().startsWith(".");)i+=P();if(!b.test(i))throw G(i,"type");var a=P();if(!v.test(a))throw G(a,"name");a=x(a),D("=");var c=new r(a,H(P()),i,t,s);if(Z(c,function(e){if("option"!==e)throw G(e);ee(c,e),D(";")},function(){re(c)}),"proto3_optional"===t){var d=new o("_"+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 s=P();if(!v.test(s))throw G(s,"name");var o=u.lcFirst(s);s===o&&(s=u.ucFirst(s));D("=");var i=H(P()),a=new n(s);a.group=!0;var c=new r(o,i,s,t);c.filename=w.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=P()))throw G(t,"name");var n=new i(t);Z(n,function(e){switch(e){case"option":ee(n,e),D(";");break;case"reserved":K(n.reserved||(n.reserved=[]),!0);break;default:!function(e,t){if(!v.test(t))throw G(t,"name");D("=");var n=H(P(),!0),r={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(r,function(e){if("option"!==e)throw G(e);ee(r,e),D(";")},function(){re(r)}),e.add(t,n,r.comment,r.options)}(n,e)}}),e.add(n)}function ee(e,t){var n=D("(",!0);if(!b.test(t=P()))throw G(t,"name");var r,s=t,o=s;n&&(D(")"),o=s="("+s+")",t=L(),C.test(t)&&(r=t.slice(1),s+=t,P())),D("="),function(e,t,n,r){e.setParsedOption&&e.setParsedOption(t,n,r)}(e,o,te(e,s),r)}function te(e,t){if(D("{",!0)){for(var n={};!D("}",!0);){if(!v.test(A=P()))throw G(A,"name");if(null===A)throw G(A,"end of input");var r,s=A;if(D(":",!0),"{"===L())r=te(e,t+"."+A);else if("["===L()){var o;if(r=[],D("[",!0)){do{o=V(!0),r.push(o)}while(D(",",!0));D("]"),void 0!==o&&ne(e,t+"."+A,o)}}else r=V(!0),ne(e,t+"."+A,r);var i=n[s];i&&(r=[].concat(i).concat(r)),n[s]=r,D(",",!0),D(";",!0)}return n}var a=V(!0);return ne(e,t,a),a}function ne(e,t,n){e.setOption&&e.setOption(t,n)}function re(e){if(D("[",!0)){do{ee(e,"option")}while(D(",",!0));D("]")}return e}for(;null!==(A=P());)switch(A){case"package":if(!j)throw G(A);z();break;case"import":if(!j)throw G(A);$();break;case"syntax":if(!j)throw G(A);W();break;case"option":ee(F,A),D(";");break;default:if(J(F,A)){j=!1;continue}throw G(A)}return w.filename=null,{package:R,imports:E,weakImports:T,syntax:_,root:O}}return dc}function _c(){if(hc)return ga.exports;hc=1;var e=ga.exports=function(){if(cc)return pa.exports;cc=1;var e=pa.exports=vn();return e.build="light",e.load=function(t,n,r){return"function"==typeof n?(r=n,n=new e.Root):n||(n=new e.Root),n.load(t,r)},e.loadSync=function(t,n){return n||(n=new e.Root),n.loadSync(t)},e.encoder=Rc(),e.decoder=Ha(),e.verifier=za(),e.converter=Ja(),e.ReflectionObject=Oc(),e.Namespace=xa(),e.Root=wc(),e.Enum=Sc(),e.Type=Cc(),e.Field=Ba(),e.OneOf=Fa(),e.MapField=Ga(),e.Service=Va(),e.Method=qa(),e.Message=Ka(),e.wrappers=bc(),e.types=ja(),e.util=Ic(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),pa.exports}();return e.build="full",e.tokenize=Ec(),e.parse=Tc(),e.common=function(){if(fc)return pc;fc=1,pc=n;var e,t=/\/|\./;function n(e,r){t.test(e)||(e="google/protobuf/"+e+".proto",r={nested:{google:{nested:{protobuf:{nested:r}}}}}),n[e]=r}return n("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),n("duration",{Duration:e={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),n("timestamp",{Timestamp:e}),n("empty",{Empty:{fields:{}}}),n("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}}}}),n("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}}}}),n("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),n.get=function(e){return n[e]||null},pc}(),e.Root._configure(e.Type,e.parse,e.common),ga.exports}var Ac=f(mc?yc:(mc=1,yc=_c()));const kc=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},Mc=e=>{const t=e.name;return ut(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},Pc=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},Nc=e=>{const t=e.match(/data:([^;]+)/)[1],n=e.replace(/^[^,]+,/,""),r=window.atob(n);let s=r.length;const o=new Uint8Array(r.length);for(;s--;)o[s]=r.charCodeAt(s);return new Blob([o],{type:t})},Lc=1680,Dc=160,Uc=e=>new Promise((t,n)=>{const r=e=>{0!==e.width||0!==e.height?t(e):n()},s=new Image;if(s.addEventListener("load",e=>r(e.target)),s.addEventListener("error",n),s.src=e,s.complete)return void r(s);const o=setInterval(()=>{s.complete&&(r(s),clearInterval(o))},40)}),jc=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),s=function(e,t,n){let r=e,s=t,o=0,i=0;const a=e*t,c=n.maxWidth*n.maxHeight;if(a<=c)return o=(n.maxWidth-r)/2,i=(n.maxHeight-s)/2,{w:r,h:s,x:o,y:i};const l=Math.sqrt(c/a);return r=e*l,s=t*l,o=(n.maxWidth-r)/2,i=(n.maxHeight-s)/2,{w:r,h:s,x:o,y:i}}(e.width,e.height,t);n.width=s.w,n.height=s.h,r.fillStyle="#FFFFFF",r.fillRect(0,0,n.width,n.height),r?.drawImage(e,0,0,s.w,s.h);try{let e=n.toDataURL("image/jpeg",t.quality);return Nc(e)}catch(e){throw new Error(e)}};function Bc(e){const t=Math.max(0,e),n=t%60,r=Math.floor(t/60%60),s=Math.floor(t/3600);return s>0?`${s}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r}:${n.toString().padStart(2,"0")}`}const Fc={maxHeight:500,maxWidth:500,quality:.6,scale:2.4};class xc{async create(e,t){try{const n=kc(e),r=await Uc(n);let s,o,i;if(Pc(n),t?.full)s=e,o=r.width,i=r.height;else{const t=((e,t=1,n="image/jpeg")=>{t=Math.min(1,t);const r=e.width,s=e.height;let o=r,i=s;if(t<1){const e=r<s,t=e?s/Lc:r/Lc;r>Lc&&s>Lc?e?(i=Lc,o/=t):(o=Lc,i/=t):r>Lc&&s>Dc?(o=Lc,i/=t,i<Dc&&(i=Dc,o=r/(s/Dc))):s>Lc&&r>Dc&&(i=Lc,o/=t,o<Dc&&(o=Dc,i=s/(r/Dc)))}o=Math.floor(o),i=Math.floor(i);const a=document.createElement("canvas");a.width=o,a.height=i;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,o,i),c.drawImage(e,0,0,r,s,0,0,o,i),n&&"image/png"!=n||(n="image/jpeg"),{imageFile:Nc(a.toDataURL(n,Math.min(.92,t))),compressWidth:o,compressHeight:i}})(r,.85,e.type);s=t.imageFile,o=t.compressWidth,i=t.compressHeight}const a=jc(r,Fc);return{success:!0,message:new mi({thumbnailObjectKey:kc(a),originalObjectKey:kc(s),width:o,height:i}),files:[a,s]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r,s],encryptedKey:o}=t;return n.originalObjectKey=s,n.thumbnailObjectKey=r,n.encryptKey=o,n}}class Gc{async create(e){if(e.size>2097152)return{success:!1};try{const t=kc(e),n=await Uc(t);return{success:!0,message:new vi({originalObjectKey:t,extension:Mc(e),width:n.width,height:n.height}),files:[e]}}catch{return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.originalObjectKey=r,n.encryptKey=s,n}}let qc;class Vc{create(e){return(t=e,gt(t.arrayBuffer)?t.arrayBuffer():new Promise((e,n)=>{const r=new FileReader;r.addEventListener("load",t=>{t.target?e(t.target.result):n("null")}),r.addEventListener("error",e=>n(e)),r.readAsArrayBuffer(t)})).then(this.getAudioInfo).then(t=>({success:!0,message:new bi({audioObjectKey:kc(e),length:t.duration,extension:Mc(e)}),files:[e]})).catch(()=>({success:!1}));var t}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.audioObjectKey=r,n.encryptKey=s,n}getAudioInfo(e){const t=qc||new AudioContext;return qc=t,new Promise((n,r)=>{t.decodeAudioData(e,function(e){n({duration:e.duration,length:e.length})},r)})}}class Kc{async create(e){return e.size>104857600?{success:!1}:{success:!0,message:new Ci({fileKey:"",title:e.name,extension:Mc(e),size:e.size}),files:[e]}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.fileKey=r,n.encryptKey=s,n}}class Hc{async create(e){try{if(e.size>104857600)return{success:!1};const t=kc(e),n=document.createElement("video");n.src=t,await new Promise((e,t)=>{n.onloadedmetadata=e,n.onerror=t}),n.currentTime=.001,await new Promise(e=>{n.onseeked=e});const r=n.duration,s=n.videoWidth,o=n.videoHeight,i=Math.min(Fc.maxWidth/s,Fc.maxHeight/o,Fc.scale),a=Math.floor(s*i),c=Math.floor(o*i),l=document.createElement("canvas");l.width=a,l.height=c;const u=l.getContext("2d");u?.drawImage(n,0,0,a,c);const d=await new Promise(e=>{l.toBlob(t=>e(t),"image/jpeg",Fc.quality)});return Pc(t),{success:!0,message:new wi({videoObjectKey:"",thumbnailObjectKey:"",during:Bc(r),width:s,height:o,extension:Mc(e)}),files:[e,d]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r,s],encryptedKey:o}=t;return n.videoObjectKey=r,n.thumbnailObjectKey=s,n.encryptKey=o,n}}var zc;!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"}(zc||(zc={}));async function $c(e,n,r){try{return ul(e,n,r,await nl(n))}catch{return{code:t.UPLOAD_FILE_FAILED}}}const Wc=new Set([ro.TEXT,ro.IMAGE,ro.GIF,ro.VIDEO,ro.FILE,ro.AUDIO,ro.LOCATION,ro.CHAT_RECORD,ro.CONTACT,ro.GROUP_INVITATION,ro.LINK]),Jc=new Set(Wc);function Zc(e,t){const n=[],r=(e,r)=>{let s=t;for(const t of e)s=s?.[t];"string"==typeof s&&s.length>0&&n.push({path:e,sourceUrl:s,encryptKey:r})},s="string"==typeof t.encryptKey?t.encryptKey:void 0;switch(e){case ro.TEXT:{const e=t.linkPreview;e&&"object"==typeof e&&r(["linkPreview","originalObjectKey"],"string"==typeof e.encryptKey?e.encryptKey:void 0);break}case ro.IMAGE:r(["thumbnailObjectKey"],s),r(["originalObjectKey"],s);break;case ro.GIF:r(["originalObjectKey"],s);break;case ro.VIDEO:r(["thumbnailObjectKey"],s),r(["videoObjectKey"],s);break;case ro.FILE:r(["fileKey"],s),r(["thumbnailObjectKey"],s);break;case ro.AUDIO:r(["audioObjectKey"],s);break;case ro.LOCATION:r(["thumbnailObjectKey"],s);break;case ro.CHAT_RECORD:r(["msgDataFileKey"],s)}return n}function Xc(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){const n=t[e];if(!n||!r[n]||"object"!=typeof r[n])throw new Error("Invalid forwarded resource path");r=r[n]}const s=t[t.length-1];if(!s)throw new Error("Invalid forwarded resource field");r[s]=n}function Yc(e,t){const n=Et.getUploader();if(!n?.copy)return Promise.resolve({finished:!1,message:t});const r=n.copy.bind(n);return new Promise(n=>{try{r(e,{onError:()=>n({finished:!1,message:t}),onCompleted:()=>n({finished:!0,message:t})})}catch(e){n({finished:!1,message:t})}})}function Qc(e){const t=Js(e.messageType,e.content);if(!t)return;const n=e.messageType===ro.TEXT?t.content.content:void 0;return{senderNickname:e.senderNickname,...e.senderAvatar?{senderAvatar:e.senderAvatar}:{},msgId:e.messageUId,srcId:e.senderUserId,destId:e.targetId,mediaConstructor:e.messageType,mediaAttribute:JSON.stringify(t.content),...void 0!==n?{msgPostContent:n}:{},msgSendTime:e.sentTime}}async function el(e,n,r){if(!Wc.has(n.messageType))return{code:t.NOT_SUPPORT};const s=lo(n.content??{});delete s.mentionedInfo;const o=Zc(n.messageType,s);let i;if(o.length>0){const r=Et.getUploader();if(!r?.prepareCopy||!r.copy)return{code:t.NOT_SUPPORT};try{i=await r.prepareCopy({sourceConversation:{conversationType:n.conversationType,targetId:n.targetId},targetConversation:e,items:o.map(e=>({sourceUrl:e.sourceUrl,...e.encryptKey?{encryptKey:e.encryptKey}:{}}))})}catch{return{code:t.UPLOAD_FILE_FAILED}}if(i.items.length!==o.length)return{code:t.UPLOAD_FILE_FAILED};for(let e=0;e<o.length;e++){const n=o[e],r=i.items[e];if(!n||!r?.url)return{code:t.UPLOAD_FILE_FAILED};Xc(s,n.path,r.url)}}const a=Js(n.messageType,s);if(!a)return{code:t.NOT_SUPPORT};const c=i;return ul(e,a,r,c?{task:e=>Yc(c,e)}:void 0)}async function tl(e,n,r,s){if(!n.length||!r)return{code:t.PARAMETER_ERROR};if(n.some(e=>!Jc.has(e.messageType)))return{code:t.NOT_SUPPORT};const o=n[0];if(!o||n.some(e=>e.conversationType!==o.conversationType||e.targetId!==o.targetId))return{code:t.PARAMETER_ERROR};const i=n.map(e=>({...e,content:lo(e.content??{})}));for(const e of i)delete e.content.mentionedInfo;const a=[];for(const e of i)for(const t of Zc(e.messageType,e.content))a.push({content:e.content,binding:t});const c=Et.getUploader();if(!c)return{code:t.NOT_SUPPORT};let l;if(a.length){if(!c.prepareCopy||!c.copy)return{code:t.NOT_SUPPORT};try{l=await c.prepareCopy({sourceConversation:{conversationType:o.conversationType,targetId:o.targetId},targetConversation:e,items:a.map(({binding:e})=>({sourceUrl:e.sourceUrl,...e.encryptKey?{encryptKey:e.encryptKey}:{}}))})}catch(e){return{code:t.UPLOAD_FILE_FAILED}}if(l.items.length!==a.length)return{code:t.UPLOAD_FILE_FAILED};for(let e=0;e<a.length;e++){const n=a[e],r=l.items[e];if(!n||!r?.url)return{code:t.UPLOAD_FILE_FAILED};Xc(n.content,n.binding.path,r.url)}}const u=i.map(Qc);if(u.some(e=>!e))return{code:t.NOT_SUPPORT};const d=u;let g;try{g=await c.prepare([new Blob([JSON.stringify(d)],{type:"application/json"})])}catch(e){return{code:t.UPLOAD_FILE_FAILED}}const p=g.items[0];if(1!==g.items.length||!p?.url)return{code:t.UPLOAD_FILE_FAILED};const f={chatTitle:r,msgDataFileKey:p.url,encryptKey:g.encryptKey,msgList:d.slice(0,4).map(e=>({srcId:e.srcId,senderNickname:e.senderNickname,mediaConstructor:e.mediaConstructor,...void 0!==e.msgPostContent?{msgPostContent:e.msgPostContent}:{},...void 0!==e.mediaAttribute?{mediaAttribute:e.mediaAttribute}:{}}))},h=new Oi(f),y=l;return ul(e,h,s,{uploadItems:g,task:async e=>{if(y){const t=await Yc(y,e);if(!t.finished)return t}return function(e,t,n){return new Promise(r=>{try{e.upload(t,{onError:()=>r({finished:!1,message:n}),onCompleted:()=>r({finished:!0,message:n})})}catch(e){r({finished:!1,message:n})}})}(c,g,e)}})}async function nl(e){if(e.messageType!==ro.TEXT)return;const t=e.content,n=t.linkPreview;if(!n?.image)return;if(!(n.image instanceof Blob))throw new Error("Link preview image must be a Blob");const r=Et.getUploader();if(!r)throw new Error("Uploader is not configured");const s=await r.prepare([n.image]),o=s.items[0];if(!o)throw new Error("Link preview image upload was not prepared");const i={...n};return delete i.image,i.originalObjectKey=o.url,i.encryptKey=s.encryptKey,e.content={...t,linkPreview:i},{uploadItems:s,task:e=>new Promise(t=>{r.upload(s,{onError:()=>t({finished:!1,message:e}),onCompleted:()=>t({finished:!0,message:e})})})}}const rl=cl.bind(null,zc.IMAGE),sl=cl.bind(null,zc.GIF),ol=cl.bind(null,zc.AUDIO),il=cl.bind(null,zc.SIGHT),al=cl.bind(null,zc.FILE);async function cl(e,n,r,s,o){const i=(e=>{let t;switch(e){case zc.IMAGE:t=new xc;break;case zc.AUDIO:t=new Vc;break;case zc.GIF:t=new Gc;break;case zc.FILE:t=new Kc;break;case zc.SIGHT:t=new Hc}return t})(e);if(!i)return{code:t.NOT_SUPPORT};const{success:a,message:c,files:l}=await i.create(r.file,o);if(!a||!c||!l)return{code:t.MEDIA_EXCEPTION};c.content.user=r.user,c.content.extra=r.extra;const u=Et.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}),ul(n,c,o,{uploadItems:e,task:t=>new Promise(n=>{u.upload(e,{onProgress:e=>s?.onProgress?.(e),onError:()=>{n({finished:!1,message:t})},onCompleted:e=>{n({finished:!0,message:s?.onComplete?.(e)??t})}})})})}catch(e){return{code:t.UPLOAD_FILE_FAILED}}}const ll=async(e,n,s)=>{let o;try{o=await nl(e)}catch{return{code:t.UPLOAD_FILE_FAILED}}const c=await dl({conversationType:n.conversationType,targetId:n.targetId},e,n,s,o?.uploadItems);if(c.code!==t.SUCCESS||!c.message||!c.sentArgs)return{code:c.code};const l=wo(c.message,c.sentArgs);if(l.quotedReply=n,await hl(l,c.sentArgs),o){const n=await o.task(e);if(!n.finished)return gl(l,t.UPLOAD_FILE_FAILED),await hl(l,c.sentArgs),{code:t.UPLOAD_FILE_FAILED,data:l};e=n.message}const u=ts(n),d=await Zs.getDialogAesKey(u.toString());if(!d)return gl(l,t.MSG_ENCRYPT_ERROR),await hl(l,c.sentArgs),{code:t.MSG_ENCRYPT_ERROR,data:l};let g,p,f,h;if(e.messageType===ro.TEXT){let t=lo(e.content),n=t.content;delete t.content,g=eo(n,d),p=JSON.stringify(ft(t))}else p=JSON.stringify(ft(e.content));const y=eo(p,d);if(n){if(n.messageType===ro.TEXT){let e=lo(n.content),t=e.content;delete e.content,f=eo(t,d),h=JSON.stringify(ft(e))}else h=JSON.stringify(ft(n.content));h=eo(h,d)}Ks.addMessage(c.sentArgs.messageId);const m={localId:Ln.fromNumber(c.sentArgs.messageId),mediaFlag:e.messageType!==ro.TEXT,mediaConstructor:e.messageType,msgPreContent:"",msgPostContent:g,mediaAttribute:y,msgIdReferenced:Ln.fromString(n.messageUId),msgSrcIdReferenced:Ln.fromString(n.senderUserId),msgDestIdReferenced:n.messageDirection==i.RECEIVE?Ln.fromString(sr.uid):Ln.fromString(n.targetId),msgPostContentReferenced:f,mediaFlagReferenced:n.messageType!==ro.TEXT,mediaConstructorReferenced:n.messageType,mediaAttributeReferenced:h,msgSendTimeReferenced:Ln.fromString(n.sentTime)};let v;if(n.conversationType===r.GROUP){const t={...m,groupId:Ln.fromString(u)};if(nt(e.content.mentionedInfo)){const n=e.content.mentionedInfo;n.userList?.length&&(t.at=n.userList.map(e=>Ln.fromString(e.uin)),t.msgPreContent=JSON.stringify({atInfo:JSON.stringify(n.userList)}))}v=await Is(t)}else{const e={...m,destId:Ln.fromString(u)};v=await Cs(e)}const b=lo(l);return v.code===t.SUCCESS?(b.sentTime=v.data.msgSendTime.toString(),b.messageUId=v.data.msgId.toString(),b.sentStatus=a.SENT,await hl(b,c.sentArgs)):(gl(b,v.code),await hl(b,c.sentArgs)),{code:v.code,data:b}};async function ul(e,n,s,o){const i=await dl(e,n,null,s,o?.uploadItems);if(i.code!==t.SUCCESS||!i.message||!i.sentArgs)return{code:i.code};{const e=wo(i.message,i.sentArgs);await hl(e,i.sentArgs)}let{message:c,sentArgs:l}=i;if(nt(o)){const e=await o.task(c);if(c=e.message,!e.finished){const e=wo(i.message,i.sentArgs,a.FAILED);return gl(e,t.UPLOAD_FILE_FAILED),await hl(e,l),{code:t.UPLOAD_FILE_FAILED,data:e}}}return async function(e,n){const s=ts(n.conversation),o=wo(e,n),i=await Zs.getDialogAesKey(s.toString());if(!i)return gl(o,t.MSG_ENCRYPT_ERROR),await hl(o,n),{code:t.MSG_ENCRYPT_ERROR,data:o};let c,l;if(e.messageType===ro.TEXT){let t=lo(e.content),n=t.content;delete t.content,c=eo(n,i),l=JSON.stringify(ft(t))}else l=JSON.stringify(ft(e.content));const u=eo(l,i);Ks.addMessage(n.messageId);const d={localId:Ln.fromNumber(n.messageId),mediaFlag:e.messageType!==ro.TEXT,mediaConstructor:e.messageType,msgPreContent:"",msgPostContent:c,mediaAttribute:u};let g;if(n.conversation.conversationType===r.GROUP){const t={...d,groupId:Ln.fromString(s)};if(nt(e.content.mentionedInfo)){const n=e.content.mentionedInfo;n.userList?.length&&(t.at=n.userList.map(e=>Ln.fromString(e.uin)),t.msgPreContent=JSON.stringify({atInfo:JSON.stringify(n.userList)}))}g=await ws(t)}else{const e={...d,destId:Ln.fromString(s)};g=await bs(e)}g.code===t.SUCCESS?(o.sentTime=g.data.msgSendTime.toString(),o.messageUId=g.data.msgId.toString(),o.sentStatus=a.SENT,await hl(o,n)):(gl(o,g.code),await hl(o,n));return{code:g.code,data:o}}(c,l)}async function dl(e,n,r,s,o){if(((e,t="utf-8")=>{let n=0;if("utf-16"===t)for(let t=0,r=e.length;t<r;t++)n+=e.charCodeAt(t)<=65535?2:4;else for(let t=0,r=e.length;t<r;t++){const r=e.charCodeAt(t);n+=r<127?1:r<=2047?2:r<=65535?3:4}return n})(JSON.stringify(ft(n.content)))>81920)return{code:t.RC_MSG_CONTENT_EXCEED_LIMIT};n.isPersited&&await Co.get().loadConvsationsIfNotExist([e]);const i={conversation:e,senderUserId:sr.uid,messageId:Go(),sentTime:fl().toString(),pushConfig:s?.pushConfig};if(s?.onSendBefore){const e=wo(n,i);r&&(e.quotedReply=r),s.onSendBefore(e,o)}return{code:t.SUCCESS,message:n,sentArgs:i}}function gl(e,t){e.sentStatus=a.FAILED,e.sendErrorCode=t}let pl=1;function fl(){pl++;const e=qs();return pl<e&&(pl=e),pl}async function hl(e,t){try{const n=ei.get();if(e.isPersited&&n){await n.upsertMessage(e);const r=await n.getLatestMessage(t.conversation);let s=e;r&&Ln.fromString(r.sentTime).greaterThan(Ln.fromString(e.sentTime))&&(s=r),Co.get().updateLatestMessage(t.conversation,s)}}catch(e){Xi.error("saveSentMessage -> ",e)}}class yl extends fo{options;static imClient;libLoader;constructor(e){if(yl.imClient)return Xi.warn("Please do not perform the init method repeatedly"),yl.imClient;super(),this.options=e,this.fixedProtobuf(),nt(e.logLevel)&&Xi.setLogLevel(e.logLevel),nt(e.logStdout)&&Xi.setLogStdout(e.logStdout),Xi.debug("IMClient.init -> "),nt(e.uploader)&&Et.setUploader(e.uploader),Et.setDeviceCode(e.deviceCode),Et.setDeviceType(e.deviceType),this.libLoader=Ki.init(e),this.watch(),yl.imClient=this}fixedProtobuf(){Ac.util.Long=Ln,Ac.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(d.CONNECTING)},onConnected:()=>{this.emit(d.CONNECTED)},onDisconnect:()=>{this.emit(d.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(d.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:e=>{this.emit(d.MESSAGES,{messages:e})},pullFinished:()=>{this.emit(d.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:e=>{this.emit(d.CONVERSATION,{conversations:e})},onPush:(e,t)=>{this.emit(d.PUSH,{cmdId:e,body:t})},onRecall:e=>{e.forEach(e=>{this.emit(d.RECALL,e)})},onReceiptReceived:async(e,t)=>{try{await(ei.get()?.updateMessageReceiptStatus(e,t))}catch(e){Xi.error("updateMessageReceiptStatus -> ",e)}0===t?this.emit(d.ARRIVAL_RECEIPT_RECEIVED,e):this.emit(d.READ_RECEIPT_RECEIVED,e)},onMessagePinnedChanged:e=>{this.emit(d.MESSAGE_PINNED_CHANGED,e)},onMessageReactionsChanged:e=>{this.emit(d.MESSAGE_REACTIONS_CHANGED,e)},onDialogFilterConfig:e=>{this.emit(d.DIALOG_FILTER_CONFIG,e)}})}connect(){return this.libLoader.connect()}disconnect(){return this.libLoader.disconnect()}setUserLogged(e){return e.uid!==sr.uid.toString()?(sr.setLogged(e),this.libLoader.setUserLogged()):Promise.resolve()}async logOut(){sr.logOut(),await this.libLoader.setUserLogout()}async deleteLocalDatabase(e){await this.logOut();const t=new Yo(this.options.appkey,e);await t.deleteDatabase()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}getServerTime=qs;async insertMessage(e,n,r){(!n.messageId||n.messageId>Vo())&&(n.messageId=Go(),n.messageUId="local_"+n.messageId),Co.get().setConversationCacheByMessage(n);try{const e=ei.get();if(n.isPersited&&e){await e.upsertMessage(n);const t=await e.getLatestMessage(n);let r=n;t&&Ln.fromString(t.sentTime).greaterThan(Ln.fromString(n.sentTime))&&(r=t),Co.get().updateLatestMessage(n,r)}}catch(e){Xi.error("insertMessage -> ",e)}return{code:t.SUCCESS,data:n}}sendMessage=$c;forwardMessage=el;mergeForwardMessages=tl;sendImageMessage=rl;sendGIFMessage=sl;sendHQVoiceMessage=ol;sendFileMessage=al;sendSightMessage=il;async recallMsg(e,n){return await(async(e,n)=>{const r=ts(e);zs.addMessage(n.messageUId);const s=await Ss(r,n.messageUId);if(s.code!==t.SUCCESS)return{code:s.code};const o=new Vi({messageUId:n.messageUId}),i={conversation:e,senderUserId:sr.uid,messageId:0,sentTime:qs().toString()},c=wo(o,i,a.SENT);c.burnAfterReadingFlag=!1,c.burnAfterReadingTime=0,Co.get().setConversationCacheByMessage(c);const l=ei.get();return l&&(await l.convertToRecallMessages([n.messageUId]),Co.get().updateLatestMessage(e,await l.getLatestMessage(e))),{code:t.SUCCESS,data:c}})(e,n)}async commentMsg(e,r){const{code:s}=await Rs(ts(e),r.messageUId,r.content);if(s!==t.SUCCESS)return{code:s,msg:n(s)};const o=await this.getMessageByUId(r.messageUId);if(!o)return Xi.warn("commentMsg: target message not found",r.messageUId),{code:t.SUCCESS};const i={uid:sr.uid,msgId:r.messageUId,content:r.content,nickname:r.nickname??"",time:qs()},a=ni(o.reactions,i);return await(ei.get()?.setMessageReactions(e,r.messageUId,a))?(o.reactions=a,this.emit(d.MESSAGE_REACTIONS_CHANGED,{conversation:e,messageUId:r.messageUId,reactions:a,change:i}),{code:t.SUCCESS,data:{reactions:a}}):(Xi.warn("commentMsg: failed to persist reactions",r.messageUId),{code:t.SUCCESS})}sendQuoteReplyMessage=ll;async getRemoteHistoryMessages(e,r){const s=r.timestamp??"0",o=r.count??20,i=ts(e);return Ts({dialogId:i,offset:s,count:o,newToOld:0===r.order}).then(({code:e,data:r})=>new Promise(r=>{e===t.SUCCESS?r({code:t.SUCCESS,data:{list:[],hasMore:!1}}):r({code:e,msg:n(e)})}))}async getPreviousHistoryMessages(e,n,r=20){const s=await ei.get().getPreviousMessages(e,n??"0",r);if(!n&&s.messages.length&&Co.get().updateLatestMessage(e,s.messages[s.messages.length-1]),s.messages.length>=r||!s.hasMore)return{code:t.SUCCESS,data:{list:s.messages,hasMore:s.hasMore}};const o=s.messages[0]?.sentTime??n,i=await this.getRemoteHistoryMessages(e,{timestamp:o,count:r-s.messages.length,order:0});if(i.code!==t.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>Vo())&&(t.messageId=qo())}o&&"0"!=o||Co.get().updateLatestMessage(e,a[a.length-1]),await ei.get().addMessages(a,e,!i.data.hasMore);const c=await ei.get().getPreviousMessages(e,n??"0",r);return!n&&c.messages.length&&Co.get().updateLatestMessage(e,c.messages[c.messages.length-1]),{code:t.SUCCESS,data:{list:c.messages,hasMore:c.hasMore}}}async getHistoryMessages(e,n){const r=n.timestamp??"0",s=n.count??20,o=await ei.get().getMessages(e,r,s,0===n.order);return{code:t.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}}}async getMessagesByType(e,n,r){const s=ei.get();if(!s)return{code:t.SUCCESS,data:{list:[],hasMore:!1}};const o=await s.getMessagesByType(e,n,r.timestamp??"0",r.count??50,1!==r.order);return{code:t.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}}}async setMessagePinned(e,n,r,s="everyone"){if(r&&"me"===s)return await(ei.get()?.setMessagePinned(e,n,!0)),this.emit(d.MESSAGE_PINNED_CHANGED,{conversation:e,messageUId:n,operation:g.PIN}),t.SUCCESS;const o=r?g.PIN:g.UNPIN;return(await Es(ts(e),n,o)).code}async unpinAllMessages(e){return(await Es(ts(e),"0",g.UNPIN_ALL)).code}async getPinnedMessages(e,n=50){const r=await(ei.get()?.getPinnedMessages(e,n))??[];return{code:t.SUCCESS,data:r}}async deleteRemoteMessage(e,n){const r=await _s(ts(e),n.map(e=>e.messageUId)).then(e=>e.code);if(r===t.SUCCESS){const t=await(ei.get()?.getLatestMessage(e));if(await(ei.get()?.removeMessagesByUId(n.map(e=>e.messageUId))),t&&n.some(e=>e.messageUId===t.messageUId)){const t=await(ei.get()?.getLatestMessage(e));Co.get().updateLatestMessage(e,t)}}return r}async deleteLocalMessages(e,n){const r=ei.get();if(!r||0===n.length)return t.SUCCESS;const s=await r.getLatestMessage(e);return await r.removeMessagesByUId(n),s&&n.includes(s.messageUId)&&Co.get().updateLatestMessage(e,await r.getLatestMessage(e)),t.SUCCESS}async deleteHistoryMessages(e){return await(ei.get()?.clearConversationCache(e)),Co.get().clearHistoryMessages(e),As(ts(e)).then(e=>e.code)}async getConversationList(e,n,r,s){const o={rows:e,type:n??0,offset:Ln.fromNumber(r),newToOld:0===s},{code:i,data:a}=await ks(o);if(i!==t.SUCCESS)return{code:i};const c=a.fullDialog.map(e=>e.dialog?.destId).filter(nt);await Zs.getDialogAesKeyList(c.map(e=>e.toString()));let l=1e4;const u=[];for(const e of a.fullDialog){const t=this.formatConversation(e);t&&u.push(t)}const d=await(ei.get()?.getLatestMessages(u))??{},g=[];for(const e of u){const t={conversationType:e.conversationType,targetId:e.targetId},n=e.latestMessage;e.latestMessage=d[ts(t)];const r=Co.get().get(t);if(r){const{unreadMessageCount:t,hasMentioned:n,lastUnreadTime:s,updateTime:o}=r;t&&(e.unreadMessageCount=t),n&&(e.hasMentioned=n),s&&(e.lastUnreadTime=s),o&&(e.updateTime=o)}nt(e.latestMessage)&&!e.updateTime&&(e.updateTime=parseInt(e.latestMessage.sentTime)),e.updateTime||(n?e.updateTime=parseInt(n.sentTime):(e.updateTime=l,l++)),Co.get().addLocalConversation(e),g.push(e)}return g.sort((e,t)=>(e.updateTime??0)-(t.updateTime??0)),{code:t.SUCCESS,data:g}}getBlockConversationList(){const e=Co.get().getBlockConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}getTopConversationList(){const e=Co.get().getTopConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}async getConversation(e){const n=Co.get().get(e);if(!n)return{code:t.CONVER_GET_ERROR};const r=await(ei.get()?.getLatestMessage(e)),s=nt(r?.sentTime)?parseInt(r.sentTime):0,o=Math.max(n.updateTime??0,s),i={...e,...n,updateTime:o||void 0,latestMessage:r};return{code:t.SUCCESS,data:i}}removeConversation(e){return Co.get().remove(e),Ds(ts(e)).then(e=>e.code)}getUnreadMentionedCount(e){return Co.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return Co.get().getAllUnreadMentionedCount()}getConversationState(e){return Co.get().getConversationState(e)}getAllConversationState(){return Co.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return Co.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return Co.get().getUnreadCount(e)}clearConversationUnreadCount(e){Co.get().getUnreadCount(e)>0&&Fs(e.targetId),Co.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){Co.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return Co.get().getNotificationLevel(e)}setConversationNotificationStatus(e,t){return Ps(ts(e),t===o.OPEN).then(n=>(!n.code&&Co.get().addStatus({...e,notificationStatus:t,notificationLevel:t==o.OPEN?l.AT_USER_NOTIFICATION:l.NOT_SET},!0),n.code))}getConversationNotificationStatus(e){return Co.get().getNotificationStatus(e)}setConversationToTop(e,t){return Ns(ts(e),t).then(n=>(!n.code&&Co.get().addStatus({...e,isTop:t},!0),n.code))}setConversationBurnAfterReading(e,t,n){return Ls(ts(e),t,t?n:0).then(r=>(!r.code&&Co.get().addStatus({...e,burnAfterReadingFlag:t,burnAfterReadingTime:t?n:null},!0),r.code))}saveConversationMessageDraft(e,t){Co.get().setDraft(e,t)}getConversationMessageDraft(e){return Co.get().getDraft(e)}clearConversationMessageDraft(e){Co.get().clearDraft(e)}async sendReadReceipts(e,t=Date.now()){await(ei.get()?.markMessagesRead(e.map(e=>e.messageUId),t));for(const n of e)(n.receivedStatus??c.IDLE)<c.READ&&(n.receivedStatus=c.READ),n.messageDirection===i.RECEIVE&&n.burnAfterReadingFlag&&null==n.burnAfterReadingStartedAt&&(n.burnAfterReadingStartedAt=t);await(jo.get()?.sendReadReceipts(e))}formatConversation(e){const{dialog:t,msg:n}=e,r=t.destId;if(!nt(r))return;const s=po(t);if(!s)return;const o=Zs.getDialogAesKeyFromLocal(r.toString());if(o){if(nt(n)){const e=No.parseSingleDialogMessages(r.toString(),[n],o,{})[0];s.latestMessage=e}return s}}async clearBurnAfterReadingExpiredMessages(e){const t=ei.get();if(!t)return Promise.resolve([]);const n=await t.clearBurnAfterReadingExpiredMessages(e);return n.length>0&&Co.get().updateLatestMessage(e,await t.getLatestMessage(e)),n}async getMessageById(e){return ei.get()?.getMessageById(e)}async getMessageByUId(e){return ei.get()?.getMessageByUId(e)}async updateMessage(e){const t=ei.get();if(!t)throw new Error("Message database is not initialized for a logged-in user");if(!e.isPersited)throw new Error("Cannot update a non-persisted message");if(!(e.messageUId?await t.getMessageByUId(e.messageUId):await t.getMessageById(e.messageId)))throw new Error(`Cannot update missing message ${e.messageUId||e.messageId}`);await t.upsertMessage(e);const n=await t.getLatestMessage(e);return Co.get().updateLatestMessage(e,n),e}async searchTextMessages(e,t){const n=ei.get();return n?n.searchTextMessages(e,t):Promise.resolve([])}async searchMessages(e,t=500){const n=ei.get();return n?n.searchMessages(e,t):Promise.resolve([])}}const ml=bn.Reader,vl=bn.Writer,bl=bn.util,Cl=bn.roots.default||(bn.roots.default={}),wl=Cl.AuthSignIn2Req=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}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=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.AuthSignIn2Req;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.langCode=e.string();break;case 2:r.phoneNum=e.string();break;case 3:r.password=e.string();break;case 4:r.appVersionCode=e.int32();break;case 5:r.deviceType=e.int32();break;case 6:r.imei=e.string();break;case 7:r.brand=e.string();break;case 8:r.model=e.string();break;case 9:r.apnsToken=e.string();break;case 10:r.bandId=e.string();break;case 11:r.appVersion=e.string();break;case 12:r.osVersion=e.string();break;case 13:r.version=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Req"},e})(),Il=Cl.AuthSignIn2Resp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=bl.Long?bl.Long.fromBits(0,0,!1):0,e.prototype.sessionId=bl.Long?bl.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=vl.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")&&Cl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.AuthSignIn2Resp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.deviceId=e.int64();break;case 4:r.sessionId=e.int64();break;case 5:r.noNickName=e.bool();break;case 6:r.noEmail=e.bool();break;case 7:r.cert=e.string();break;case 9:r.userFileDomain=e.string();break;case 10:r.dialogFileDomain=e.string();break;case 11:r.user=Cl.User.decode(e,e.uint32());break;case 13:r.frozenDays=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Resp"},e})();Cl.User=(()=>{function e(e){if(this.aliasMobile=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.uid=bl.Long?bl.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=bl.emptyArray,e.prototype.aliasDesp="",e.encode=function(e,t){if(t||(t=vl.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 n=0;n<e.aliasMobile.length;++n)t.uint32(106).string(e.aliasMobile[n]);return null!=e.aliasDesp&&Object.hasOwnProperty.call(e,"aliasDesp")&&t.uint32(114).string(e.aliasDesp),t},e.decode=function(e,t){e instanceof ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.User;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.uid=e.int64();break;case 2:r.nickName=e.string();break;case 3:r.langCode=e.string();break;case 4:r.phone=e.string();break;case 5:r.numberInPhoneBook=e.string();break;case 6:r.smallAvatarUrl=e.string();break;case 7:r.originalAvatarUrl=e.string();break;case 8:r.email=e.string();break;case 9:r.qrcodeString=e.string();break;case 10:r.gender=e.int32();break;case 11:r.contactStatus=e.int32();break;case 12:r.alias=e.string();break;case 13:r.aliasMobile&&r.aliasMobile.length||(r.aliasMobile=[]),r.aliasMobile.push(e.string());break;case 14:r.aliasDesp=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e})();const Ol=Cl.WebGetLoginCodeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.account="",e.prototype.langCode="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.account=e.string();break;case 2:r.langCode=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeReq"},e})(),Sl=Cl.WebGetLoginCodeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeResp"},e})(),Rl=Cl.WebGetLoginCodeVerifyReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.account="",e.prototype.langCode="",e.prototype.code="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeVerifyReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.account=e.string();break;case 2:r.langCode=e.string();break;case 3:r.code=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeVerifyReq"},e})(),El=Cl.ClickOKToWebResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=bl.Long?bl.Long.fromBits(0,0,!1):0,e.prototype.sessionId=bl.Long?bl.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=vl.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")&&Cl.User.encode(e.user,t.uint32(90).fork()).ldelim(),t},e.decode=function(e,t){e instanceof ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.ClickOKToWebResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.deviceId=e.int64();break;case 4:r.sessionId=e.int64();break;case 5:r.noNickName=e.bool();break;case 6:r.noEmail=e.bool();break;case 7:r.cert=e.string();break;case 9:r.userFileDomain=e.string();break;case 10:r.dialogFileDomain=e.string();break;case 11:r.user=Cl.User.decode(e,e.uint32());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ClickOKToWebResp"},e})();let Tl;const _l=e=>{Tl=Tl||new yl(e)},Al=async e=>{const t=ei.get();if(!t)throw new Error("Message database is not initialized for a logged-in user");return t.migrateLegacyDatabase(e)},kl=async()=>{const e=ei.get();if(!e)throw new Error("Message database is not initialized for a logged-in user");return e.getLegacyMigrationInfo()},Ml=async(e=0,t=500)=>{const n=ei.get();if(!n)throw new Error("Message database is not initialized for a logged-in user");return n.getLegacyMediaReferences(e,t)},Pl=async()=>{const e=ei.get();if(!e)throw new Error("Message database is not initialized for a logged-in user");await e.deleteLegacyDatabase()},Nl=async()=>{const e=await Tl.connect();return e.code===t.SUCCESS?{code:e.code}:{code:e.code,msg:n(e.code)}},Ll=()=>Tl.disconnect(),Dl=e=>Tl.setUserLogged(e),Ul=()=>Tl.logOut(),jl=e=>Tl.deleteLocalDatabase(e),Bl=()=>Tl.getConnectionStatus(),Fl=(e,t,n,r=3e4)=>lr.request(e,t,n,r),xl=()=>Tl.getServerTime(),Gl=(e,t,n)=>{Tl.on(e,t,n)};function ql(e,t,n){Tl.once(e,t,n)}const Vl=(e,t,n)=>{Tl?.off(e,t,n)},Kl=()=>di,Hl=async e=>{Xi.debug("get conversation list ->");const{code:r,data:s}=await Tl.getConversationList(e?.count??20,null,e?.startTime??0,e?.order??0);return r!==t.SUCCESS&&Xi.warn("get conversation list fail ->"+r+":"+n(r)),{code:r,msg:n(r),data:s}},zl=async e=>{ia("options",e,sa,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get conversation ->"+r);const{code:s,data:o}=await Tl.getConversation(e);return s!==t.SUCCESS?(Xi.warn("get conversation fail ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:s,data:o}},$l=async e=>{ia("options",e,sa,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("remove conversation ->"+r);const s=await Tl.removeConversation(e);return s!==t.SUCCESS?(Xi.warn("remove conversation fail ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:s}},Wl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get draft ->"+n);const r=Tl.getConversationMessageDraft(e);return Promise.resolve({code:t.SUCCESS,data:r})},Jl=(e,n)=>{ia("options",e,sa,!0),ia("draft",n,Yi,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("set draft ->"+r),Tl.saveConversationMessageDraft(e,n),Promise.resolve({code:t.SUCCESS})},Zl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("delete draft ->"+n),Tl.clearConversationMessageDraft(e),Promise.resolve({code:t.SUCCESS})},Xl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("get unreadMentionedCount ->"+n),Promise.resolve({code:t.SUCCESS,data:Tl.getUnreadMentionedCount(e)})},Yl=()=>{Xi.debug("getAllUnreadMentionedCount");const e=Tl.getAllUnreadMentionedCount();return Promise.resolve({code:t.SUCCESS,data:e})},Ql=e=>(Xi.debug("getConversationState"),Tl.getConversationState(e)),eu=()=>{Xi.debug("getAllConversationState");const e=Tl.getAllConversationState();return Promise.resolve({code:t.SUCCESS,data:e})},tu=(e,n)=>{if(Xi.debug("get total unread count -> ConversationType:"+JSON.stringify(n)+" includeMuted:"+e),ia("includeMuted",e,ea,!1),ia("conversationTypes",n,na,!1),n)for(const e of n)ia("conversationType",e,ra,!0);const r=Tl.getAllConversationUnreadCount(n??[],e??!1);return Promise.resolve({code:t.SUCCESS,data:r})},nu=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get unreadCount ->"+n);const r=Tl.getConversationUnreadCount(e);return Promise.resolve({code:t.SUCCESS,data:r})},ru=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("clear unreadMsgNum ->"+n),Tl.clearConversationUnreadCount(e),Promise.resolve({code:t.SUCCESS})},su=()=>(Xi.debug("clear allMessagesUnreadStatus"),Tl.clearAllConversationsUnreadCount(),Promise.resolve({code:t.SUCCESS})),ou=e=>{ia("options",e,sa,!0),Xi.info("getConversationNotificationLevel ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const n=Tl.getConversationNotificationLevel(e);return Promise.resolve({code:t.SUCCESS,data:n})},iu=async(e,r)=>{ia("options",e,sa,!0),ia("notificationStatus",r,e=>1===e||2===e,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("set conversation status ->"+s);const o=await Tl.setConversationNotificationStatus(e,r);return o!==t.SUCCESS?(Xi.warn("set conversation status fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:o}},au=e=>{ia("options",e,sa,!0),Xi.info("getConversationNotificationStatus ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const n=Tl.getConversationNotificationStatus(e);return Promise.resolve({code:t.SUCCESS,data:n})},cu=()=>Tl.getBlockConversationList(),lu=async(e,r=!0)=>{ia("options",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("set conversation status ->"+s);const o=await Tl.setConversationToTop(e,r);return o!==t.SUCCESS?(Xi.warn("set conversation status fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:o}},uu=async(e,r,s=0)=>{ia("conversation",e,sa,!0),ia("enabled",r,ea,!0),ia("burnAfterReadingTime",s,e=>Number.isSafeInteger(e)&&e>=0,!0);const o=await Tl.setConversationBurnAfterReading(e,r,r?s:0);return o!==t.SUCCESS?{code:o,msg:n(o)}:{code:t.SUCCESS}},du=()=>Tl.getTopConversationList(),gu=(e,t,n,r)=>{let s=function(s){return new fi(e,s,t,n,r)};return Ws(e,s),s},pu=async(e,t,n)=>Tl.insertMessage(e,t,n),fu=async(e,n,r)=>{if(n instanceof fi==!1)return Xi.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:t.PARAMETER_ERROR};ia("conversation",e,sa,!0),Fu(e);const s=await Tl.sendMessage(e,n,r);return xu(e,s.code),s},hu=async(e,t,n)=>{ia("conversation",e,sa,!0),ia("originalMessage",t,ta,!0),Fu(e);const r=await Tl.forwardMessage(e,t,n);return xu(e,r.code),r},yu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("originalMessages",t,na,!0),ia("chatTitle",n,Yi,!0),Fu(e);const s=await Tl.mergeForwardMessages(e,t,n,r);return xu(e,s.code),s},mu=(e,t,n)=>{const r=new yi(t);return fu(e,r,n)},vu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("image/"),!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendImageMessage(e,t,n,r);return xu(e,o.code),o},bu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.endsWith("image/gif"),!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendGIFMessage(e,t,n,r);return xu(e,o.code),o},Cu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob,!0),Fu(e);const s=await Tl.sendHQVoiceMessage(e,t,n,r);return xu(e,s.code),s},wu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendFileMessage(e,t,n,r);return xu(e,o.code),o},Iu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("video/"),!0),Fu(e);const s=await Tl.sendSightMessage(e,t,n,r);return xu(e,s.code),s},Ou=async(e,r)=>{ia("options.messageUId",r.messageUId,Yi,!0),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+r.messageUId;Xi.debug("recall message ->"+s);const o=await Tl.recallMsg(e,r);return o.code!==t.SUCCESS&&Xi.warn("recall message fail ->"+o.code+":"+n(o.code)+","+s),o},Su=async(e,r)=>{ia("options.messageUId",r.messageUId,Yi,!0),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+r.messageUId;Xi.debug("comment message ->"+s);const o=await Tl.commentMsg(e,r);return o.code!==t.SUCCESS&&Xi.warn("comment message fail ->"+o.code+":"+n(o.code)+","+s),o},Ru=async(e,r)=>{ia("options.count",r.count??0,Qi),ia("options.order",r.order??0,e=>0===e||1===e),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;let o;return Xi.debug("get remote history message ->"+s),nt(r.timestamp)&&(r.timestamp=r.timestamp.toString()),o=r.order?await Tl.getHistoryMessages(e,r):await Tl.getPreviousHistoryMessages(e,r.timestamp,r.count),o.code!==t.SUCCESS&&Xi.warn("get remote history message fail ->"+o.code+":"+n(o.code)+","+s),o},Eu=async(e,r)=>{ia("options.count",r.count??0,Qi),ia("options.order",r.order??0,e=>0===e||1===e),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get history messages ->"+s),nt(r.timestamp)&&(r.timestamp=r.timestamp.toString());let o=await Tl.getHistoryMessages(e,r);return o.code!==t.SUCCESS&&Xi.warn("get history message fail ->"+o.code+":"+n(o.code)+","+s),o},Tu=async(e,r,s,o="everyone")=>{ia("conversation",e,sa,!0),ia("messageUId",r,Yi,!0),ia("pinned",s,ea,!0),ia("scope",o,e=>"everyone"===e||"me"===e,!0);const i=await Tl.setMessagePinned(e,r,s,o);return i!==t.SUCCESS?{code:i,msg:n(i)}:{code:t.SUCCESS}},_u=async e=>{ia("conversation",e,sa,!0);const r=await Tl.unpinAllMessages(e);return r!==t.SUCCESS?{code:r,msg:n(r)}:{code:t.SUCCESS}},Au=async(e,t=50)=>(ia("conversation",e,sa,!0),ia("count",t,e=>Number.isInteger(e)&&e>0,!0),Tl.getPinnedMessages(e,t)),ku=async(e,r)=>{ia("messages",r,e=>ct(e)&&!!e.length,!0),r.forEach(e=>{ia("messages.messageUId",e.messageUId,Yi,!0),ia("messages.sentTime",e.sentTime,Qi,!1),ia("messages.messageDirection",e.messageDirection,e=>1===e||2===e,!1)}),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("delete messages ->"+s);const o=await Tl.deleteRemoteMessage(e,r);return o!==t.SUCCESS?(Xi.warn("delete message fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:t.SUCCESS}},Mu=async(e,t)=>(ia("conversation",e,sa,!0),ia("messageUIds",t,e=>ct(e)&&e.length>0,!0),t.forEach(e=>{ia("messageUIds.messageUId",e,Yi,!0)}),{code:await Tl.deleteLocalMessages(e,t)}),Pu=async e=>{ia("conversation",e,sa);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("clear message ->"+r);const s=await Tl.deleteHistoryMessages(e);return s!==t.SUCCESS?(Xi.warn("clear message ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:t.SUCCESS}},Nu=(e,t)=>No.decodeChatRecordMsgDetails2ReceivedMessages(e,t),Lu=e=>No.encodeReceivedMessage2ChatRecordMsgDetail(e),Du=async(e,n=Date.now())=>{try{return await Tl.sendReadReceipts(e,n),{code:t.SUCCESS}}catch(e){return{code:t.UNKNOWN}}},Uu=e=>(e=>lr.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:wl,decoder:Il}))(e),ju=e=>(e=>lr.request(805404721,{langCode:e.langCode,account:e.phone},{encoder:Ol,decoder:Sl}))(e),Bu=e=>(e=>lr.request(805404723,{langCode:e.country,account:e.phone,code:e.code},{encoder:Rl,decoder:El}))(e),Fu=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+t)},xu=(e,r)=>{if(r!==t.SUCCESS){const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.warn("send message fail ->"+r+":"+n(r)+","+t)}},Gu=async e=>{ia("conversation",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("clear burn after reading expired messages ->"+n);const r=await Tl.clearBurnAfterReadingExpiredMessages(e);return r.length>0&&Xi.debug(`已清除会话 ${n} 中的 ${r.length} 条阅后即焚过期消息`),Promise.resolve({code:t.SUCCESS,data:r})},qu=async(e,t,n)=>await Tl.sendQuoteReplyMessage(e,t,n),Vu=async e=>{const n=await Tl.getMessageById(e);return{code:t.SUCCESS,data:n}},Ku=async e=>{const n=await Tl.getMessageByUId(e);return{code:t.SUCCESS,data:n}},Hu=async e=>{try{const n=await Tl.updateMessage(e);return{code:t.SUCCESS,data:n}}catch(e){return Xi.error("updateMessage -> ",e),{code:t.UNKNOWN,msg:e instanceof Error?e.message:String(e)}}},zu=async(e,t,n={})=>{ia("conversation",e,sa,!0);const r=Array.isArray(t)?[...t]:[t];return r.forEach((e,t)=>{ia(`messageTypes[${t}]`,e,Qi,!0)}),nt(n.count)&&ia("options.count",n.count,Qi,!0),nt(n.order)&&ia("options.order",n.order,e=>0===e||1===e),nt(n.timestamp)&&(n.timestamp=n.timestamp.toString()),Tl.getMessagesByType(e,r,n)},$u=async(e,n)=>{const r=await Tl.searchTextMessages(e,n);return{code:t.SUCCESS,data:r}},Wu=async(e,n=500)=>{const r=await Tl.searchMessages(e,n);return{code:t.SUCCESS,data:r}};export{Oi as ChatRecordMessage,e as ConnectionStatus,Si as ContactMessage,r as ConversationType,t as ErrorCode,n as ErrorDesc,d as Events,Ci as FileMessage,vi as GIFMessage,Ui as GroupCloseBurnAfterReadingMessage,Gi as GroupMessagePinnedNotification,Di as GroupOpenBurnAfterReadingMessage,bi as HQVoiceMessage,mi as ImageMessage,Ri as InvitationMessage,_i as LinkMessage,Ii as LocationMessage,u as LogLevel,s as MentionedType,i as MessageDirection,g as MessagePinnedOperation,ro as MessageTypes,io as NotiMessageTypes,l as NotificationLevel,o as NotificationStatus,Li as PrivateCloseBurnAfterReadingMessage,xi as PrivateMessagePinnedNotification,Ni as PrivateOpenBurnAfterReadingMessage,Vi as RecallCommandMessage,c as ReceivedStatus,Ei as RedEnvelopeMessage,a as SentStatus,yi as TextMessage,Ti as TransferMessage,wi as VideoMessage,Gl as addEventListener,su as clearAllMessagesUnreadStatus,Gu as clearBurnAfterReadingExpiredMessages,Pu as clearHistoryMessages,ru as clearMessagesUnreadStatus,Zl as clearTextMessageDraft,Su as commentMessage,Nl as connect,Pl as deleteLegacyDatabase,jl as deleteLocalDatabase,Mu as deleteLocalMessages,ku as deleteMessages,Ll as disconnect,Lu as encodeReceivedMessage2ChatRecordMsgDetail,hu as forwardMessage,eu as getAllConversationState,Yl as getAllUnreadMentionedCount,cu as getBlockedConversationList,Kl as getCachedDialogFilterConfig,Bl as getConnectionStatus,zl as getConversation,Hl as getConversationList,ou as getConversationNotificationLevel,au as getConversationNotificationStatus,Ql as getConversationState,Eu as getHistoryMessages,Ml as getLegacyMediaReferences,kl as getLegacyMigrationInfo,Vu as getMessageById,Ku as getMessageByUId,zu as getMessagesByType,Au as getPinnedMessages,Ru as getRemoteHistoryMessages,xl as getServerTime,Wl as getTextMessageDraft,du as getTopConversationList,tu as getTotalUnreadCount,nu as getUnreadCount,Xl as getUnreadMentionedCount,_l as init,pu as insertMessage,ao as isRecallMessageType,Ul as logOut,yu as mergeForwardMessages,Al as migrateLegacyDatabase,ju as mockGetLoginCode,Uu as mockLogin,Bu as mockVerifyLoginCode,ql as onceEventListener,Nu as parseChatRecordMsgDetails,Ou as recallMessage,gu as registerMessageType,co as remapIncomingRecallConstructor,$l as removeConversation,Vl as removeEventListener,Fl as request,Jl as saveTextMessageDraft,Wu as searchMessages,$u as searchTextMessages,wu as sendFileMessage,bu as sendGIFMessage,Cu as sendHQVoiceMessage,vu as sendImageMessage,fu as sendMessage,qu as sendQuoteReplyMessage,Du as sendReadReceipts,Iu as sendSightMessage,mu as sendTextMessage,uu as setConversationBurnAfterReading,iu as setConversationNotificationStatus,lu as setConversationToTop,Tu as setMessagePinned,Dl as setUserLogged,_u as unpinAllMessages,Hu as updateMessage};
|
|
37
|
+
*/var Nn=null;try{Nn=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 Ln(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Dn(e){return!0===(e&&e.__isLong__)}function Un(e){var t=Math.clz32(e&-e);return e?31-t:t}Ln.prototype.__isLong__,Object.defineProperty(Ln.prototype,"__isLong__",{value:!0}),Ln.isLong=Dn;var jn={},Bn={};function Fn(e,t){var n,r,s;return t?(s=0<=(e>>>=0)&&e<256)&&(r=Bn[e])?r:(n=Gn(e,0,!0),s&&(Bn[e]=n),n):(s=-128<=(e|=0)&&e<128)&&(r=jn[e])?r:(n=Gn(e,e<0?-1:0,!1),s&&(jn[e]=n),n)}function xn(e,t){if(isNaN(e))return t?Zn:Jn;if(t){if(e<0)return Zn;if(e>=zn)return tr}else{if(e<=-$n)return nr;if(e+1>=$n)return er}return e<0?xn(-e,t).neg():Gn(e%Hn|0,e/Hn|0,t)}function Gn(e,t,n){return new Ln(e,t,n)}Ln.fromInt=Fn,Ln.fromNumber=xn,Ln.fromBits=Gn;var qn=Math.pow;function Vn(e,t,n){if(0===e.length)throw Error("empty string");if("number"==typeof t?(n=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?Zn:Jn;if((n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Vn(e.substring(1),t,n).neg();for(var s=xn(qn(n,8)),o=Jn,i=0;i<e.length;i+=8){var a=Math.min(8,e.length-i),c=parseInt(e.substring(i,i+a),n);if(a<8){var l=xn(qn(n,a));o=o.mul(l).add(xn(c))}else o=(o=o.mul(s)).add(xn(c))}return o.unsigned=t,o}function Kn(e,t){return"number"==typeof e?xn(e,t):"string"==typeof e?Vn(e,t):Gn(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}Ln.fromString=Vn,Ln.fromValue=Kn;var Hn=4294967296,zn=Hn*Hn,$n=zn/2,Wn=Fn(1<<24),Jn=Fn(0);Ln.ZERO=Jn;var Zn=Fn(0,!0);Ln.UZERO=Zn;var Xn=Fn(1);Ln.ONE=Xn;var Yn=Fn(1,!0);Ln.UONE=Yn;var Qn=Fn(-1);Ln.NEG_ONE=Qn;var er=Gn(-1,2147483647,!1);Ln.MAX_VALUE=er;var tr=Gn(-1,-1,!0);Ln.MAX_UNSIGNED_VALUE=tr;var nr=Gn(0,-2147483648,!1);Ln.MIN_VALUE=nr;var rr=Ln.prototype;rr.toInt=function(){return this.unsigned?this.low>>>0:this.low},rr.toNumber=function(){return this.unsigned?(this.high>>>0)*Hn+(this.low>>>0):this.high*Hn+(this.low>>>0)},rr.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(nr)){var t=xn(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var s=xn(qn(e,6),this.unsigned),o=this,i="";;){var a=o.div(s),c=(o.sub(a.mul(s)).toInt()>>>0).toString(e);if((o=a).isZero())return c+i;for(;c.length<6;)c="0"+c;i=""+c+i}},rr.getHighBits=function(){return this.high},rr.getHighBitsUnsigned=function(){return this.high>>>0},rr.getLowBits=function(){return this.low},rr.getLowBitsUnsigned=function(){return this.low>>>0},rr.getNumBitsAbs=function(){if(this.isNegative())return this.eq(nr)?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},rr.isZero=function(){return 0===this.high&&0===this.low},rr.eqz=rr.isZero,rr.isNegative=function(){return!this.unsigned&&this.high<0},rr.isPositive=function(){return this.unsigned||this.high>=0},rr.isOdd=function(){return!(1&~this.low)},rr.isEven=function(){return!(1&this.low)},rr.equals=function(e){return Dn(e)||(e=Kn(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},rr.eq=rr.equals,rr.notEquals=function(e){return!this.eq(e)},rr.neq=rr.notEquals,rr.ne=rr.notEquals,rr.lessThan=function(e){return this.comp(e)<0},rr.lt=rr.lessThan,rr.lessThanOrEqual=function(e){return this.comp(e)<=0},rr.lte=rr.lessThanOrEqual,rr.le=rr.lessThanOrEqual,rr.greaterThan=function(e){return this.comp(e)>0},rr.gt=rr.greaterThan,rr.greaterThanOrEqual=function(e){return this.comp(e)>=0},rr.gte=rr.greaterThanOrEqual,rr.ge=rr.greaterThanOrEqual,rr.compare=function(e){if(Dn(e)||(e=Kn(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},rr.comp=rr.compare,rr.negate=function(){return!this.unsigned&&this.eq(nr)?nr:this.not().add(Xn)},rr.neg=rr.negate,rr.add=function(e){Dn(e)||(e=Kn(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,s=65535&this.low,o=e.high>>>16,i=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=s+(65535&e.low))>>>16,l+=(u+=r+a)>>>16,c+=(l+=n+i)>>>16,c+=t+o,Gn((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},rr.subtract=function(e){return Dn(e)||(e=Kn(e)),this.add(e.neg())},rr.sub=rr.subtract,rr.multiply=function(e){if(this.isZero())return this;if(Dn(e)||(e=Kn(e)),Nn)return Gn(Nn.mul(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned);if(e.isZero())return this.unsigned?Zn:Jn;if(this.eq(nr))return e.isOdd()?nr:Jn;if(e.eq(nr))return this.isOdd()?nr:Jn;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(Wn)&&e.lt(Wn))return xn(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,s=65535&this.low,o=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+=s*c)>>>16,u+=(d+=r*c)>>>16,d&=65535,u+=(d+=s*a)>>>16,l+=(u+=n*c)>>>16,u&=65535,l+=(u+=r*a)>>>16,u&=65535,l+=(u+=s*i)>>>16,l+=t*c+n*a+r*i+s*o,Gn((d&=65535)<<16|(g&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},rr.mul=rr.multiply,rr.divide=function(e){if(Dn(e)||(e=Kn(e)),e.isZero())throw Error("division by zero");var t,n,r;if(Nn)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Gn((this.unsigned?Nn.div_u:Nn.div_s)(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?Zn:Jn;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Zn;if(e.gt(this.shru(1)))return Yn;r=Zn}else{if(this.eq(nr))return e.eq(Xn)||e.eq(Qn)?nr:e.eq(nr)?Xn:(t=this.shr(1).div(e).shl(1)).eq(Jn)?e.isNegative()?Xn:Qn:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(nr))return this.unsigned?Zn:Jn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=Jn}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),o=s<=48?1:qn(2,s-48),i=xn(t),a=i.mul(e);a.isNegative()||a.gt(n);)a=(i=xn(t-=o,this.unsigned)).mul(e);i.isZero()&&(i=Xn),r=r.add(i),n=n.sub(a)}return r},rr.div=rr.divide,rr.modulo=function(e){return Dn(e)||(e=Kn(e)),Nn?Gn((this.unsigned?Nn.rem_u:Nn.rem_s)(this.low,this.high,e.low,e.high),Nn.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},rr.mod=rr.modulo,rr.rem=rr.modulo,rr.not=function(){return Gn(~this.low,~this.high,this.unsigned)},rr.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},rr.clz=rr.countLeadingZeros,rr.countTrailingZeros=function(){return this.low?Un(this.low):Un(this.high)+32},rr.ctz=rr.countTrailingZeros,rr.and=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low&e.low,this.high&e.high,this.unsigned)},rr.or=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low|e.low,this.high|e.high,this.unsigned)},rr.xor=function(e){return Dn(e)||(e=Kn(e)),Gn(this.low^e.low,this.high^e.high,this.unsigned)},rr.shiftLeft=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Gn(0,this.low<<e-32,this.unsigned)},rr.shl=rr.shiftLeft,rr.shiftRight=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Gn(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},rr.shr=rr.shiftRight,rr.shiftRightUnsigned=function(e){return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Gn(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Gn(32===e?this.high:this.high>>>e-32,0,this.unsigned)},rr.shru=rr.shiftRightUnsigned,rr.shr_u=rr.shiftRightUnsigned,rr.rotateLeft=function(e){var t;return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Gn(this.high,this.low,this.unsigned):e<32?(t=32-e,Gn(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),Gn(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},rr.rotl=rr.rotateLeft,rr.rotateRight=function(e){var t;return Dn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Gn(this.high,this.low,this.unsigned):e<32?(t=32-e,Gn(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),Gn(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},rr.rotr=rr.rotateRight,rr.toSigned=function(){return this.unsigned?Gn(this.low,this.high,!1):this},rr.toUnsigned=function(){return this.unsigned?this:Gn(this.low,this.high,!0)},rr.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},rr.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]},rr.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]},Ln.fromBytes=function(e,t,n){return n?Ln.fromBytesLE(e,t):Ln.fromBytesBE(e,t)},Ln.fromBytesLE=function(e,t){return new Ln(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Ln.fromBytesBE=function(e,t){return new Ln(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var sr=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:Ln.isLong(e.uid)?e.uid.toString():e.uid,deviceId:Ln.isLong(e.deviceId)?e.deviceId.toString():e.deviceId,sessionId:Ln.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 or={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const ir=t=>e[t],ar=e=>{const t=new kn;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},cr=e=>{const t=new Mn(new Uint8Array(e));t.readInt8(),t.readInt8();const n=t.readInt32(),r=t.readArr(n-7);if(t.readInt8(),e.byteLength!==n)throw new Error("packet resolve failed");return r};var lr=new class{url="";watcher;options;socket;status=e.DISCONNECTED;autoReconnect=!1;isConnected=!1;responseCallbacks=new Map;failedCount=0;reconnectTimer;connectResolve;pendingMessages=[];constructor(e){this.options=Object.assign(or,e)}setServerInfo(e){this.url=e}setCallback(e){this.watcher=e}async connect(){return this.autoReconnect=!0,new Promise(n=>{this.connectResolve=n,this.open().then(r=>{n(r),r===t.SUCCESS?(this.isConnected=!0,this.onConnect()):this.onDisconnect(r===t.TIMEOUT?e.NETWORK_UNAVAILABLE:e.WEBSOCKET_UNAVAILABLE)})})}async request(e,n,r,s=this.options.signalTimeout){const{code:o,data:i}=await this.sendRawData(e,nt(n)&&nt(r.encoder)?r.encoder.encode(n).finish():new Uint8Array,s);if(0!==o)return{code:o,msg:"time out",data:null};if(!nt(i)||!nt(r.decoder))return{code:t.SUCCESS,msg:""};const a=r.decoder?.decode(i);return a.errorCode?{code:a.errorCode,msg:a.errorMessage,data:null}:{data:a,code:t.SUCCESS,msg:""}}async send(e,n,r,s=this.options.signalTimeout){const o=await this.request(e,n,r,s);return o.code!==t.SUCCESS?{code:Pn(o.code),msg:o.msg,data:null}:{data:o.data,code:t.SUCCESS,msg:o.msg}}async sendRawData(e,n,r=this.options.signalTimeout){if(!this.socket)return{code:t.RC_NET_CHANNEL_INVALID};const s=this.generateMessageSeq();this.isConnected?this.doSendRawData(e,n,s):this.pendingMessages.push({cmdId:e,body:n,messageSeq:s});const o=await new Promise(e=>{this.responseCallbacks.set(s,e),setTimeout(()=>{this.responseCallbacks.get(s)&&this.responseCallbacks.delete(s),e(null)},r)});return o?{code:0,data:o}:(Xi.warn(`send timeout -> cmd: 0x${e.toString(16)}, messageSeq: ${s}, timeout: ${r}`),{code:t.TIMEOUT})}doSendRawData(e,t,n){const r={cmdId:e,messageSeq:Ln.fromNumber(n),deviceId:Ln.fromString(sr.user.deviceId),sessionId:Ln.fromString(sr.user.sessionId),uid:Ln.fromString(sr.user.uid),protocolVersion:0,destId:"",body:t,deviceCode:Et.getDeviceCode()??"",deviceType:Et.getDeviceType()};e!==Tt.Heartbean&&Xi.info(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${n}`),this.socket?.send(ar(Sn.encode(r).finish()))}close(){this.autoReconnect=!1,this.doClose(),this.setStatus(e.DISCONNECTED),this.connectResolve?.(t.RC_SOCKET_DISCONNECTED)}async open(){const n=this.url;Xi.info(`connect start -> ${n}`),this.setStatus(e.CONNECTING);const r=function(e,t){const n=new WebSocket(e,t);return n.binaryType="arraybuffer",{onClose(e){n.onclose=t=>{const{code:n,reason:r}=t;e?.(n,r)}},onError(e){n.onerror=t=>{e(t)}},onMessage(e){n.onmessage=t=>{e(t.data)}},onOpen(e){n.onopen=e},send(e){n.send(e)},close(e,t){n.close(e,t)}}}(this.url);this.socket=r;return await new Promise(s=>{r.onMessage(e=>{"ArrayBuffer"===tt(e)?this.onReceiveMessage(e):Xi.error("Socket received invalid data:",e)}),r.onClose((n,r)=>{Xi.warn("websocket closed -> code:",n,"reason:",r),this.onDisconnect(e.CONNECTION_CLOSED),s(t.RC_SOCKET_DISCONNECTED)}),r.onError(n=>{Xi.warn("websocket error -> ",n),this.onDisconnect(e.WEBSOCKET_ERROR),s(t.RC_SOCKET_NOT_CREATED)}),r.onOpen(()=>{Xi.info("websocket open -> ",n),s(t.SUCCESS)}),setTimeout(()=>{s(t.TIMEOUT)},this.options.webSocketTimeout)})}async checkAlive(){if(!this.socket||!this.isConnected)return;Xi.debug("send ping ->");const n={pingId:Ln.ZERO,disconnectDelay:Ln.ZERO},{code:r}=await this.send(Tt.Heartbean,n,{encoder:En},this.options.pingTimeout);r===t.SUCCESS?(Xi.debug("recv pong <-"),this.failedCount=0,setTimeout(()=>this.checkAlive(),this.options.pingInterval)):(this.failedCount+=1,Xi.warn(`ping failed count: ${this.failedCount}, code: ${r}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,Xi.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let n;try{const e=cr(t);n=Rn.decode(e)}catch(t){return Xi.error("unpack payload error -> ",t),void this.onDisconnect(e.DISCONNECT_BY_SERVER)}if(n.code)return Xi.error("on received message error -> ",n.code),void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(n.cmdId===Tt.SessionKilledPush)return void this.onDisconnect(e.KICKED_OFFLINE_BY_OTHER_CLIENT);if(n.cmdId===Tt.SignOutPish||n.cmdId===Tt.SignOutPish2)return Xi.warn("on received signoutpush -> ",n.cmdId),void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(n.cmdId===Tt.UserFrozenToLogin||n.cmdId===Tt.UserFrozenToLogin2)return void this.onDisconnect(e.BLOCKED);const r=Ln.isLong(n.messageSeq)?n.messageSeq.toNumber():0,s=r>0?this.responseCallbacks.get(r):null;nt(s)?(n.cmdId!==Tt.HeartbeanResp&&Xi.info(`websocket recv ack -> messageSeq: ${r}`),s(n.body),this.responseCallbacks.delete(r)):(Xi.info(`websocket recv -> cmd: 0x${n.cmdId.toString(16)}`),this.watcher?.message(n.cmdId,n.body))}async try2Reconnect(){this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},5e3)}async onConnect(){for(this.setStatus(e.CONNECTED),this.checkAlive(),nt(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);this.pendingMessages.length>0;){let{cmdId:e,body:t,messageSeq:n}=this.pendingMessages.shift();this.doSendRawData(e,t,n),await new Promise(e=>setTimeout(e,200))}}onDisconnect(e){nt(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(nt(this.socket)){this.pendingMessages.length=0;const e=this.socket;this.socket=null,e.onClose(null),e.close()}nt(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.DISCONNECTED&&this.status!==e.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.BLOCKED&&this.status!==e.DISCONNECT_BY_SERVER}setStatus(e){Xi.info(`socketServer is changing status from ${ir(this.status)} to ${ir(e)}`),this.status=e,this.watcher?.status(e)}idCount=0;generateMessageSeq(){return++this.idCount}};const ur=bn.Reader,dr=bn.Writer,gr=bn.util,pr=bn.roots.default||(bn.roots.default={}),fr=pr.SendPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.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=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e})(),hr=pr.SendPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e})(),yr=pr.DeletePrivateChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeletePrivateChatDialogReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.destId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e})(),mr=pr.GetNewMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetNewMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.offset=e.int64();break;case 2:r.rows=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e})(),vr=pr.GetNewMessageResp=(()=>{function e(e){if(this.msg={},this.reference={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msg=gr.emptyObject,e.prototype.reference=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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 n=Object.keys(e.msg),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.DialogMessageList.encode(e.msg[n[r]],t.uint32(18).fork()).ldelim().ldelim();if(null!=e.reference&&Object.hasOwnProperty.call(e,"reference"))for(let n=Object.keys(e.reference),r=0;r<n.length;++r)t.uint32(50).fork().uint32(10).string(n[r]),pr.ReferenceDialogMessage.encode(e.reference[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetNewMessageResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.offset=e.int64();break;case 4:o.seqno=e.int64();break;case 5:{o.msg===gr.emptyObject&&(o.msg={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.msg[n]=r;break}case 6:{o.reference===gr.emptyObject&&(o.reference={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.reference[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e})();pr.DialogMessageList=(()=>{function e(e){if(this.dialogMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialogMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.dialogMessage&&e.dialogMessage.length)for(let n=0;n<e.dialogMessage.length;++n)pr.DialogMessage.encode(e.dialogMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DialogMessageList;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.dialogMessage&&r.dialogMessage.length||(r.dialogMessage=[]),r.dialogMessage.push(pr.DialogMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e})(),pr.DialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.destId=gr.Long?gr.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=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=gr.Long?gr.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=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DialogMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.msgId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgStatus=e.int32();break;case 4:r.srcId=e.int64();break;case 5:r.destId=e.int64();break;case 6:r.isOut=e.bool();break;case 7:r.senderCategory=e.int32();break;case 8:r.msgCategory=e.int32();break;case 9:r.msgPreContent=e.string();break;case 10:r.msgPostContent=e.string();break;case 11:r.mediaFlag=e.bool();break;case 12:r.mediaConstructor=e.int32();break;case 13:r.mediaAttribute=e.string();break;case 14:r.msgSendTime=e.int64();break;case 15:r.burnAfterReadingFlag=e.bool();break;case 16:r.atFlag=e.bool();break;case 17:r.replyFlag=e.bool();break;case 18:r.referenceFlag=e.bool();break;case 19:r.msgIdReferenced=e.int64();break;case 20:r.uploadFlag=e.bool();break;case 21:r.burnAfterReadingTime=e.int64();break;case 22:r.sharingGroupFlag=e.bool();break;case 23:r.seqno=e.int64();break;case 24:r.replyMarkup=e.string();break;case 25:r.extra=e.string();break;case 26:r.msgArrival=e.bool();break;case 27:r.msgRead=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e})(),pr.ReferenceDialogMessage=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.srcId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.srcName="",e.prototype.destId=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReferenceDialogMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.msgId=e.int64();break;case 2:r.srcId=e.int64();break;case 3:r.srcName=e.string();break;case 4:r.destId=e.int64();break;case 5:r.destName=e.string();break;case 6:r.msgPreContent=e.string();break;case 7:r.msgPostContent=e.string();break;case 8:r.mediaFlag=e.bool();break;case 9:r.mediaConstructor=e.int32();break;case 10:r.mediaAttribute=e.string();break;case 11:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReferenceDialogMessage"},e})();const br=pr.UpdatePrivateChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.UpdatePrivateChatDialogStickyConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e})(),Cr=pr.UpdatePrivateChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.UpdatePrivateChatDialogMuteConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.muteFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e})(),wr=pr.DeleteChatMessageReq=(()=>{function e(e){if(this.msgIdList=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgIdList.length;++n)t.int64(e.msgIdList[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeleteChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;case 3:if(r.msgIdList&&r.msgIdList.length||(r.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgIdList.push(e.int64())}else r.msgIdList.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e})();pr.DeletePrivateChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.DeletePrivateChatHistoryReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e})();const Ir=pr.CleanHistoryMessageReq=(()=>{function e(e){if(this.msgIdList=[],this.destIdList=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId="",e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=gr.emptyArray,e.prototype.destIdList=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgIdList.length;++n)t.int64(e.msgIdList[n]);t.ldelim()}if(null!=e.destIdList&&e.destIdList.length)for(let n=0;n<e.destIdList.length;++n)t.uint32(34).string(e.destIdList[n]);return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.CleanHistoryMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.string();break;case 2:r.msgId=e.int64();break;case 3:if(r.msgIdList&&r.msgIdList.length||(r.msgIdList=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgIdList.push(e.int64())}else r.msgIdList.push(e.int64());break;case 4:r.destIdList&&r.destIdList.length||(r.destIdList=[]),r.destIdList.push(e.string());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e})(),Or=pr.GetBriefDialogListReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let n=0;n<e.destId.length;++n)t.int64(e.destId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetBriefDialogListReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)if(r.destId&&r.destId.length||(r.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.destId.push(e.int64())}else r.destId.push(e.int64());else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e})(),Sr=pr.GetBriefDialogListResp=(()=>{function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=gr.emptyArray,e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.notExistDestId.length;++n)t.int64(e.notExistDestId[n]);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 n=Object.keys(e.briefDialog),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.BriefDialog.encode(e.briefDialog[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetBriefDialogListResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:if(o.notExistDestId&&o.notExistDestId.length||(o.notExistDestId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)o.notExistDestId.push(e.int64())}else o.notExistDestId.push(e.int64());break;case 4:o.seqno=e.int64();break;case 5:{o.briefDialog===gr.emptyObject&&(o.briefDialog={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.briefDialog[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e})();pr.BriefDialog=(()=>{function e(e){if(this.groupMemberSmallAvatarUrl=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.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=gr.emptyArray,e.prototype.burnAfterReadingTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.dialogMenuContent="",e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.groupMemberSmallAvatarUrl.length;++n)t.uint32(98).string(e.groupMemberSmallAvatarUrl[n]);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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.BriefDialog;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.dialogTitle=e.string();break;case 3:r.smallAvatarUrl=e.string();break;case 4:r.backgroundImage=e.string();break;case 5:r.stickyFlag=e.bool();break;case 6:r.muteFlag=e.bool();break;case 7:r.blockFlag=e.bool();break;case 8:r.burnAfterReadingFlag=e.bool();break;case 9:r.takeScreenshotFlag=e.bool();break;case 10:r.groupFlag=e.bool();break;case 11:r.totalMemberNumber=e.int32();break;case 12:r.groupMemberSmallAvatarUrl&&r.groupMemberSmallAvatarUrl.length||(r.groupMemberSmallAvatarUrl=[]),r.groupMemberSmallAvatarUrl.push(e.string());break;case 13:r.burnAfterReadingTime=e.int64();break;case 14:r.dialogMenuContent=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e})();const Rr=pr.GetDialogKeyReq=(()=>{function e(e){if(this.destId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=dr.create()),null!=e.destId&&e.destId.length){t.uint32(10).fork();for(let n=0;n<e.destId.length;++n)t.int64(e.destId[n]);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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetDialogKeyReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:if(r.destId&&r.destId.length||(r.destId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.destId.push(e.int64())}else r.destId.push(e.int64());break;case 2:r.clientSign=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e})(),Er=pr.GetDialogKeyResp=(()=>{function e(e){if(this.retryUid=[],this.entry={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.retryUid=gr.emptyArray,e.prototype.entry=gr.emptyObject,e.prototype.serverSign="",e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.retryUid.length;++n)t.int64(e.retryUid[n]);t.ldelim()}if(null!=e.entry&&Object.hasOwnProperty.call(e,"entry"))for(let n=Object.keys(e.entry),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.AesKeyAndIV.encode(e.entry[n[r]],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 ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetDialogKeyResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.dialogKeyVersion=e.int64();break;case 4:if(o.retryUid&&o.retryUid.length||(o.retryUid=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)o.retryUid.push(e.int64())}else o.retryUid.push(e.int64());break;case 5:{o.entry===gr.emptyObject&&(o.entry={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.entry[n]=r;break}case 6:o.serverSign=e.string();break;default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e})();pr.AesKeyAndIV=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.AesKeyAndIV;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.aesKey=e.string();break;case 2:r.aesIV=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e})();const Tr=pr.RecallPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.RecallPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e})(),_r=pr.GetHistoryMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialogKeys="",e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetHistoryMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.dialogKeys=e.string();break;case 2:r.offset=e.int64();break;case 3:r.oldOffset=e.int64();break;case 4:r.rows=e.int32();break;case 5:r.newToOld=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e})(),Ar=pr.GetHistoryMessageResp=(()=>{function e(e){if(this.reference={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.prototype.reference=gr.emptyObject,e.encode=function(e,t){if(t||(t=dr.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")&&pr.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 n=Object.keys(e.reference),r=0;r<n.length;++r)t.uint32(42).fork().uint32(10).string(n[r]),pr.ReferenceDialogMessage.encode(e.reference[n[r]],t.uint32(18).fork()).ldelim().ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetHistoryMessageResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:o.msg=pr.DialogMessageList.decode(e,e.uint32());break;case 4:o.isEnd=e.bool();break;case 5:{o.reference===gr.emptyObject&&(o.reference={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.ReferenceDialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.reference[n]=r;break}default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e})(),kr=pr.GetWebDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.type=0,e.prototype.offset=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetWebDialogListReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.type=e.int32();break;case 2:r.offset=e.int64();break;case 3:r.rows=e.int32();break;case 4:r.newToOld=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e})(),Mr=pr.GetWebDialogListResp=(()=>{function e(e){if(this.fullDialog=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.fullDialog.length;++n)pr.WebFullDialog.encode(e.fullDialog[n],t.uint32(26).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetWebDialogListResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.fullDialog&&r.fullDialog.length||(r.fullDialog=[]),r.fullDialog.push(pr.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e})();pr.WebFullDialog=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.dialog=null,e.prototype.msg=null,e.encode=function(e,t){return t||(t=dr.create()),null!=e.dialog&&Object.hasOwnProperty.call(e,"dialog")&&pr.BriefDialog.encode(e.dialog,t.uint32(10).fork()).ldelim(),null!=e.msg&&Object.hasOwnProperty.call(e,"msg")&&pr.DialogMessage.encode(e.msg,t.uint32(18).fork()).ldelim(),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.WebFullDialog;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.dialog=pr.BriefDialog.decode(e,e.uint32());break;case 2:r.msg=pr.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e})();const Pr=pr.GetNewSettingDialogListReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.time=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.GetNewSettingDialogListReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.time=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e})(),Nr=pr.GetNewSettingDialogListResp=(()=>{function e(e){if(this.briefDialog={},e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=gr.emptyObject,e.prototype.setTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=dr.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 n=Object.keys(e.briefDialog),r=0;r<n.length;++r)t.uint32(26).fork().uint32(10).string(n[r]),pr.BriefDialog.encode(e.briefDialog[n[r]],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 ur||(e=ur.create(e));let n,r,s=void 0===t?e.len:e.pos+t,o=new pr.GetNewSettingDialogListResp;for(;e.pos<s;){let t=e.uint32();switch(t>>>3){case 1:o.errorCode=e.int32();break;case 2:o.errorMessage=e.string();break;case 3:{o.briefDialog===gr.emptyObject&&(o.briefDialog={});let t=e.uint32()+e.pos;for(n="",r=null;e.pos<t;){let t=e.uint32();switch(t>>>3){case 1:n=e.string();break;case 2:r=pr.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&t)}}o.briefDialog[n]=r;break}case 4:o.setTime=e.int64();break;default:e.skipType(7&t)}}return o},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e})(),Lr=pr.NewMessageNotificationResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.NewMessageNotificationResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.seqno=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e})();pr.ChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.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 n=0;n<e.msgId.length;++n)t.int64(e.msgId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ChatMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:if(r.msgId&&r.msgId.length||(r.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgId.push(e.int64())}else r.msgId.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ChatMessage"},e})();const Dr=pr.SendPrivateChatArrivalAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.chatMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.chatMessage&&e.chatMessage.length)for(let n=0;n<e.chatMessage.length;++n)pr.ChatMessage.encode(e.chatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatArrivalAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.chatMessage&&r.chatMessage.length||(r.chatMessage=[]),r.chatMessage.push(pr.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatArrivalAckReq"},e})(),Ur=pr.SendPrivateChatReadAckReq=(()=>{function e(e){if(this.chatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.chatMessage=gr.emptyArray,e.encode=function(e,t){if(t||(t=dr.create()),null!=e.chatMessage&&e.chatMessage.length)for(let n=0;n<e.chatMessage.length;++n)pr.ChatMessage.encode(e.chatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.SendPrivateChatReadAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.chatMessage&&r.chatMessage.length||(r.chatMessage=[]),r.chatMessage.push(pr.ChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatReadAckReq"},e})(),jr=pr.ReplyPrivateChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.localId=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=gr.Long?gr.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=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReplyPrivateChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.destId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:r.msgIdReferenced=e.int64();break;case 9:r.msgSrcIdReferenced=e.int64();break;case 10:r.msgDestIdReferenced=e.int64();break;case 11:r.msgPreContentReferenced=e.string();break;case 12:r.msgPostContentReferenced=e.string();break;case 13:r.mediaFlagReferenced=e.bool();break;case 14:r.mediaConstructorReferenced=e.int32();break;case 15:r.mediaAttributeReferenced=e.string();break;case 16:r.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageReq"},e})(),Br=pr.ReplyPrivateChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.ReplyPrivateChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyPrivateChatMessageResp"},e})(),Fr=pr.MessageReadedNoticeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.destId=gr.Long?gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=dr.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(8).int64(e.destId),t},e.decode=function(e,t){e instanceof ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.MessageReadedNoticeReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.destId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/MessageReadedNoticeReq"},e})(),xr=pr.MessageReadedNoticeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=dr.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 ur||(e=ur.create(e));let n=void 0===t?e.len:e.pos+t,r=new pr.MessageReadedNoticeResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/MessageReadedNoticeResp"},e})(),Gr=bn.Reader,qr=bn.Writer,Vr=bn.util,Kr=bn.roots.default||(bn.roots.default={}),Hr=Kr.SendGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.localId=Vr.Long?Vr.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=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.at.length;++n)t.int64(e.at[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:if(r.at&&r.at.length||(r.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.at.push(e.int64())}else r.at.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e})(),zr=Kr.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.seqno=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;case 6:r.seqno=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();Kr.DeleteGroupChatHistoryReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.DeleteGroupChatHistoryReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e})();const $r=Kr.UpdateGroupChatDialogStickyConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.UpdateGroupChatDialogStickyConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.stickyFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e})(),Wr=Kr.UpdateGroupChatDialogMuteConfigReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.UpdateGroupChatDialogMuteConfigReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.muteFlag=e.bool();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e})(),Jr=Kr.RecallGroupChatMessageReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.RecallGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.msgId=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e})();Kr.DeleteGroupChatDialogReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(8).int64(e.groupId),t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.DeleteGroupChatDialogReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupId=e.int64();else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e})(),Kr.GroupChatMessage=(()=>{function e(e){if(this.msgId=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.userId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.msgId.length;++n)t.int64(e.msgId[n]);t.ldelim()}return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.GroupChatMessage;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.userId=e.int64();break;case 3:if(r.msgId&&r.msgId.length||(r.msgId=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.msgId.push(e.int64())}else r.msgId.push(e.int64());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GroupChatMessage"},e})();const Zr=Kr.SendGroupChatArrivalAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupChatMessage=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let n=0;n<e.groupChatMessage.length;++n)Kr.GroupChatMessage.encode(e.groupChatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatArrivalAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupChatMessage&&r.groupChatMessage.length||(r.groupChatMessage=[]),r.groupChatMessage.push(Kr.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatArrivalAckReq"},e})(),Xr=Kr.SendGroupChatReadAckReq=(()=>{function e(e){if(this.groupChatMessage=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupChatMessage=Vr.emptyArray,e.encode=function(e,t){if(t||(t=qr.create()),null!=e.groupChatMessage&&e.groupChatMessage.length)for(let n=0;n<e.groupChatMessage.length;++n)Kr.GroupChatMessage.encode(e.groupChatMessage[n],t.uint32(10).fork()).ldelim();return t},e.decode=function(e,t){e instanceof Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.SendGroupChatReadAckReq;for(;e.pos<n;){let t=e.uint32();if(t>>>3==1)r.groupChatMessage&&r.groupChatMessage.length||(r.groupChatMessage=[]),r.groupChatMessage.push(Kr.GroupChatMessage.decode(e,e.uint32()));else e.skipType(7&t)}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatReadAckReq"},e})(),Yr=Kr.ReplyGroupChatMessageReq=(()=>{function e(e){if(this.at=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.groupId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.localId=Vr.Long?Vr.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=Vr.emptyArray,e.prototype.msgIdReferenced=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSrcIdReferenced=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgDestIdReferenced=Vr.Long?Vr.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=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){if(t||(t=qr.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 n=0;n<e.at.length;++n)t.int64(e.at[n]);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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.ReplyGroupChatMessageReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.groupId=e.int64();break;case 2:r.localId=e.int64();break;case 3:r.msgPreContent=e.string();break;case 4:r.msgPostContent=e.string();break;case 5:r.mediaFlag=e.bool();break;case 6:r.mediaConstructor=e.int32();break;case 7:r.mediaAttribute=e.string();break;case 8:if(r.at&&r.at.length||(r.at=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)r.at.push(e.int64())}else r.at.push(e.int64());break;case 9:r.msgIdReferenced=e.int64();break;case 10:r.msgSrcIdReferenced=e.int64();break;case 11:r.msgDestIdReferenced=e.int64();break;case 12:r.msgPreContentReferenced=e.string();break;case 13:r.msgPostContentReferenced=e.string();break;case 14:r.mediaFlagReferenced=e.bool();break;case 15:r.mediaConstructorReferenced=e.int32();break;case 16:r.mediaAttributeReferenced=e.string();break;case 17:r.msgSendTimeReferenced=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageReq"},e})(),Qr=Kr.ReplyGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgId=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Vr.Long?Vr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=qr.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 Gr||(e=Gr.create(e));let n=void 0===t?e.len:e.pos+t,r=new Kr.ReplyGroupChatMessageResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.localId=e.int64();break;case 4:r.msgId=e.int64();break;case 5:r.msgSendTime=e.int64();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ReplyGroupChatMessageResp"},e})();function es(e){return(lt(e)?Ln.fromString(e):e).greaterThan(Ln.fromNumber(9e10))?r.GROUP:r.PRIVATE}const ts=e=>e.targetId,ns=e=>({conversationType:es(e),targetId:Ln.isLong(e)?e.toString():e});function rs(e,t,n){return e&&n.uint32(8).int64(e),n.uint32(16).int32(t.pinned),n.uint32(24).int64(t.msgId),n}class ss{static encode(e,t=bn.Writer.create()){return rs(e.destId,e,t)}}class os{static encode(e,t=bn.Writer.create()){return rs(e.groupId,e,t)}}class is{static encode(e,t=bn.Writer.create()){return t.uint32(8).int64(e.msgId),t.uint32(16).int64(e.destId),e.content&&t.uint32(26).string(e.content),t}}class as{static encode(e,t=bn.Writer.create()){return t.uint32(8).int64(e.msgId),t.uint32(16).int64(e.groupId),e.content&&t.uint32(26).string(e.content),t}}function cs(e,t,n){return e&&n.uint32(8).int64(e),n.uint32(16).bool(t.burnAfterReadingFlag),n.uint32(24).int64(t.burnAfterReadingTime),n}class ls{static encode(e,t=bn.Writer.create()){return cs(e.destId,e,t)}}class us{static encode(e,t=bn.Writer.create()){return cs(e.groupId,e,t)}}function ds(e){return String(e)}function gs(e,t){const n=e.pos+t,r=[];for(;e.pos<n;)r.push(ds(e.int64()));return r}function ps(e,t){const n=void 0===t?e.len:e.pos+t,r={id:"0",title:"",colorId:-1,categories:0,excludeMuted:!1,excludeRead:!1,sortIndex:0,includeDestIds:[],excludeDestIds:[],excludeFolded:!1};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.id=ds(e.int64());break;case 2:r.title=e.string();break;case 3:r.colorId=e.int32();break;case 4:r.categories=e.int32();break;case 5:r.excludeMuted=e.bool();break;case 6:r.excludeRead=e.bool();break;case 7:r.sortIndex=e.int32();break;case 8:2==(7&t)?r.includeDestIds.push(...gs(e,e.uint32())):r.includeDestIds.push(ds(e.int64()));break;case 9:2==(7&t)?r.excludeDestIds.push(...gs(e,e.uint32())):r.excludeDestIds.push(ds(e.int64()));break;case 10:r.excludeFolded=e.bool();break;default:e.skipType(7&t)}}return r}function fs(e,t){const n=void 0===t?e.len:e.pos+t,r={filters:[],displayTags:!1};for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.filters.push(ps(e,e.uint32()));break;case 2:r.displayTags=e.bool();break;default:e.skipType(7&t)}}return r}class hs{static encode(e={},t=bn.Writer.create()){return t}}class ys{errorCode=0;errorMessage="";config={filters:[],displayTags:!1};static decode(e,t){const n=e instanceof bn.Reader?e:bn.Reader.create(e),r=void 0===t?n.len:n.pos+t,s=new ys;for(;n.pos<r;){const e=n.uint32();switch(e>>>3){case 1:s.errorCode=n.int32();break;case 2:s.errorMessage=n.string();break;case 3:s.config=fs(n,n.uint32());break;default:n.skipType(7&e)}}return s}}const ms=()=>lr.send(Tt.GetServerTime,null,{decoder:Tn}),vs=e=>lr.send(Tt.GetDialogKey,{destId:e,clientSign:""},{encoder:Rr,decoder:Er}),bs=e=>lr.send(Tt.SendPrivateChatMessage,e,{encoder:fr,decoder:hr}),Cs=e=>lr.send(Tt.SendQuotePrivateChatMessage,e,{encoder:jr,decoder:Br}),ws=e=>lr.send(Tt.SendGroupChatMessage,e,{encoder:Hr,decoder:zr}),Is=e=>lr.send(Tt.SendQuoteGroupChatMessage,e,{encoder:Yr,decoder:Qr}),Os=(e,t)=>lr.send(Tt.GetNewMessage,{offset:e,rows:t},{encoder:mr,decoder:vr}),Ss=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.RecallGroupMessage,{groupId:Ln.fromString(e),msgId:Ln.fromString(t)},{encoder:Jr,decoder:_n}):lr.send(Tt.RecallPrivateMessage,{destId:Ln.fromString(e),msgId:Ln.fromString(t)},{encoder:Tr,decoder:_n}),n},Rs=(e,t,n)=>{const s=Ln.fromString(t);return es(e)===r.GROUP?lr.send(Tt.PostGroupChatComment,{groupId:Ln.fromString(e),msgId:s,content:n},{encoder:as,decoder:_n}):lr.send(Tt.PostPrivateChatComment,{destId:Ln.fromString(e),msgId:s,content:n},{encoder:is,decoder:_n})},Es=(e,t,n)=>{const s=Ln.fromString(t);return es(e)===r.GROUP?lr.send(Tt.PinnedGroupMessage,{groupId:Ln.fromString(e),pinned:n,msgId:s},{encoder:os,decoder:_n}):lr.send(Tt.PinnedPrivateMessage,{destId:Ln.fromString(e),pinned:n,msgId:s},{encoder:ss,decoder:_n})},Ts=e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=Ln.fromString(e.offset):t.oldOffset=Ln.fromString(e.offset),lr.send(Tt.GetRemoteMessages,t,{encoder:_r,decoder:Ar})},_s=(e,t)=>lr.send(Tt.DeleteChatMessages,{destId:Ln.fromString(e),msgIdList:t.map(e=>Ln.fromString(e))},{encoder:wr,decoder:_n}),As=e=>lr.send(Tt.ClearChatHistoryMessage,{destId:e},{encoder:Ir,decoder:_n}),ks=e=>lr.send(Tt.GetDialogList,e,{encoder:kr,decoder:Mr}),Ms=e=>lr.send(Tt.GetBriefDialogList,{destId:e.map(e=>Ln.fromString(e))},{encoder:Or,decoder:Sr}),Ps=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.UpdateGroupChatMuteConfig,{groupId:Ln.fromString(e),muteFlag:t},{encoder:Wr,decoder:_n}):lr.send(Tt.UpdatePrivateChatMuteConfig,{destId:Ln.fromString(e),muteFlag:t},{encoder:Cr,decoder:_n}),n},Ns=(e,t)=>{let n;return n=es(e)==r.GROUP?lr.send(Tt.UpdateGroupChatStickyConfig,{groupId:Ln.fromString(e),stickyFlag:t},{encoder:$r,decoder:_n}):lr.send(Tt.UpdatePrivateChatStickyConfig,{destId:Ln.fromString(e),stickyFlag:t},{encoder:br,decoder:_n}),n},Ls=(e,t,n)=>{const s=Ln.fromString(e),o=Ln.fromNumber(n);return es(e)===r.GROUP?lr.send(Tt.UpdateGroupChatBurnAfterReadingConfig,{groupId:s,burnAfterReadingFlag:t,burnAfterReadingTime:o},{encoder:us,decoder:_n}):lr.send(Tt.UpdatePrivateChatBurnAfterReadingConfig,{destId:s,burnAfterReadingFlag:t,burnAfterReadingTime:o},{encoder:ls,decoder:_n})},Ds=e=>lr.send(Tt.DeletePrivateDialog,{destId:Ln.fromString(e)},{encoder:yr,decoder:_n}),Us=e=>lr.send(Tt.GetDialogChangedStatus,{time:Ln.fromNumber(e)},{encoder:Pr,decoder:Nr}),js=e=>lr.send(Tt.PostAnalyticsLogs,{data:e},{encoder:An,decoder:_n}),Bs=()=>lr.send(Tt.GetDialogFilterConfig,{},{encoder:hs,decoder:ys}),Fs=e=>lr.send(Tt.SYNC_CONVERSATION_READ_STATUS,{destId:Ln.fromString(e)},{encoder:Fr,decoder:xr});var xs=Object.freeze({__proto__:null,clearHistoryMessage:As,commentChatMessage:Rs,deleteDialog:Ds,deleteMessages:_s,getBriefDialogList:Ms,getDialogChangedStatus:Us,getDialogFilterConfig:Bs,getDialogKey:vs,getDialogList:ks,getNewMessages:Os,getRemoteMessages:Ts,getServerTime:ms,postAnalyticsLogs:js,recallChatMessage:Ss,sendGroupChatArrivalAck:e=>lr.send(Tt.SendGroupChatArrivalAck,e,{encoder:Zr,decoder:_n}),sendGroupChatMessage:ws,sendGroupChatReadAck:e=>lr.send(Tt.SendGroupChatReadAck,e,{encoder:Xr,decoder:_n}),sendPrivateChatArrivalAck:e=>lr.send(Tt.SendPrivateChatArrivalAck,e,{encoder:Dr,decoder:_n}),sendPrivateChatMessage:bs,sendPrivateChatReadAck:e=>lr.send(Tt.SendPrivateChatReadAck,e,{encoder:Ur,decoder:_n}),sendQuoteGroupChatMessage:Is,sendQuotePrivateChatMessage:Cs,syncConversationReadStatus:Fs,updateChatBurnAfterReadingConfig:Ls,updateChatMuteConfig:Ps,updateChatStickyConfig:Ns,updateMessagePinned:Es});let Gs=0;const qs=()=>(new Date).getTime()+Gs,Vs=new Set;var Ks={addMessage(e){Vs.add(e)},remove(e){Vs.delete(e)},has:e=>Vs.has(e),reset(){Vs.clear()}};const Hs=new Set;var zs={addMessage(e){Hs.add(e)},remove(e){Hs.delete(e)},has:e=>Hs.has(e),reset(){Hs.clear()}};const $s=new Map;function Ws(e,t){$s.set(e,t)}function Js(e,t){const n=$s.get(e);if(!n)return console.warn(`No message constructor found for type: ${e}`),null;try{return new n(t)}catch(t){return console.error(`Failed to decode message type ${e}:`,t),null}}var Zs=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(n=>{t(n.get(e))}),setTimeout(()=>{t(null)},8e3)}):null}getDialogAesKeyList(e){return new Promise(t=>{const n=new Map;this.getDialogAesKeyListInBatches(e,(r,s)=>{if(s.size)for(const[e,t]of s)n.set(e,t);(n.size===e.length||r)&&t(n)})})}getDialogAesKeyListInBatches(e,t){const n=new Map,r=[];e.forEach(e=>{if(!ut(e))return;const t=this.getDialogAesKeyFromLocal(e);t?n.set(e,t):r.push(e)}),t(!1,n),r.length&&this.getDialogAesKeyListFromRemote(r).then(e=>{t(!0,e)})}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(e){if(!e.length)return new Map;try{const{code:n,data:r}=await vs(e.map(e=>Ln.fromString(e)));if(n===t.SUCCESS){const e=new Map;for(const t in r.entry){const n=r.entry[t];if(n.aesKey?.length&&n.aesIV?.length){const r={key:n.aesKey,iv:n.aesIV};e.set(t,r),this.aesKeyRecord.set(t,r)}}return e}}catch(e){Xi.error("getDialogAesKeyListFromRemote error",e)}return new Map}getDialogAesKeyFromLocal(e){return ut(e)?this.aesKeyRecord.get(e):null}};const Xs="time",Ys=(e,t)=>[e,t,Xs].join("_");class Qs{appkey;userId;inBoxOffset=Ln.ZERO;constructor(e,t){this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=Ys(this.appkey,this.userId);Ct.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=Ys(this.appkey,this.userId);this.inBoxOffset=Ln.fromString(Ct.get(e)??"0")}return this.inBoxOffset}}const eo=(e,t)=>{if(!ut(e))return"";const n=et.AES.encrypt(e,et.enc.Utf8.parse(t.key),{iv:nt(t.iv)?et.enc.Utf8.parse(t.iv):void 0});return Array.from(no(n.ciphertext.words)).map(e=>e.toString(16).padStart(2,"0")).join("")},to=(e,t)=>{const n=new Uint8Array(e.match(/.{1,2}/g)?.map(e=>parseInt(e,16))||[]),r=window.btoa(String.fromCharCode(...n));return et.AES.decrypt(r,et.enc.Utf8.parse(t.key),{iv:nt(t.iv)?et.enc.Utf8.parse(t.iv):void 0}).toString(et.enc.Utf8)},no=e=>{const t=[];let n,r,s;for(r=0;r<e.length;++r)for(n=e[r],s=3;s>=0;--s)t.push(n>>8*s&255);return new Uint8Array(t)},ro={TEXT:0,IMAGE:805310464,GIF:805310475,FILE:805310490,AUDIO:805310481,VIDEO:805310470,RECALL:1610678302,STORED_RECALL:1610678301,LOCATION:805310469,CHAT_RECORD:805310489,CONTACT:268439554,GROUP_INVITATION:805310467,REDPACKET:268439616,TRANSFER:268439600,LINK:268439556},so=1610678290,oo=1610743841,io={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,MESSAGE_READ:1610678295,CHANGE_GROUP_TITLE:1610743809,CHANGE_GROUP_AVATAR:1610809394,PRIVATE_MESSAGE_PINNED:1610711169,GROUP_MESSAGE_PINNED:1610776706,CHAT_COMMENT:1610678301};function ao(e){return e===ro.RECALL||e===ro.STORED_RECALL}function co(e){return e===so||e===oo?ro.RECALL:e}function lo(e){if(!nt(e))return e;if(Array.isArray(e))return e.map(e=>lo(e));if(at(e)){const t={};return Object.keys(e).forEach(n=>{t[n]=lo(e[n])}),t}return e}const uo={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 go{localStore;constructor(e,t){const n=`con-${e}-${t}`;this.localStore=new It(n)}getStoreKey(e){return`${e.conversationType}_${e.targetId}\n }`}getConOptionByKey(e){const t=(e=e||"").split("_");if(t.length>=2){const e=t.shift(),n=t.shift();return{conversationType:Number(e),targetId:n}}return{conversationType:r.PRIVATE,targetId:"0"}}updateUnreadCount(e){const{conversationType:t,targetId:n,content:r,messageType:s,sentTime:o,isCounted:a,messageDirection:c}=e,l=c===i.SEND,u=ao(s),d=at(r),g={conversationType:t,targetId:n},p=this.get(g)||{},f=p.lastUnreadTime||Ln.ZERO,h=p.unreadMessageCount||0;if(!(o<=f)&&!l){if(a&&(p.unreadMessageCount=h+1,f||(p.lastUnreadTime=o)),u&&d){r.sentTime>=f&&h&&(p.unreadMessageCount=h-1)}this.set(g,p)}}updateMentionedData(e){const{conversationType:t,targetId:n,messageUId:s,messageType:o,isMentioned:a,messageDirection:c,content:l}=e;if(!s||c===i.SEND||!a&&!ao(o))return;const u=this.getStoreKey({conversationType:t,targetId:n}),d=this.localStore.get(u)||{},g=uo.mentionedUIds.keyName,p=d[g]||[];if(a&&t===r.GROUP&&(p.includes(s.toString())||p.push(s.toString())),ao(o)&&t===r.GROUP){const e=l,t=p.indexOf(e.messageUId?.toString()??"");t>=0&&p.splice(t,1)}p.length?d[g]=p:delete d[g],dt(d)?this.localStore.set(u,d):this.localStore.remove(u)}updateUpdateTime(e,t){const n=this.getStoreKey(e),r=this.localStore.get(n)||{},s=uo.updateTime.keyName,o=Number(r[s]||0);r[s]=Math.max(o,t),this.localStore.set(n,r)}set(e,t){const n=this.getStoreKey(e),r=this.localStore.get(n)||{};for(const e of pt(t)){const n=uo[e],s=t[e];if(ot(n?.keyName)||ot(s))continue;s===n.defaultVal?delete r[n.keyName]:r[n.keyName]=s,r[uo.unreadMessageCount.keyName]||(delete r[uo.lastUnreadTime.keyName],delete r[uo.mentionedUIds.keyName])}dt(r)?this.localStore.set(n,r):this.localStore.remove(n)}remove(e){const t=this.getStoreKey(e);this.localStore.remove(t)}get(e){const t=this.getStoreKey(e),n=this.localStore.get(t)||{},r={};for(const e of pt(uo)){const{keyName:t,defaultVal:s}=uo[e];"mentionedUIds"===e?(r.unreadMentionedCount=n[t]?.length??0,r.hasMentioned=!!r.unreadMentionedCount):r[e]=n[t]||lo(s)}return r}getAll(){const e=this.localStore.getCache()||{},t=[];for(const n in e){const r=this.getConOptionByKey(n),s=e[n];for(const e of pt(uo)){const{keyName:t,defaultVal:n}=uo[e];"mentionedUIds"!==e&&(r[e]=s[t]||lo(n))}t.push(r)}return t}}const po=e=>{const t=e.destId??"",n=ns(t);if(!n)return;e.dialogTitle,e.smallAvatarUrl;return{...n,unreadMessageCount:0,notificationStatus:e.muteFlag?o.OPEN:o.CLOSE,notificationLevel:e.muteFlag?l.NOT_MESSAGE_NOTIFICATION:l.ALL_MESSAGE,isTop:!!e.stickyFlag,dialogTitle:e.dialogTitle,smallAvatarUrl:e.smallAvatarUrl,lastUnreadTime:"0",burnAfterReadingFlag:!!e.burnAfterReadingFlag,burnAfterReadingTime:e.burnAfterReadingTime&&e.burnAfterReadingTime.toNumber()}};class fo{events={};on(e,t,n){const r=this.events[e]||(this.events[e]=[]);r.some(e=>e.listener===t&&e.target===n)||r.push({listener:t,target:n})}emit(e,...t){const n=this.events[e];n?.length&&n.map(e=>{const{target:n,listener:r}=e;try{r.call(n,...t)}catch(e){}})}off(e,t,n){let r=this.events[e];r?.length&&(r=r.filter(e=>e.listener!==t||e.target!==n),r.length?this.events[e]=r:delete this.events[e])}once(e,t,n){const r=(...s)=>{t.call(n,...s),this.off(e,r,n)};return this.on(e,r,n),this}}const ho="STATUS_CHANGED";class yo{storageKey;eventEmitter;isPulling=!1;constructor(e,t){this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new fo}async pull(){if(this.isPulling)return;let e;this.isPulling=!0;const n=Ct.get(this.storageKey);e=rt(n)&&n>0?n:qs()-1e4;let{code:r,data:s}=await Us(e);r===t.SUCCESS&&(Ln.isLong(s.setTime)&&s.setTime.toNumber()>0&&Ct.set(this.storageKey,s.setTime.toNumber()),s.briefDialog&&pt(s.briefDialog).forEach(e=>{const t=s.briefDialog[e],n=po(t);n&&this.eventEmitter.emit(ho,n)})),this.isPulling=!1}watch(e){this.eventEmitter.on(ho,t=>{e(t)})}}class mo{updatedConversationFunc;store;draftMap=new Map;localConversationSet=new Set;updatedConversations=[];notify;statusManager;constructor(e,t,n){this.updatedConversationFunc=n,this.store=new go(e,t),this.notify=ht(this.notifyConversationChanged.bind(this),0),this.statusManager=new yo(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),removed:e.removed||this.updatedConversations[t].removed},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){const e=this.updatedConversations.map(e=>e.removed?{conversation:e.conversation,updatedItems:e.updatedItems,removed:!0}:{conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems});this.updatedConversations=[],this.updatedConversationFunc?.(e)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(e){if(!e?.length)return;const n=e.filter(e=>!this.localConversationSet.has(this.getConversationKey(e)));if(!n.length)return;const r=n.map(ts);if(!r.length)return;const{code:s,data:o}=await Ms(r);s===t.SUCCESS&&pt(o.briefDialog).forEach(e=>{const t=o.briefDialog[e],n=po(t);n&&(this.localConversationSet.add(this.getConversationKey(n)),this.addStatus(n,!0))})}addLocalConversation(e){const{conversationType:t,targetId:n,isTop:r,notificationStatus:s,notificationLevel:o,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:n,isTop:r,notificationStatus:s,notificationLevel:o,dialogTitle:i,smallAvatarUrl:a,burnAfterReadingFlag:c,burnAfterReadingTime:l,updateTime:u},!1)}addStatus(e,t=!1){const{conversationType:n,targetId:r,notificationStatus:s,notificationLevel:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u,updateTime:d}=e,g={conversationType:n,targetId:r},p=qs(),f=this.store.get(g),h={};nt(o)&&f.notificationLevel!==o&&(h.notificationLevel={time:p,val:o}),nt(s)&&f.notificationStatus!==s&&(h.notificationStatus={time:p,val:s}),nt(i)&&f.isTop!==i&&(h.isTop={time:p,val:i}),nt(a)&&f.dialogTitle!==a&&(h.dialogTitle={time:p,val:a}),nt(c)&&f.smallAvatarUrl!==c&&(h.smallAvatarUrl={time:p,val:c}),nt(l)&&f.burnAfterReadingFlag!==l&&(h.burnAfterReadingFlag={time:p,val:l}),nt(u)&&f.burnAfterReadingTime!==u&&(h.burnAfterReadingTime={time:p,val:u}),this.store.set(g,{notificationStatus:s,isTop:i,notificationLevel:o,dialogTitle:a,smallAvatarUrl:c,burnAfterReadingFlag:l,burnAfterReadingTime:u}),nt(d)&&this.store.updateUpdateTime(g,d),Object.keys(h).length&&t&&this.setUpdatedConversation({conversation:g,updatedItems:h})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:n,targetId:r}=e;if(!n)return;const s={conversationType:t,targetId:r},o={conversation:s,updatedItems:{}},i=lo(this.get(s));this.store.updateUnreadCount(e),this.store.updateMentionedData(e),this.store.updateUpdateTime(s,parseInt(e.sentTime));const a=this.get(s);i.unreadMessageCount!==a.unreadMessageCount&&(o.updatedItems.unreadMessageCount={time:parseInt(e.sentTime),val:a.unreadMessageCount}),i.hasMentioned!==a.hasMentioned&&(o.updatedItems.hasMentioned={time:parseInt(e.sentTime),val:a.hasMentioned}),i.unreadMentionedCount!==a.unreadMentionedCount&&(o.updatedItems.unreadMentionedCount={time:parseInt(e.sentTime),val:a.unreadMentionedCount}),Object.keys(o.updatedItems).length&&this.setUpdatedConversation(o)}get(e){return this.store.get(e)}getAllUnreadCount(e,t){const n=this.store.getAll();let r=0;return n.forEach(({unreadMessageCount:n,notificationStatus:s,notificationLevel:i,conversationType:a})=>{n=n||0;const c=s===o.OPEN||i>0;!t&&c||(e.length>0?e.includes(+a)&&(r+=+n):r+=+n)}),r}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:n,unreadMentionedCount:r}=t;(n||r)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const s={};n&&(s.unreadMessageCount={val:0,time:qs()}),r&&(s.hasMentioned={val:!1,time:qs()},s.unreadMentionedCount={val:0,time:qs()}),Object.keys(s).length&&this.setUpdatedConversation({conversation:e,updatedItems:s})}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(e=>e.notificationStatus===o.OPEN||e.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:n,unreadMentionedCount:r,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}=t;return{...e,unreadCount:n,unreadMentionedCount:r??0,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}}return null}getAllConversationState(){return this.store.getAll().map(({conversationType:e,targetId:t,unreadMessageCount:n,unreadMentionedCount:r,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l})=>({conversationType:e,targetId:t,unreadCount:n,unreadMentionedCount:r??0,notificationLevel:s,notificationStatus:o,isTop:i,dialogTitle:a,smallAvatarUrl:c,updateTime:l}))}remove(e){this.store.remove(e),this.localConversationSet.delete(this.getConversationKey(e)),this.setUpdatedConversation({conversation:e,updatedItems:{},removed:!0})}clearHistoryMessages(e){this.clearUnreadCount(e);const t={conversation:e,updatedItems:{}};t.conversation.latestMessage=void 0,t.updatedItems.latestMessage={val:null,time:qs()},this.setUpdatedConversation(t)}updateLatestMessage(e,t){nt(t)&&this.store.updateUpdateTime(e,parseInt(t.sentTime));const n={conversation:e,updatedItems:{}};nt(t)&&(n.conversation.updateTime=parseInt(t.sentTime)),n.conversation.latestMessage=t,n.updatedItems.latestMessage={val:t,time:qs()},this.setUpdatedConversation(n)}destroyed(){this.updatedConversationFunc=void 0}}const vo={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(e){return l.NOT_SET},getNotificationStatus:function(e){return o.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 bo;var Co={create(e,t,n){bo=new mo(e,t,n)},get:()=>bo??vo};const wo=(e,t,n=a.SENDING)=>{const r=Co.get().get(t.conversation);return{conversationType:t.conversation.conversationType,targetId:t.conversation.targetId,senderUserId:t.senderUserId,messageDirection:i.SEND,isCounted:e.isCounted,isMentioned:!1,content:lo(e.content),messageType:e.messageType,isOffLineMessage:!1,isPersited:e.isPersited,messageId:t.messageId,messageUId:"local"+t.sentTime,sentTime:t.sentTime,sentStatus:n,receivedTime:t.sentTime,isStatusMessage:e.isStatusMessage,receivedStatus:c.IDLE,disableNotification:!0,burnAfterReadingFlag:r?.burnAfterReadingFlag??!1,burnAfterReadingTime:r?.burnAfterReadingTime??0,pinned:!1}};function Io(e){if(e instanceof Error){const t=e.cause;return{type:e.constructor?.name??"Error",name:e.name,message:e.message,stack:e.stack,...void 0===t?{}:{cause:Io(t)}}}let t;try{t="string"==typeof e?e:JSON.stringify(e)??String(e)}catch{t=String(e)}return{type:null===e?"null":typeof e,value:t}}function Oo(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 So=(e,t,n,r)=>{const s=new Map;return e.forEach(e=>{const o=Ro(e,t.get(e),n.get(e),r);o.length&&s.set(e,o)}),s},Ro=(e,t,n,r)=>{const s=ns(e);if(!s)return[];const l=Co.get().get(s);let u=[];return t.forEach(e=>{const t=e;let d=t.mediaConstructor,g=Eo(t,n);if(!g)return;if(d===so||d===oo){const{msgId:e}=g,t={messageUId:e};d=co(d),g=t}const p=Js(d,g);if(nt(p)){const d={...s,senderUserId:t.srcId.toString(),messageDirection:t.isOut?i.SEND:i.RECEIVE,isCounted:p.isCounted,isMentioned:t.atFlag,content:p.content,messageType:p.messageType,isOffLineMessage:!1,isPersited:p.isPersited,messageId:Ln.isLong(t.localId)?t.localId.toNumber():0,messageUId:t.msgId.toString(),sentTime:t.seqno.toString(),sentStatus:a.SENT,receivedTime:qs().toString(),isStatusMessage:p.isStatusMessage,receivedStatus:t.msgRead?c.READ:t.msgArrival?c.RECEIVED:c.IDLE,disableNotification:l?.notificationStatus===o.OPEN||t.srcId.toString()==sr.uid,burnAfterReadingFlag:t.burnAfterReadingFlag,burnAfterReadingTime:t.burnAfterReadingTime&&t.burnAfterReadingTime.toNumber(),pinned:!1};if(d.isStatusMessage&&Ln.fromNumber(qs()).subtract(d.sentTime).greaterThan(6e3))return;if(t.msgIdReferenced&&Ln.isLong(t.msgIdReferenced)){const e=r[t.msgIdReferenced.toString()];if(e){let t=Eo({mediaAttribute:e.mediaAttribute,msgPreContent:e.msgPreContent,msgPostContent:e.msgPostContent,mediaConstructor:e.mediaConstructor??0,msgId:e.msgId??Ln.fromNumber(0)},n);if(t){const n=Js(e.mediaConstructor??0,t);nt(n)&&(d.quotedReply=((e,t,n)=>({conversationType:n.conversationType,targetId:e.destId.toString(),senderUserId:e.srcId.toString(),messageDirection:e.srcId.toString()===sr.uid?i.SEND:i.RECEIVE,isCounted:t.isCounted,isMentioned:!1,content:lo(t.content),messageType:t.messageType,isOffLineMessage:!1,isPersited:t.isPersited,messageId:1,messageUId:e.msgId.toString(),sentTime:e.msgSendTime.toString(),sentStatus:a.SENT,receivedTime:e.msgSendTime.toString(),isStatusMessage:t.isStatusMessage,receivedStatus:c.RECEIVED,disableNotification:!0,burnAfterReadingFlag:!1,burnAfterReadingTime:0,pinned:!1,senderUserName:e.srcName}))(e,n,s))}}}ut(d.messageUId)?u.push(d):Xi.error("message is invalid",Oo(e))}}),u},Eo=(e,t)=>{try{let n,r;return n=e.mediaAttribute?.length?to(e.mediaAttribute,t):e.msgPreContent??"",e.msgPostContent?.length&&(r=to(e.msgPostContent,t)),To(e.mediaConstructor,n,r)}catch(t){return Xi.error("decode message content fail",e,t),null}},To=(e,t,n)=>{let r={};if(t?.length){const e=_o(t);r=JSON.parse(e,Po)}return e===ro.TEXT&&void 0!==n&&(r.content=n),r},_o=e=>{let t=e.replace(/("[\w\d_]+"\s*:\s*)(?<!\d\.)(\d{15,})(?!\.\d*)(?=[\s,}\]])/g,'$1"$2"');return t=t.replace(/(\[\s*|,\s*)(?<!\d\.)(\d{15,})(?!\.\d*)(?=[\s,\]])/g,'$1"$2"'),t},Ao=new Set(["destId","groupId","groupUin","msgId"]),ko=new Set(["msgIdList"]),Mo=(e,t)=>{if("string"==typeof t)return t;if("number"==typeof t&&Number.isSafeInteger(t))return t.toString();throw new TypeError(`${e} must be an Int64 string or a safe integer, received ${typeof t}`)},Po=(e,t)=>null==t?t:Ao.has(e)?Mo(e,t):ko.has(e)?Array.isArray(t)?t.map(t=>Mo(e,t)):Mo(e,t):t;var No={parse:function(e,t,n){const r=new Map;if(Object.keys(e).forEach(t=>{const n=e[t].dialogMessage?.filter(e=>!e.sharingGroupFlag);n?.length&&r.set(t,n)}),!r.size)return void n(!0,new Map);const s=new Set([...r.keys()]);Zs.getDialogAesKeyListInBatches([...r.keys()],(e,o)=>{try{if(o.size){const e=[...o.keys()];for(const t of e)s.delete(t);n(!s.size,So(e,r,o,t))}s.size&&e&&n(!0,new Map)}catch(t){Xi.error("parseDialogsMessages error",t),s.size&&e&&n(!0,new Map)}})},parseSingleDialogMessages:Ro,decodeChatRecordMsgDetails2ReceivedMessages:(e,t)=>{let n=[];return t.forEach(t=>{const r=To(t.mediaConstructor,t.mediaAttribute,t.msgPostContent);if(!r)return;const s=Js(t.mediaConstructor,r);if(nt(s)){const r={...e,senderUserId:t.srcId.toString(),messageDirection:t.srcId==sr.uid?i.SEND:i.RECEIVE,isCounted:s.isCounted,isMentioned:!1,content:s.content,messageType:s.messageType,isOffLineMessage:!1,isPersited:s.isPersited,messageId:0,messageUId:t.msgId+"",sentTime:t.msgSendTime+"",sentStatus:a.SENT,receivedTime:t.msgSendTime+"",isStatusMessage:s.isStatusMessage,receivedStatus:c.READ,disableNotification:!1};n.push(r)}}),n},encodeReceivedMessage2ChatRecordMsgDetail:e=>{const t=Js(e.messageType,e.content);if(!t)return null;const n=JSON.stringify(t.content),r=e.messageType===ro.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:n,msgPostContent:r,msgSendTime:e.sentTime}}};const Lo="unreadMessageUids";class Do{api;localStore;constructor(e,t,n=xs){this.api=n;const r=`receipt-v2-${e}-${t}`;this.localStore=new It(r)}storeUnreadMessageUids(e){const t=e.filter(e=>e.isCounted&&e.messageDirection!==i.SEND).map(e=>({uid:e.messageUId,timestamp:Date.now()})),n=[...this.localStore.get(Lo)||[],...t];this.localStore.set(Lo,n)}cleanExpiredMessages(){const e=this.localStore.get(Lo)||[],t=Date.now(),n=e.filter(e=>t-e.timestamp<=1728e5);this.localStore.set(Lo,n)}formatReceiptMessages(e){const t=[],n=[];e.forEach(e=>{e.conversationType===r.PRIVATE?t.push(e):n.push(e)});return{privateReceiptMessages:Object.entries(t.reduce((e,t)=>(e[t.targetId]||(e[t.targetId]=[]),e[t.targetId].push(t.messageUId),e),{})).map(([e,t])=>({destId:Ln.fromString(e),msgId:t.map(e=>Ln.fromString(e))})),groupReceiptMessages:n.reduce((e,t)=>{const n=e.find(e=>e.groupId.equals(Ln.fromString(t.targetId))&&e.userId.equals(Ln.fromString(t.senderUserId)));return n?n.msgId.push(Ln.fromString(t.messageUId)):e.push({groupId:Ln.fromString(t.targetId),userId:Ln.fromString(t.senderUserId),msgId:[Ln.fromString(t.messageUId)]}),e},[])}}filterValidMessages(e){return e.filter(e=>e.isCounted&&e.messageDirection!==i.SEND)}async sendArrivalReceipts(e){this.storeUnreadMessageUids(e);const t=this.filterValidMessages(e),{privateReceiptMessages:n,groupReceiptMessages:r}=this.formatReceiptMessages(t);n.length&&await this.api.sendPrivateChatArrivalAck({chatMessage:n}),r.length&&await this.api.sendGroupChatArrivalAck({groupChatMessage:r})}async sendReadReceipts(e){const t=this.localStore.get(Lo)||[],n=this.filterValidMessages(e).filter(e=>t.some(t=>t.uid===e.messageUId));try{const{privateReceiptMessages:e,groupReceiptMessages:t}=this.formatReceiptMessages(n);e.length&&await this.api.sendPrivateChatReadAck({chatMessage:e}),t.length&&await this.api.sendGroupChatReadAck({groupChatMessage:t});const r=this.localStore.get(Lo)||[],s=n.map(e=>e.messageUId),o=r.filter(e=>!s.includes(e.uid));this.localStore.set(Lo,o)}catch(e){throw console.error("发送已读回执失败:",e),e}}}let Uo;var jo={create(e,t){Uo=new Do(e,t),Uo.cleanExpiredMessages()},get:()=>Uo};let Bo=0,Fo=0;function xo(e,t){Bo=e+100,Fo=t+100}function Go(){return Fo++,Fo}function qo(){return Bo--,Bo}function Vo(){return Fo}async function Ko(e,t){const n=await e.request(t);if(n.ok)return n.value;const r=new Error(n.error.message);throw r.name=n.error.name,r.stack=n.error.stack,r}function Ho(e,t,n){if(!e)return null;if(!/^[0-9a-f]+$/i.test(e)||e.length%2!=0)return e;const r=n.lib.CipherParams.create({ciphertext:n.enc.Hex.parse(e)}),s=n.AES.decrypt(r,n.enc.Utf8.parse(t.key),{iv:n.enc.Utf8.parse(t.iv)}).toString(n.enc.Utf8);if(!s)throw new Error("Unable to decrypt a legacy message");return JSON.parse(s)}function zo(e,t,n=et){const r={...e};return"string"==typeof r.content&&(r.content=Ho(r.content,t,n)),r.quotedReply&&"string"==typeof r.quotedReply.content&&(r.quotedReply={...r.quotedReply,content:Ho(r.quotedReply.content,t,n)}),r}function $o(e,t){return new Promise((n,r)=>{const s=e.open(t);s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error??new Error("Unable to open legacy database"))})}function Wo(e,t,n,r,s){return new Promise((o,i)=>{const a=e.transaction(t,"readonly"),c=a.objectStore(t),l=void 0===n?void 0:s.lowerBound(n,!0),u=c.openCursor(l),d=[];let g;u.onsuccess=()=>{const e=u.result;!e||d.length>=r?o({values:d,lastKey:g}):(d.push(e.value),g=e.primaryKey,d.length>=r?o({values:d,lastKey:g}):e.continue())},u.onerror=()=>i(u.error??new Error(`Unable to read ${t}`)),a.onabort=()=>i(a.error??new Error(`Unable to read ${t}`))})}async function Jo(e,t){if("function"!=typeof e.databases)throw new Error("IndexedDB.databases() is required for safe legacy migration");return(await e.databases()).some(e=>e.name===t)}function Zo(e,t){return new Promise((n,r)=>{const s=e.transaction(t,"readonly"),o=s.objectStore(t).count();o.onsuccess=()=>n(o.result),o.onerror=()=>r(o.error??new Error(`Unable to count ${t}`)),s.onabort=()=>r(s.error??new Error(`Unable to count ${t}`))})}async function Xo({appKey:e,userId:t,bridge:n,indexedDBFactory:r=indexedDB,keyRange:s=IDBKeyRange,batchSize:o=200,onProgress:i}){if("complete"===await Ko(n,{type:"read",method:"getLegacyMigrationState",args:[]}))return{migrated:!1,messages:0,dialogStates:0};const a=`im_message_cache_1_${e}_${t}`;if(!await Jo(r,a))return{migrated:!1,messages:0,dialogStates:0};const c=await $o(r,a),l=function(e,t){const n="im_message_cache_salt_prefix",r=et.SHA256(`${n}${e}_${t}im_message_cache_salt_suffix`).toString(),s=r.substring(0,16),o=r.substring(16,48),i=et.SHA256(`${s}:${n}:${t}:${e}`).toString().substring(0,8);return{key:et.PBKDF2(o,i,{keySize:8,iterations:1e3,hasher:et.algo.SHA256}).toString().substring(0,32),iv:s}}(e,t);let u=0,d=0;try{if(c.objectStoreNames.contains("messages_new")){let e;for(;;){const t=await Wo(c,"messages_new",e,o,s);if(0===t.values.length)break;const r=t.values.map(e=>zo(e,l));if(await Ko(n,{type:"write",method:"importLegacyBatch",args:[{messages:r,dialogStates:[]}]}),u+=r.length,i?.({processedMessages:u,processedDialogStates:d}),e=t.lastKey,t.values.length<o)break}}if(c.objectStoreNames.contains("dialogStates_new")){let e;for(;;){const t=await Wo(c,"dialogStates_new",e,o,s);if(0===t.values.length)break;if(await Ko(n,{type:"write",method:"importLegacyBatch",args:[{messages:[],dialogStates:t.values}]}),d+=t.values.length,i?.({processedMessages:u,processedDialogStates:d}),e=t.lastKey,t.values.length<o)break}}return await Ko(n,{type:"write",method:"completeLegacyMigration",args:[]}),{migrated:!0,messages:u,dialogStates:d}}finally{c.close()}}class Yo{appKey;userId;bridge;options;initialization=null;constructor(e,t,n=function(){const e=globalThis;if(!e.acimDatabase)throw new Error("ACIM database preload bridge is unavailable; install the Electron preload entry first");return e.acimDatabase}(),r={}){this.appKey=e,this.userId=t,this.bridge=n,this.options=r}initDB(){return this.initialization||(this.initialization=Ko(this.bridge,{type:"open",options:{appKey:this.appKey,userId:this.userId}}).then(async()=>{const e=this.options.indexedDBFactory??("undefined"==typeof indexedDB?void 0:indexedDB),t=this.options.keyRange??("undefined"==typeof IDBKeyRange?void 0:IDBKeyRange);"manual"!==this.options.legacyMigrationMode&&e&&t&&await Xo(this.migrationOptions({indexedDBFactory:e,keyRange:t}))})),this.initialization}async migrateLegacyDatabase(e){return await this.initDB(),Xo(this.migrationOptions({onProgress:e}))}async getLegacyMigrationInfo(){return await this.initDB(),async function({appKey:e,userId:t,bridge:n,indexedDBFactory:r=indexedDB}){const s=await Ko(n,{type:"read",method:"getLegacyMigrationState",args:[]}),o=`im_message_cache_1_${e}_${t}`;if(!await Jo(r,o))return{state:s,exists:!1,totalMessages:0,totalDialogStates:0};const i=await $o(r,o);try{return{state:s,exists:!0,totalMessages:i.objectStoreNames.contains("messages_new")?await Zo(i,"messages_new"):0,totalDialogStates:i.objectStoreNames.contains("dialogStates_new")?await Zo(i,"dialogStates_new"):0}}finally{i.close()}}(this.migrationOptions())}async getLegacyMediaReferences(e=0,t=500){return this.read("getLegacyMediaReferences",[e,t])}async deleteLegacyDatabase(){await this.initDB(),await async function({appKey:e,userId:t,indexedDBFactory:n=indexedDB}){const r=`im_message_cache_1_${e}_${t}`;await Jo(n,r)&&await new Promise((e,t)=>{const s=n.deleteDatabase(r);s.onsuccess=()=>e(),s.onerror=()=>t(s.error??new Error("Unable to delete legacy database")),s.onblocked=()=>t(new Error("Legacy database deletion was blocked"))})}({appKey:this.appKey,userId:this.userId,indexedDBFactory:this.options.indexedDBFactory})}async close(){this.initialization&&(await this.initialization,await Ko(this.bridge,{type:"close"}),this.initialization=null)}async deleteDatabase(){await this.close(),await Ko(this.bridge,{type:"delete",options:{appKey:this.appKey,userId:this.userId}})}async addMessages(e,t,n){const r=e.filter(e=>e.isPersited);await this.write("addMessages",[r,ts(t),n])}async getMessages(e,t="0",n=20,r=!0){return this.read("getMessages",[ts(e),t,n,r])}getPreviousMessages(e,t="0",n=20){return this.getMessages(e,t,n,!0)}getMessagesByType(e,t,n="0",r=50,s=!0){return this.read("getMessagesByType",[ts(e),t,n,r,s])}getLatestMessage(e){return this.read("getLatestMessage",[ts(e)])}async getLatestMessages(e){const t=e.map(ts);return this.read("getLatestMessages",[t])}getMessageById(e){return this.read("getMessageById",[e])}getMessageByUId(e){return this.read("getMessageByUId",[e])}getPinnedMessages(e,t=50){return this.read("getPinnedMessages",[ts(e),t])}getMessageIdRange(){return this.read("getMessageIdRange",[])}getDialogLoadedState(e){return this.read("getDialogLoadedState",[e])}async clearConversationCache(e){await this.write("clearConversationCache",[ts(e)])}async clearAllCache(){await this.write("clearAllCache",[])}async removeMessagesByUId(e){await this.write("removeMessagesByUId",[e])}async updateMessageReceiptStatus(e,t){const n=0===t?c.RECEIVED:c.READ;await this.write("updateMessageReceiptStatus",[e.messageUIdList,n])}async markMessagesRead(e,t){await this.write("updateMessageReceiptStatus",[e,c.READ,t])}async setMessagePinned(e,t,n){await this.write("setMessagePinned",[ts(e),t,n])}async setMessageReactions(e,t,n){return this.write("setMessageReactions",[ts(e),t,n])}async unpinAllMessages(e){await this.write("unpinAllMessages",[ts(e)])}clearBurnAfterReadingExpiredMessages(e){return this.write("clearBurnAfterReadingExpiredMessages",[ts(e)])}async upsertMessage(e){await this.write("upsertMessage",[e,ts(e)])}async convertToRecallMessages(e){await this.write("convertToRecallMessages",[e,ro.RECALL])}searchTextMessages(e,t){return this.read("searchTextMessages",[ts(e),t])}searchMessages(e,t=500){return this.read("searchMessages",[e,void 0,t])}migrationOptions(e={}){return{appKey:this.appKey,userId:this.userId,bridge:this.bridge,indexedDBFactory:this.options.indexedDBFactory,keyRange:this.options.keyRange,...e}}async read(e,t){return await this.initDB(),Ko(this.bridge,{type:"read",method:e,args:t})}async write(e,t){return await this.initDB(),Ko(this.bridge,{type:"write",method:e,args:t})}}let Qo=null;var ei={create:(e,t,n={})=>(Qo=new Yo(e,t,void 0,n),Qo),get:()=>Qo};function ti(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e&&Number.isFinite(e))return String(e);if("object"==typeof e&&"function"==typeof e.toString){const t=e.toString;if(t!==Object.prototype.toString){const n=t.call(e);if("string"==typeof n)return n}}return""}function ni(e,t){const n=ti(t.uid),r=(e??[]).filter(e=>ti(e.uid)!==n);return t.content.trim()?[{...t,uid:n},...r]:r}class ri{handlers=new Map;register(e,t){this.handlers.set(e,t)}contains(e){return this.handlers.has(e)}async process(e,t){const n=this.handlers.get(e.messageType);return!!n&&(await n.process(e,t),n.shouldConsume?.(e)??n.consumed)}}class si{consumed;callback;constructor(e,t){this.consumed=e,this.callback=t}async process(e,t){await this.callback(e,t)}}class oi{receivedStatus;receiptType;publish;consumed=!0;constructor(e,t,n){this.receivedStatus=e,this.receiptType=t,this.publish=n}async process(e,t){const n=e.content,r=n.msgIdList;if(null==r)return;const s=(Array.isArray(r)?r:[r]).map(e=>e.toString()),o=new Set(s);for(const e of t)e.messageDirection===i.SEND&&o.has(e.messageUId)&&e.receivedStatus<this.receivedStatus&&(e.receivedStatus=this.receivedStatus);await this.publish({conversation:{conversationType:e.conversationType,targetId:n.groupId??n.destId??e.targetId},messageUIdList:s},this.receiptType)}}class ii{setMessagePinned;unpinAllMessages;publish;consumed=!1;constructor(e,t,n){this.setMessagePinned=e,this.unpinAllMessages=t,this.publish=n}shouldConsume(e){return e.content.pinned!==g.PIN}async process(e,t){const n=e.content.pinned;if(n!==g.PIN&&n!==g.UNPIN&&n!==g.UNPIN_ALL)return;const r={conversationType:e.conversationType,targetId:e.targetId},s=String(e.content.msgId??"");if(n===g.UNPIN_ALL)t.forEach(e=>{e.pinned=!1}),await this.unpinAllMessages(r);else{const e=n===g.PIN;t.forEach(t=>{t.messageUId===s&&(t.pinned=e)}),await this.setMessagePinned(r,s,e)}await this.publish({conversation:r,messageUId:n===g.UNPIN_ALL?void 0:s,operation:n})}}function ai(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e&&Number.isFinite(e))return String(e);if("object"==typeof e&&"function"==typeof e.toString){const t=e.toString;if(t!==Object.prototype.toString){const n=t.call(e);if("string"==typeof n&&"[object Object]"!==n)return n}}return""}class ci{getMessageByUId;setMessageReactions;publish;consumed=!0;constructor(e,t,n){this.getMessageByUId=e,this.setMessageReactions=t,this.publish=n}async process(e,t){const n=e.content,r=ai(n.uid);if(!r||"0"===r)return;const s=ai(n.msgId);if(!s||"0"===s)return;const o={conversationType:e.conversationType,targetId:e.targetId},i=t.find(t=>t!==e&&ai(t.messageUId)===s),a=await this.getMessageByUId(s),c=i??a;if(!c)return void Xi.warn("chat comment notification: target message not found",s);const l=c.reactions??(c===a?void 0:a?.reactions),u={uid:r,msgId:s,content:n.content??"",nickname:n.nickName??n.nickname??"",time:Number(n.time)||0},d=ni(l,u);c.reactions=d;(await this.setMessageReactions(o,s,d)||i)&&await this.publish({conversation:o,messageUId:s,reactions:d,change:u})}}class li{watcher;pullingMsg=!1;letterbox;serverMsgSeqno=Ln.ZERO;pullOfflineFinished=!1;intervalTimer;retryTimer;latestSyncTimestamp=0;started=!1;notificationProcessor=new ri;constructor(e,t){this.watcher=e,this.letterbox=new Qs(t.appkey,sr.uid.toString()),this.registerNotificationHandlers()}registerNotificationHandlers(){this.notificationProcessor.register(io.MESSAGE_READ,new si(!0,e=>{const{toPc:t,destId:n}=e.content;t&&Co.get().clearUnreadCount({conversationType:es(Ln.fromString(n)),targetId:n})})),this.notificationProcessor.register(io.CHANGE_GROUP_TITLE,new si(!1,e=>{this.handleGroupTitleChangeMessage(e)})),this.notificationProcessor.register(io.CHANGE_GROUP_AVATAR,new si(!1,e=>{this.handleGroupAvatarChangeMessage(e)}));const e=new si(!1,e=>{this.handleBurnAfterReadingMessage(e)});[io.PRIVATE_OPEN_BURNAFTERREADING,io.GROUP_OPEN_BURNAFTERREADING,io.PRIVATE_CLOSE_BURNAFTERREADING,io.GROUP_CLOSE_BURNAFTERREADING].forEach(t=>{this.notificationProcessor.register(t,e)});const t=(e,t)=>this.watcher.onReceiptReceived?.(e,t);this.notificationProcessor.register(io.GROUP_ARRIVAL_RECEIPT,new oi(c.RECEIVED,0,t)),this.notificationProcessor.register(io.PRIVATE_ARRIVAL_RECEIPT,new oi(c.RECEIVED,0,t)),this.notificationProcessor.register(io.GROUP_READ_RECEIPT,new oi(c.READ,1,t)),this.notificationProcessor.register(io.PRIVATE_READ_RECEIPT,new oi(c.READ,1,t));const n=new ii(async(e,t,n)=>{await(ei.get()?.setMessagePinned(e,t,n))},async e=>{await(ei.get()?.unpinAllMessages(e))},e=>this.watcher.onMessagePinnedChanged?.(e));this.notificationProcessor.register(io.PRIVATE_MESSAGE_PINNED,n),this.notificationProcessor.register(io.GROUP_MESSAGE_PINNED,n),this.notificationProcessor.register(io.CHAT_COMMENT,new ci(async e=>ei.get()?.getMessageByUId(e),async(e,t,n)=>await(ei.get()?.setMessageReactions(e,t,n))??!1,e=>this.watcher.onMessageReactionsChanged?.(e)))}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 n=this.letterbox.getInboxOffset();Xi.info(`pullMsg -> time: ${n}`),this.latestSyncTimestamp=Date.now();const{code:r,data:s}=await Os(n,60);if(r!==t.SUCCESS)return Xi.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void(Ki.loader?.getConnectionStatus()==e.CONNECTED&&this.try2RePullMsg());const{offset:o,seqno:i,msg:a,reference:c}=s,l=Object.keys(a).map(e=>({conversationType:es(Ln.fromString(e)),targetId:e}));await Co.get().loadConvsationsIfNotExist(l),No.parse(a,c,async(e,t)=>{let r,s=[];try{for(const[e,n]of t.entries()){if(r=e,s=n,0===n.length)return;await this.processMessages(n,!this.pullOfflineFinished)}}catch(e){Xi.error("processMessages error ->",Io(e),"context ->",{inboxTime:n,offset:o?.toString(),seqno:i?.toString(),dialogId:r,isOfflineMessage:!this.pullOfflineFinished,messageCount:s.length,messages:(a=s,a.map(Oo))})}var a;if(e)try{let e;i&&(Ln.isLong(i)?e=i:"string"==typeof i?e=Ln.fromString(i):"number"==typeof i&&(e=Ln.fromNumber(i))),e&&Ln.isLong(e)&&e.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=e);const t=this.serverMsgSeqno.lessThanOrEqual(o);Xi.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){Xi.error("setPullMsgDone error",e),this.pullingMsg=!1}})}async processMessages(e,t){const n={conversationType:e[0].conversationType,targetId:e[0].targetId};let r=[];const s=[];let o=[];for(const n of e)this.notificationProcessor.contains(n.messageType)&&await this.notificationProcessor.process(n,e)||(ao(n.messageType)&&zs.has(n.content.messageUId)?n.content.messageUId?(zs.remove(n.content.messageUId),o.push(n.content.messageUId)):Xi.error("recallMessage's messageUId is undefined",Oo(n)):n.messageUId?(n.isOffLineMessage=t,(!n.messageId||n.messageId>Vo())&&(n.messageId=Go()),Co.get().setConversationCacheByMessage(n),r.push(n),ao(n.messageType)&&s.push(r.length-1)):Xi.error("message's messageUId is undefined",Oo(n)));let i=[];for(let e=s.length-1;e>=0;e--){const t=s[e],n=r[t],a=n.content,c=r.findIndex(e=>e.messageUId===a.messageUId);if(-1!==c){const e=r[c];n.messageId=e.messageId,n.sentTime=e.sentTime,r[c]=n,r[t]=e,i.push(t)}else o.push(a.messageUId),i.push(t)}if(i.length){let e=[];r.forEach((t,n)=>{i.includes(n)||e.push(t)}),r=e}const a=r;if(a.length&&(await(ei.get()?.addMessages(a,{conversationType:a[0].conversationType,targetId:a[0].targetId})),this.handleBatchMessages(a),jo.get()?.sendArrivalReceipts(a)),o.length){await(ei.get()?.convertToRecallMessages(o)),this.watcher.onRecall?.(o);const e=await(ei.get()?.getLatestMessage(n));Co.get().updateLatestMessage(n,e)}if(r.some(e=>e.isPersited)){const e=await(ei.get()?.getLatestMessage(n));Co.get().updateLatestMessage(n,e)}}handleBurnAfterReadingMessage(e){const t=e.content,n=e.conversationType,r=e.targetId,{templateId:s,burnAfterReadingTime:o}=t,i=60010010===s||60010011===s;Co.get().addStatus({conversationType:n,targetId:r,burnAfterReadingFlag:i,burnAfterReadingTime:i?o:null},!0)}handleGroupTitleChangeMessage(e){const t=e.content,n=t.groupUin??e.targetId;Co.get().addStatus({conversationType:e.conversationType,targetId:n,dialogTitle:t.newTitle},!0)}handleGroupAvatarChangeMessage(e){const t=e.content,n=t.groupId??e.targetId;Co.get().addStatus({conversationType:e.conversationType,targetId:n,smallAvatarUrl:t.smallAvatarUrl},!0)}async handleBatchMessages(e){const t=e.filter(e=>e.messageDirection!==i.SEND||!e.messageId||!Ks.has(e.messageId)||(Ks.remove(e.messageId),!1));t.length&&this.watcher.batchMessage?.(t)}}const ui={filters:[],displayTags:!1};let di=ui,gi=0;async function pi(){const e=++gi;return(async()=>{try{const r=await Bs();return e!==gi?di:r.code!==t.SUCCESS?(Xi.warn("getDialogFilterConfig failed",r.code,r.msg),di=ui,di):(n=r.data?.config,di=n?{filters:(n.filters??[]).filter(e=>{const t=e.title?.trim(),n=e.id?.trim();if(!t||!n||"0"===n)return!1;const r=e.colorId??-1;return!(r<-1||r>7)}),displayTags:Boolean(n.displayTags)}:ui,di)}catch(t){return e!==gi||(Xi.warn("getDialogFilterConfig threw",t),di=ui),di}var n})()}class fi{messageType;content;isPersited;isCounted;isStatusMessage;constructor(e,t,n=!0,r=!0,s=!1){this.messageType=e,this.content=t,s?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=n,this.isCounted=r),this.isStatusMessage=s}}const hi=(e,t,n,r)=>function(s){return new fi(e,s,t,n,r)},yi=hi(ro.TEXT,!0,!0,!1),mi=hi(ro.IMAGE,!0,!0,!1),vi=hi(ro.GIF,!0,!0,!1),bi=hi(ro.AUDIO,!0,!0,!1),Ci=hi(ro.FILE,!0,!0,!1),wi=hi(ro.VIDEO,!0,!0,!1);let Ii=hi(ro.LOCATION,!0,!0,!1),Oi=hi(ro.CHAT_RECORD,!0,!0,!1),Si=hi(ro.CONTACT,!0,!0,!1),Ri=hi(ro.GROUP_INVITATION,!0,!0,!1),Ei=hi(ro.REDPACKET,!0,!0,!1),Ti=hi(ro.TRANSFER,!0,!0,!1),_i=hi(ro.LINK,!0,!0,!1);const Ai=hi(io.GROUP_ARRIVAL_RECEIPT,!1,!1,!1),ki=hi(io.GROUP_READ_RECEIPT,!1,!1,!1),Mi=hi(io.PRIVATE_ARRIVAL_RECEIPT,!1,!1,!1),Pi=hi(io.PRIVATE_READ_RECEIPT,!1,!1,!1),Ni=hi(io.PRIVATE_OPEN_BURNAFTERREADING,!1,!1,!1),Li=hi(io.PRIVATE_CLOSE_BURNAFTERREADING,!1,!1,!1),Di=hi(io.GROUP_OPEN_BURNAFTERREADING,!1,!1,!1),Ui=hi(io.GROUP_CLOSE_BURNAFTERREADING,!1,!1,!1),ji=hi(io.MESSAGE_READ,!1,!1,!1),Bi=hi(io.CHANGE_GROUP_TITLE,!0,!1,!1),Fi=hi(io.CHANGE_GROUP_AVATAR,!0,!1,!1),xi=hi(io.PRIVATE_MESSAGE_PINNED,!0,!1,!1),Gi=hi(io.GROUP_MESSAGE_PINNED,!0,!1,!1),qi=hi(io.CHAT_COMMENT,!1,!1,!1),Vi=hi(ro.RECALL,!0,!1,!1);class Ki{options;connectionStatus=e.DISCONNECTED;isInternalConnected=!1;watcher;messageLoader;static _loader;static init(e){return this._loader||(this._loader=new Ki(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,onMessagePinnedChanged:void 0,onMessageReactionsChanged:void 0,onDialogFilterConfig:void 0},lr.setServerInfo(this.getWebSocketUrl()),lr.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://web.sugramapp.com:3443";var t}registerMessage(){Ws(ro.TEXT,yi),Ws(ro.IMAGE,mi),Ws(ro.GIF,vi),Ws(ro.AUDIO,bi),Ws(ro.FILE,Ci),Ws(ro.VIDEO,wi),Ws(ro.RECALL,Vi),Ws(ro.LOCATION,Ii),Ws(ro.CHAT_RECORD,Oi),Ws(ro.CONTACT,Si),Ws(ro.GROUP_INVITATION,Ri),Ws(ro.REDPACKET,Ei),Ws(ro.TRANSFER,Ti),Ws(ro.LINK,_i),Ws(io.GROUP_ARRIVAL_RECEIPT,Ai),Ws(io.GROUP_READ_RECEIPT,ki),Ws(io.PRIVATE_ARRIVAL_RECEIPT,Mi),Ws(io.PRIVATE_READ_RECEIPT,Pi),Ws(io.PRIVATE_OPEN_BURNAFTERREADING,Ni),Ws(io.PRIVATE_CLOSE_BURNAFTERREADING,Li),Ws(io.GROUP_OPEN_BURNAFTERREADING,Di),Ws(io.GROUP_CLOSE_BURNAFTERREADING,Ui),Ws(io.MESSAGE_READ,ji),Ws(io.CHANGE_GROUP_TITLE,Bi),Ws(io.CHANGE_GROUP_AVATAR,Fi),Ws(io.PRIVATE_MESSAGE_PINNED,xi),Ws(io.GROUP_MESSAGE_PINNED,Gi),Ws(io.CHAT_COMMENT,qi)}async connect(){if(this.connectionStatus===e.CONNECTED)return{code:t.SUCCESS};if(this.connectionStatus===e.CONNECTING)return{code:t.BIZ_ERROR_CONNECTING};lr.close();const n=await lr.connect();return this.isInternalConnected=!0,{code:n}}reconnect(){return this.isInternalConnected?Promise.resolve({code:t.CAN_NOT_RECONNECT}):this.connect()}disconnect(){return this.isInternalConnected=!1,lr.close(),Promise.resolve()}async setUserLogged(){zi.setUserId(sr.uid.toString()),Co.get().destroyed(),Co.create(this.options.appkey,sr.uid.toString(),this.watcher.conversationState),jo.create(this.options.appkey,sr.uid.toString()),this.messageLoader?.stop(),this.messageLoader=new li(this.watcher,this.options),Ks.reset(),zs.reset(),Zs.reset();const t=ei.create(this.options.appkey,sr.uid.toString(),{legacyMigrationMode:this.options.legacyMigrationMode??"automatic"});await t.initDB();const n=await t.getMessageIdRange();if(n){const{oldest:e,newest:t}=n;xo(e,t)}else xo(1e4,1e4);this.getConnectionStatus()===e.CONNECTED&&this.handleUserConnected()}async setUserLogout(){this.messageLoader?.stop(),await(ei.get()?.close());const e=(gi+=1,di=ui,di);this.watcher.onDialogFilterConfig?.(e)}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){pt(this.watcher).forEach(t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t];this.watcher[t]=it(n)?n:void 0}})}resetWatcher(){pt(this.watcher).forEach(e=>{this.watcher[e]=void 0})}async connectionStatusListener(t){switch(this.connectionStatus=t,t){case e.BLOCKED:case e.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.CONNECTING:this.handleConnecting();break;case e.CONNECTED:this.handleConnected();break;case e.DISCONNECTED:this.handleDisconnect()}}handleConnecting(){this.watcher.onConnecting?.()}handleConnected(){sr.isActive&&(this.handleUserConnected(),(async()=>{const e=(new Date).getTime(),{code:n,data:r}=await ms();if(n===t.SUCCESS){const{currentTimeMillis:t}=r;Gs=t.toNumber()-e}})()),this.watcher.onConnected?.(),Xi.cleanupOldLogs()}handleDisconnect(){this.watcher.onDisconnect?.(),this.messageLoader?.stop()}handleSuspend(){this.watcher.onSuspend?.()}handleUserConnected(){Xi.info("user connected -> ",sr.uid.toString()),this.messageLoader||(this.messageLoader=new li(this.watcher,this.options)),this.messageLoader?.start(),pi().then(e=>{this.watcher.onDialogFilterConfig?.(e)}),setTimeout(()=>{this.connectionStatus===e.CONNECTED&&Co.get().syncConversationStatus()},2e3)}messageListener(e,t){if(e===Tt.NewMessagePush){const e=Lr.decode(t);this.messageLoader?.syncMsg(e.seqno)}else e===Tt.DialogChangedPush?Co.get().syncConversationStatus():this.watcher.onPush?.(e,t)}}class Hi{static instance;messageQueue;config;flushTimer=null;userId=null;isFlushing=!1;constructor(e){this.config=e,this.messageQueue=new St,this.startFlushTimer()}static getInstance(e){return Hi.instance||(Hi.instance=new Hi(e)),Hi.instance}trackEvent(e,t){const n={type:e,...this.collectAutomaticProperties(),content:t};this.messageQueue.enqueue(n),this.config.debugMode&&this.flush()}collectAutomaticProperties(){return{user_id:this.userId,os:"web",appVersion:Et.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),n=(new TextEncoder).encode(t);if("CompressionStream"in window){const e=new Response(n).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 Ki.loader?.getConnectionStatus()==e.CONNECTED}async sendData(e){try{const n=await js(e);if(n.code!==t.SUCCESS)throw new Error(`Socket error! status: ${n.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 zi=Hi.getInstance({flushInterval:6e4,flushBulkSize:100,debugMode:!1});const $i=Ct.get("ACIM-slf")===(new Date).getDate();const Wi={[u.DEBUG]:console.debug,[u.INFO]:console.info,[u.WARN]:console.warn,[u.ERROR]:console.error,[u.FATAL]:console.log,[u.NONE]:null},Ji={[u.DEBUG]:console.debug,[u.INFO]:console.info,[u.WARN]:console.warn,[u.ERROR]:console.error,[u.FATAL]:console.log,[u.NONE]:null},Zi=e=>lt(e)||rt(e)||ot(e)||st(e)?e:e instanceof Error?JSON.stringify({name:e.name,message:e.message,stack:e.stack}):JSON.stringify(e);var Xi=new class{debug;info;warn;error;fatal;outLevel=u.WARN;tag;logStdout;constructor(e){this.tag=e,this.debug=this.log.bind(this,u.DEBUG),this.info=this.log.bind(this,u.INFO),this.warn=this.log.bind(this,u.WARN),this.error=this.log.bind(this,u.ERROR),this.fatal=this.log.bind(this,u.FATAL)}async addLog(e,t){const n={timestamp:(new Date).toISOString(),level:e,content:t};try{e===u.ERROR&&zi.trackEvent("error_log",{timestamp:n.timestamp,content:n.content})}catch(e){console.error("Failed to add log:",e)}}getCallerLocation(){try{const e=(new Error).stack;if(!e)return null;const t=e.split("\n");for(let e=4;e<t.length;e++){const n=t[e].trim();if(n&&!n.includes("logger.ts")&&!n.includes("at Logger.")){const e=n.match(/at\s+(?:.*?\s+)?\(?(.+?):(\d+):(\d+)\)?/)||n.match(/at\s+(.+?):(\d+):(\d+)/);if(e){const t=e[1],n=e[2];return`${t.split("/").pop()||t.split("\\").pop()||t}:${n}`}}}}catch(e){}return null}defaultStdout(e,t,...n){const r=Wi[e];if(nt(r)){const s=this.getCallerLocation(),o=Ji[e];o?s?o(`${t} @ ${s}:`,...n):o(`${t}:`,...n):s?r(`${t} @ ${s}:`,...n):r(`${t}:`,...n)}}reqInfo(...e){this.info(...e)}setLogLevel(e){this.outLevel=e}setLogStdout(e){this.logStdout=e}log(e,...t){if($i){const n=`${(new Date).toISOString()}[${this.tag}][${u[e]}]`;return this.defaultStdout(e,n,...t),void this.addLog(e,t.map(Zi).join(" "))}if(e<this.outLevel)return;const n=`${(new Date).toISOString()}[${this.tag}][${u[e]}]`,r=`${n} - ${t.map(Zi).join(" ")}`;if(this.logStdout)return this.logStdout(e,r),void this.addLog(e,t.map(Zi).join(" "));this.defaultStdout(e,n,...t),this.addLog(e,t.map(Zi).join(" "))}async exportLogs(){return[]}async clearLogs(){}async cleanupOldLogs(){}}("ACLog");const Yi=ut,Qi=rt,ea=st,ta=at,na=ct,ra=e=>rt(e)&&Object.prototype.hasOwnProperty.call(r,e),sa=e=>{if(!at(e))return!1;const{conversationType:t,targetId:n,channelId:s}=e;return rt(t)&&Object.prototype.hasOwnProperty.call(r,t)&&(rt(n)||ut(n)||Ln.isLong(n)&&!n.isZero())&&(!nt(s)||lt(s)&&!/_/g.test(s)&&s.length<=20)};class oa extends Error{constructor(e){super(e),this.name="ACAssertError"}}const ia=(e,t,n,r=!1)=>{if(!aa(e,t,n,r))throw new oa(`'${e}' is invalid: ${JSON.stringify(t)}`)},aa=(e,t,n,r=!1)=>{const s=r&&!n(t)||!r&&nt(t)&&!n(t);return s&&Xi.error(`'${e}' is invalid: ${JSON.stringify(t)}`),!s};var ca,la,ua,da,ga={exports:{}},pa={exports:{}},fa={exports:{}};var ha,ya={};var ma,va,ba,Ca,wa,Ia,Oa,Sa,Ra,Ea,Ta,_a,Aa,ka,Ma,Pa,Na,La,Da,Ua={};function ja(){return ma||(ma=1,function(e){var t=e,n=Ic(),r=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function s(e,t){var n=0,s={};for(t|=0;n<e.length;)s[r[n+t]]=e[n++];return s}t.basic=s([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=s([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",n.emptyArray,null]),t.long=s([0,0,0,1,1],7),t.mapKey=s([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=s([1,5,0,0,0,5,5,0,0,0,1,1,0])}(Ua)),Ua}function Ba(){if(ba)return va;ba=1,va=i;var e=Oc();((i.prototype=Object.create(e.prototype)).constructor=i).className="Field";var t,n=Sc(),r=ja(),s=Ic(),o=/^required|optional|repeated$/;function i(t,n,i,a,c,l,u){if(s.isObject(a)?(u=c,l=a,a=c=void 0):s.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!s.isInteger(n)||n<0)throw TypeError("id must be a non-negative integer");if(!s.isString(i))throw TypeError("type must be a string");if(void 0!==a&&!o.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!s.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=n,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=!!s.Long&&void 0!==r.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,n,r){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,n,r)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return s.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=r.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 n&&"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 n)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=s.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var o;s.base64.test(this.typeDefault)?s.base64.decode(this.typeDefault,o=s.newBuffer(s.base64.length(this.typeDefault)),0):s.utf8.write(this.typeDefault,o=s.newBuffer(s.utf8.length(this.typeDefault)),0),this.typeDefault=o}return this.map?this.defaultValue=s.emptyObject:this.repeated?this.defaultValue=s.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,n,r){return"function"==typeof t?t=s.decorateType(t).name:t&&"object"==typeof t&&(t=s.decorateEnum(t).name),function(o,a){s.decorateType(o.constructor).add(new i(a,e,t,n,{default:r}))}},i._configure=function(e){t=e},va}function Fa(){if(wa)return Ca;wa=1,Ca=r;var e=Oc();((r.prototype=Object.create(e.prototype)).constructor=r).className="OneOf";var t=Ba(),n=Ic();function r(t,n,r,s){if(Array.isArray(n)||(r=n,n=void 0),e.call(this,t,r),void 0!==n&&!Array.isArray(n))throw TypeError("fieldNames must be an Array");this.oneof=n||[],this.fieldsArray=[],this.comment=s}function s(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return r.fromJSON=function(e,t){return new r(e,t.oneof,t.options,t.comment)},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},r.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,s(this),this},r.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var n=this.fieldsArray.indexOf(e);if(n<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(n,1),(n=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(n,1),e.partOf=null,this},r.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var n=0;n<this.oneof.length;++n){var r=t.get(this.oneof[n]);r&&!r.partOf&&(r.partOf=this,this.fieldsArray.push(r))}s(this)},r.prototype.onRemove=function(t){for(var n,r=0;r<this.fieldsArray.length;++r)(n=this.fieldsArray[r]).parent&&n.parent.remove(n);e.prototype.onRemove.call(this,t)},r.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,s){n.decorateType(t.constructor).add(new r(s,e)),Object.defineProperty(t,s,{get:n.oneOfGetter(e),set:n.oneOfSetter(e)})}},Ca}function xa(){if(Oa)return Ia;Oa=1,Ia=c;var e=Oc();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,n,r,s=Ba(),o=Ic(),i=Fa();function a(e,t){if(e&&e.length){for(var n={},r=0;r<e.length;++r)n[e[r].name]=e[r].toJSON(t);return n}}function c(t,n){e.call(this,t,n),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 n=0;n<e.length;++n)if("string"!=typeof e[n]&&e[n][0]<=t&&e[n][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var n=0;n<e.length;++n)if(e[n]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=o.toArray(this.nested))}}),c.prototype.toJSON=function(e){return o.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var o,i=Object.keys(e),a=0;a<i.length;++a)o=e[i[a]],this.add((void 0!==o.fields?t.fromJSON:void 0!==o.values?r.fromJSON:void 0!==o.methods?n.fromJSON:void 0!==o.id?s.fromJSON:c.fromJSON)(i[a],o));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 r)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof s&&void 0!==e.extend||e instanceof t||e instanceof i||e instanceof r||e instanceof n||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var o=this.get(e.name);if(o){if(!(o instanceof c&&e instanceof c)||o instanceof t||o instanceof n)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=o.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(o),this.nested||(this.nested={}),e.setOptions(o.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(o.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 n=this;e.length>0;){var r=e.shift();if(n.nested&&n.nested[r]){if(!((n=n.nested[r])instanceof c))throw Error("path conflicts with non-namespace objects")}else n.add(n=new c(r))}return t&&n.addJSON(t),n},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,n){if("boolean"==typeof t?(n=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),o.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 r=this.get(e[0]);if(r){if(1===e.length){if(!t||t.indexOf(r.constructor)>-1)return r}else if(r instanceof c&&(r=r.lookup(e.slice(1),t,!0)))return r}else for(var s=0;s<this.nestedArray.length;++s)if(this._nestedArray[s]instanceof c&&(r=this._nestedArray[s].lookup(e,t,!0)))return r;return null===this.parent||n?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var n=this.lookup(e,[t]);if(!n)throw Error("no such type: "+e);return n},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var n=this.lookup(e,[t,r]);if(!n)throw Error("no such Type or Enum '"+e+"' in "+this);return n},c.prototype.lookupService=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,s,o){t=e,n=s,r=o},Ia}function Ga(){if(Ra)return Sa;Ra=1,Sa=r;var e=Ba();((r.prototype=Object.create(e.prototype)).constructor=r).className="MapField";var t=ja(),n=Ic();function r(t,r,s,o,i,a){if(e.call(this,t,r,o,void 0,void 0,i,a),!n.isString(s))throw TypeError("keyType must be a string");this.keyType=s,this.resolvedKeyType=null,this.map=!0}return r.fromJSON=function(e,t){return new r(e,t.id,t.keyType,t.type,t.options,t.comment)},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},r.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)},r.d=function(e,t,s){return"function"==typeof s?s=n.decorateType(s).name:s&&"object"==typeof s&&(s=n.decorateEnum(s).name),function(o,i){n.decorateType(o.constructor).add(new r(i,e,t,s))}},Sa}function qa(){if(Ta)return Ea;Ta=1,Ea=n;var e=Oc();((n.prototype=Object.create(e.prototype)).constructor=n).className="Method";var t=Ic();function n(n,r,s,o,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!==r&&!t.isString(r))throw TypeError("type must be a string");if(!t.isString(s))throw TypeError("requestType must be a string");if(!t.isString(o))throw TypeError("responseType must be a string");e.call(this,n,c),this.type=r||"rpc",this.requestType=s,this.requestStream=!!i||void 0,this.responseType=o,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return n.fromJSON=function(e,t){return new n(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},n.prototype.toJSON=function(e){var n=!!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",n?this.comment:void 0,"parsedOptions",this.parsedOptions])},n.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))},Ea}function Va(){if(Aa)return _a;Aa=1,_a=s;var e=xa();((s.prototype=Object.create(e.prototype)).constructor=s).className="Service";var t=qa(),n=Ic(),r=yn();function s(t,n){e.call(this,t,n),this.methods={},this._methodsArray=null}function o(e){return e._methodsArray=null,e}return s.fromJSON=function(e,n){var r=new s(e,n.options);if(n.methods)for(var o=Object.keys(n.methods),i=0;i<o.length;++i)r.add(t.fromJSON(o[i],n.methods[o[i]]));return n.nested&&r.addJSON(n.nested),r.comment=n.comment,r},s.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),s=!!t&&Boolean(t.keepComments);return n.toObject(["options",r&&r.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",r&&r.nested||void 0,"comment",s?this.comment:void 0])},Object.defineProperty(s.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=n.toArray(this.methods))}}),s.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},s.prototype.resolveAll=function(){for(var t=this.methodsArray,n=0;n<t.length;++n)t[n].resolve();return e.prototype.resolve.call(this)},s.prototype.add=function(n){if(this.get(n.name))throw Error("duplicate name '"+n.name+"' in "+this);return n instanceof t?(this.methods[n.name]=n,n.parent=this,o(this)):e.prototype.add.call(this,n)},s.prototype.remove=function(n){if(n instanceof t){if(this.methods[n.name]!==n)throw Error(n+" is not a member of "+this);return delete this.methods[n.name],n.parent=null,o(this)}return e.prototype.remove.call(this,n)},s.prototype.create=function(e,t,s){for(var o,i=new r.Service(e,t,s),a=0;a<this.methodsArray.length;++a){var c=n.lcFirst((o=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");i[c]=n.codegen(["r","c"],n.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:o,q:o.resolvedRequestType.ctor,s:o.resolvedResponseType.ctor})}return i},_a}function Ka(){if(Ma)return ka;Ma=1,ka=t;var e=rn();function t(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)this[t[n]]=e[t[n]]}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)},ka}function Ha(){if(Na)return Pa;Na=1,Pa=function(s){var o=n.codegen(["r","l"],s.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(s.fieldsArray.filter(function(e){return e.map}).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");s.group&&o("if((t&7)===4)")("break");o("switch(t>>>3){");for(var i=0;i<s.fieldsArray.length;++i){var a=s._fieldsArray[i].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+n.safeProp(a.name);o("case %i: {",a.id),a.map?(o("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?o("k=%j",t.defaults[a.keyType]):o("k=null"),void 0!==t.defaults[c]?o("value=%j",t.defaults[c]):o("value=null"),o("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]?o("value=types[%i].decode(r,r.uint32())",i):o("value=r.%s()",c),o("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?o('%s[typeof k==="object"?util.longToHash(k):k]=value',l):o("%s[k]=value",l)):a.repeated?(o("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&o("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]?o(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,i):o("%s.push(r.%s())",l,c)):void 0===t.basic[c]?o(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,i):o("%s=r.%s()",l,c),o("break")("}")}for(o("default:")("r.skipType(t&7)")("break")("}")("}"),i=0;i<s._fieldsArray.length;++i){var u=s._fieldsArray[i];u.required&&o("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",r(u))}return o("return m")};var e=Sc(),t=ja(),n=Ic();function r(e){return"missing required '"+e.name+"'"}return Pa}function za(){if(Da)return La;Da=1,La=function(e){var o=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),i=e.oneofsArray,a={};i.length&&o("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&&o("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)o("if(!util.isObject(%s))",u)("return%j",n(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),s(o,l,"k[i]"),r(o,l,c,u+"[k[i]]")("}");else if(l.repeated)o("if(!Array.isArray(%s))",u)("return%j",n(l,"array"))("for(var i=0;i<%s.length;++i){",u),r(o,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&o("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,o("p%s=1",d)}r(o,l,c,u)}l.optional&&o("}")}return o("return null")};var e=Sc(),t=Ic();function n(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function r(t,r,s,o){if(r.resolvedType)if(r.resolvedType instanceof e){t("switch(%s){",o)("default:")("return%j",n(r,"enum value"));for(var i=Object.keys(r.resolvedType.values),a=0;a<i.length;++a)t("case %i:",r.resolvedType.values[i[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",s,o)("if(e)")("return%j+e",r.name+".")("}");else switch(r.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",o)("return%j",n(r,"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)))",o,o,o,o)("return%j",n(r,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',o)("return%j",n(r,"number"));break;case"bool":t('if(typeof %s!=="boolean")',o)("return%j",n(r,"boolean"));break;case"string":t("if(!util.isString(%s))",o)("return%j",n(r,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',o,o,o)("return%j",n(r,"buffer"))}return t}function s(e,t,r){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",r)("return%j",n(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",r)("return%j",n(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",r)("return%j",n(t,"boolean key"))}return e}return La}var $a,Wa={};function Ja(){return $a||($a=1,function(e){var t=e,n=Sc(),r=Ic();function s(e,t,r,s){var o=!1;if(t.resolvedType)if(t.resolvedType instanceof n){e("switch(d%s){",s);for(var i=t.resolvedType.values,a=Object.keys(i),c=0;c<a.length;++c)i[a[c]]!==t.typeDefault||o||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',s,s,s),t.repeated||e("break"),o=!0),e("case%j:",a[c])("case %i:",i[a[c]])("m%s=%j",s,i[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',s)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",s,r,s);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",s,s);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",s,s);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",s,s);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",s,s,l)('else if(typeof d%s==="string")',s)("m%s=parseInt(d%s,10)",s,s)('else if(typeof d%s==="number")',s)("m%s=d%s",s,s)('else if(typeof d%s==="object")',s)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",s,s,s,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',s)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",s,s,s)("else if(d%s.length >= 0)",s)("m%s=d%s",s,s);break;case"string":e("m%s=String(d%s)",s,s);break;case"bool":e("m%s=Boolean(d%s)",s,s)}}return e}function o(e,t,r,s){if(t.resolvedType)t.resolvedType instanceof n?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",s,r,s,s,r,s,s):e("d%s=types[%i].toObject(m%s,o)",s,r,s);else{var o=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",s,s,s,s);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',s)("d%s=o.longs===String?String(m%s):m%s",s,s,s)("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",s,s,s,s,o?"true":"",s);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",s,s,s,s,s);break;default:e("d%s=m%s",s,s)}}return e}t.fromObject=function(e){var t=e.fieldsArray,o=r.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return o("return new this.ctor");o("var m=new this.ctor");for(var i=0;i<t.length;++i){var a=t[i].resolve(),c=r.safeProp(a.name);a.map?(o("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),s(o,a,i,c+"[ks[i]]")("}")("}")):a.repeated?(o("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),s(o,a,i,c+"[i]")("}")("}")):(a.resolvedType instanceof n||o("if(d%s!=null){",c),s(o,a,i,c),a.resolvedType instanceof n||o("}"))}return o("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(r.compareFieldsById);if(!t.length)return r.codegen()("return {}");for(var s=r.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(s("if(o.arrays||o.defaults){"),l=0;l<i.length;++l)s("d%s=[]",r.safeProp(i[l].name));s("}")}if(a.length){for(s("if(o.objects||o.defaults){"),l=0;l<a.length;++l)s("d%s={}",r.safeProp(a[l].name));s("}")}if(c.length){for(s("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=r.safeProp(u.name);if(u.resolvedType instanceof n)s("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)s("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(",")+"]";s("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 s("d%s=%j",d,u.typeDefault)}s("}")}var p=!1;for(l=0;l<t.length;++l){u=t[l];var f=e._fieldsArray.indexOf(u);d=r.safeProp(u.name);u.map?(p||(p=!0,s("var ks2")),s("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),o(s,u,f,d+"[ks2[j]]")("}")):u.repeated?(s("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),o(s,u,f,d+"[j]")("}")):(s("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),o(s,u,f,d),u.partOf&&s("if(o.oneofs)")("d%s=%j",r.safeProp(u.partOf.name),u.name)),s("}")}return s("return d")}}(Wa)),Wa}var Za,Xa,Ya,Qa,ec,tc,nc,rc,sc,oc,ic,ac,cc,lc,uc,dc,gc,pc,fc,hc,yc,mc,vc={};function bc(){return Za||(Za=1,function(e){var t=e,n=Ka();t[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),n=this.lookup(t);if(n){var r="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===r.indexOf("/")&&(r="/"+r),this.create({type_url:r,value:n.encode(n.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var r="",s="";if(t&&t.json&&e.type_url&&e.value){s=e.type_url.substring(e.type_url.lastIndexOf("/")+1),r=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var o=this.lookup(s);o&&(e=o.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof n){var i=e.$type.toObject(e,t);return""===r&&(r="type.googleapis.com/"),s=r+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),i["@type"]=s,i}return this.toObject(e,t)}}}(vc)),vc}function Cc(){if(Ya)return Xa;Ya=1,Xa=h;var e=xa();((h.prototype=Object.create(e.prototype)).constructor=h).className="Type";var t=Sc(),n=Fa(),r=Ba(),s=Ga(),o=Va(),i=Ka(),a=on(),c=sn(),l=Ic(),u=Rc(),d=Ha(),g=za(),p=Ja(),f=bc();function h(t,n){e.call(this,t,n),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 n=this.fields[e[t]],r=n.id;if(this._fieldsById[r])throw Error("duplicate id "+r+" in "+this);this._fieldsById[r]=n}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 n=0;n<this.fieldsArray.length;++n)this._fieldsArray[n].resolve();var r={};for(n=0;n<this.oneofsArray.length;++n)r[this._oneofsArray[n].resolve().name]={get:l.oneOfGetter(this._oneofsArray[n].oneof),set:l.oneOfSetter(this._oneofsArray[n].oneof)};n&&Object.defineProperties(e.prototype,r)}}}),h.generateConstructor=function(e){for(var t,n=l.codegen(["p"],e.name),r=0;r<e.fieldsArray.length;++r)(t=e._fieldsArray[r]).map?n("this%s={}",l.safeProp(t.name)):t.repeated&&n("this%s=[]",l.safeProp(t.name));return n("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?s.fromJSON:r.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(n.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?r.fromJSON:void 0!==d.fields?h.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?o.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 n=e.prototype.toJSON.call(this,t),r=!!t&&Boolean(t.keepComments);return l.toObject(["options",n&&n.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",n&&n.nested||void 0,"comment",r?this.comment:void 0])},h.prototype.resolveAll=function(){for(var t=this.fieldsArray,n=0;n<t.length;)t[n++].resolve();var r=this.oneofsArray;for(n=0;n<r.length;)r[n++].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 r&&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 n?(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 r&&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 n){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=[],n=0;n<this.fieldsArray.length;++n)t.push(this._fieldsArray[n].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 r=f[e];if(r){var s=Object.create(this);s.fromObject=this.fromObject,this.fromObject=r.fromObject.bind(s),s.toObject=this.toObject,this.toObject=r.toObject.bind(s)}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)}},Xa}function wc(){if(ec)return Qa;ec=1,Qa=c;var e=xa();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,n,r,s=Ba(),o=Sc(),i=Fa(),a=Ic();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,s,o){"function"==typeof s&&(o=s,s=void 0);var i=this;if(!o)return a.asPromise(e,i,t,s);var c=o===l;function u(e,t){if(o){if(c)throw e;var n=o;o=null,n(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var n=e.substring(t);if(n in r)return n}return null}function g(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){n.filename=e;var r,o=n(t,i,s),l=0;if(o.imports)for(;l<o.imports.length;++l)(r=d(o.imports[l])||i.resolvePath(e,o.imports[l]))&&p(r);if(o.weakImports)for(l=0;l<o.weakImports.length;++l)(r=d(o.weakImports[l])||i.resolvePath(e,o.weakImports[l]))&&p(r,!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 r)c?g(e,r[e]):(++f,setTimeout(function(){--f,g(e,r[e])}));else if(c){var n;try{n=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}g(e,n)}else++f,i.fetch(e,function(n,r){--f,o&&(n?t?f||u(null,i):u(n):g(e,r))})}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 n=t.parent.lookup(t.extend);if(n){var r=new s(t.fullName,t.id,t.type,t.rule,void 0,t.options);return n.get(r.name)||(r.declaringField=t,t.extensionField=r,n.add(r)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof s)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof o)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof i)){if(e instanceof t)for(var n=0;n<this.deferred.length;)d(0,this.deferred[n])?this.deferred.splice(n,1):++n;for(var r=0;r<e.nestedArray.length;++r)this._handleAdd(e._nestedArray[r]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof s){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var n=this.deferred.indexOf(t);n>-1&&this.deferred.splice(n,1)}}else if(t instanceof o)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var r=0;r<t.nestedArray.length;++r)this._handleRemove(t._nestedArray[r]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,s,o){t=e,n=s,r=o},Qa}function Ic(){if(tc)return fa.exports;tc=1;var e,t,n=fa.exports=rn(),r=mn();n.codegen=function(){if(la)return ca;function e(t,n){"string"==typeof t&&(n=t,t=void 0);var r=[];function s(t){if("string"!=typeof t){var n=o();if(e.verbose&&console.log("codegen: "+n),n="return "+n,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]=n,Function.apply(null,a).apply(null,c)}return Function(n)()}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 n=u[d++];switch(t){case"d":case"f":return String(Number(n));case"i":return String(Math.floor(n));case"j":return JSON.stringify(n);case"s":return String(n)}return"%"}),d!==u.length)throw Error("parameter count mismatch");return r.push(t),s}function o(e){return"function "+(e||n||"")+"("+(t&&t.join(",")||"")+"){\n "+r.join("\n ")+"\n}"}return s.toString=o,s}return la=1,ca=e,e.verbose=!1,ca}(),n.fetch=function(){if(da)return ua;da=1,ua=n;var e=Pt(),t=Gt()("fs");function n(r,s,o){return"function"==typeof s?(o=s,s={}):s||(s={}),o?!s.xhr&&t&&t.readFile?t.readFile(r,function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?n.xhr(r,s,o):e?o(e):o(null,s.binary?t:t.toString("utf8"))}):n.xhr(r,s,o):e(n,this,r,s)}return n.xhr=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(0!==r.status&&200!==r.status)return n(Error("status "+r.status));if(t.binary){var e=r.response;if(!e){e=[];for(var s=0;s<r.responseText.length;++s)e.push(255&r.responseText.charCodeAt(s))}return n(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return n(null,r.responseText)}},t.binary&&("overrideMimeType"in r&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.responseType="arraybuffer"),r.open("GET",e),r.send()},ua}(),n.path=(ha||(ha=1,function(e){var t=e,n=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},r=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=n(e),s="";r&&(s=t.shift()+"/");for(var o=0;o<t.length;)".."===t[o]?o>0&&".."!==t[o-1]?t.splice(--o,2):r?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return s+t.join("/")};t.resolve=function(e,t,s){return s||(t=r(t)),n(t)?t:(s||(e=r(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?r(e+"/"+t):t)}}(ya)),ya),n.fs=n.inquire("fs"),n.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),r=0;r<t.length;)n[r]=e[t[r++]];return n}return[]},n.toObject=function(e){for(var t={},n=0;n<e.length;){var r=e[n++],s=e[n++];void 0!==s&&(t[r]=s)}return t};var s=/\\/g,o=/"/g;n.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)},n.safeProp=function(e){return!/^[$\w_]+$/.test(e)||n.isReserved(e)?'["'+e.replace(s,"\\\\").replace(o,'\\"')+'"]':"."+e},n.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var i=/_([a-z])/g;n.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(i,function(e,t){return t.toUpperCase()})},n.compareFieldsById=function(e,t){return e.id-t.id},n.decorateType=function(t,r){if(t.$type)return r&&t.$type.name!==r&&(n.decorateRoot.remove(t.$type),t.$type.name=r,n.decorateRoot.add(t.$type)),t.$type;e||(e=Cc());var s=new e(r||t.name);return n.decorateRoot.add(s),s.ctor=t,Object.defineProperty(t,"$type",{value:s,enumerable:!1}),Object.defineProperty(t.prototype,"$type",{value:s,enumerable:!1}),s};var a=0;return n.decorateEnum=function(e){if(e.$type)return e.$type;t||(t=Sc());var r=new t("Enum"+a++,e);return n.decorateRoot.add(r),Object.defineProperty(e,"$type",{value:r,enumerable:!1}),r},n.setProperty=function(e,t,n){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,n,r){var s=n.shift();if("__proto__"===s||"prototype"===s)return t;if(n.length>0)t[s]=e(t[s]||{},n,r);else{var o=t[s];o&&(r=[].concat(o).concat(r)),t[s]=r}return t}(e,t=t.split("."),n)},Object.defineProperty(n,"decorateRoot",{get:function(){return r.decorated||(r.decorated=new(wc()))}}),fa.exports}function Oc(){if(rc)return nc;rc=1,nc=n,n.className="ReflectionObject";var e,t=Ic();function n(e,n){if(!t.isString(e))throw TypeError("name must be a string");if(n&&!t.isObject(n))throw TypeError("options must be an object");this.options=n,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(n.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(".")}}}),n.prototype.toJSON=function(){throw Error()},n.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var n=t.root;n instanceof e&&n._handleAdd(this)},n.prototype.onRemove=function(t){var n=t.root;n instanceof e&&n._handleRemove(this),this.parent=null,this.resolved=!1},n.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},n.prototype.getOption=function(e){if(this.options)return this.options[e]},n.prototype.setOption=function(e,t,n){return n&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},n.prototype.setParsedOption=function(e,n,r){this.parsedOptions||(this.parsedOptions=[]);var s=this.parsedOptions;if(r){var o=s.find(function(t){return Object.prototype.hasOwnProperty.call(t,e)});if(o){var i=o[e];t.setProperty(i,r,n)}else(o={})[e]=t.setProperty({},r,n),s.push(o)}else{var a={};a[e]=n,s.push(a)}return this},n.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),r=0;r<n.length;++r)this.setOption(n[r],e[n[r]],t);return this},n.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},n._configure=function(t){e=t},nc}function Sc(){if(oc)return sc;oc=1,sc=r;var e=Oc();((r.prototype=Object.create(e.prototype)).constructor=r).className="Enum";var t=xa(),n=Ic();function r(t,n,r,s,o,i){if(e.call(this,t,r),n&&"object"!=typeof n)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=s,this.comments=o||{},this.valuesOptions=i,this.reserved=void 0,n)for(var a=Object.keys(n),c=0;c<a.length;++c)"number"==typeof n[a[c]]&&(this.valuesById[this.values[a[c]]=n[a[c]]]=a[c])}return r.fromJSON=function(e,t){var n=new r(e,t.values,t.options,t.comment,t.comments);return n.reserved=t.reserved,n},r.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return n.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])},r.prototype.add=function(e,t,r,s){if(!n.isString(e))throw TypeError("name must be a string");if(!n.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 s&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=s||null),this.comments[e]=r||null,this},r.prototype.remove=function(e){if(!n.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},r.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},r.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},sc}function Rc(){if(ac)return ic;ac=1,ic=function(s){for(var o,i=n.codegen(["m","w"],s.name+"$encode")("if(!w)")("w=Writer.create()"),a=s.fieldsArray.slice().sort(n.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=s._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,g=t.basic[d];o="m"+n.safeProp(l.name),l.map?(i("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",o,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",o)("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,o):i(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|g,d,o),i("}")("}")):l.repeated?(i("if(%s!=null&&%s.length){",o,o),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)",o)("w.%s(%s[i])",d,o)("w.ldelim()"):(i("for(var i=0;i<%s.length;++i)",o),void 0===g?r(i,l,u,o+"[i]"):i("w.uint32(%i).%s(%s[i])",(l.id<<3|g)>>>0,d,o)),i("}")):(l.optional&&i("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",o,l.name),void 0===g?r(i,l,u,o):i("w.uint32(%i).%s(%s)",(l.id<<3|g)>>>0,d,o))}return i("return w")};var e=Sc(),t=ja(),n=Ic();function r(e,t,n,r){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(t.id<<3|2)>>>0)}return ic}function Ec(){if(uc)return lc;uc=1,lc=u;var e=/[\s{}=;:[\],'"()<>]/g,t=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,r=/^ *[*/]+ */,s=/^\s*\*?\/*/,o=/\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,n){var i,l={type:a.charAt(e++),lineEmpty:!1,leading:n},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(o),h=0;h<d.length;++h)d[h]=d[h].replace(c?s:r,"").trim();l.text=d.join("\n").trim(),f[g]=l,p=g}function C(e){var t=w(e),n=a.substring(e,t);return/^\s*\/\//.test(n)}function w(e){for(var t=e;t<d&&"\n"!==v(t);)t++;return t}function I(){if(h.length>0)return h.shift();if(y)return function(){var e="'"===y?n:t;e.lastIndex=u-1;var r=e.exec(a);if(!r)throw m("string");return u=e.lastIndex,O(y),y=null,l(r[1])}();var r,s,o,p,f,I=0===u;do{if(u===d)return null;for(r=!1;i.test(o=v(u));)if("\n"===o&&(I=!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=w(u))===d)break;if(u++,!I)break}while(C(u))}else u=Math.min(d,w(u)+1);f&&(b(p,u,I),I=!0),g++,r=!0}else{for(f="/"===v(p=u+1);"\n"!==v(++u);)if(u===d)return null;++u,f&&(b(p,u-1,I),I=!0),++g,r=!0}else{if("*"!==(o=v(u)))return"/";p=u+1,f=c||"*"===v(p);do{if("\n"===o&&++g,++u===d)throw m("comment");s=o,o=v(u)}while("*"!==s||"/"!==o);++u,f&&(b(p,u-2,I),I=!0),r=!0}}}while(r);var S=u;if(e.lastIndex=0,!e.test(v(S++)))for(;S<d&&!e.test(v(S));)++S;var R=a.substring(u,u=S);return'"'!==R&&"'"!==R||(y=R),R}function O(e){h.push(e)}function S(){if(!h.length){var e=I();if(null===e)return null;O(e)}return h[0]}return Object.defineProperty({next:I,peek:S,push:O,skip:function(e,t){var n=S();if(n===e)return I(),!0;if(!t)throw m("token '"+n+"', '"+e+"' expected");return!1},cmnt:function(e){var t,n=null;return void 0===e?(t=f[g-1],delete f[g-1],t&&(c||"*"===t.type||t.lineEmpty)&&(n=t.leading?t.text:null)):(p<e&&S(),t=f[e],delete f[e],!t||t.lineEmpty||!c&&"/"!==t.type||(n=t.leading?null:t.text)),n}},"line",{get:function(){return g}})}return u.unescape=l,lc}function Tc(){if(gc)return dc;gc=1,dc=w,w.filename=null,w.defaults={keepCase:!1};var e=Ec(),t=wc(),n=Cc(),r=Ba(),s=Ga(),o=Fa(),i=Sc(),a=Va(),c=qa(),l=ja(),u=Ic(),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 w(I,O,S){O instanceof t||(S=O,O=new t),S||(S=w.defaults);var R,E,T,_,A,k=S.preferTrailingComment||!1,M=e(I,S.alternateCommentMode||!1),P=M.next,N=M.push,L=M.peek,D=M.skip,U=M.cmnt,j=!0,B=!1,F=O,x=S.keepCase?function(e){return e}:u.camelCase;function G(e,t,n){var r=w.filename;return n||(w.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(r?r+", ":"")+"line "+M.line+")")}function q(){var e,t=[];do{if('"'!==(e=P())&&"'"!==e)throw G(e);t.push(P()),D(e),e=L()}while('"'===e||"'"===e);return t.join("")}function V(e){var t=P();switch(t){case"'":case'"':return N(t),q();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var n=1;"-"===e.charAt(0)&&(n=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return n*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(d.test(e))return n*parseInt(e,10);if(p.test(e))return n*parseInt(e,16);if(h.test(e))return n*parseInt(e,8);if(m.test(e))return n*parseFloat(e);throw G(e,"number",t)}(t,!0)}catch(n){if(e&&b.test(t))return t;throw G(t,"value")}}function K(e,t){var n,r;do{!t||'"'!==(n=L())&&"'"!==n?e.push([r=H(P()),D("to",!0)?H(P()):r]):e.push(q())}while(D(",",!0));var s={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(s,function(e){if("option"!==e)throw G(e);ee(s,e),D(";")},function(){re(s)})}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!==R)throw G("package");if(R=P(),!b.test(R))throw G(R,"name");F=F.define(R),D(";")}function $(){var e,t=L();switch(t){case"weak":e=T||(T=[]),P();break;case"public":P();default:e=E||(E=[])}t=q(),D(";"),e.push(t)}function W(){if(D("="),_=q(),!(B="proto3"===_)&&"proto2"!==_)throw G(_,"syntax");O.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=P()))throw G(t,"service name");var n=new a(t);Z(n,function(e){if(!J(n,e)){if("rpc"!==e)throw G(e);!function(e,t){var n=U(),r=t;if(!v.test(t=P()))throw G(t,"name");var s,o,i,a,l=t;D("("),D("stream",!0)&&(o=!0);if(!b.test(t=P()))throw G(t);s=t,D(")"),D("returns"),D("("),D("stream",!0)&&(a=!0);if(!b.test(t=P()))throw G(t);i=t,D(")");var u=new c(l,r,s,i,o,a);u.comment=n,Z(u,function(e){if("option"!==e)throw G(e);ee(u,e),D(";")}),e.add(u)}(n,e)}}),e.add(n)}(e,t),!0;case"extend":return function(e,t){if(!b.test(t=P()))throw G(t,"reference");var n=t;Z(null,function(t){switch(t){case"required":case"repeated":Y(e,t,n);break;case"optional":Y(e,B?"proto3_optional":"optional",n);break;default:if(!B||!b.test(t))throw G(t);N(t),Y(e,"optional",n)}})}(e,t),!0}return!1}function Z(e,t,n){var r=M.line;if(e&&("string"!=typeof e.comment&&(e.comment=U()),e.filename=w.filename),D("{",!0)){for(var s;"}"!==(s=P());)t(s);D(";",!0)}else n&&n(),D(";"),e&&("string"!=typeof e.comment||k)&&(e.comment=U(r)||e.comment)}function X(e,t){if(!v.test(t=P()))throw G(t,"type name");var r=new n(t);Z(r,function(e){if(!J(r,e))switch(e){case"map":!function(e){D("<");var t=P();if(void 0===l.mapKey[t])throw G(t,"type");D(",");var n=P();if(!b.test(n))throw G(n,"type");D(">");var r=P();if(!v.test(r))throw G(r,"name");D("=");var o=new s(x(r),H(P()),t,n);Z(o,function(e){if("option"!==e)throw G(e);ee(o,e),D(";")},function(){re(o)}),e.add(o)}(r);break;case"required":case"repeated":Y(r,e);break;case"optional":Y(r,B?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!v.test(t=P()))throw G(t,"name");var n=new o(x(t));Z(n,function(e){"option"===e?(ee(n,e),D(";")):(N(e),Y(n,"optional"))}),e.add(n)}(r,e);break;case"extensions":K(r.extensions||(r.extensions=[]));break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:if(!B||!b.test(e))throw G(e);N(e),Y(r,"optional")}}),e.add(r)}function Y(e,t,s){var i=P();if("group"!==i){for(;i.endsWith(".")||L().startsWith(".");)i+=P();if(!b.test(i))throw G(i,"type");var a=P();if(!v.test(a))throw G(a,"name");a=x(a),D("=");var c=new r(a,H(P()),i,t,s);if(Z(c,function(e){if("option"!==e)throw G(e);ee(c,e),D(";")},function(){re(c)}),"proto3_optional"===t){var d=new o("_"+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 s=P();if(!v.test(s))throw G(s,"name");var o=u.lcFirst(s);s===o&&(s=u.ucFirst(s));D("=");var i=H(P()),a=new n(s);a.group=!0;var c=new r(o,i,s,t);c.filename=w.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=P()))throw G(t,"name");var n=new i(t);Z(n,function(e){switch(e){case"option":ee(n,e),D(";");break;case"reserved":K(n.reserved||(n.reserved=[]),!0);break;default:!function(e,t){if(!v.test(t))throw G(t,"name");D("=");var n=H(P(),!0),r={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Z(r,function(e){if("option"!==e)throw G(e);ee(r,e),D(";")},function(){re(r)}),e.add(t,n,r.comment,r.options)}(n,e)}}),e.add(n)}function ee(e,t){var n=D("(",!0);if(!b.test(t=P()))throw G(t,"name");var r,s=t,o=s;n&&(D(")"),o=s="("+s+")",t=L(),C.test(t)&&(r=t.slice(1),s+=t,P())),D("="),function(e,t,n,r){e.setParsedOption&&e.setParsedOption(t,n,r)}(e,o,te(e,s),r)}function te(e,t){if(D("{",!0)){for(var n={};!D("}",!0);){if(!v.test(A=P()))throw G(A,"name");if(null===A)throw G(A,"end of input");var r,s=A;if(D(":",!0),"{"===L())r=te(e,t+"."+A);else if("["===L()){var o;if(r=[],D("[",!0)){do{o=V(!0),r.push(o)}while(D(",",!0));D("]"),void 0!==o&&ne(e,t+"."+A,o)}}else r=V(!0),ne(e,t+"."+A,r);var i=n[s];i&&(r=[].concat(i).concat(r)),n[s]=r,D(",",!0),D(";",!0)}return n}var a=V(!0);return ne(e,t,a),a}function ne(e,t,n){e.setOption&&e.setOption(t,n)}function re(e){if(D("[",!0)){do{ee(e,"option")}while(D(",",!0));D("]")}return e}for(;null!==(A=P());)switch(A){case"package":if(!j)throw G(A);z();break;case"import":if(!j)throw G(A);$();break;case"syntax":if(!j)throw G(A);W();break;case"option":ee(F,A),D(";");break;default:if(J(F,A)){j=!1;continue}throw G(A)}return w.filename=null,{package:R,imports:E,weakImports:T,syntax:_,root:O}}return dc}function _c(){if(hc)return ga.exports;hc=1;var e=ga.exports=function(){if(cc)return pa.exports;cc=1;var e=pa.exports=vn();return e.build="light",e.load=function(t,n,r){return"function"==typeof n?(r=n,n=new e.Root):n||(n=new e.Root),n.load(t,r)},e.loadSync=function(t,n){return n||(n=new e.Root),n.loadSync(t)},e.encoder=Rc(),e.decoder=Ha(),e.verifier=za(),e.converter=Ja(),e.ReflectionObject=Oc(),e.Namespace=xa(),e.Root=wc(),e.Enum=Sc(),e.Type=Cc(),e.Field=Ba(),e.OneOf=Fa(),e.MapField=Ga(),e.Service=Va(),e.Method=qa(),e.Message=Ka(),e.wrappers=bc(),e.types=ja(),e.util=Ic(),e.ReflectionObject._configure(e.Root),e.Namespace._configure(e.Type,e.Service,e.Enum),e.Root._configure(e.Type),e.Field._configure(e.Type),pa.exports}();return e.build="full",e.tokenize=Ec(),e.parse=Tc(),e.common=function(){if(fc)return pc;fc=1,pc=n;var e,t=/\/|\./;function n(e,r){t.test(e)||(e="google/protobuf/"+e+".proto",r={nested:{google:{nested:{protobuf:{nested:r}}}}}),n[e]=r}return n("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),n("duration",{Duration:e={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),n("timestamp",{Timestamp:e}),n("empty",{Empty:{fields:{}}}),n("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}}}}),n("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}}}}),n("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),n.get=function(e){return n[e]||null},pc}(),e.Root._configure(e.Type,e.parse,e.common),ga.exports}var Ac=f(mc?yc:(mc=1,yc=_c()));const kc=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},Mc=e=>{const t=e.name;return ut(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},Pc=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},Nc=e=>{const t=e.match(/data:([^;]+)/)[1],n=e.replace(/^[^,]+,/,""),r=window.atob(n);let s=r.length;const o=new Uint8Array(r.length);for(;s--;)o[s]=r.charCodeAt(s);return new Blob([o],{type:t})},Lc=1680,Dc=160,Uc=e=>new Promise((t,n)=>{const r=e=>{0!==e.width||0!==e.height?t(e):n()},s=new Image;if(s.addEventListener("load",e=>r(e.target)),s.addEventListener("error",n),s.src=e,s.complete)return void r(s);const o=setInterval(()=>{s.complete&&(r(s),clearInterval(o))},40)}),jc=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),s=function(e,t,n){let r=e,s=t,o=0,i=0;const a=e*t,c=n.maxWidth*n.maxHeight;if(a<=c)return o=(n.maxWidth-r)/2,i=(n.maxHeight-s)/2,{w:r,h:s,x:o,y:i};const l=Math.sqrt(c/a);return r=e*l,s=t*l,o=(n.maxWidth-r)/2,i=(n.maxHeight-s)/2,{w:r,h:s,x:o,y:i}}(e.width,e.height,t);n.width=s.w,n.height=s.h,r.fillStyle="#FFFFFF",r.fillRect(0,0,n.width,n.height),r?.drawImage(e,0,0,s.w,s.h);try{let e=n.toDataURL("image/jpeg",t.quality);return Nc(e)}catch(e){throw new Error(e)}};function Bc(e){const t=Math.max(0,e),n=t%60,r=Math.floor(t/60%60),s=Math.floor(t/3600);return s>0?`${s}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r}:${n.toString().padStart(2,"0")}`}const Fc={maxHeight:500,maxWidth:500,quality:.6,scale:2.4};class xc{async create(e,t){try{const n=kc(e),r=await Uc(n);let s,o,i;if(Pc(n),t?.full)s=e,o=r.width,i=r.height;else{const t=((e,t=1,n="image/jpeg")=>{t=Math.min(1,t);const r=e.width,s=e.height;let o=r,i=s;if(t<1){const e=r<s,t=e?s/Lc:r/Lc;r>Lc&&s>Lc?e?(i=Lc,o/=t):(o=Lc,i/=t):r>Lc&&s>Dc?(o=Lc,i/=t,i<Dc&&(i=Dc,o=r/(s/Dc))):s>Lc&&r>Dc&&(i=Lc,o/=t,o<Dc&&(o=Dc,i=s/(r/Dc)))}o=Math.floor(o),i=Math.floor(i);const a=document.createElement("canvas");a.width=o,a.height=i;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,o,i),c.drawImage(e,0,0,r,s,0,0,o,i),n&&"image/png"!=n||(n="image/jpeg"),{imageFile:Nc(a.toDataURL(n,Math.min(.92,t))),compressWidth:o,compressHeight:i}})(r,.85,e.type);s=t.imageFile,o=t.compressWidth,i=t.compressHeight}const a=jc(r,Fc);return{success:!0,message:new mi({thumbnailObjectKey:kc(a),originalObjectKey:kc(s),width:o,height:i}),files:[a,s]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r,s],encryptedKey:o}=t;return n.originalObjectKey=s,n.thumbnailObjectKey=r,n.encryptKey=o,n}}class Gc{async create(e){if(e.size>2097152)return{success:!1};try{const t=kc(e),n=await Uc(t);return{success:!0,message:new vi({originalObjectKey:t,extension:Mc(e),width:n.width,height:n.height}),files:[e]}}catch{return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.originalObjectKey=r,n.encryptKey=s,n}}let qc;class Vc{create(e){return(t=e,gt(t.arrayBuffer)?t.arrayBuffer():new Promise((e,n)=>{const r=new FileReader;r.addEventListener("load",t=>{t.target?e(t.target.result):n("null")}),r.addEventListener("error",e=>n(e)),r.readAsArrayBuffer(t)})).then(this.getAudioInfo).then(t=>({success:!0,message:new bi({audioObjectKey:kc(e),length:Math.round(1e3*t.duration),extension:Mc(e)}),files:[e]})).catch(()=>({success:!1}));var t}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.audioObjectKey=r,n.encryptKey=s,n}getAudioInfo(e){const t=qc||new AudioContext;return qc=t,new Promise((n,r)=>{t.decodeAudioData(e,function(e){n({duration:e.duration,length:e.length})},r)})}}class Kc{async create(e){return e.size>104857600?{success:!1}:{success:!0,message:new Ci({fileKey:"",title:e.name,extension:Mc(e),size:e.size}),files:[e]}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r],encryptedKey:s}=t;return n.fileKey=r,n.encryptKey=s,n}}class Hc{async create(e){try{if(e.size>104857600)return{success:!1};const t=kc(e),n=document.createElement("video");n.src=t,await new Promise((e,t)=>{n.onloadedmetadata=e,n.onerror=t}),n.currentTime=.001,await new Promise(e=>{n.onseeked=e});const r=n.duration,s=n.videoWidth,o=n.videoHeight,i=Math.min(Fc.maxWidth/s,Fc.maxHeight/o,Fc.scale),a=Math.floor(s*i),c=Math.floor(o*i),l=document.createElement("canvas");l.width=a,l.height=c;const u=l.getContext("2d");u?.drawImage(n,0,0,a,c);const d=await new Promise(e=>{l.toBlob(t=>e(t),"image/jpeg",Fc.quality)});return Pc(t),{success:!0,message:new wi({videoObjectKey:"",thumbnailObjectKey:"",during:Bc(r),width:s,height:o,extension:Mc(e)}),files:[e,d]}}catch(e){return{success:!1}}}updateMessageRemoteUrlProperty(e,t){let n=lo(e);const{urls:[r,s],encryptedKey:o}=t;return n.videoObjectKey=r,n.thumbnailObjectKey=s,n.encryptKey=o,n}}var zc;!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"}(zc||(zc={}));async function $c(e,n,r){try{return ul(e,n,r,await nl(n))}catch{return{code:t.UPLOAD_FILE_FAILED}}}const Wc=new Set([ro.TEXT,ro.IMAGE,ro.GIF,ro.VIDEO,ro.FILE,ro.AUDIO,ro.LOCATION,ro.CHAT_RECORD,ro.CONTACT,ro.GROUP_INVITATION,ro.LINK]),Jc=new Set(Wc);function Zc(e,t){const n=[],r=(e,r)=>{let s=t;for(const t of e)s=s?.[t];"string"==typeof s&&s.length>0&&n.push({path:e,sourceUrl:s,encryptKey:r})},s="string"==typeof t.encryptKey?t.encryptKey:void 0;switch(e){case ro.TEXT:{const e=t.linkPreview;e&&"object"==typeof e&&r(["linkPreview","originalObjectKey"],"string"==typeof e.encryptKey?e.encryptKey:void 0);break}case ro.IMAGE:r(["thumbnailObjectKey"],s),r(["originalObjectKey"],s);break;case ro.GIF:r(["originalObjectKey"],s);break;case ro.VIDEO:r(["thumbnailObjectKey"],s),r(["videoObjectKey"],s);break;case ro.FILE:r(["fileKey"],s),r(["thumbnailObjectKey"],s);break;case ro.AUDIO:r(["audioObjectKey"],s);break;case ro.LOCATION:r(["thumbnailObjectKey"],s);break;case ro.CHAT_RECORD:r(["msgDataFileKey"],s)}return n}function Xc(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){const n=t[e];if(!n||!r[n]||"object"!=typeof r[n])throw new Error("Invalid forwarded resource path");r=r[n]}const s=t[t.length-1];if(!s)throw new Error("Invalid forwarded resource field");r[s]=n}function Yc(e,t){const n=Et.getUploader();if(!n?.copy)return Promise.resolve({finished:!1,message:t});const r=n.copy.bind(n);return new Promise(n=>{try{r(e,{onError:()=>n({finished:!1,message:t}),onCompleted:()=>n({finished:!0,message:t})})}catch(e){n({finished:!1,message:t})}})}function Qc(e){const t=Js(e.messageType,e.content);if(!t)return;const n=e.messageType===ro.TEXT?t.content.content:void 0;return{senderNickname:e.senderNickname,...e.senderAvatar?{senderAvatar:e.senderAvatar}:{},msgId:e.messageUId,srcId:e.senderUserId,destId:e.targetId,mediaConstructor:e.messageType,mediaAttribute:JSON.stringify(t.content),...void 0!==n?{msgPostContent:n}:{},msgSendTime:e.sentTime}}async function el(e,n,r){if(!Wc.has(n.messageType))return{code:t.NOT_SUPPORT};const s=lo(n.content??{});delete s.mentionedInfo;const o=Zc(n.messageType,s);let i;if(o.length>0){const r=Et.getUploader();if(!r?.prepareCopy||!r.copy)return{code:t.NOT_SUPPORT};try{i=await r.prepareCopy({sourceConversation:{conversationType:n.conversationType,targetId:n.targetId},targetConversation:e,items:o.map(e=>({sourceUrl:e.sourceUrl,...e.encryptKey?{encryptKey:e.encryptKey}:{}}))})}catch{return{code:t.UPLOAD_FILE_FAILED}}if(i.items.length!==o.length)return{code:t.UPLOAD_FILE_FAILED};for(let e=0;e<o.length;e++){const n=o[e],r=i.items[e];if(!n||!r?.url)return{code:t.UPLOAD_FILE_FAILED};Xc(s,n.path,r.url)}}const a=Js(n.messageType,s);if(!a)return{code:t.NOT_SUPPORT};const c=i;return ul(e,a,r,c?{task:e=>Yc(c,e)}:void 0)}async function tl(e,n,r,s){if(!n.length||!r)return{code:t.PARAMETER_ERROR};if(n.some(e=>!Jc.has(e.messageType)))return{code:t.NOT_SUPPORT};const o=n[0];if(!o||n.some(e=>e.conversationType!==o.conversationType||e.targetId!==o.targetId))return{code:t.PARAMETER_ERROR};const i=n.map(e=>({...e,content:lo(e.content??{})}));for(const e of i)delete e.content.mentionedInfo;const a=[];for(const e of i)for(const t of Zc(e.messageType,e.content))a.push({content:e.content,binding:t});const c=Et.getUploader();if(!c)return{code:t.NOT_SUPPORT};let l;if(a.length){if(!c.prepareCopy||!c.copy)return{code:t.NOT_SUPPORT};try{l=await c.prepareCopy({sourceConversation:{conversationType:o.conversationType,targetId:o.targetId},targetConversation:e,items:a.map(({binding:e})=>({sourceUrl:e.sourceUrl,...e.encryptKey?{encryptKey:e.encryptKey}:{}}))})}catch(e){return{code:t.UPLOAD_FILE_FAILED}}if(l.items.length!==a.length)return{code:t.UPLOAD_FILE_FAILED};for(let e=0;e<a.length;e++){const n=a[e],r=l.items[e];if(!n||!r?.url)return{code:t.UPLOAD_FILE_FAILED};Xc(n.content,n.binding.path,r.url)}}const u=i.map(Qc);if(u.some(e=>!e))return{code:t.NOT_SUPPORT};const d=u;let g;try{g=await c.prepare([new Blob([JSON.stringify(d)],{type:"application/json"})])}catch(e){return{code:t.UPLOAD_FILE_FAILED}}const p=g.items[0];if(1!==g.items.length||!p?.url)return{code:t.UPLOAD_FILE_FAILED};const f={chatTitle:r,msgDataFileKey:p.url,encryptKey:g.encryptKey,msgList:d.slice(0,4).map(e=>({srcId:e.srcId,senderNickname:e.senderNickname,mediaConstructor:e.mediaConstructor,...void 0!==e.msgPostContent?{msgPostContent:e.msgPostContent}:{},...void 0!==e.mediaAttribute?{mediaAttribute:e.mediaAttribute}:{}}))},h=new Oi(f),y=l;return ul(e,h,s,{uploadItems:g,task:async e=>{if(y){const t=await Yc(y,e);if(!t.finished)return t}return function(e,t,n){return new Promise(r=>{try{e.upload(t,{onError:()=>r({finished:!1,message:n}),onCompleted:()=>r({finished:!0,message:n})})}catch(e){r({finished:!1,message:n})}})}(c,g,e)}})}async function nl(e){if(e.messageType!==ro.TEXT)return;const t=e.content,n=t.linkPreview;if(!n?.image)return;if(!(n.image instanceof Blob))throw new Error("Link preview image must be a Blob");const r=Et.getUploader();if(!r)throw new Error("Uploader is not configured");const s=await r.prepare([n.image]),o=s.items[0];if(!o)throw new Error("Link preview image upload was not prepared");const i={...n};return delete i.image,i.originalObjectKey=o.url,i.encryptKey=s.encryptKey,e.content={...t,linkPreview:i},{uploadItems:s,task:e=>new Promise(t=>{r.upload(s,{onError:()=>t({finished:!1,message:e}),onCompleted:()=>t({finished:!0,message:e})})})}}const rl=cl.bind(null,zc.IMAGE),sl=cl.bind(null,zc.GIF),ol=cl.bind(null,zc.AUDIO),il=cl.bind(null,zc.SIGHT),al=cl.bind(null,zc.FILE);async function cl(e,n,r,s,o){const i=(e=>{let t;switch(e){case zc.IMAGE:t=new xc;break;case zc.AUDIO:t=new Vc;break;case zc.GIF:t=new Gc;break;case zc.FILE:t=new Kc;break;case zc.SIGHT:t=new Hc}return t})(e);if(!i)return{code:t.NOT_SUPPORT};const{success:a,message:c,files:l}=await i.create(r.file,o);if(!a||!c||!l)return{code:t.MEDIA_EXCEPTION};c.content.user=r.user,c.content.extra=r.extra;const u=Et.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}),ul(n,c,o,{uploadItems:e,task:t=>new Promise(n=>{u.upload(e,{onProgress:e=>s?.onProgress?.(e),onError:()=>{n({finished:!1,message:t})},onCompleted:e=>{n({finished:!0,message:s?.onComplete?.(e)??t})}})})})}catch(e){return{code:t.UPLOAD_FILE_FAILED}}}const ll=async(e,n,s)=>{let o;try{o=await nl(e)}catch{return{code:t.UPLOAD_FILE_FAILED}}const c=await dl({conversationType:n.conversationType,targetId:n.targetId},e,n,s,o?.uploadItems);if(c.code!==t.SUCCESS||!c.message||!c.sentArgs)return{code:c.code};const l=wo(c.message,c.sentArgs);if(l.quotedReply=n,await hl(l,c.sentArgs),o){const n=await o.task(e);if(!n.finished)return gl(l,t.UPLOAD_FILE_FAILED),await hl(l,c.sentArgs),{code:t.UPLOAD_FILE_FAILED,data:l};e=n.message}const u=ts(n),d=await Zs.getDialogAesKey(u.toString());if(!d)return gl(l,t.MSG_ENCRYPT_ERROR),await hl(l,c.sentArgs),{code:t.MSG_ENCRYPT_ERROR,data:l};let g,p,f,h;if(e.messageType===ro.TEXT){let t=lo(e.content),n=t.content;delete t.content,g=eo(n,d),p=JSON.stringify(ft(t))}else p=JSON.stringify(ft(e.content));const y=eo(p,d);if(n){if(n.messageType===ro.TEXT){let e=lo(n.content),t=e.content;delete e.content,f=eo(t,d),h=JSON.stringify(ft(e))}else h=JSON.stringify(ft(n.content));h=eo(h,d)}Ks.addMessage(c.sentArgs.messageId);const m={localId:Ln.fromNumber(c.sentArgs.messageId),mediaFlag:e.messageType!==ro.TEXT,mediaConstructor:e.messageType,msgPreContent:"",msgPostContent:g,mediaAttribute:y,msgIdReferenced:Ln.fromString(n.messageUId),msgSrcIdReferenced:Ln.fromString(n.senderUserId),msgDestIdReferenced:n.messageDirection==i.RECEIVE?Ln.fromString(sr.uid):Ln.fromString(n.targetId),msgPostContentReferenced:f,mediaFlagReferenced:n.messageType!==ro.TEXT,mediaConstructorReferenced:n.messageType,mediaAttributeReferenced:h,msgSendTimeReferenced:Ln.fromString(n.sentTime)};let v;if(n.conversationType===r.GROUP){const t={...m,groupId:Ln.fromString(u)};if(nt(e.content.mentionedInfo)){const n=e.content.mentionedInfo;n.userList?.length&&(t.at=n.userList.map(e=>Ln.fromString(e.uin)),t.msgPreContent=JSON.stringify({atInfo:JSON.stringify(n.userList)}))}v=await Is(t)}else{const e={...m,destId:Ln.fromString(u)};v=await Cs(e)}const b=lo(l);return v.code===t.SUCCESS?(b.sentTime=v.data.msgSendTime.toString(),b.messageUId=v.data.msgId.toString(),b.sentStatus=a.SENT,await hl(b,c.sentArgs)):(gl(b,v.code),await hl(b,c.sentArgs)),{code:v.code,data:b}};async function ul(e,n,s,o){const i=await dl(e,n,null,s,o?.uploadItems);if(i.code!==t.SUCCESS||!i.message||!i.sentArgs)return{code:i.code};{const e=wo(i.message,i.sentArgs);await hl(e,i.sentArgs)}let{message:c,sentArgs:l}=i;if(nt(o)){const e=await o.task(c);if(c=e.message,!e.finished){const e=wo(i.message,i.sentArgs,a.FAILED);return gl(e,t.UPLOAD_FILE_FAILED),await hl(e,l),{code:t.UPLOAD_FILE_FAILED,data:e}}}return async function(e,n){const s=ts(n.conversation),o=wo(e,n),i=await Zs.getDialogAesKey(s.toString());if(!i)return gl(o,t.MSG_ENCRYPT_ERROR),await hl(o,n),{code:t.MSG_ENCRYPT_ERROR,data:o};let c,l;if(e.messageType===ro.TEXT){let t=lo(e.content),n=t.content;delete t.content,c=eo(n,i),l=JSON.stringify(ft(t))}else l=JSON.stringify(ft(e.content));const u=eo(l,i);Ks.addMessage(n.messageId);const d={localId:Ln.fromNumber(n.messageId),mediaFlag:e.messageType!==ro.TEXT,mediaConstructor:e.messageType,msgPreContent:"",msgPostContent:c,mediaAttribute:u};let g;if(n.conversation.conversationType===r.GROUP){const t={...d,groupId:Ln.fromString(s)};if(nt(e.content.mentionedInfo)){const n=e.content.mentionedInfo;n.userList?.length&&(t.at=n.userList.map(e=>Ln.fromString(e.uin)),t.msgPreContent=JSON.stringify({atInfo:JSON.stringify(n.userList)}))}g=await ws(t)}else{const e={...d,destId:Ln.fromString(s)};g=await bs(e)}g.code===t.SUCCESS?(o.sentTime=g.data.msgSendTime.toString(),o.messageUId=g.data.msgId.toString(),o.sentStatus=a.SENT,await hl(o,n)):(gl(o,g.code),await hl(o,n));return{code:g.code,data:o}}(c,l)}async function dl(e,n,r,s,o){if(((e,t="utf-8")=>{let n=0;if("utf-16"===t)for(let t=0,r=e.length;t<r;t++)n+=e.charCodeAt(t)<=65535?2:4;else for(let t=0,r=e.length;t<r;t++){const r=e.charCodeAt(t);n+=r<127?1:r<=2047?2:r<=65535?3:4}return n})(JSON.stringify(ft(n.content)))>81920)return{code:t.RC_MSG_CONTENT_EXCEED_LIMIT};n.isPersited&&await Co.get().loadConvsationsIfNotExist([e]);const i={conversation:e,senderUserId:sr.uid,messageId:Go(),sentTime:fl().toString(),pushConfig:s?.pushConfig};if(s?.onSendBefore){const e=wo(n,i);r&&(e.quotedReply=r),s.onSendBefore(e,o)}return{code:t.SUCCESS,message:n,sentArgs:i}}function gl(e,t){e.sentStatus=a.FAILED,e.sendErrorCode=t}let pl=1;function fl(){pl++;const e=qs();return pl<e&&(pl=e),pl}async function hl(e,t){try{const n=ei.get();if(e.isPersited&&n){await n.upsertMessage(e);const r=await n.getLatestMessage(t.conversation);let s=e;r&&Ln.fromString(r.sentTime).greaterThan(Ln.fromString(e.sentTime))&&(s=r),Co.get().updateLatestMessage(t.conversation,s)}}catch(e){Xi.error("saveSentMessage -> ",e)}}class yl extends fo{options;static imClient;libLoader;constructor(e){if(yl.imClient)return Xi.warn("Please do not perform the init method repeatedly"),yl.imClient;super(),this.options=e,this.fixedProtobuf(),nt(e.logLevel)&&Xi.setLogLevel(e.logLevel),nt(e.logStdout)&&Xi.setLogStdout(e.logStdout),Xi.debug("IMClient.init -> "),nt(e.uploader)&&Et.setUploader(e.uploader),Et.setDeviceCode(e.deviceCode),Et.setDeviceType(e.deviceType),this.libLoader=Ki.init(e),this.watch(),yl.imClient=this}fixedProtobuf(){Ac.util.Long=Ln,Ac.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(d.CONNECTING)},onConnected:()=>{this.emit(d.CONNECTED)},onDisconnect:()=>{this.emit(d.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(d.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:e=>{this.emit(d.MESSAGES,{messages:e})},pullFinished:()=>{this.emit(d.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:e=>{this.emit(d.CONVERSATION,{conversations:e})},onPush:(e,t)=>{this.emit(d.PUSH,{cmdId:e,body:t})},onRecall:e=>{e.forEach(e=>{this.emit(d.RECALL,e)})},onReceiptReceived:async(e,t)=>{try{await(ei.get()?.updateMessageReceiptStatus(e,t))}catch(e){Xi.error("updateMessageReceiptStatus -> ",e)}0===t?this.emit(d.ARRIVAL_RECEIPT_RECEIVED,e):this.emit(d.READ_RECEIPT_RECEIVED,e)},onMessagePinnedChanged:e=>{this.emit(d.MESSAGE_PINNED_CHANGED,e)},onMessageReactionsChanged:e=>{this.emit(d.MESSAGE_REACTIONS_CHANGED,e)},onDialogFilterConfig:e=>{this.emit(d.DIALOG_FILTER_CONFIG,e)}})}connect(){return this.libLoader.connect()}disconnect(){return this.libLoader.disconnect()}setUserLogged(e){return e.uid!==sr.uid.toString()?(sr.setLogged(e),this.libLoader.setUserLogged()):Promise.resolve()}async logOut(){sr.logOut(),await this.libLoader.setUserLogout()}async deleteLocalDatabase(e){await this.logOut();const t=new Yo(this.options.appkey,e);await t.deleteDatabase()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}getServerTime=qs;async insertMessage(e,n,r){(!n.messageId||n.messageId>Vo())&&(n.messageId=Go(),n.messageUId="local_"+n.messageId),Co.get().setConversationCacheByMessage(n);try{const e=ei.get();if(n.isPersited&&e){await e.upsertMessage(n);const t=await e.getLatestMessage(n);let r=n;t&&Ln.fromString(t.sentTime).greaterThan(Ln.fromString(n.sentTime))&&(r=t),Co.get().updateLatestMessage(n,r)}}catch(e){Xi.error("insertMessage -> ",e)}return{code:t.SUCCESS,data:n}}sendMessage=$c;forwardMessage=el;mergeForwardMessages=tl;sendImageMessage=rl;sendGIFMessage=sl;sendHQVoiceMessage=ol;sendFileMessage=al;sendSightMessage=il;async recallMsg(e,n){return await(async(e,n)=>{const r=ts(e);zs.addMessage(n.messageUId);const s=await Ss(r,n.messageUId);if(s.code!==t.SUCCESS)return{code:s.code};const o=new Vi({messageUId:n.messageUId}),i={conversation:e,senderUserId:sr.uid,messageId:0,sentTime:qs().toString()},c=wo(o,i,a.SENT);c.burnAfterReadingFlag=!1,c.burnAfterReadingTime=0,Co.get().setConversationCacheByMessage(c);const l=ei.get();return l&&(await l.convertToRecallMessages([n.messageUId]),Co.get().updateLatestMessage(e,await l.getLatestMessage(e))),{code:t.SUCCESS,data:c}})(e,n)}async commentMsg(e,r){const{code:s}=await Rs(ts(e),r.messageUId,r.content);if(s!==t.SUCCESS)return{code:s,msg:n(s)};const o=await this.getMessageByUId(r.messageUId);if(!o)return Xi.warn("commentMsg: target message not found",r.messageUId),{code:t.SUCCESS};const i={uid:sr.uid,msgId:r.messageUId,content:r.content,nickname:r.nickname??"",time:qs()},a=ni(o.reactions,i);return await(ei.get()?.setMessageReactions(e,r.messageUId,a))?(o.reactions=a,this.emit(d.MESSAGE_REACTIONS_CHANGED,{conversation:e,messageUId:r.messageUId,reactions:a,change:i}),{code:t.SUCCESS,data:{reactions:a}}):(Xi.warn("commentMsg: failed to persist reactions",r.messageUId),{code:t.SUCCESS})}sendQuoteReplyMessage=ll;async getRemoteHistoryMessages(e,r){const s=r.timestamp??"0",o=r.count??20,i=ts(e);return Ts({dialogId:i,offset:s,count:o,newToOld:0===r.order}).then(({code:e,data:r})=>new Promise(r=>{e===t.SUCCESS?r({code:t.SUCCESS,data:{list:[],hasMore:!1}}):r({code:e,msg:n(e)})}))}async getPreviousHistoryMessages(e,n,r=20){const s=await ei.get().getPreviousMessages(e,n??"0",r);if(!n&&s.messages.length&&Co.get().updateLatestMessage(e,s.messages[s.messages.length-1]),s.messages.length>=r||!s.hasMore)return{code:t.SUCCESS,data:{list:s.messages,hasMore:s.hasMore}};const o=s.messages[0]?.sentTime??n,i=await this.getRemoteHistoryMessages(e,{timestamp:o,count:r-s.messages.length,order:0});if(i.code!==t.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>Vo())&&(t.messageId=qo())}o&&"0"!=o||Co.get().updateLatestMessage(e,a[a.length-1]),await ei.get().addMessages(a,e,!i.data.hasMore);const c=await ei.get().getPreviousMessages(e,n??"0",r);return!n&&c.messages.length&&Co.get().updateLatestMessage(e,c.messages[c.messages.length-1]),{code:t.SUCCESS,data:{list:c.messages,hasMore:c.hasMore}}}async getHistoryMessages(e,n){const r=n.timestamp??"0",s=n.count??20,o=await ei.get().getMessages(e,r,s,0===n.order);return{code:t.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}}}async getMessagesByType(e,n,r){const s=ei.get();if(!s)return{code:t.SUCCESS,data:{list:[],hasMore:!1}};const o=await s.getMessagesByType(e,n,r.timestamp??"0",r.count??50,1!==r.order);return{code:t.SUCCESS,data:{list:o.messages,hasMore:o.hasMore}}}async setMessagePinned(e,n,r,s="everyone"){if(r&&"me"===s)return await(ei.get()?.setMessagePinned(e,n,!0)),this.emit(d.MESSAGE_PINNED_CHANGED,{conversation:e,messageUId:n,operation:g.PIN}),t.SUCCESS;const o=r?g.PIN:g.UNPIN;return(await Es(ts(e),n,o)).code}async unpinAllMessages(e){return(await Es(ts(e),"0",g.UNPIN_ALL)).code}async getPinnedMessages(e,n=50){const r=await(ei.get()?.getPinnedMessages(e,n))??[];return{code:t.SUCCESS,data:r}}async deleteRemoteMessage(e,n){const r=await _s(ts(e),n.map(e=>e.messageUId)).then(e=>e.code);if(r===t.SUCCESS){const t=await(ei.get()?.getLatestMessage(e));if(await(ei.get()?.removeMessagesByUId(n.map(e=>e.messageUId))),t&&n.some(e=>e.messageUId===t.messageUId)){const t=await(ei.get()?.getLatestMessage(e));Co.get().updateLatestMessage(e,t)}}return r}async deleteLocalMessages(e,n){const r=ei.get();if(!r||0===n.length)return t.SUCCESS;const s=await r.getLatestMessage(e);return await r.removeMessagesByUId(n),s&&n.includes(s.messageUId)&&Co.get().updateLatestMessage(e,await r.getLatestMessage(e)),t.SUCCESS}async deleteHistoryMessages(e){return await(ei.get()?.clearConversationCache(e)),Co.get().clearHistoryMessages(e),As(ts(e)).then(e=>e.code)}async getConversationList(e,n,r,s){const o={rows:e,type:n??0,offset:Ln.fromNumber(r),newToOld:0===s},{code:i,data:a}=await ks(o);if(i!==t.SUCCESS)return{code:i};const c=a.fullDialog.map(e=>e.dialog?.destId).filter(nt);await Zs.getDialogAesKeyList(c.map(e=>e.toString()));let l=1e4;const u=[];for(const e of a.fullDialog){const t=this.formatConversation(e);t&&u.push(t)}const d=await(ei.get()?.getLatestMessages(u))??{},g=[];for(const e of u){const t={conversationType:e.conversationType,targetId:e.targetId},n=e.latestMessage;e.latestMessage=d[ts(t)];const r=Co.get().get(t);if(r){const{unreadMessageCount:t,hasMentioned:n,lastUnreadTime:s,updateTime:o}=r;t&&(e.unreadMessageCount=t),n&&(e.hasMentioned=n),s&&(e.lastUnreadTime=s),o&&(e.updateTime=o)}nt(e.latestMessage)&&!e.updateTime&&(e.updateTime=parseInt(e.latestMessage.sentTime)),e.updateTime||(n?e.updateTime=parseInt(n.sentTime):(e.updateTime=l,l++)),Co.get().addLocalConversation(e),g.push(e)}return g.sort((e,t)=>(e.updateTime??0)-(t.updateTime??0)),{code:t.SUCCESS,data:g}}getBlockConversationList(){const e=Co.get().getBlockConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}getTopConversationList(){const e=Co.get().getTopConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}async getConversation(e){const n=Co.get().get(e);if(!n)return{code:t.CONVER_GET_ERROR};const r=await(ei.get()?.getLatestMessage(e)),s=nt(r?.sentTime)?parseInt(r.sentTime):0,o=Math.max(n.updateTime??0,s),i={...e,...n,updateTime:o||void 0,latestMessage:r};return{code:t.SUCCESS,data:i}}removeConversation(e){return Co.get().remove(e),Ds(ts(e)).then(e=>e.code)}getUnreadMentionedCount(e){return Co.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return Co.get().getAllUnreadMentionedCount()}getConversationState(e){return Co.get().getConversationState(e)}getAllConversationState(){return Co.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return Co.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return Co.get().getUnreadCount(e)}clearConversationUnreadCount(e){Co.get().getUnreadCount(e)>0&&Fs(e.targetId),Co.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){Co.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return Co.get().getNotificationLevel(e)}setConversationNotificationStatus(e,t){return Ps(ts(e),t===o.OPEN).then(n=>(!n.code&&Co.get().addStatus({...e,notificationStatus:t,notificationLevel:t==o.OPEN?l.AT_USER_NOTIFICATION:l.NOT_SET},!0),n.code))}getConversationNotificationStatus(e){return Co.get().getNotificationStatus(e)}setConversationToTop(e,t){return Ns(ts(e),t).then(n=>(!n.code&&Co.get().addStatus({...e,isTop:t},!0),n.code))}setConversationBurnAfterReading(e,t,n){return Ls(ts(e),t,t?n:0).then(r=>(!r.code&&Co.get().addStatus({...e,burnAfterReadingFlag:t,burnAfterReadingTime:t?n:null},!0),r.code))}saveConversationMessageDraft(e,t){Co.get().setDraft(e,t)}getConversationMessageDraft(e){return Co.get().getDraft(e)}clearConversationMessageDraft(e){Co.get().clearDraft(e)}async sendReadReceipts(e,t=Date.now()){await(ei.get()?.markMessagesRead(e.map(e=>e.messageUId),t));for(const n of e)(n.receivedStatus??c.IDLE)<c.READ&&(n.receivedStatus=c.READ),n.messageDirection===i.RECEIVE&&n.burnAfterReadingFlag&&null==n.burnAfterReadingStartedAt&&(n.burnAfterReadingStartedAt=t);await(jo.get()?.sendReadReceipts(e))}formatConversation(e){const{dialog:t,msg:n}=e,r=t.destId;if(!nt(r))return;const s=po(t);if(!s)return;const o=Zs.getDialogAesKeyFromLocal(r.toString());if(o){if(nt(n)){const e=No.parseSingleDialogMessages(r.toString(),[n],o,{})[0];s.latestMessage=e}return s}}async clearBurnAfterReadingExpiredMessages(e){const t=ei.get();if(!t)return Promise.resolve([]);const n=await t.clearBurnAfterReadingExpiredMessages(e);return n.length>0&&Co.get().updateLatestMessage(e,await t.getLatestMessage(e)),n}async getMessageById(e){return ei.get()?.getMessageById(e)}async getMessageByUId(e){return ei.get()?.getMessageByUId(e)}async updateMessage(e){const t=ei.get();if(!t)throw new Error("Message database is not initialized for a logged-in user");if(!e.isPersited)throw new Error("Cannot update a non-persisted message");if(!(e.messageUId?await t.getMessageByUId(e.messageUId):await t.getMessageById(e.messageId)))throw new Error(`Cannot update missing message ${e.messageUId||e.messageId}`);await t.upsertMessage(e);const n=await t.getLatestMessage(e);return Co.get().updateLatestMessage(e,n),e}async searchTextMessages(e,t){const n=ei.get();return n?n.searchTextMessages(e,t):Promise.resolve([])}async searchMessages(e,t=500){const n=ei.get();return n?n.searchMessages(e,t):Promise.resolve([])}}const ml=bn.Reader,vl=bn.Writer,bl=bn.util,Cl=bn.roots.default||(bn.roots.default={}),wl=Cl.AuthSignIn2Req=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}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=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.AuthSignIn2Req;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.langCode=e.string();break;case 2:r.phoneNum=e.string();break;case 3:r.password=e.string();break;case 4:r.appVersionCode=e.int32();break;case 5:r.deviceType=e.int32();break;case 6:r.imei=e.string();break;case 7:r.brand=e.string();break;case 8:r.model=e.string();break;case 9:r.apnsToken=e.string();break;case 10:r.bandId=e.string();break;case 11:r.appVersion=e.string();break;case 12:r.osVersion=e.string();break;case 13:r.version=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Req"},e})(),Il=Cl.AuthSignIn2Resp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=bl.Long?bl.Long.fromBits(0,0,!1):0,e.prototype.sessionId=bl.Long?bl.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=vl.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")&&Cl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.AuthSignIn2Resp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.deviceId=e.int64();break;case 4:r.sessionId=e.int64();break;case 5:r.noNickName=e.bool();break;case 6:r.noEmail=e.bool();break;case 7:r.cert=e.string();break;case 9:r.userFileDomain=e.string();break;case 10:r.dialogFileDomain=e.string();break;case 11:r.user=Cl.User.decode(e,e.uint32());break;case 13:r.frozenDays=e.int32();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2Resp"},e})();Cl.User=(()=>{function e(e){if(this.aliasMobile=[],e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.uid=bl.Long?bl.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=bl.emptyArray,e.prototype.aliasDesp="",e.encode=function(e,t){if(t||(t=vl.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 n=0;n<e.aliasMobile.length;++n)t.uint32(106).string(e.aliasMobile[n]);return null!=e.aliasDesp&&Object.hasOwnProperty.call(e,"aliasDesp")&&t.uint32(114).string(e.aliasDesp),t},e.decode=function(e,t){e instanceof ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.User;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.uid=e.int64();break;case 2:r.nickName=e.string();break;case 3:r.langCode=e.string();break;case 4:r.phone=e.string();break;case 5:r.numberInPhoneBook=e.string();break;case 6:r.smallAvatarUrl=e.string();break;case 7:r.originalAvatarUrl=e.string();break;case 8:r.email=e.string();break;case 9:r.qrcodeString=e.string();break;case 10:r.gender=e.int32();break;case 11:r.contactStatus=e.int32();break;case 12:r.alias=e.string();break;case 13:r.aliasMobile&&r.aliasMobile.length||(r.aliasMobile=[]),r.aliasMobile.push(e.string());break;case 14:r.aliasDesp=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e})();const Ol=Cl.WebGetLoginCodeReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.account="",e.prototype.langCode="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.account=e.string();break;case 2:r.langCode=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeReq"},e})(),Sl=Cl.WebGetLoginCodeResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeResp"},e})(),Rl=Cl.WebGetLoginCodeVerifyReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.account="",e.prototype.langCode="",e.prototype.code="",e.encode=function(e,t){return t||(t=vl.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 ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.WebGetLoginCodeVerifyReq;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.account=e.string();break;case 2:r.langCode=e.string();break;case 3:r.code=e.string();break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebGetLoginCodeVerifyReq"},e})(),El=Cl.ClickOKToWebResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=bl.Long?bl.Long.fromBits(0,0,!1):0,e.prototype.sessionId=bl.Long?bl.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=vl.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")&&Cl.User.encode(e.user,t.uint32(90).fork()).ldelim(),t},e.decode=function(e,t){e instanceof ml||(e=ml.create(e));let n=void 0===t?e.len:e.pos+t,r=new Cl.ClickOKToWebResp;for(;e.pos<n;){let t=e.uint32();switch(t>>>3){case 1:r.errorCode=e.int32();break;case 2:r.errorMessage=e.string();break;case 3:r.deviceId=e.int64();break;case 4:r.sessionId=e.int64();break;case 5:r.noNickName=e.bool();break;case 6:r.noEmail=e.bool();break;case 7:r.cert=e.string();break;case 9:r.userFileDomain=e.string();break;case 10:r.dialogFileDomain=e.string();break;case 11:r.user=Cl.User.decode(e,e.uint32());break;default:e.skipType(7&t)}}return r},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/ClickOKToWebResp"},e})();let Tl;const _l=e=>{Tl=Tl||new yl(e)},Al=async e=>{const t=ei.get();if(!t)throw new Error("Message database is not initialized for a logged-in user");return t.migrateLegacyDatabase(e)},kl=async()=>{const e=ei.get();if(!e)throw new Error("Message database is not initialized for a logged-in user");return e.getLegacyMigrationInfo()},Ml=async(e=0,t=500)=>{const n=ei.get();if(!n)throw new Error("Message database is not initialized for a logged-in user");return n.getLegacyMediaReferences(e,t)},Pl=async()=>{const e=ei.get();if(!e)throw new Error("Message database is not initialized for a logged-in user");await e.deleteLegacyDatabase()},Nl=async()=>{const e=await Tl.connect();return e.code===t.SUCCESS?{code:e.code}:{code:e.code,msg:n(e.code)}},Ll=()=>Tl.disconnect(),Dl=e=>Tl.setUserLogged(e),Ul=()=>Tl.logOut(),jl=e=>Tl.deleteLocalDatabase(e),Bl=()=>Tl.getConnectionStatus(),Fl=(e,t,n,r=3e4)=>lr.request(e,t,n,r),xl=()=>Tl.getServerTime(),Gl=(e,t,n)=>{Tl.on(e,t,n)};function ql(e,t,n){Tl.once(e,t,n)}const Vl=(e,t,n)=>{Tl?.off(e,t,n)},Kl=()=>di,Hl=async e=>{Xi.debug("get conversation list ->");const{code:r,data:s}=await Tl.getConversationList(e?.count??20,null,e?.startTime??0,e?.order??0);return r!==t.SUCCESS&&Xi.warn("get conversation list fail ->"+r+":"+n(r)),{code:r,msg:n(r),data:s}},zl=async e=>{ia("options",e,sa,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get conversation ->"+r);const{code:s,data:o}=await Tl.getConversation(e);return s!==t.SUCCESS?(Xi.warn("get conversation fail ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:s,data:o}},$l=async e=>{ia("options",e,sa,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("remove conversation ->"+r);const s=await Tl.removeConversation(e);return s!==t.SUCCESS?(Xi.warn("remove conversation fail ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:s}},Wl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get draft ->"+n);const r=Tl.getConversationMessageDraft(e);return Promise.resolve({code:t.SUCCESS,data:r})},Jl=(e,n)=>{ia("options",e,sa,!0),ia("draft",n,Yi,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("set draft ->"+r),Tl.saveConversationMessageDraft(e,n),Promise.resolve({code:t.SUCCESS})},Zl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("delete draft ->"+n),Tl.clearConversationMessageDraft(e),Promise.resolve({code:t.SUCCESS})},Xl=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("get unreadMentionedCount ->"+n),Promise.resolve({code:t.SUCCESS,data:Tl.getUnreadMentionedCount(e)})},Yl=()=>{Xi.debug("getAllUnreadMentionedCount");const e=Tl.getAllUnreadMentionedCount();return Promise.resolve({code:t.SUCCESS,data:e})},Ql=e=>(Xi.debug("getConversationState"),Tl.getConversationState(e)),eu=()=>{Xi.debug("getAllConversationState");const e=Tl.getAllConversationState();return Promise.resolve({code:t.SUCCESS,data:e})},tu=(e,n)=>{if(Xi.debug("get total unread count -> ConversationType:"+JSON.stringify(n)+" includeMuted:"+e),ia("includeMuted",e,ea,!1),ia("conversationTypes",n,na,!1),n)for(const e of n)ia("conversationType",e,ra,!0);const r=Tl.getAllConversationUnreadCount(n??[],e??!1);return Promise.resolve({code:t.SUCCESS,data:r})},nu=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get unreadCount ->"+n);const r=Tl.getConversationUnreadCount(e);return Promise.resolve({code:t.SUCCESS,data:r})},ru=e=>{ia("options",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return Xi.debug("clear unreadMsgNum ->"+n),Tl.clearConversationUnreadCount(e),Promise.resolve({code:t.SUCCESS})},su=()=>(Xi.debug("clear allMessagesUnreadStatus"),Tl.clearAllConversationsUnreadCount(),Promise.resolve({code:t.SUCCESS})),ou=e=>{ia("options",e,sa,!0),Xi.info("getConversationNotificationLevel ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const n=Tl.getConversationNotificationLevel(e);return Promise.resolve({code:t.SUCCESS,data:n})},iu=async(e,r)=>{ia("options",e,sa,!0),ia("notificationStatus",r,e=>1===e||2===e,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("set conversation status ->"+s);const o=await Tl.setConversationNotificationStatus(e,r);return o!==t.SUCCESS?(Xi.warn("set conversation status fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:o}},au=e=>{ia("options",e,sa,!0),Xi.info("getConversationNotificationStatus ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const n=Tl.getConversationNotificationStatus(e);return Promise.resolve({code:t.SUCCESS,data:n})},cu=()=>Tl.getBlockConversationList(),lu=async(e,r=!0)=>{ia("options",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("set conversation status ->"+s);const o=await Tl.setConversationToTop(e,r);return o!==t.SUCCESS?(Xi.warn("set conversation status fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:o}},uu=async(e,r,s=0)=>{ia("conversation",e,sa,!0),ia("enabled",r,ea,!0),ia("burnAfterReadingTime",s,e=>Number.isSafeInteger(e)&&e>=0,!0);const o=await Tl.setConversationBurnAfterReading(e,r,r?s:0);return o!==t.SUCCESS?{code:o,msg:n(o)}:{code:t.SUCCESS}},du=()=>Tl.getTopConversationList(),gu=(e,t,n,r)=>{let s=function(s){return new fi(e,s,t,n,r)};return Ws(e,s),s},pu=async(e,t,n)=>Tl.insertMessage(e,t,n),fu=async(e,n,r)=>{if(n instanceof fi==!1)return Xi.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:t.PARAMETER_ERROR};ia("conversation",e,sa,!0),Fu(e);const s=await Tl.sendMessage(e,n,r);return xu(e,s.code),s},hu=async(e,t,n)=>{ia("conversation",e,sa,!0),ia("originalMessage",t,ta,!0),Fu(e);const r=await Tl.forwardMessage(e,t,n);return xu(e,r.code),r},yu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("originalMessages",t,na,!0),ia("chatTitle",n,Yi,!0),Fu(e);const s=await Tl.mergeForwardMessages(e,t,n,r);return xu(e,s.code),s},mu=(e,t,n)=>{const r=new yi(t);return fu(e,r,n)},vu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("image/"),!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendImageMessage(e,t,n,r);return xu(e,o.code),o},bu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.endsWith("image/gif"),!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendGIFMessage(e,t,n,r);return xu(e,o.code),o},Cu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob,!0),Fu(e);const s=await Tl.sendHQVoiceMessage(e,t,n,r);return xu(e,s.code),s},wu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+s),Fu(e);const o=await Tl.sendFileMessage(e,t,n,r);return xu(e,o.code),o},Iu=async(e,t,n,r)=>{ia("conversation",e,sa,!0),ia("uploader",Et.getUploader(),ta,!0),ia("msgBody.file",t.file,e=>e instanceof Blob&&e.type.startsWith("video/"),!0),Fu(e);const s=await Tl.sendSightMessage(e,t,n,r);return xu(e,s.code),s},Ou=async(e,r)=>{ia("options.messageUId",r.messageUId,Yi,!0),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+r.messageUId;Xi.debug("recall message ->"+s);const o=await Tl.recallMsg(e,r);return o.code!==t.SUCCESS&&Xi.warn("recall message fail ->"+o.code+":"+n(o.code)+","+s),o},Su=async(e,r)=>{ia("options.messageUId",r.messageUId,Yi,!0),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+r.messageUId;Xi.debug("comment message ->"+s);const o=await Tl.commentMsg(e,r);return o.code!==t.SUCCESS&&Xi.warn("comment message fail ->"+o.code+":"+n(o.code)+","+s),o},Ru=async(e,r)=>{ia("options.count",r.count??0,Qi),ia("options.order",r.order??0,e=>0===e||1===e),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;let o;return Xi.debug("get remote history message ->"+s),nt(r.timestamp)&&(r.timestamp=r.timestamp.toString()),o=r.order?await Tl.getHistoryMessages(e,r):await Tl.getPreviousHistoryMessages(e,r.timestamp,r.count),o.code!==t.SUCCESS&&Xi.warn("get remote history message fail ->"+o.code+":"+n(o.code)+","+s),o},Eu=async(e,r)=>{ia("options.count",r.count??0,Qi),ia("options.order",r.order??0,e=>0===e||1===e),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("get history messages ->"+s),nt(r.timestamp)&&(r.timestamp=r.timestamp.toString());let o=await Tl.getHistoryMessages(e,r);return o.code!==t.SUCCESS&&Xi.warn("get history message fail ->"+o.code+":"+n(o.code)+","+s),o},Tu=async(e,r,s,o="everyone")=>{ia("conversation",e,sa,!0),ia("messageUId",r,Yi,!0),ia("pinned",s,ea,!0),ia("scope",o,e=>"everyone"===e||"me"===e,!0);const i=await Tl.setMessagePinned(e,r,s,o);return i!==t.SUCCESS?{code:i,msg:n(i)}:{code:t.SUCCESS}},_u=async e=>{ia("conversation",e,sa,!0);const r=await Tl.unpinAllMessages(e);return r!==t.SUCCESS?{code:r,msg:n(r)}:{code:t.SUCCESS}},Au=async(e,t=50)=>(ia("conversation",e,sa,!0),ia("count",t,e=>Number.isInteger(e)&&e>0,!0),Tl.getPinnedMessages(e,t)),ku=async(e,r)=>{ia("messages",r,e=>ct(e)&&!!e.length,!0),r.forEach(e=>{ia("messages.messageUId",e.messageUId,Yi,!0),ia("messages.sentTime",e.sentTime,Qi,!1),ia("messages.messageDirection",e.messageDirection,e=>1===e||2===e,!1)}),ia("conversation",e,sa,!0);const s="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("delete messages ->"+s);const o=await Tl.deleteRemoteMessage(e,r);return o!==t.SUCCESS?(Xi.warn("delete message fail ->"+o+":"+n(o)+","+s),{code:o,msg:n(o)}):{code:t.SUCCESS}},Mu=async(e,t)=>(ia("conversation",e,sa,!0),ia("messageUIds",t,e=>ct(e)&&e.length>0,!0),t.forEach(e=>{ia("messageUIds.messageUId",e,Yi,!0)}),{code:await Tl.deleteLocalMessages(e,t)}),Pu=async e=>{ia("conversation",e,sa);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("clear message ->"+r);const s=await Tl.deleteHistoryMessages(e);return s!==t.SUCCESS?(Xi.warn("clear message ->"+s+":"+n(s)+","+r),{code:s,msg:n(s)}):{code:t.SUCCESS}},Nu=(e,t)=>No.decodeChatRecordMsgDetails2ReceivedMessages(e,t),Lu=e=>No.encodeReceivedMessage2ChatRecordMsgDetail(e),Du=async(e,n=Date.now())=>{try{return await Tl.sendReadReceipts(e,n),{code:t.SUCCESS}}catch(e){return{code:t.UNKNOWN}}},Uu=e=>(e=>lr.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:wl,decoder:Il}))(e),ju=e=>(e=>lr.request(805404721,{langCode:e.langCode,account:e.phone},{encoder:Ol,decoder:Sl}))(e),Bu=e=>(e=>lr.request(805404723,{langCode:e.country,account:e.phone,code:e.code},{encoder:Rl,decoder:El}))(e),Fu=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("send message ->"+t)},xu=(e,r)=>{if(r!==t.SUCCESS){const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.warn("send message fail ->"+r+":"+n(r)+","+t)}},Gu=async e=>{ia("conversation",e,sa,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;Xi.debug("clear burn after reading expired messages ->"+n);const r=await Tl.clearBurnAfterReadingExpiredMessages(e);return r.length>0&&Xi.debug(`已清除会话 ${n} 中的 ${r.length} 条阅后即焚过期消息`),Promise.resolve({code:t.SUCCESS,data:r})},qu=async(e,t,n)=>await Tl.sendQuoteReplyMessage(e,t,n),Vu=async e=>{const n=await Tl.getMessageById(e);return{code:t.SUCCESS,data:n}},Ku=async e=>{const n=await Tl.getMessageByUId(e);return{code:t.SUCCESS,data:n}},Hu=async e=>{try{const n=await Tl.updateMessage(e);return{code:t.SUCCESS,data:n}}catch(e){return Xi.error("updateMessage -> ",e),{code:t.UNKNOWN,msg:e instanceof Error?e.message:String(e)}}},zu=async(e,t,n={})=>{ia("conversation",e,sa,!0);const r=Array.isArray(t)?[...t]:[t];return r.forEach((e,t)=>{ia(`messageTypes[${t}]`,e,Qi,!0)}),nt(n.count)&&ia("options.count",n.count,Qi,!0),nt(n.order)&&ia("options.order",n.order,e=>0===e||1===e),nt(n.timestamp)&&(n.timestamp=n.timestamp.toString()),Tl.getMessagesByType(e,r,n)},$u=async(e,n)=>{const r=await Tl.searchTextMessages(e,n);return{code:t.SUCCESS,data:r}},Wu=async(e,n=500)=>{const r=await Tl.searchMessages(e,n);return{code:t.SUCCESS,data:r}};export{Oi as ChatRecordMessage,e as ConnectionStatus,Si as ContactMessage,r as ConversationType,t as ErrorCode,n as ErrorDesc,d as Events,Ci as FileMessage,vi as GIFMessage,Ui as GroupCloseBurnAfterReadingMessage,Gi as GroupMessagePinnedNotification,Di as GroupOpenBurnAfterReadingMessage,bi as HQVoiceMessage,mi as ImageMessage,Ri as InvitationMessage,_i as LinkMessage,Ii as LocationMessage,u as LogLevel,s as MentionedType,i as MessageDirection,g as MessagePinnedOperation,ro as MessageTypes,io as NotiMessageTypes,l as NotificationLevel,o as NotificationStatus,Li as PrivateCloseBurnAfterReadingMessage,xi as PrivateMessagePinnedNotification,Ni as PrivateOpenBurnAfterReadingMessage,Vi as RecallCommandMessage,c as ReceivedStatus,Ei as RedEnvelopeMessage,a as SentStatus,yi as TextMessage,Ti as TransferMessage,wi as VideoMessage,Gl as addEventListener,su as clearAllMessagesUnreadStatus,Gu as clearBurnAfterReadingExpiredMessages,Pu as clearHistoryMessages,ru as clearMessagesUnreadStatus,Zl as clearTextMessageDraft,Su as commentMessage,Nl as connect,Pl as deleteLegacyDatabase,jl as deleteLocalDatabase,Mu as deleteLocalMessages,ku as deleteMessages,Ll as disconnect,Lu as encodeReceivedMessage2ChatRecordMsgDetail,hu as forwardMessage,eu as getAllConversationState,Yl as getAllUnreadMentionedCount,cu as getBlockedConversationList,Kl as getCachedDialogFilterConfig,Bl as getConnectionStatus,zl as getConversation,Hl as getConversationList,ou as getConversationNotificationLevel,au as getConversationNotificationStatus,Ql as getConversationState,Eu as getHistoryMessages,Ml as getLegacyMediaReferences,kl as getLegacyMigrationInfo,Vu as getMessageById,Ku as getMessageByUId,zu as getMessagesByType,Au as getPinnedMessages,Ru as getRemoteHistoryMessages,xl as getServerTime,Wl as getTextMessageDraft,du as getTopConversationList,tu as getTotalUnreadCount,nu as getUnreadCount,Xl as getUnreadMentionedCount,_l as init,pu as insertMessage,ao as isRecallMessageType,Ul as logOut,yu as mergeForwardMessages,Al as migrateLegacyDatabase,ju as mockGetLoginCode,Uu as mockLogin,Bu as mockVerifyLoginCode,ql as onceEventListener,Nu as parseChatRecordMsgDetails,Ou as recallMessage,gu as registerMessageType,co as remapIncomingRecallConstructor,$l as removeConversation,Vl as removeEventListener,Fl as request,Jl as saveTextMessageDraft,Wu as searchMessages,$u as searchTextMessages,wu as sendFileMessage,bu as sendGIFMessage,Cu as sendHQVoiceMessage,vu as sendImageMessage,fu as sendMessage,qu as sendQuoteReplyMessage,Du as sendReadReceipts,Iu as sendSightMessage,mu as sendTextMessage,uu as setConversationBurnAfterReading,iu as setConversationNotificationStatus,lu as setConversationToTop,Tu as setMessagePinned,Dl as setUserLogged,_u as unpinAllMessages,Hu as updateMessage};
|