@rongcloud/electron 5.7.3 → 5.7.4-beem.1
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/binding/electron-v22.3-darwin-arm64.node +0 -0
- package/binding/electron-v22.3-darwin-x64.node +0 -0
- package/binding/electron-v22.3-win32-ia32.node +0 -0
- package/binding/electron-v22.3-win32-x64.node +0 -0
- package/index.d.ts +76 -4
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +4 -5
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -46,7 +46,11 @@ interface ICppProtocol {
|
|
|
46
46
|
/**
|
|
47
47
|
* 连接被断开回调。也会被调用多次,因 TCP 连接断开本身会通知
|
|
48
48
|
*/
|
|
49
|
-
onDisconnect: (status: number) => void
|
|
49
|
+
onDisconnect: (status: number) => void,
|
|
50
|
+
/**
|
|
51
|
+
* TCP 连接结果的回调
|
|
52
|
+
*/
|
|
53
|
+
onHandshake: (code: number, host: string, port: number, duration: number, dnsDuration: number, index: number, context: string) => void) => void;
|
|
50
54
|
/**
|
|
51
55
|
* 心跳发送 4.0 + 协议栈需 lib 层维护心跳, 有回调即认为 ping 成功
|
|
52
56
|
*/
|
|
@@ -124,7 +128,10 @@ interface ICppProtocol {
|
|
|
124
128
|
expansionContent: string, // 扩展消息内容
|
|
125
129
|
enableVoipPush: boolean, // 开启 voip 推送 , 音视频 CAllLib SDK 发消息使用。IM 消息均为 false
|
|
126
130
|
channelId?: string, // 会话组织标识
|
|
127
|
-
messageId?: number
|
|
131
|
+
messageId?: number, // 要重发的消息的 messageId, 正常发送时传 <=0 即可, 重发时需是正确的 messageId
|
|
132
|
+
isResend?: boolean, // 是否是重发消息
|
|
133
|
+
sessionTag?: number, // 会话标记
|
|
134
|
+
isBroadcast?: boolean) => any;
|
|
128
135
|
/**
|
|
129
136
|
* 撤回消息
|
|
130
137
|
*/
|
|
@@ -144,6 +151,12 @@ interface ICppProtocol {
|
|
|
144
151
|
* @param timestamp : 如果传 0 且降序 获取最新时间戳之前降序排列。 非 0 降序为获取时间戳之前的, 非 0 升序为获取时间戳时候的
|
|
145
152
|
*/
|
|
146
153
|
getHistoryMessages: (conversationType: ConversationType, targetId: string, timestamp: number, count: number, objectName: string, isDesc: boolean, tag: string) => string;
|
|
154
|
+
/**
|
|
155
|
+
* 获取历史消息,并按时间降序排列
|
|
156
|
+
* @param isDesc : 是否降序取
|
|
157
|
+
* @param timestamp : 如果传 0 且降序 获取最新时间戳之前降序排列。 非 0 降序为获取时间戳之前的, 非 0 升序为获取时间戳时候的
|
|
158
|
+
*/
|
|
159
|
+
getHistoryMessagesV2: (conversationType: ConversationType, targetId: string, timestamp: number, count: number, objectName: string, isDesc: boolean, tag: string) => Array<Object>;
|
|
147
160
|
/**
|
|
148
161
|
* 通过消息类型获取历史消息列表
|
|
149
162
|
* @param desc 是否按 sentTime 降序排列,默认为 true
|
|
@@ -214,6 +227,18 @@ interface ICppProtocol {
|
|
|
214
227
|
* 获取第一个未读消息
|
|
215
228
|
*/
|
|
216
229
|
getTheFirstUnreadMessage: (conversationType: ConversationType, targetId: string, tag: string) => unknown;
|
|
230
|
+
/**
|
|
231
|
+
* 按UId批量获取消息
|
|
232
|
+
*/
|
|
233
|
+
getMessageByUids: (msgUIds: string[]) => string;
|
|
234
|
+
/**
|
|
235
|
+
* 设置消息的可搜索内容
|
|
236
|
+
*/
|
|
237
|
+
setMessageSearchContent: (messageId: number, content: string) => void;
|
|
238
|
+
/**
|
|
239
|
+
* 按会话内消息的UId批量获取消息
|
|
240
|
+
*/
|
|
241
|
+
getMessageByMsgUids: (targetId: string, channelId: string, conversationType: ConversationType, msgUIds: string[]) => string;
|
|
217
242
|
/**
|
|
218
243
|
* 设置会话置顶、免打扰状态
|
|
219
244
|
*/
|
|
@@ -226,6 +251,18 @@ interface ICppProtocol {
|
|
|
226
251
|
* 获取会话置顶状态
|
|
227
252
|
*/
|
|
228
253
|
getConversationTopStatus: (conversationType: ConversationType, targetId: string, channelId: string) => number;
|
|
254
|
+
/**
|
|
255
|
+
* 批量设置会话置顶状态
|
|
256
|
+
* @param status
|
|
257
|
+
* @returns
|
|
258
|
+
*/
|
|
259
|
+
setConversationsTopStatus: (status: string, createConversation: boolean, onSuccess: () => void, onError: (code: number) => void) => void;
|
|
260
|
+
/**
|
|
261
|
+
* 批量设置会话免打扰状态
|
|
262
|
+
* @param status
|
|
263
|
+
* @returns
|
|
264
|
+
*/
|
|
265
|
+
setConversationsMuteStatus: (status: string, onSuccess: () => void, onError: (code: number) => void) => void;
|
|
229
266
|
/**
|
|
230
267
|
* 设置会话隐藏
|
|
231
268
|
*/
|
|
@@ -253,6 +290,35 @@ interface ICppProtocol {
|
|
|
253
290
|
* 获取已读列表
|
|
254
291
|
*/
|
|
255
292
|
getMessageReader: (targetId: string, channelId: string, msgUid: string, onSuccess: (list: any[], count: number) => void, onError: IOnErrorCallBack) => void;
|
|
293
|
+
/**
|
|
294
|
+
* 设置群语音消息已听状态
|
|
295
|
+
* @param targetId
|
|
296
|
+
* @param channelId
|
|
297
|
+
* @param messageUId
|
|
298
|
+
*/
|
|
299
|
+
setGroupVoiceMessagePlayed: (targetId: string, channelId: string, messageUId: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
300
|
+
/**
|
|
301
|
+
* 获取群语音消息已听列表
|
|
302
|
+
* @param targetId
|
|
303
|
+
* @param channelId
|
|
304
|
+
* @param messageUId
|
|
305
|
+
*/
|
|
306
|
+
getGroupVoiceMessageReader: (targetId: string, channelId: string, messageUId: string, onSuccess: (list: any[], count: number) => void, onError: IOnErrorCallBack) => void;
|
|
307
|
+
/**
|
|
308
|
+
* 设置消息已读
|
|
309
|
+
* @param targetId
|
|
310
|
+
* @param channelId
|
|
311
|
+
* @param beginMessageUId
|
|
312
|
+
* @param endMessageUId
|
|
313
|
+
* @param onSuccess
|
|
314
|
+
* @param onError
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
setReadMessages: (targetId: string, channelId: string, beginMessageUId: string, endMessageUId: string, onSuccess: () => void, onError: IOnErrorCallBack) => void;
|
|
318
|
+
/**
|
|
319
|
+
* 获取已读回执信息
|
|
320
|
+
*/
|
|
321
|
+
getMessageReceiptInfo: (targetId: string, channelId: string, msgUid: string, onSuccess: (list: any[], count: number) => void, onError: IOnErrorCallBack) => void;
|
|
256
322
|
/**
|
|
257
323
|
* 更新消息已读回执信息
|
|
258
324
|
*/
|
|
@@ -407,7 +473,8 @@ interface ICppProtocol {
|
|
|
407
473
|
searchContent?: string, // 消息的搜索关键字
|
|
408
474
|
isUnread?: number, // 存入时是否计入未读数,1:不计入,0:计入 (注意:direction 为接收消息方向时才生效)
|
|
409
475
|
messageUId?: string, // 消息唯一标识,服务生成,不确定时填入空字符串
|
|
410
|
-
disableNotification?: boolean, canIncludeExpansion?: boolean, expansionMsg?: string, tag?: string
|
|
476
|
+
disableNotification?: boolean, canIncludeExpansion?: boolean, expansionMsg?: string, tag?: string, // 会话标识
|
|
477
|
+
sessionTag?: number) => string;
|
|
411
478
|
/**
|
|
412
479
|
* 批量向本地插入消息
|
|
413
480
|
*/
|
|
@@ -431,6 +498,10 @@ interface ICppProtocol {
|
|
|
431
498
|
* messageId 可以传 messageId 或 messageUId 均能查到消息
|
|
432
499
|
*/
|
|
433
500
|
getMessage: (messageId: number | string) => string;
|
|
501
|
+
/**
|
|
502
|
+
* 设置消息附加信息
|
|
503
|
+
*/
|
|
504
|
+
setTextMessageExtra: (messageId: number, value: string) => void;
|
|
434
505
|
/**
|
|
435
506
|
* 设置消息内容
|
|
436
507
|
*/
|
|
@@ -487,7 +558,7 @@ interface ICppProtocol {
|
|
|
487
558
|
*/
|
|
488
559
|
sendRTCHeartbeat(roomId: string[]): void;
|
|
489
560
|
setRTCHeartbeatListener(onReq: (roomId: string, seqId: string) => void, onRes: (roomId: string, code: number, seqId: string, version: bigint) => void): void;
|
|
490
|
-
setRTCRoomEventListener(callback: (buffer: number[]) => void): void;
|
|
561
|
+
setRTCRoomEventListener(callback: (buffer: number[]) => void, onMeetingEventReceived: (eventType: number, buffer: number[]) => void): void;
|
|
491
562
|
/**
|
|
492
563
|
* 初始化日志模块
|
|
493
564
|
* @param dbpath 日志数据库存储目录
|
|
@@ -519,6 +590,7 @@ interface ICppProtocol {
|
|
|
519
590
|
* 退出应用前调用
|
|
520
591
|
*/
|
|
521
592
|
destroy(): void;
|
|
593
|
+
subscribeAccount(conversationType: number, targetId: string, channelId: string, subscribe: boolean, onSuccess: () => void, onError: IOnErrorCallBack): void;
|
|
522
594
|
}
|
|
523
595
|
|
|
524
596
|
declare class RCServiceProxy {
|
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"os";import{platform as t,arch as n}from"os";import{resolve as o}from"path";import{getUUID as r,BasicLogger as s,appendUrl as i,ErrorCode as a,HTTP_TIMEOUT as c,LogTagId as u,StoreKeys as p,BasicReporter as l,REAT_TIME_LOG_SIZE as d,notEmptyObject as f,NAVI_CACHE_DURATION as h,BasicNavi as g,FORMATED_VERSION as v,RCConnectionStatus as C,AConnectionMgr as _,ConversationType as S,SEND_MESSAGE_TYPE_OPTION as y,isObject as m,isUndefined as P,pushJSONToConfigs as E,MessageDirection as I,NotificationStatus as T,MessageType as R,MentionedType as O,pushConfigsToJSON as N,ReceivedStatus as M,isArray as U,getUploadFileName as w}from"@rongcloud/engine";import{fork as b}from"child_process";import{app as x,ipcMain as L}from"electron";import{existsSync as A,readFileSync as k,writeFileSync as D,mkdirSync as J}from"fs";import{Agent as j,request as H}from"http";import{Agent as B,request as F}from"https";import{parse as G}from"url";import{isIP as V,Socket as q}from"net";import{EventEmitter as K}from"events";import{connect as W}from"tls";import{createHash as Y}from"crypto";var X=process.versions.electron.replace(/\.\d+$/,""),Q=o(__dirname,"binding","electron-v".concat(X,"-").concat(t(),"-").concat(n(),".node")),z={addon:null};try{z.addon=require(Q)}catch(e){console.error("error ->",Q,"\n",e)}var $=z.addon,Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Z(e,t)};function ee(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Z(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var te,ne=function(){return ne=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ne.apply(this,arguments)};function oe(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function re(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,o=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){i.label=a[1];break}if(6===a[0]&&i.label<r[1]){i.label=r[1],r=a;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(a);break}r[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function se(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_O="P-connect-O",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R"}(te||(te={}));var ie,ae={flushTimestamp:Date.now(),queue:[],locked:!1};function ce(){ie&&clearInterval(ie)}function ue(e,t){ce(),ie=setInterval((function(){return de(e,t)}),1e4)}function pe(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=ae.queue).push.apply(e,t)}var le=200;function de(e,t){var n=ae.queue,o=ae.flushTimestamp;if(!(ae.locked||0===n.length||Date.now()-o<3e4&&n.length<le)){ae.locked=!0;var r=t.createTraceId(),s=n.splice(0,le).map((function(e){var t=e.sessionId,n=e.level,o=e.time,r=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:n,time:o,type:r,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(te.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(te.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),ae.flushTimestamp=Date.now(),ae.locked=!1,setTimeout((function(){return de(e,t)}))}}var fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ee(t,e),t.prototype.flush=function(e){pe(e)},t}(s),he=function(e,t){var n,o=Buffer.from(e),r=o.length;for(t.push(r),n=0;n<r;n++)t.push(o[n])},ge=function(e){return"string"==typeof e},ve=function(e){return ge(e)?e.toUpperCase():""},Ce=function(e,t){var n="";return 2!==e.length?n="Unexpected number of bytes received.":5!==e[0]?n="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?n="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(n="Unexpected SOCKS authentication method: ".concat(e[1],".")),n},_e=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},Se=function(e){var t=ve(e.method)||"GET",n=e.pathname||"/",o=e.headers||{},r=e.search||"";o.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(n+r," HTTP/1.1\n"),o)if(Object.hasOwnProperty.call(o,i)){var a=o[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},ye=function(e){return new Promise((function(t){var n,o;e.socket.once("data",(function(o){var r,s=Ce(o,n);if(!s)return 2===o[1]?(e.socket.once("data",(function(n){var o=_e(n);o?e.emit("error",new Error("SOCKS authentication failed. ".concat(o))):t()})),r=[1],he(e.socksUsername,r),he(e.socksPassword,r),void e.write(Buffer.from(r))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),n=[0],e.socksUsername&&n.push(2),(o=Buffer.alloc(2+n.length))[0]=5,o[1]=n.length,n.forEach((function(e,t){o[2+t]=e})),e.write(o)}))},me=function(e,t,n){return new Promise((function(o){var r,s;switch(e.socket.once("data",(function(t){var n;5!==t[0]?n="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?n="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(n="The reserved byte must be 0x00."),n?e.emit("error",new Error("SOCKS connection failed. ".concat(n))):o()})),(r=[]).push(5),r.push(1),r.push(0),V(t)){case 0:r.push(3),he(t,r);break;case 4:r.push(1),function(e,t){var n,o,r=e.split(".");for(n=0;n<4;n++)o=parseInt(r[n],10),t.push(o)}(t,r);break;case 6:e.emit("error",new Error("Does not support IPV6"))}r.length+=2,(s=Buffer.from(r)).writeUInt16BE(n,s.length-2),e.write(s)}))},Pe=function(e){function t(t){var n=e.call(this)||this;return n.readable=!0,n.socket=new q,n.options=t,n.socksHost=t.socksHost||"localhost",n.socksPort=t.socksPort||1080,n.socksUsername=t.socksUsername||"",n.socksPassword=t.socksPassword||"",n.socket.on("error",(function(e){n.emit("error",e)})),n.on("error",(function(){n.socket.destroyed||n.socket.destroy()})),n.on("end",n.end),n}return ee(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var n=this.socket.end(e,t);return this.writable=this.socket.writable,n},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,n){return this.socket.write(e,t,n)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var n=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return oe(n,void 0,void 0,(function(){var n;return re(this,(function(o){switch(o.label){case 0:return[4,ye(this)];case 1:return o.sent(),[4,me(this,t,e)];case 2:return o.sent(),this.onProxied(),n=Se(this.options),this.socket.write(Buffer.from(n)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(K),Ee=function(e){var t,n=e.hostname,o=e.port;return!e.host||n&&o||(t=e.host.split(":")),!o&&t&&(o=parseInt(t[1],10)||0),!n&&t&&(n=t[0]),new Pe(e).connect(o,n)},Ie=function(e){function t(t){var n=e.call(this)||this;return n.createConnection=Ee,n}return ee(t,e),t}(j),Te=function(e,t,n){return(t=ne(ne({},t),G(e))).port||(t.port=80),t.agent=new Ie(t),H(t,n)},Re=function(e){var t,n;return t=Ee(e),n=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=W(e,(function(){t.authorized=t.socket.authorized,n.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},Oe=function(e){function t(t,n){var o=e.call(this,n)||this;return o.url=t,o.socksHost=n.socksHost||"localhost",o.socksPort=n.socksPort||1080,o.createConnection=Re,o}return ee(t,e),t}(B),Ne=function(e,t,n,o){var r,s;return t.protocol="https:",!t.port&&t.host&&(r=t.host.split(":"),t.port=r[0],t.port=r[1]),t.port||(t.port=443),s=new Oe(e,t),t.agent=s,F(e,t,n)},Me=null;function Ue(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,a=t.method,u=t.query,p=t.timeout,l=void 0===p?c:p;return new Promise((function(t){var c=/^https/.test(o),p={headers:r,method:a};c&&(p.rejectUnauthorized=n);var d=null;Me?((p=ne(ne({},p),Me)).body=s,d=c?Ne:Te):(d=H,c&&(p.agent=new B(p),d=F));var f=d(i(o,u),p,(function(e){var n=e.statusCode,o="";e.setEncoding("utf8"),e.on("data",(function(e){o+=e})),e.once("end",(function(){t({status:n||0,data:o})}))}));f.once("timeout",(function(){e.warn(te.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:a,query:u,timeout:l})),t({status:0})})),f.setTimeout(l),f.once("error",(function(n){e.warn(te.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:a,query:u,timeout:l})),t({status:0})})),f.write(s),f.end()}))}function we(e,t){return e?(Me=ne(ne({},Me),e),t.info(u.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Me})),{code:a.SUCCESS}):(Me=null,t.info(u.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:a.SUCCESS})}function be(){var e=Me||void 0;return{code:a.SUCCESS,data:e}}var xe,Le=[],Ae=function(e){return oe(void 0,void 0,void 0,(function(){return re(this,(function(t){return[2,new Promise((function(t){Le.push({resolve:t,args:e}),De()}))]}))}))},ke=!1,De=function(){return oe(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c,u,p;return re(this,(function(l){return ke||0===Le.length||(ke=!0,e=Le.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=0,u=0,p=[],o.setLogEventListener((function(e){c+=e.length;var t=e.split(","),o=t[0],r=t[1],s=t[2],l=t[3],f=t[4],h=t.slice(5);if(c>d&&parseInt(r,10)!==u)n(p);else{u=parseInt(r,10);try{var g=JSON.parse(decodeURIComponent(h.join(","))),v=g.loggerId,C=g.sessionId,_=g.content,S=g.traceId;if(!a&&i<0)return;var y={time:parseInt(r,10),level:parseInt(l,10),sessionId:"".concat(o,":").concat(C),type:s,tag:f,loggerId:v,content:_,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){n(p),ke=!1,De()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},Je=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,c="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return(i=e.call(this,n,o,c,{getLogs:function(e,n,o,r){return oe(this,void 0,void 0,(function(){return re(this,(function(s){switch(s.label){case 0:return[4,Ae({startTime:e,endTime:n,level:o,realtimeReport:r,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(p.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(p.REALTIME_LOG_TIMESTAMP,e.toString())}},r)||this).subProcess=s,i}return ee(t,e),t.prototype.send=function(e){return Ue(this.logger,e)},t.prototype.compressLogs=function(e){return oe(this,void 0,void 0,(function(){var t,n,o;return re(this,(function(r){switch(r.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=r.sent(),n=t.success,o=t.data,n?[2,{success:n,data:o}]:[2,{success:n,data:""}]}}))}))},t}(l),je=null,He=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,Y("md5").update(e).digest("hex")},Be=function(e){if(je)return je;var t=o(e,"deviceId");return A(t)?je=k(t).toString():(je=He(),D(t,je),je)},Fe=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,n,o,r,s){var i=JSON.stringify(r);"{}"!==i&&e.info(te.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:o,ext:r})),this._cppProto.setMessageExtension(t,n,o,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,o,r,s,c,n||"")},e.prototype.setLocalFromExtMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,l=JSON.parse(p||"{}");if(c)for(var d in c){var f=l[d];f&&f.ts<i-this._setTime?(f.v=c[d],f.ts=i-this._setTime):(l[d]={v:"",ts:0},l[d].v=c[d],l[d].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete l[e]})),this._setToProtocol(e,o,r,a.mid,l,n||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),n={};for(var o in t)n[o]=t[o].v;return n},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),n=JSON.parse(t||"{}"),o={};for(var r in n)o[r]=n[r].v;return o},e}(),Ge=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var n=e.reqId,o=e.success,r=e.data,s=t.maps[n];s&&(s({success:o,data:r}),delete t.maps[n])}))}return e.prototype.call=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return oe(this,void 0,void 0,(function(){var n=this;return re(this,(function(o){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(o){var r=++n.count;n.maps[r]=o;var s={reqId:r,method:e,args:t};n.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),Ve=function(e){function t(t,n,o,r){var s=e.call(this,t,n,[])||this;return s.addon=r,s.naviPath="",s._caches={},s.naviPath="".concat(o,"/navi-cache.json"),s}return ee(t,e),t.prototype.updateCustomNavis=function(e){var t;e.length&&(t=this.navigators).splice.apply(t,se([0,this.navigators.length],e,!1))},t.prototype.httpRequest=function(e,t,n,o,r,s){return oe(this,void 0,void 0,(function(){var i,c,p,l,d;return re(this,(function(f){switch(f.label){case 0:return i="token=".concat(encodeURIComponent(n),"&v=").concat(o,"&p=PC&ev=").concat("5.7.3"),c="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(u.L_REQUEST_T,JSON.stringify({url:c,body:i}),s),[4,Ue(this.logger,{method:"POST",headers:{appId:t},body:i,url:c,timeout:r})];case 1:if(200!==(p=f.sent()).status)return this.logger.warn(u.L_REQUEST_R,JSON.stringify({url:c,code:p.status}),s),[2,{code:this.transHttpCode(p.status)}];try{return l=JSON.parse(p.data),d=/^https/.test(c)?"https":"http",l.protocol=d,[2,{code:a.SUCCESS,data:l}]}catch(e){return this.logger.error(u.L_PARSE_NAVI_E,p.data,s),[2,{code:a.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!A(this.naviPath))return null;var n=k(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[e]}catch(e){this.logger.error(u.L_PARSE_NAVI_E,n)}return null},t.prototype.setNaviCache=function(e,t){var n=Date.now();if(f(this._caches))for(var o in this._caches){var r=this._caches[o];(n-r.timestamp>h||e===r.token)&&delete this._caches[o]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},D(this.naviPath,JSON.stringify(this._caches))},t}(g),qe=function(e){function t(t,n,o,r,s){var i=e.call(this,t,o,r,s)||this;return i.addon=n,i._connectedTime=0,i.connectResolve=null,i.pingResolve=null,i.addon.setConnectionStatusListener(i._onConnectionStatusChange.bind(i),(function(e){i.logger.info(te.P_DB_OPEN_O,e)}),(function(){return i.recvPong(a.SUCCESS)}),i._onConnectionStatusChange.bind(i)),i}return ee(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,n,o){var r=this;return new Promise((function(s){r.connectResolve={resolve:s,traceId:o,userId:t.userId};var i=null,c=be().data;c&&(i=JSON.stringify({proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0}));try{r.addon.connectWithToken(e,v,JSON.stringify(t),n,i)}catch(e){r.logger.error(te.P_CALL_ADDON_E,null==e?void 0:e.stack,o),r.recvConnectRes(a.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(n){t.pingResolve=n,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(a.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e){switch(this.logger.info(te.P_CONNECT_S,e),e){case a.SUCCESS:this.recvConnectRes(a.SUCCESS);break;case a.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(a.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case a.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case a.RC_SOCKET_NOT_CREATED:case a.RC_CONN_ACK_TIMEOUT:case a.RC_TCP_RESET:this.recvConnectRes(e);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t){if(this.connectResolve){var n=this.connectResolve,o=n.resolve,r=n.userId;return e===a.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),o({code:e,data:r}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e);else{if(e===a.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==C.CONNECTED)return;this.onDisconenctUnusual(e)}},t}(_),Ke=function(e){if(!A(e)){var t=o(e,"..");A(t)||Ke(t),J(e)}},We=function(){function t(e,t,n,s){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._logOutputLevel=s,this._customMessageType={},this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var c=this._dbpath||o(x.getPath("userData")),u=Be(c);this._cppProtocol.initWithAppkey(e,c,v);var p=b(o(__dirname,"sub-process.js"));this.subProxy=new Ge(p);var l=o(c,"RongCloud/rclogs",e);Ke(l),function(e,t,n){n.initLogModule(t,e,r())}(e,l,this._cppProtocol),this.logger=new fe(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),ue(this._cppProtocol,this.logger),this.reporter=new Je(this._cppProtocol,e,u,this.logger,this.subProxy),this.logger.info(te.P_INIT_O,JSON.stringify({appkey:e,dbpath:c,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:u,commit:"220aab3f259b3e6bad2f34423d46543464baa635"})),this._callCppProxy("setDeviceId",u);var d=o(c,"RongCloud/navis",e);Ke(d),this.navi=new Ve(e,this.logger,d,this._cppProtocol),this.tcpMgr=new qe(e,this._cppProtocol,this.navi,this.logger,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),L.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return oe(i,void 0,void 0,(function(){var o,r,s;return re(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(te.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=a.NOT_SUPPORT,[2];r=a.EXTRA_METHOD_UNDEFINED,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,se([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(te.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==s?void 0:s.stack,method:t})),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),L.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return oe(i,void 0,void 0,(function(){var r,s,i,c,u=this;return re(this,(function(p){switch(p.label){case 0:if("function"!=typeof(r=this[n]))return this.logger.error(te.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a.NOT_SUPPORT),[2];"sendMessage"===n&&(s=o[3],o[3]=function(t){u._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=a.EXTRA_METHOD_UNDEFINED,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,r.call.apply(r,se([this],o,!1))];case 2:return i=p.sent(),[3,4];case 3:return c=p.sent(),this.logger.error(te.P_CALL_MAIN_E,JSON.stringify({error:null==c?void 0:c.stack,method:n})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i),[2]}}))}))})),L.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=i[t];if("function"==typeof r)try{r.call.apply(r,se([i],n,!1))}catch(e){i.logger.error(te.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(te.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),L.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new Fe(this._cppProtocol)}return t.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},t.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},t.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.logger.createTraceId();try{return(t=this._cppProtocol)[e].apply(t,n)}catch(t){this.logger.error(te.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return Ue(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){pe.apply(void 0,e)},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){ce(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},t.prototype.callExtra=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this[e];if(!o)return this.logger.warn(te.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:a.EXTRA_METHOD_UNDEFINED});try{return o.call.apply(o,se([this],t,!1))}catch(t){this.logger.error(te.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:a.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(e,t,n,o){var r,s=this,i=this._callCppProxy("getConversationListByPage",e,t,n,o||"");try{r=JSON.parse(i).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:r})},t.prototype.getUnreadConversationList=function(e){var t,n=this,o=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(o).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[S.PRIVATE,S.GROUP],o=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(o).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:e})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[S.PRIVATE,S.GROUP],s=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{n=JSON.parse(s).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:n})},t.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,s,i){var c=0===s,u=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,r,c,i||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var h=this._buildMessage(d[f].obj);l[f]=h}}catch(e){return Promise.resolve({code:a.MAIN_PROCESS_ERROR})}return Promise.resolve({code:a.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:o<l.length}})},t.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o="");var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:a.SUCCESS,data:r})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==C.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new fe(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,se([t],n,!1))},t.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var s=o._senders[r];n.includes(s)||o._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),n=this.getNaviInfoFromCache(),o=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:o,naviInfo:n,connectionStatus:t}},t.prototype._registerRenderers=function(e,t){var n=this,o=e.sender,r=o.id;this.navi.updateCustomNavis(t.navigators),this._senders[r]||(this._senders[r]=o,o.once("destroyed",(function(){delete n._senders[r]})))},t.prototype._registerMsgTypes=function(){for(var e in y["RC:RcCmd"]={isCounted:!1,isPersited:!1},y){var t=y[e],n=t.isCounted,o=t.isPersited,r=t.searchProps,s=0;o&&(s|=1),n&&(s|=2),"RC:TypSts"===e&&(s=16),this._callCppProxy("registerMessageType",e,s,r||[])}},t.prototype._buildIsMentioned=function(e,t){var n,o=!1;if(m(e))n=e;else try{n=e?JSON.parse(e):e}catch(o){n=e,this.logger.error(te.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return m(n)&&(o=!!n.mentionedInfo),{isMentioned:o,msgContent:n}},t.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in y?t=y[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},t.prototype._buildSupportExt=function(e,t,n){var o=null;return e&&(o=this._msgExpansionHandler.parseReceiveExpansion(n),"conversation"!==t&&"history"!==t||(o=this._msgExpansionHandler.parseConverOrHisExpansion(n))),o},t.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e),s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,p=r.objectName,l=r.messageUid,d=r.direction,f=r.status,h=r.messageId,g=r.sentTime,v=r.readReceiptRequest,C=r.supportExt,_=r.pushContent,S=r.pushTitle,y=r.pushId,m=r.pushConfig,T=r.templateId,R=r.disableTitle,O=r.forcePushDetail,N=this._buildIsMentioned(u,h),M=N.isMentioned,U=N.msgContent,w=this._buildMsgOption(p),b=this._buildSupportExt(C,o,r),x=P(n)?g<this.tcpMgr.getConnectedTime():n,L={};m&&(L=E(this.logger,m,y));var A=ne(ne({},L),{pushTitle:S,pushContent:_,pushData:_,disablePushTitle:R,forceShowDetailContent:O,templateId:T}),k={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:U||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:x,sentTime:g,receivedTime:0,isPersited:w.isPersited,isCounted:w.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:C,expansion:C?b:null,receivedStatus:f,messageId:h,pushConfig:A};if(d===I.RECEIVE?k.receivedStatus=f:d===I.SEND&&(k.sentStatus=f),v){var D=JSON.parse(v),J=D.hasRespond,j=D.readerInfo,H={hasRespond:J,readCount:D.readCount,totalCount:D.totalCount},B=[];if(j)for(var F in j)B.push({userId:F,readTime:j[F]});H.readerList=B,k.readReceiptInfo=H}return k},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=ne(ne({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},t.prototype._buildConversation=function(e){var t=JSON.parse(e),n=t.channelId,o=t.conversationType,r=t.targetId,s=t.unreadCount,i=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=t.hasUnreadMention,l=c?T.OPEN:T.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:p,mentionedInfo:null,notificationStatus:l,isTop:a,lastUnreadTime:0,matchCount:u}},t.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},t.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var s,i=e._buildMessage(t,{isOffLineMessage:o}),a=i.messageType,c=i.channelId,u=void 0===c?"":c;if(a!==R.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===R.GROUP_READ_RECEIPT_REQUEST){var p=i.content,l=p.msgId,d=p.rrn,f=p.tmn;e._updateReadReceiptInfo(l,{readCount:d,totalCount:f})}if("RC:MsgExMsg"===a)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(e.logger,i),a!==R.SYNC_READ_STATUS||i.senderUserId===e.tcpMgr.getCurrentUserId()){a===R.SYNC_READ_STATUS&&e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,u);var h=!0;if(0!==n||r||(h=!1),a===R.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(i.content)),void e._sendMessageDelivered(i.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(a!==R.DELIVERED_MSG){var g=i.conversationType,v=i.targetId;if(a===R.RECALL){e.handleRecalledMessage(i);var C=e._fixRecallContentInfo(i);g=C.conversationType,v=C.targetId}e._sendMessageNotification(Object.assign(i,{hasMoreMsg:h,conversationType:g,targetId:v}))}else{var _={totalCount:i.content.tmn,list:null===(s=i.content.dl)||void 0===s?void 0:s.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(_)}}}else{var S=i.content,y=S.startTime,m=S.endTime,P=S.platform,E=S.logId,I=S.uri;e.reporter.report(parseInt(y,10),parseInt(m,10),P,I,E,i.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,n=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,n=e.content.targetId||n),{conversationType:t,targetId:n}},t.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var n=this._callCppProxy("getMessage",t),o=this._buildMessage(n,{isOffLineMessage:!1});if(o.messageId){var r={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:o.messageType,originalMessageContent:o.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(r.user=e.content.user),e.content.extra&&(r.extra=e.content.extra),o.messageType===R.TextMessage&&(r.recallContent=o.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[o.messageId]):(o.receivedStatus||this.setMessageReceivedStatus(o.messageId,1),this._callCppProxy("setMessageContent",o.messageId,JSON.stringify(r),R.RECALL_NOTIFICATION_MESSAGE))}}},t.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,s=o.del,i=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:n,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},t.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},t.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},t.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,o=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,r=t.targetId,s=t.status,i=t.channelId,a={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?T.OPEN:T.CLOSE:a.isTop=1===Number(t.value)})),o.push({channelId:i,conversationType:n,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",o)}),(function(t){e._send2AllRenderer("conversationTag",t)}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var n=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",n)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var n=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",n)}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._updateMentionedInfo=function(e,t,n){var o,r,s;return{userIdList:(null===(o=e.mentionedInfo)||void 0===o?void 0:o.userIdList)||t,type:(null===(r=e.mentionedInfo)||void 0===r?void 0:r.type)||n||O.ALL,mentionedContent:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,n,o){void 0===o&&(o=[]);var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(te.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:o})),this._callCppProxy("registerMessageType",e,r,o)},t.prototype.connect=function(e,t,n){return this.tcpMgr.connect(e,t,n)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(ne(ne({},e),{"electron-main":"5.7.3"}));this.logger.info(te.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o)},t.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),we(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},t.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("subscribeUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(a.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:a.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},t.prototype.sendMessage=function(e,t,n,o,r){var s=this;void 0===r&&(r=this.logger.createTraceId());var i=n.messageType,c=n.content,u=n.expansion,p=n.pushConfig,l=n.isMentioned,d=n.mentionedType,f=n.mentionedUserIdList,h=void 0===f?[]:f,g=n.pushContent,v=void 0===g?"":g,C=n.pushData,_=void 0===C?"":C,y=n.directionalUserIdList,m=void 0===y?[]:y,P=n.disableNotification,E=void 0!==P&&P,I=n.canIncludeExpansion,T=void 0!==I&&I,O=n.isVoipPush,M=void 0!==O&&O,U=n.channelId,w=void 0===U?"":U,b=n.messageId,x=void 0===b?0:b,L=p||{},A=L.iOSConfig,k=L.androidConfig,D=L.templateId,J=void 0===D?"":D,j=L.pushTitle,H=void 0===j?"":j,B=L.pushContent,F=void 0===B?v:B,G=L.pushData,V=void 0===G?_:G,q=L.disablePushTitle,K=void 0!==q&&q,W=L.forceShowDetailContent,Y=void 0!==W&&W,X=N(A,k);return new Promise((function(n){v=F,_=V;var p=(null==k?void 0:k.notificationId)||"";if(e===S.GROUP&&l&&c&&(c.mentionedInfo=s._updateMentionedInfo(c,h,d)),e===S.GROUP&&i===R.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)m.push(f);var g={};for(var f in u)g[f]={v:""},g[f].v=u[f];var C=J;s.logger.info(te.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:w}),r);var y=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(te.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===a.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===o.messageType&&s._msgExpansionHandler.setLocalFromExtMsg(s.logger,o),o.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(s.logger,o),n({code:a.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(te.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),r),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(c),m,E,K,Y,v,_,p,H,X,C,T,JSON.stringify(g),M,w,x),P=JSON.parse(y);null==o||o(P.messageId)}))},t.prototype.recallMsg=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){var u,p=r.user,l=r.pushContent,d=r.channelId,f=r.extra,h=r.pushConfig,g=r.disableNotification,v=r.isDelete,C={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:p,extra:f,channelId:d,isDelete:v||!1};p&&(C.user=p),f&&(C.extra=f);var _={conversationType:e,targetId:t,senderUserId:s.tcpMgr.getCurrentUserId(),content:C,objectName:R.RECALL,messageUid:n,direction:I.SEND,status:M.UNREAD,sentTime:o,channelId:d},S=s._buildMessage(JSON.stringify(_),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(S),i({code:a.SUCCESS,data:S})}),(function(e){i({code:e})}),R.RECALL,JSON.stringify(C),g||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,l||"",(null==h?void 0:h.pushData)||"",(null===(u=null==h?void 0:h.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==h?void 0:h.pushTitle)||"",N(null==h?void 0:h.iOSConfig,null==h?void 0:h.androidConfig),(null==h?void 0:h.templateId)||"",d)}))},t.prototype.getHistoryMessage=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(u,p){n=n||0;var l=0===r,d=o+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,i,l,s),h=JSON.parse(f).list,g=[];h.reverse();for(var v=0;v<h.length;v++){var C=c._buildMessage(h[v].obj);g[v]=C}u({code:a.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:o<g.length}})}))},t.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,s){var i=this;return new Promise((function(c,u){n=n||0;i._callCppProxy("getRemoteHistoryMessages",e,t,n,o,(function(e,t){var n=JSON.parse(e).list,o=[];n.reverse();for(var r=0;r<n.length;r++){var s=i._buildMessage(n[r].obj);o[r]=s}c({code:a.SUCCESS,data:{list:o,hasMore:!!t}})}),(function(e){c({code:e})}),r,!0,s)}))},t.prototype.deleteRemoteMessage=function(e,t,n,o){var r=this;return new Promise((function(s,i){var c=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,o,(function(){s(a.SUCCESS)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(a.SUCCESS)}),(function(e){s(e)}),o)}))},t.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("clearMessages",e,t,n),r(a.SUCCESS)}))},t.prototype.getConversationList=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],r),o=JSON.parse(n).list,i=[],c=0;c<o.length;c++)i.push(s._buildConversation(o[c].obj));e({code:a.SUCCESS,data:i})}))},t.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversation",e,t,n);if(i)r({code:a.SUCCESS,data:o._buildConversation(i)});else{var c=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){o.logger.error(te.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),u=[]}var p=null;u.length>0&&(p=o._buildMessage(u[0].obj));var l=o._callCppProxy("getConversationNotificationStatus",e,t,n),d=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:a.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?T.OPEN:T.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(o?a.SUCCESS:a.UNKNOWN)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var s=[];s=U(e)?e:[S.PRIVATE,S.GROUP,S.SYSTEM,S.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),o(a.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:a.SUCCESS,data:o})},t.prototype.getConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){var s=o._callCppProxy("getUnreadCount",e,t,n);r({code:a.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r,s){o._callCppProxy("clearUnreadCount",e,t,n),r(a.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),s(a.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=o._buildMessage(i);r({code:a.SUCCESS,data:-1!==c.messageId?c:null})}))},t.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s,i){r._callCppProxy("setConversationToTop",e,t,n,o,!0),s(a.SUCCESS)}))},t.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationHidden",e,t,n,o),s(a.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(a.SUCCESS)}),s,o)}))},t.prototype.setConversationStatus=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._callCppProxy("setConversationStatus",e,t,n,o,(function(){i(a.SUCCESS)}),i,r,!0)}))},t.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:a.SUCCESS,data:i?T.OPEN:T.CLOSE})}))},t.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(s,i){o=o||[1,3,6,7];for(var c=r._callCppProxy("searchConversationByContent",o,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=r._buildConversation(u[l].obj);s({code:a.SUCCESS,data:p})}))},t.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r,s){n=n||[1,3,6,7];for(var i=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(i).list,u=[],p=0;p<c.length;p++)u[p]=o._buildConversation(c[p].obj);r({code:a.SUCCESS,data:u})}))},t.prototype.searchMessageByContent=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(s,u){c._callCppProxy("searchMessageByContent",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=c._buildMessage(n[r].obj);s({code:a.SUCCESS,data:{messages:o,count:t}})}),i)}))},t.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=s._buildMessage(n[r].obj);i({code:a.SUCCESS,data:{messages:o,count:t}})}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,o,r,s,i){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,o,r,s,i,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=c._buildMessage(t[o].obj);u({code:a.SUCCESS,data:{messages:n}})}))}))},t.prototype.getUnreadMentionedMessages=function(e,t,n){for(var o=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,n)).list,r=0;r<o.length;r++)o[r]=this._buildMessage(o[r].obj);return o},t.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addToBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(a.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:a.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},t.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:a.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},t.prototype.insertMessage=function(e,t,n){var o=this,r=n.content,s=n.senderUserId,i=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,h=n.messageUId,g=n.disableNotification,v=n.canIncludeExpansion,C=n.expansionMsg,_=n.channelId;r=JSON.stringify(r);var S={};if(C){var y=JSON.parse(C);for(var m in y)S[m]={v:"",ts:0},S[m].v=y[m],S[m].ts=l||0}return new Promise((function(n,C){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),c,u||0,p||10,l||0,d||"",y||0,h||"",g||!1,v||!1,JSON.stringify(S)||"",_||""),P=o._buildMessage(m,{isOffLineMessage:!1});P.messageUId=h,P.sentTime=l,n({code:-1===P.messageId?a.MSG_INSERT_ERROR:a.SUCCESS,data:P})}))},t.prototype.batchInsertMessage=function(e,t){var n=this;return new Promise((function(o){var r=e.map((function(e){var t=e.content,n=e.senderUserId,o=e.messageType,r=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,l=e.disableNotification,d=e.canIncludeExpansion,f=e.expansion,h=e.channelId,g=e.conversationType,v=e.targetId,C=e.source,_=e.isMentioned,S={};if(f)for(var y in f)S[y]={v:"",ts:0},S[y].v=f[y],S[y].ts=a||0;return{conversationType:g,targetId:v,channelId:h||"",direction:r,senderUserId:n,status:i||10,sentTime:a||0,objectName:o,content:JSON.stringify(t),messageUid:p||"",noNotification:l||!1,supportExt:d||!1,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:u||!1,source:C||"",isMention:_}})),s=n._callCppProxy("insertMessages",JSON.stringify(r),t||!1);o({code:s?a.SUCCESS:a.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getMessageCount",e,t,n);r({code:a.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteMessages",e),n(a.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var s=this;return new Promise((function(i,c){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),i(a.SUCCESS)}))},t.prototype.getMessage=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getMessage",e),s=t._buildMessage(r,{isOffLineMessage:!1});n({code:a.SUCCESS,data:s})}))},t.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r,s){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(a.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setMessageSearchField",e,t,n),r(a.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(a.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(a.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(e,t,n,o){throw new Error("Method not implemented.")},t.prototype.getConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},t.prototype.clearConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,s=t.notificationStatus,i=t.channelId,a=this._callCppProxy("getConversationNotificationStatus",n,o,i||""),c=this._callCppProxy("getConversationTopStatus",n,o,i||""),u=P(s)?Boolean(a):s===T.OPEN,p=P(r)?Boolean(c):r;return this.setConversationStatus(n,o,u,p,i)},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){o._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(o._callCppProxy("getMessage",e)).messageId;o.setMessageReceivedStatus(t,1)}catch(t){o.logger.error(te.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getMessageReader",e,n,t,(function(e,n){var s=[],i={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;s.push({userId:n,readTime:o}),i[n]=o}));var c={readerInfo:i,readCount:s.length,totalCount:n};o._updateReadReceiptInfo(t,c),r({code:a.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype._addChatroomCache=function(e,t,n){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:n,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(n){return oe(e,void 0,void 0,(function(){var e,o,r,s;return re(this,(function(i){switch(i.label){case 0:return e=n.chatroomId,o=n.joinExist,r=n.count,this.logger.info(u.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,r,o,!1)];case 1:return(s=i.sent())===a.SUCCESS?(this.logger.info(u.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,count:r}}),[2]):(s===a.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:s}}),this.logger.warn(u.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(s),t),[2])}}))}))}))}},t.prototype._joinChrm=function(e,t,n,o){var r=this,s=n?"joinExistChatRoom":"joinChatRoom";return new Promise((function(i){o&&r._callCppProxy("clearMessages",S.CHATROOM,e,""),r._callCppProxy(s,e,t,(function(){r._addChatroomCache(e,t,n),i(a.SUCCESS)}),i)}))},t.prototype.joinChatroom=function(e,t){return this._joinChrm(e,t,!1,!0)},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(a.SUCCESS)}),n)}))},t.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],o=[];if(n.length>0)for(var s=0;s<n.length;s++)o.push(JSON.parse(n[s].obj));r({code:a.SUCCESS,data:{userInfos:o,userCount:t}})}),(function(e){r({code:e})}))}))},t.prototype.getChatroomHistoryMessages=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomHistoryMessage",e,t,n,o,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:a.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},t.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o,r){var s='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(a.SUCCESS)}),(function(e){o(e)}))}))},t.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r,s){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(a.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return oe(this,void 0,void 0,(function(){var n;return re(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===a.SUCCESS?[2,{code:a.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},t.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:a.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},t.prototype.getFileToken=function(e,t,n,o){var r=this;return n=n||"",o=o||"",new Promise((function(s){var i;i=o&&"uploads"!==o?t||"":w(e,t),r._callCppProxy("getUploadToken",e,i,n,o,(function(e,t,n,o,r,c,u,p,l,d,f,h,g,v,C,_,S,y){s({code:a.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:i,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:h,s3Signature:g,s3BucketName:v,stcAuthorization:C,stcContentSha256:_,stcDate:S,stcBucketName:y}})}),(function(e){s({code:e})}))}))},t.prototype.getFileUrl=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("getDownloadUrl",e,n,o,t-1,(function(e){s({code:a.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},t.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("clearData");t({code:a.SUCCESS,data:o})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(x.getPath("userData"));return Be(e)},t.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:a.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},t.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,o){var r=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,s,(function(){n(a.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getGroupMessageDeliverList=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getGroupMessageDeliverList",e,n,t,(function(e,t){var n=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));r({code:a.SUCCESS,data:{totalCount:t,list:n}})}),(function(e){r({code:e})}))}))},t.prototype.getPrivateMessageDeliverTime=function(e,t){var n=this;return new Promise((function(o,r){var s=n._callCppProxy("getMessageDeliverTime",e);if(s)o({code:a.SUCCESS,data:s});else{n._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,n=JSON.parse(e).list;n.length>0&&(t=JSON.parse(n[0].obj).time);o({code:a.SUCCESS,data:t})}),(function(e){o({code:e})}))}}))},t.prototype.rtcSignaling=function(e,t,n,o){var r=this,s=Array.prototype.slice.call(new Uint8Array(o));return new Promise((function(o){r._callCppProxy("rtcSignaling",e,t,n,s,(function(e){var t=new Uint8Array(e).buffer;o({code:a.SUCCESS,buffer:t})}),(function(e){o({code:e})}))}))},t.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,n){var o=e.rtcHeartbeatResolves[t];if(o){var r=o.find((function(e){return""===e.seqId}));r&&(r.seqId=n)}}),(function(t,n,o,r){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===o}));-1!==i&&s.splice(i,1)[0].resolve({code:n,data:{version:Number(r)}})}}))},t.prototype.rtcPing=function(e,t,n){var o=this;return new Promise((function(t){var n={resolve:t,seqId:""},r=o.rtcHeartbeatResolves[e];r?r.push(n):o.rtcHeartbeatResolves[e]=[n],o._callCppProxy("sendRTCHeartbeat",[e])}))},t.prototype.createTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteTag",e,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.updateTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:a.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("getTags"),r=e._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:a.SUCCESS,data:r})}))},t.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:a.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getConversationListByTag=function(e,t,n,o){var r=this;return new Promise((function(s){var i=r._callCppProxy("getConversationsForTagByPage",e,t,n||20,o||""),c=r._convertResultList(i,(function(e){return ne(ne({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:a.SUCCESS,data:c})}))},t.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o,r){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);o({code:a.SUCCESS,data:s})}))},t.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:a.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),s=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:a.SUCCESS,data:s})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(e,t){var n=this;return new Promise((function(o){var r=P(t)?n._callCppProxy("getTopConversations",e):n._callCppProxy("getTopConversations",e,t),s=JSON.parse(r).list.map((function(e){return n._buildConversation(e.obj)}));o({code:a.SUCCESS,data:s})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},t.prototype.getOSInfo=function(){return oe(this,void 0,void 0,(function(){var t;return re(this,(function(n){return t={arch:e.arch(),platform:e.platform(),type:e.type(),version:e.version(),release:e.release(),uptime:e.uptime(),cpus:e.cpus(),freemem:e.freemem(),totalmem:e.totalmem(),networkInterfaces:e.networkInterfaces()},[2,{code:a.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return oe(this,void 0,void 0,(function(){return re(this,(function(e){return[2,{code:a.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},t.prototype.setCallInfo=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("callInfoSignaling",e,t,n,(function(e,t){r({code:a.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t.prototype.setProxy=function(e){var t=this;return this.tcpMgr.getConnectionStatus()!==C.DISCONNECTED?new Promise((function(e){e({code:a.RC_CONN_PROXY_UNAVAILABLE})})):new Promise((function(n){n(we(e,t.logger))}))},t.prototype.getProxy=function(){return new Promise((function(e){e(be())}))},t.prototype.testProxy=function(e,t){return function(e,t,n){return new Promise((function(o){var r=/^https/.test(t)?Ne:Te;n.info(u.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var s=r(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var n="";e.on("data",(function(e){n+=e})),e.once("end",(function(){o({status:t||0,data:n})}))}));s.once("timeout",(function(){return o({status:0})})),s.once("error",(function(e){return o({status:0,data:e.stack})})),s.end()}))}(e,t,this.logger)},t.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(n){t._callCppProxy("checkDuplicateMessage",e),n({code:a.SUCCESS})}))},t}(),Ye=function(){function e(e,t,n,o){void 0===n&&(n=""),this._cppService=new We(e,t,n,o)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e.prototype.__createLogger=function(e,t){return null},e}(),Xe=function(e){return function(e,t,n){if(xe)return xe;if(!t)throw new Error("Initializ failed, `appkey` is required!");return xe=new Ye(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.logOutputLevel)}($,e.appkey,e)};export{Xe as default};
|
|
1
|
+
import*as e from"os";import{platform as t,arch as n}from"os";import{resolve as o}from"path";import{fork as r}from"child_process";import{existsSync as s,readFileSync as i,writeFileSync as a,mkdirSync as c}from"fs";import{app as u,ipcMain as p}from"electron";import{getUUID as l,BasicLogger as d,appendUrl as f,ErrorCode as h,HTTP_TIMEOUT as g,LogTagId as v,StoreKeys as C,BasicReporter as S,REAT_TIME_LOG_SIZE as _,notEmptyObject as y,NAVI_CACHE_DURATION as m,BasicNavi as P,NAVI_REQ_TIMEOUT as E,FORMATED_VERSION as I,RCConnectionStatus as T,AConnectionMgr as R,ConversationType as M,SEND_MESSAGE_TYPE_OPTION as O,isObject as N,isUndefined as U,pushJSONToConfigs as b,MessageDirection as x,NotificationStatus as w,MessageType as L,MentionedType as A,pushConfigsToJSON as D,ReceivedStatus as k,isArray as J,getUploadFileName as j}from"@rongcloud/engine";import{Agent as H,request as B}from"http";import{Agent as F,request as V}from"https";import{parse as G}from"url";import{isIP as q,Socket as K}from"net";import{EventEmitter as W}from"events";import{connect as X}from"tls";import{createHash as Y}from"crypto";var Q=process.versions.electron.replace(/\.\d+$/,""),z=o(__dirname,"binding","electron-v".concat(Q,"-").concat(t(),"-").concat(n(),".node")),$={addon:null};try{$.addon=require(z)}catch(e){console.error("error ->",z,"\n",e)}var Z=$.addon,ee=function(e,t){return ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ee(e,t)};function te(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}ee(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ne,oe=function(){return oe=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},oe.apply(this,arguments)};function re(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function se(e,t){var n,o,r,s,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,o=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){i.label=a[1];break}if(6===a[0]&&i.label<r[1]){i.label=r[1],r=a;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(a);break}r[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function ie(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_O="P-connect-O",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R"}(ne||(ne={}));var ae,ce={flushTimestamp:Date.now(),queue:[],locked:!1};function ue(){ae&&clearInterval(ae)}function pe(e,t){ue(),ae=setInterval((function(){return de(e,t)}),1e4)}function le(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=ce.queue).push.apply(e,t)}function de(e,t){var n=ce.queue,o=ce.flushTimestamp;if(!(ce.locked||0===n.length||Date.now()-o<3e4&&n.length<200)){ce.locked=!0;var r=t.createTraceId(),s=n.splice(0,200).map((function(e){var t=e.sessionId,n=e.level,o=e.time,r=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:n,time:o,type:r,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(ne.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(ne.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),ce.flushTimestamp=Date.now(),ce.locked=!1,setTimeout((function(){return de(e,t)}))}}var fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return te(t,e),t.prototype.flush=function(e){le(e)},t}(d),he=function(e,t){var n,o=Buffer.from(e),r=o.length;for(t.push(r),n=0;n<r;n++)t.push(o[n])},ge=function(e){return"string"==typeof e},ve=function(e){return ge(e)?e.toUpperCase():""},Ce=function(e,t){var n="";return 2!==e.length?n="Unexpected number of bytes received.":5!==e[0]?n="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?n="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(n="Unexpected SOCKS authentication method: ".concat(e[1],".")),n},Se=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},_e=function(e){var t=ve(e.method)||"GET",n=e.pathname||"/",o=e.headers||{},r=e.search||"";o.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(n+r," HTTP/1.1\n"),o)if(Object.hasOwnProperty.call(o,i)){var a=o[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},ye=function(e){return new Promise((function(t){var n,o;e.socket.once("data",(function(o){var r,s=Ce(o,n);if(!s)return 2===o[1]?(e.socket.once("data",(function(n){var o=Se(n);o?e.emit("error",new Error("SOCKS authentication failed. ".concat(o))):t()})),r=[1],he(e.socksUsername,r),he(e.socksPassword,r),void e.write(Buffer.from(r))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),n=[0],e.socksUsername&&n.push(2),(o=Buffer.alloc(2+n.length))[0]=5,o[1]=n.length,n.forEach((function(e,t){o[2+t]=e})),e.write(o)}))},me=function(e,t,n){return new Promise((function(o){var r,s;switch(e.socket.once("data",(function(t){var n;5!==t[0]?n="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?n="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(n="The reserved byte must be 0x00."),n?e.emit("error",new Error("SOCKS connection failed. ".concat(n))):o()})),(r=[]).push(5),r.push(1),r.push(0),q(t)){case 0:r.push(3),he(t,r);break;case 4:r.push(1),function(e,t){var n,o,r=e.split(".");for(n=0;n<4;n++)o=parseInt(r[n],10),t.push(o)}(t,r);break;case 6:e.emit("error",new Error("Does not support IPV6"))}r.length+=2,(s=Buffer.from(r)).writeUInt16BE(n,s.length-2),e.write(s)}))},Pe=function(e){function t(t){var n=e.call(this)||this;return n.readable=!0,n.socket=new K,n.options=t,n.socksHost=t.socksHost||"localhost",n.socksPort=t.socksPort||1080,n.socksUsername=t.socksUsername||"",n.socksPassword=t.socksPassword||"",n.socket.on("error",(function(e){n.emit("error",e)})),n.on("error",(function(){n.socket.destroyed||n.socket.destroy()})),n.on("end",n.end),n}return te(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var n=this.socket.end(e,t);return this.writable=this.socket.writable,n},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,n){return this.socket.write(e,t,n)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var n=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return re(n,void 0,void 0,(function(){var n;return se(this,(function(o){switch(o.label){case 0:return[4,ye(this)];case 1:return o.sent(),[4,me(this,t,e)];case 2:return o.sent(),this.onProxied(),n=_e(this.options),this.socket.write(Buffer.from(n)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(W),Ee=function(e){var t,n=e.hostname,o=e.port;return!e.host||n&&o||(t=e.host.split(":")),!o&&t&&(o=parseInt(t[1],10)||0),!n&&t&&(n=t[0]),new Pe(e).connect(o,n)},Ie=function(e){function t(t){var n=e.call(this)||this;return n.createConnection=Ee,n}return te(t,e),t}(H),Te=function(e,t,n){return(t=oe(oe({},t),G(e))).port||(t.port=80),t.agent=new Ie(t),B(t,n)},Re=function(e){var t,n;return t=Ee(e),n=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=X(e,(function(){t.authorized=t.socket.authorized,n.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},Me=function(e){function t(t,n){var o=e.call(this,n)||this;return o.url=t,o.socksHost=n.socksHost||"localhost",o.socksPort=n.socksPort||1080,o.createConnection=Re,o}return te(t,e),t}(F),Oe=function(e,t,n,o){var r,s;return t.protocol="https:",!t.port&&t.host&&(r=t.host.split(":"),t.port=r[0],t.port=r[1]),t.port||(t.port=443),s=new Me(e,t),t.agent=s,V(e,t,n)},Ne=null;function Ue(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,i=t.method,a=t.query,c=t.timeout,u=void 0===c?g:c;return new Promise((function(t){var c=/^https/.test(o),p={headers:r,method:i};c&&(p.rejectUnauthorized=n);var l=null;Ne?((p=oe(oe({},p),Ne)).body=s,l=c?Oe:Te):(l=B,c&&(p.agent=new F(p),l=V));var d=l(f(o,a),p,(function(e){var n=e.statusCode,o="";e.setEncoding("utf8"),e.on("data",(function(e){o+=e})),e.once("end",(function(){t({status:n||0,data:o})}))}));d.once("timeout",(function(){e.warn(ne.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:i,query:a,timeout:u})),t({status:0})})),d.setTimeout(u),d.once("error",(function(n){e.warn(ne.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:i,query:a,timeout:u})),t({status:0})})),d.write(s),d.end()}))}function be(e,t){return e?(Ne=oe(oe({},Ne),e),t.info(v.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Ne})),{code:h.SUCCESS}):(Ne=null,t.info(v.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:h.SUCCESS})}function xe(){var e=Ne||void 0;return{code:h.SUCCESS,data:e}}var we,Le=[],Ae=!1,De=function(){return re(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c,u,p;return se(this,(function(l){return Ae||0===Le.length||(Ae=!0,e=Le.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=0,u=0,p=[],o.setLogEventListener((function(e){c+=e.length;var t=e.split(","),o=t[0],r=t[1],s=t[2],l=t[3],d=t[4],f=t.slice(5);if(c>_&&parseInt(r,10)!==u)n(p);else{u=parseInt(r,10);try{var h=JSON.parse(decodeURIComponent(f.join(","))),g=h.loggerId,v=h.sessionId,C=h.content,S=h.traceId;if(!a&&i<0)return;var y={time:parseInt(r,10),level:parseInt(l,10),sessionId:"".concat(o,":").concat(v),type:s,tag:d,loggerId:g,content:C,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){n(p),Ae=!1,De()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},ke=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,c="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return i=e.call(this,n,o,c,{getLogs:function(e,n,o,r){return re(this,void 0,void 0,(function(){return se(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:n,level:o,realtimeReport:r,addon:t},re(void 0,void 0,void 0,(function(){return se(this,(function(e){return[2,new Promise((function(e){Le.push({resolve:e,args:i}),De()}))]}))})))];case 1:return[2,{logs:s.sent(),dbReady:!0}]}var i}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(C.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(C.REALTIME_LOG_TIMESTAMP,e.toString())}},r)||this,i.subProcess=s,i}return te(t,e),t.prototype.send=function(e){return Ue(this.logger,e)},t.prototype.compressLogs=function(e){return re(this,void 0,void 0,(function(){var t,n,o;return se(this,(function(r){switch(r.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=r.sent(),n=t.success,o=t.data,n?[2,{success:n,data:o}]:[2,{success:n,data:""}]}}))}))},t}(S),Je=null,je=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,Y("md5").update(e).digest("hex")},He=function(e){if(Je)return Je;var t=o(e,"deviceId");return s(t)?Je=i(t).toString():(Je=je(),a(t,Je),Je)},Be=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,n,o,r,s){var i=JSON.stringify(r);"{}"!==i&&e.info(ne.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:o,ext:r})),this._cppProto.setMessageExtension(t,n,o,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,o,r,s,c,n||"")},e.prototype.setLocalFromExtMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,l=JSON.parse(p||"{}");if(c)for(var d in c){var f=l[d];f&&f.ts<i-this._setTime?(f.v=c[d],f.ts=i-this._setTime):(l[d]={v:"",ts:0},l[d].v=c[d],l[d].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete l[e]})),this._setToProtocol(e,o,r,a.mid,l,n||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),n={};for(var o in t)n[o]=t[o].v;return n},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),n=JSON.parse(t||"{}"),o={};for(var r in n)o[r]=n[r].v;return o},e}(),Fe=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var n=e.reqId,o=e.success,r=e.data,s=t.maps[n];s&&(s({success:o,data:r}),delete t.maps[n])}))}return e.prototype.call=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return re(this,void 0,void 0,(function(){var n=this;return se(this,(function(o){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(o){var r=++n.count;n.maps[r]=o;var s={reqId:r,method:e,args:t};n.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),Ve=function(e){function t(t,n,o,r){var s=e.call(this,t,n,[])||this;return s.addon=r,s.naviPath="",s._caches={},s.naviPath="".concat(o,"/navi-cache.json"),s}return te(t,e),t.prototype.updateCustomNavis=function(e){var t;e.length&&(t=this.navigators).splice.apply(t,ie([0,this.navigators.length],e,!1))},t.prototype.httpRequest=function(e,t,n,o){return re(this,void 0,void 0,(function(){var r,s,i,a,c;return se(this,(function(u){switch(u.label){case 0:return r="token=".concat(encodeURIComponent(n),"&v=").concat(I,"&p=PC&ev=").concat("5.7.4-beem.1"),s="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(v.L_REQUEST_T,JSON.stringify({url:s,body:r}),o),[4,Ue(this.logger,{method:"POST",headers:{appId:t},body:r,url:s,timeout:E})];case 1:if(200!==(i=u.sent()).status)return this.logger.warn(v.L_REQUEST_R,JSON.stringify({url:s,code:i.status}),o),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s)?"https":"http",a.protocol=c,[2,{code:h.SUCCESS,data:a}]}catch(e){return this.logger.error(v.L_PARSE_NAVI_E,i.data,o),[2,{code:h.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.httpRequestV2=function(e,t,n,o){return re(this,void 0,void 0,(function(){var r,s,i,a;return se(this,(function(c){switch(c.label){case 0:return r=this.getNaviV2RequestOption({appkey:t,token:n,uri:e,platform:"electron",isTcp:!0}),this.logger.debug(v.L_REQUEST_T,JSON.stringify({url:r.url,body:r.body,headers:r.headers}),o),[4,Ue(this.logger,r)];case 1:if(200!==(s=c.sent()).status)return this.logger.warn(v.L_REQUEST_R,JSON.stringify({url:r.url,code:s.status}),o),[2,{code:this.transHttpCode(s.status)}];try{return i=JSON.parse(s.data),a=/^https/.test(r.url)?"https":"http",i.protocol=a,[2,{code:h.SUCCESS,data:i}]}catch(e){return this.logger.error(v.L_PARSE_NAVI_E,s.data,o),[2,{code:h.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!s(this.naviPath))return null;var n=i(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[e]}catch(e){this.logger.error(v.L_PARSE_NAVI_E,n)}return null},t.prototype.setNaviCache=function(e,t){var n=Date.now();if(y(this._caches))for(var o in this._caches){var r=this._caches[o];(n-r.timestamp>m||e===r.token)&&delete this._caches[o]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},a(this.naviPath,JSON.stringify(this._caches))},t}(P),Ge=function(e){function t(t,n,o,r,s){var i=e.call(this,t,o,r,s)||this;return i.addon=n,i._connectedTime=0,i._curCmpUrl="",i.connectResolve=null,i.pingResolve=null,i.addon.setConnectionStatusListener(i._onConnectionStatusChange.bind(i),(function(e){i.logger.info(ne.P_DB_OPEN_O,e)}),(function(){return i.recvPong(h.SUCCESS)}),i._onConnectionStatusChange.bind(i),i._onTcpConnectResponse.bind(i)),i}return te(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,n,o){var r=this;return new Promise((function(s){r.connectResolve={resolve:s,traceId:o,userId:t.userId};var i=null,a=xe().data;a&&(i=JSON.stringify({proxy_passwd:a.socksPassword||"",proxy_name:a.socksUsername||"",proxy_port:a.socksPort||1082,proxy_host:a.socksHost||"localhost",proxy_type:0}));var c=r.getCmpList(t,!0).sort((function(e,t){return e.weight>t.weight?-1:1}));try{r.addon.connectWithToken(e,I,JSON.stringify(oe(oe({},t),{serverAddr:c})),n,i)}catch(e){r.logger.error(ne.P_CALL_ADDON_E,null==e?void 0:e.stack,o),r.recvConnectRes(h.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(n){t.pingResolve=n,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(h.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e){switch(this.logger.info(ne.P_CONNECT_S,e),e){case h.SUCCESS:this.recvConnectRes(h.SUCCESS);break;case h.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(h.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case h.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case h.RC_SOCKET_NOT_CREATED:case h.RC_CONN_ACK_TIMEOUT:case h.RC_TCP_RESET:this.recvConnectRes(e);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t){if(this.connectResolve){var n=this.connectResolve,o=n.resolve,r=n.userId;return e===h.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),o({code:e,data:r}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e);else{if(e===h.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==T.CONNECTED)return;e===h.RC_TCP_RESET&&this.updateCmpWeight(this._curCmpUrl,!1),this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,n,o,r,s,i){e===h.SUCCESS&&(this._curCmpUrl="".concat(t,":").concat(n),this.updateCmpWeight("".concat(t,":").concat(n)))},t}(R),qe=function(e){if(!s(e)){var t=o(e,"..");s(t)||qe(t),c(e)}},Ke=function(){function t(e,t,n,s){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._logOutputLevel=s,this._customMessageType={},this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var a=this._dbpath||o(u.getPath("userData")),c=He(a);this._cppProtocol.initWithAppkey(e,a,I);var d=r(o(__dirname,"sub-process.js"));this.subProxy=new Fe(d);var f=o(a,"RongCloud/rclogs",e);qe(f),function(e,t,n){n.initLogModule(t,e,l())}(e,f,this._cppProtocol),this.logger=new fe(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),pe(this._cppProtocol,this.logger),this.reporter=new ke(this._cppProtocol,e,c,this.logger,this.subProxy),this.logger.info(ne.P_INIT_O,JSON.stringify({appkey:e,dbpath:a,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:c,commit:"d99bbfee11594dfbe4a84452e1b654ca0fb130ca"})),this._callCppProxy("setDeviceId",c);var g=o(a,"RongCloud/navis",e);qe(g),this.navi=new Ve(e,this.logger,g,this._cppProtocol),this.tcpMgr=new Ge(e,this._cppProtocol,this.navi,this.logger,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),p.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return re(i,void 0,void 0,(function(){var o,r,s;return se(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(ne.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=h.NOT_SUPPORT,[2];r=h.EXTRA_METHOD_UNDEFINED,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,ie([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(ne.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==s?void 0:s.stack,method:t})),[3,4];case 4:return e.returnValue=r,[2]}}))}))})),p.handle("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return re(i,void 0,void 0,(function(){var t,r,s,i=this;return se(this,(function(a){if("function"!=typeof(t=this[n]))return this.logger.error(ne.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),[2,h.NOT_SUPPORT];"sendMessage"===n&&(r=o[3],o[3]=function(t){i._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",r,t)});try{return s=t.call.apply(t,ie([this],o,!1)),[2,Promise.resolve(s).catch((function(e){return i.logger.error(ne.P_CALL_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:n})),h.EXTRA_METHOD_UNDEFINED}))]}catch(e){return this.logger.error(ne.P_CALL_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:n})),[2,Promise.resolve(h.EXTRA_METHOD_UNDEFINED)]}return[2]}))}))})),p.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=i[t];if("function"==typeof r)try{r.call.apply(r,ie([i],n,!1))}catch(e){i.logger.error(ne.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(ne.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),p.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new Be(this._cppProtocol)}return t.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},t.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},t.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.logger.createTraceId();try{var s=(t=this._cppProtocol)[e].apply(t,n);return s}catch(t){this.logger.error(ne.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return Ue(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){le.apply(void 0,e)},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){ue(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},t.prototype.callExtra=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this[e];if(!o)return this.logger.warn(ne.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:h.EXTRA_METHOD_UNDEFINED});try{var r=o.call.apply(o,ie([this],t,!1));return r}catch(t){this.logger.error(ne.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:h.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(e,t,n,o){var r,s=this,i=this._callCppProxy("getConversationListByPage",e,t,n,o||"");try{r=JSON.parse(i).list.map((function(e){return s._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:h.MAIN_PROCESS_ERROR})}return Promise.resolve({code:h.SUCCESS,data:r})},t.prototype.getUnreadConversationList=function(e){var t,n=this,o=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(o).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:h.MAIN_PROCESS_ERROR})}return Promise.resolve({code:h.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannel=function(e){var t=this;void 0===e&&(e=[1,3,13]);var n,o=this._callCppProxy("getConversationListWithAllChannel",e);try{n=JSON.parse(o).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:h.MAIN_PROCESS_ERROR})}return Promise.resolve({code:h.SUCCESS,data:n})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[M.PRIVATE,M.GROUP,M.OFFICIAL],s=this._callCppProxy("getConversationListWithAllChannelByPage",r,e,t);try{n=JSON.parse(s).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:h.MAIN_PROCESS_ERROR})}return Promise.resolve({code:h.SUCCESS,data:n})},t.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,s,i){var a=0===s,c=o+1,u=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,c,r,a,i||""),p=[];try{var l=JSON.parse(u).list;l.reverse();for(var d=0;d<l.length;d++){var f=this._buildMessage(l[d].obj);p[d]=f}}catch(e){return Promise.resolve({code:h.MAIN_PROCESS_ERROR})}return Promise.resolve({code:h.SUCCESS,data:{list:c===p.length?p.slice(1,c):p,hasMore:o<p.length}})},t.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o="");var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:h.SUCCESS,data:r})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==T.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new fe(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,ie([t],n,!1))},t.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var s=o._senders[r];n.includes(s)||o._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),n=this.getNaviInfoFromCache(),o=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:o,naviInfo:n,connectionStatus:t}},t.prototype._registerRenderers=function(e,t){var n=this,o=e.sender,r=o.id;this.navi.updateCustomNavis(t.navigators),this._senders[r]||(this._senders[r]=o,o.once("destroyed",(function(){delete n._senders[r]})))},t.prototype._registerMsgTypes=function(){for(var e in O["RC:RcCmd"]={isCounted:!1,isPersited:!1},O){var t=O[e],n=t.isCounted,o=t.isPersited,r=t.searchProps,s=0;o&&(s|=1),n&&(s|=2),"RC:TypSts"===e&&(s=16),this._callCppProxy("registerMessageType",e,s,r||[])}},t.prototype._buildIsMentioned=function(e,t){var n,o=!1;if(N(e))n=e;else try{n=e?JSON.parse(e):e}catch(o){n=e,this.logger.error(ne.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return N(n)&&(o=!!n.mentionedInfo),{isMentioned:o,msgContent:n}},t.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in O?t=O[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},t.prototype._buildSupportExt=function(e,t,n){var o=null;return e&&(o=this._msgExpansionHandler.parseReceiveExpansion(n),"conversation"!==t&&"history"!==t||(o=this._msgExpansionHandler.parseConverOrHisExpansion(n))),o},t.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e),s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,p=r.objectName,l=r.messageUid,d=r.direction,f=r.status,h=r.messageId,g=r.sentTime,v=r.readReceiptRequest,C=r.supportExt;r.extMsg;var S=r.extraContent,_=r.pushContent,y=r.pushTitle,m=r.pushId,P=r.pushConfig,E=r.templateId,I=r.disableTitle,T=r.forcePushDetail,R=r.ftsHighlight,M=this._buildIsMentioned(u,h),O=M.isMentioned,N=M.msgContent,w=this._buildMsgOption(p),L=this._buildSupportExt(C,o,r),A=U(n)?g<this.tcpMgr.getConnectedTime():n,D={};P&&(D=b(this.logger,P,m));var k=oe(oe({},D),{pushTitle:y,pushContent:_,pushData:_,disablePushTitle:I,forceShowDetailContent:T,templateId:E}),J={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:N||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:A,sentTime:g,extraContent:S,receivedTime:0,isPersited:w.isPersited,isCounted:w.isCounted,isMentioned:O,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:C,expansion:C?L:null,receivedStatus:f,messageId:h,pushConfig:k,ftsHighlight:R};if(d===x.RECEIVE?J.receivedStatus=f:d===x.SEND&&(J.sentStatus=f),v){var j=JSON.parse(v),H=j.hasRespond,B=j.readerInfo,F={hasRespond:H,readCount:j.readCount,totalCount:j.totalCount},V=[];if(B)for(var G in B)V.push({userId:G,readTime:B[G]});F.readerList=V,J.readReceiptInfo=F}return J},t.prototype._buildMessageV2=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=e,s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,p=r.objectName,l=r.messageUid,d=r.direction,f=r.status,h=r.messageId,g=r.sentTime,v=r.readReceiptRequest,C=r.supportExt;r.extMsg;var S=r.extraContent,_=r.pushContent,y=r.pushTitle,m=r.pushId,P=r.pushConfig,E=r.templateId,I=r.disableTitle,T=r.forcePushDetail,R=this._buildIsMentioned(u,h),M=R.isMentioned,O=R.msgContent,N=this._buildMsgOption(p),w=this._buildSupportExt(C,o,r),L=U(n)?g<this.tcpMgr.getConnectedTime():n,A={};P&&(A=b(this.logger,P,m));var D=oe(oe({},A),{pushTitle:y,pushContent:_,pushData:_,disablePushTitle:I,forceShowDetailContent:T,templateId:E}),k={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:O||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:L,sentTime:g,extraContent:S,receivedTime:0,isPersited:N.isPersited,isCounted:N.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:C,expansion:C?w:null,receivedStatus:f,messageId:h,pushConfig:D};if(d===x.RECEIVE?k.receivedStatus=f:d===x.SEND&&(k.sentStatus=f),v){var J=JSON.parse(v),j=J.hasRespond,H=J.readerInfo,B={hasRespond:j,readCount:J.readCount,totalCount:J.totalCount},F=[];if(H)for(var V in H)F.push({userId:V,readTime:H[V]});B.readerList=F,k.readReceiptInfo=B}return k},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=oe(oe({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},t.prototype._buildConversation=function(e){var t=JSON.parse(e),n=t.channelId,o=t.conversationType,r=t.targetId,s=t.unreadCount,i=t.lastestMsg,a=t.isTop,c=t.isBlocked,u=t.matchCount,p=t.hasUnreadMention,l=t.sortTime,d=c?w.OPEN:w.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:p,mentionedInfo:null,notificationStatus:d,isTop:a,lastUnreadTime:0,matchCount:u,sortTime:l}},t.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},t.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var s,i=e._buildMessage(t,{isOffLineMessage:o}),a=i.messageType,c=i.channelId,u=void 0===c?"":c;if(a!==L.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===L.GROUP_READ_RECEIPT_REQUEST){var p=i.content,l=p.msgId,d=p.rrn,f=p.tmn;e._updateReadReceiptInfo(l,{readCount:d,totalCount:f})}if("RC:MsgExMsg"===a)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,i),void e._sendMessageExpansion(i);if(i.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(e.logger,i),a!==L.SYNC_READ_STATUS||i.senderUserId===e.tcpMgr.getCurrentUserId()){a===L.SYNC_READ_STATUS&&e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,u);var h=!0;if(0!==n||r||(h=!1),a===L.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(i.content)),void e._sendMessageDelivered(i.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(a!==L.DELIVERED_MSG){var g=i.conversationType,v=i.targetId;if(a===L.RECALL){e.handleRecalledMessage(i);var C=e._fixRecallContentInfo(i);g=C.conversationType,v=C.targetId}e._sendMessageNotification(Object.assign(i,{hasMoreMsg:h,conversationType:g,targetId:v}))}else{var S={totalCount:i.content.tmn,list:null===(s=i.content.dl)||void 0===s?void 0:s.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(S)}}}else{var _=i.content,y=_.startTime,m=_.endTime,P=_.platform,E=_.logId,I=_.uri;e.reporter.report(parseInt(y,10),parseInt(m,10),P,I,E,i.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,n=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,n=e.content.targetId||n),{conversationType:t,targetId:n}},t.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var n=this._callCppProxy("getMessage",t),o=this._buildMessage(n,{isOffLineMessage:!1});if(o.messageId){var r={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:o.messageType,originalMessageContent:o.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(r.user=e.content.user),e.content.extra&&(r.extra=e.content.extra),o.messageType===L.TextMessage&&(r.recallContent=o.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[o.messageId]):(o.receivedStatus||this.setMessageReceivedStatus(o.messageId,1),this._callCppProxy("setMessageContent",o.messageId,JSON.stringify(r),L.RECALL_NOTIFICATION_MESSAGE))}}},t.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,s=o.del,i=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:n,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},t.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},t.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},t.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,o=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=t.conversationType,r=t.targetId,s=t.status,i=t.channelId,a={notificationStatus:2,isTop:!1};s.forEach((function(e){var t=JSON.parse(e.item);1===t.type?a.notificationStatus=1===Number(t.value)?w.OPEN:w.CLOSE:a.isTop=1===Number(t.value)})),o.push({channelId:i,conversationType:n,targetId:r,updatedItems:{notificationStatus:{val:a.notificationStatus,time:0},isTop:{val:a.isTop,time:0}}})})),e._send2AllRenderer("conversation",o)}),(function(t){e._send2AllRenderer("conversationTag",t)}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var n=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",n)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var n=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",n)}),(function(t,n){e._send2AllRenderer("onMeetingEvent",{eventType:t,buffer:n})}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._updateMentionedInfo=function(e,t,n){var o,r,s;return{userIdList:(null===(o=e.mentionedInfo)||void 0===o?void 0:o.userIdList)||t,type:(null===(r=e.mentionedInfo)||void 0===r?void 0:r.type)||n||A.ALL,mentionedContent:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,n,o){void 0===o&&(o=[]);var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(ne.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:o})),this._callCppProxy("registerMessageType",e,r,o)},t.prototype.connect=function(e,t,n){return this.tcpMgr.connect(e,t,n)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(oe(oe({},e),{"electron-main":"5.7.4-beem.1"}));this.logger.info(ne.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o)},t.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),be(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},t.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("subscribeUserStatus",e,(function(){n(h.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(h.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:h.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},t.prototype.sendMessage=function(e,t,n,o,r){var s=this;void 0===r&&(r=this.logger.createTraceId());var i=n.messageType,a=n.content,c=n.expansion,u=n.pushConfig,p=n.isMentioned,l=n.mentionedType,d=n.mentionedUserIdList,f=void 0===d?[]:d,g=n.pushContent,v=void 0===g?"":g,C=n.pushData,S=void 0===C?"":C,_=n.directionalUserIdList,y=void 0===_?[]:_,m=n.disableNotification,P=void 0!==m&&m,E=n.canIncludeExpansion,I=void 0!==E&&E,T=n.isVoipPush,R=void 0!==T&&T,O=n.channelId,N=void 0===O?"":O,U=n.messageId,b=void 0===U?0:U,x=n.isResend,w=void 0!==x&&x,A=n.sessionTag,k=void 0===A?0:A,J=n.isBroadcast,j=void 0!==J&&J,H=u||{},B=H.iOSConfig,F=H.androidConfig,V=H.templateId,G=void 0===V?"":V,q=H.pushTitle,K=void 0===q?"":q,W=H.pushContent,X=void 0===W?v:W,Y=H.pushData,Q=void 0===Y?S:Y,z=H.disablePushTitle,$=void 0!==z&&z,Z=H.forceShowDetailContent,ee=void 0!==Z&&Z,te=D(B,F);return new Promise((function(n){v=X,S=Q;var u=(null==F?void 0:F.notificationId)||"";if(e===M.GROUP&&p&&a&&(a.mentionedInfo=s._updateMentionedInfo(a,f,l)),e===M.GROUP&&i===L.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var d in a.receiptMessageDic)y.push(d);var g={};for(var d in c)g[d]={v:""},g[d].v=c[d];var C=G;s.logger.info(ne.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:N,messageId:b,isResend:w}),r);var _=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(ne.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===h.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===o.messageType&&s._msgExpansionHandler.setLocalFromExtMsg(s.logger,o),o.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(s.logger,o),n({code:h.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(ne.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),r),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(a),y,P,$,ee,v,S,u,K,te,C,I,JSON.stringify(g),R,N,b,w,k,j),m=JSON.parse(_);null==o||o(m.messageId)}))},t.prototype.recallMsg=function(e,t,n,o,r){var s=this;return new Promise((function(i,a){var c,u=r.user,p=r.pushContent,l=r.channelId,d=r.extra,f=r.pushConfig,g=r.disableNotification,v=r.isDelete,C={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:u,extra:d,channelId:l,isDelete:v||!1};u&&(C.user=u),d&&(C.extra=d);var S={conversationType:e,targetId:t,senderUserId:s.tcpMgr.getCurrentUserId(),content:C,objectName:L.RECALL,messageUid:n,direction:x.SEND,status:k.UNREAD,sentTime:o,channelId:l},_=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(_),i({code:h.SUCCESS,data:_})}),(function(e){i({code:e})}),L.RECALL,JSON.stringify(C),g||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,p||"",(null==f?void 0:f.pushData)||"",(null===(c=null==f?void 0:f.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==f?void 0:f.pushTitle)||"",D(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig),(null==f?void 0:f.templateId)||"",l)}))},t.prototype.getHistoryMessage=function(e,t,n,o,r,s,i){var a=this;return new Promise((function(c,u){n=n||0;var p=0===r,l=o+1,d=a._callCppProxy("getHistoryMessagesV2",e,t,n,l,i,p,s),f=[];d.reverse();for(var g=0;g<d.length;g++){d[g].content=JSON.parse(d[g].content);var v=a._buildMessageV2(d[g]);f[g]=v}c({code:h.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:o<f.length}})}))},t.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,s){var i=this;return new Promise((function(a,c){n=n||0;i._callCppProxy("getRemoteHistoryMessages",e,t,n,o,(function(e,t){var n=JSON.parse(e).list,o=[];n.reverse();for(var r=0;r<n.length;r++){var s=i._buildMessage(n[r].obj);o[r]=s}a({code:h.SUCCESS,data:{list:o,hasMore:!!t}})}),(function(e){a({code:e})}),r,!0,s)}))},t.prototype.deleteRemoteMessage=function(e,t,n,o){var r=this;return new Promise((function(s,i){var a=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,a,!1,o,(function(){s(h.SUCCESS)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(h.SUCCESS)}),(function(e){s(e)}),o)}))},t.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("clearMessages",e,t,n),r(h.SUCCESS)}))},t.prototype.getConversationList=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),new Promise((function(e,t){for(var n=s._callCppProxy("getConversationList",[1,3,6,7],r),o=JSON.parse(n).list,i=[],a=0;a<o.length;a++)i.push(s._buildConversation(o[a].obj));e({code:h.SUCCESS,data:i})}))},t.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversation",e,t,n);if(i)r({code:h.SUCCESS,data:o._buildConversation(i)});else{var a=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),c=void 0;try{c=JSON.parse(a).list}catch(e){o.logger.error(ne.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),c=[]}var u=null;c.length>0&&(u=o._buildMessage(c[0].obj));var p=o._callCppProxy("getConversationNotificationStatus",e,t,n),l=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:h.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:u,notificationStatus:p?w.OPEN:w.CLOSE,isTop:Boolean(l),lastUnreadTime:0,sortTime:(null==u?void 0:u.sentTime)||0}})}}))},t.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(o?h.SUCCESS:h.UNKNOWN)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var s=[];s=J(e)?e:[M.PRIVATE,M.GROUP,M.SYSTEM,M.PUBLIC_SERVICE,M.OFFICIAL],n._callCppProxy("clearConversations",s,t),o(h.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:h.SUCCESS,data:o})},t.prototype.getConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){var s=o._callCppProxy("getUnreadCount",e,t,n);r({code:h.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r,s){o._callCppProxy("clearUnreadCount",e,t,n),r(h.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),s(h.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),a=o._buildMessage(i);r({code:h.SUCCESS,data:-1!==a.messageId?a:null})}))},t.prototype.getMessageByUids=function(e){var t,n=this,o=this._callCppProxy("getMessageByUids",e);try{t=JSON.parse(o).list.map((function(e){return n._buildMessage(e.obj)}))}catch(e){t=[]}return t},t.prototype.setMessageSearchContent=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSearchContent",e,t),o(h.SUCCESS)}))},t.prototype.getMessageByMsgUids=function(e,t,n,o){var r,s=this,i=this._callCppProxy("getMessageByMsgUids",e,t,n,o);try{r=JSON.parse(i).list.map((function(e){return s._buildMessage(e.obj)}))}catch(e){r=[]}return r},t.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s,i){r._callCppProxy("setConversationToTop",e,t,n,o,!0),s(h.SUCCESS)}))},t.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationHidden",e,t,n,o),s(h.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(h.SUCCESS)}),s,o)}))},t.prototype.setConversationStatus=function(e,t,n,o,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationStatus",e,t,n,o,(function(){i(h.SUCCESS)}),i,r,!0)}))},t.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r,s){var i=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:h.SUCCESS,data:i?w.OPEN:w.CLOSE})}))},t.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(s,i){o=o||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContent",o,e,t,n),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);s({code:h.SUCCESS,data:u})}))},t.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r,s){n=n||[1,3,6,7];for(var i=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),a=JSON.parse(i).list,c=[],u=0;u<a.length;u++)c[u]=o._buildConversation(a[u].obj);r({code:h.SUCCESS,data:c})}))},t.prototype.searchMessageByContent=function(e,t,n,o,r,s,i){var a=this;return new Promise((function(s,c){a._callCppProxy("searchMessageByContent",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=a._buildMessage(n[r].obj);s({code:h.SUCCESS,data:{messages:o,count:t}})}),i)}))},t.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var s=this;return new Promise((function(i,a){s._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,o,r,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],o=[],r=0;r<n.length;r++)o[r]=s._buildMessage(n[r].obj);i({code:h.SUCCESS,data:{messages:o,count:t}})}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,o,r,s,i){var a=this;return new Promise((function(c,u){a._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,o,r,s,i,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=a._buildMessage(t[o].obj);c({code:h.SUCCESS,data:{messages:n}})}))}))},t.prototype.getUnreadMentionedMessages=function(e,t,n){for(var o=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,n)).list,r=0;r<o.length;r++)o[r]=this._buildMessage(o[r].obj);return o},t.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addToBlacklist",e,(function(){n(h.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(h.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:h.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},t.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:h.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},t.prototype.insertMessage=function(e,t,n){var o=this,r=n.content,s=n.senderUserId,i=n.messageType,a=n.messageDirection,c=n.readStatus,u=n.sentStatus,p=n.sentTime,l=n.searchContent,d=n.isUnread,f=n.messageUId,g=n.disableNotification,v=n.canIncludeExpansion,C=n.expansionMsg,S=n.channelId,_=n.sessionTag,y=void 0===_?0:_;r=JSON.stringify(r);var m={};if(C){var P=JSON.parse(C);for(var E in P)m[E]={v:"",ts:0},m[E].v=P[E],m[E].ts=p||0}return new Promise((function(n,C){var _=d?0:1,P=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),a,c||0,u||10,p||0,l||"",_||0,f||"",g||!1,v||!1,JSON.stringify(m)||"",S||"",y),E=o._buildMessage(P,{isOffLineMessage:!1});E.messageUId=f,E.sentTime=p,n({code:-1===E.messageId?h.MSG_INSERT_ERROR:h.SUCCESS,data:E})}))},t.prototype.batchInsertMessage=function(e,t){var n=this;return new Promise((function(o){var r=e.map((function(e){var t=e.content,n=e.senderUserId,o=e.messageType,r=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,l=e.disableNotification,d=e.canIncludeExpansion,f=e.expansion,h=e.channelId,g=e.conversationType,v=e.targetId,C=e.source,S=e.isMentioned,_={};if(f)for(var y in f)_[y]={v:"",ts:0},_[y].v=f[y],_[y].ts=a||0;return{conversationType:g,targetId:v,channelId:h||"",direction:r,senderUserId:n,status:i||10,sentTime:a||0,objectName:o,content:JSON.stringify(t),messageUid:p||"",noNotification:l||!1,supportExt:d||!1,extMsg:JSON.stringify(_),readStatus:s||0,searchContent:c||"",isUnread:u||!1,source:C||"",isMention:S}})),s=n._callCppProxy("insertMessages",JSON.stringify(r),t||!1);o({code:s?h.SUCCESS:h.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getMessageCount",e,t,n);r({code:h.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteMessages",e),n(h.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var s=this;return new Promise((function(i,a){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),i(h.SUCCESS)}))},t.prototype.getMessage=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getMessage",e),s=t._buildMessage(r,{isOffLineMessage:!1});n({code:h.SUCCESS,data:s})}))},t.prototype.setTextMessageExtra=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setTextMessageExtra",e,t),o(h.SUCCESS)}))},t.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r,s){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(h.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setMessageSearchField",e,t,n),r(h.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(h.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(h.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(e,t,n,o){throw new Error("Method not implemented.")},t.prototype.getConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},t.prototype.clearConversationMessageDraft=function(e,t,n){throw new Error("Method not implemented.")},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,s=t.notificationStatus,i=t.channelId,a=this._callCppProxy("getConversationNotificationStatus",n,o,i||""),c=this._callCppProxy("getConversationTopStatus",n,o,i||""),u=U(s)?Boolean(a):s===w.OPEN,p=U(r)?Boolean(c):r;return this.setConversationStatus(n,o,u,p,i)},t.prototype.setConversationsMuteStatus=function(e){var t=this;return new Promise((function(n){var o=[];e.forEach((function(e){var t=1===e.notificationStatus?"1":"0";o.push({conversationType:e.conversationType,channelId:e.channelId||"",targetId:e.targetId,statusType:1,statusValue:t})})),t._callCppProxy("setConversationsMuteStatus",JSON.stringify(o),(function(){n(h.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.setConversationsTopStatus=function(e){var t=this;return new Promise((function(n){var o=[];e.forEach((function(e){var t=e.isTop?"1":"0";o.push({conversationType:e.conversationType,channelId:e.channelId||"",targetId:e.targetId,statusType:2,statusValue:t})})),t._callCppProxy("setConversationsTopStatus",JSON.stringify(o),!0,(function(){n(h.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("sendReadReceipt",e,n||"",t,(function(){t.forEach((function(e){o._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(o._callCppProxy("getMessage",e)).messageId;o.setMessageReceivedStatus(t,1)}catch(t){o.logger.error(ne.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:h.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getMessageReader",e,n,t,(function(e,n){var s=[],i={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;s.push({userId:n,readTime:o}),i[n]=o}));var a={readerInfo:i,readCount:s.length,totalCount:n};o._updateReadReceiptInfo(t,a),r({code:h.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype.setGroupVoiceMessagePlayed=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setGroupVoiceMessagePlayed",e,t,n,(function(){r({code:h.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getGroupVoiceMessageReader=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getGroupVoiceMessageReader",e,t,n,(function(e,t){var n=[];(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;n.push({userId:o,readTime:r})})),r({code:h.SUCCESS,data:{list:n,totalMemberCount:t}})}),(function(e){r({code:e})}))}))},t.prototype.setReadMessages=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("setReadMessages",e,t,n,o,(function(){s({code:h.SUCCESS})}),(function(e){s({code:e})}))}))},t.prototype.getMessageReceiptInfo=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getMessageReceiptInfo",e,n,t,(function(e,n){var s=[],i={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),n=t.id,o=t.time;s.push({userId:n,readTime:o}),i[n]=o}));var a={readerInfo:i,readCount:s.length,totalCount:n};o._updateReadReceiptInfo(t,a),r({code:h.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype._addChatroomCache=function(e,t,n){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:n,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(n){return re(e,void 0,void 0,(function(){var e,o,r,s;return se(this,(function(i){switch(i.label){case 0:return e=n.chatroomId,o=n.joinExist,r=n.count,this.logger.info(v.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,r,o,!1)];case 1:return(s=i.sent())===h.SUCCESS?(this.logger.info(v.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,count:r}}),[2]):(s===h.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:s}}),this.logger.warn(v.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(s),t),[2])}}))}))}))}},t.prototype._joinChrm=function(e,t,n,o){var r=this,s=n?"joinExistChatRoom":"joinChatRoom";return new Promise((function(i){o&&r._callCppProxy("clearMessages",M.CHATROOM,e,""),r._callCppProxy(s,e,t,(function(){r._addChatroomCache(e,t,n),i(h.SUCCESS)}),i)}))},t.prototype.joinChatroom=function(e,t){return this._joinChrm(e,t,!1,!0)},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(h.SUCCESS)}),n)}))},t.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],o=[];if(n.length>0)for(var s=0;s<n.length;s++)o.push(JSON.parse(n[s].obj));r({code:h.SUCCESS,data:{userInfos:o,userCount:t}})}),(function(e){r({code:e})}))}))},t.prototype.getChatroomHistoryMessages=function(e,t,n,o){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomHistoryMessage",e,t,n,o,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var n=t.list;if(n&&n.length)try{t.list=n.map((function(e){return r._buildMessage(e.obj)}))}catch(e){t.list=[]}s({code:h.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},t.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o,r){var s='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(h.SUCCESS)}),(function(e){o(e)}))}))},t.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){o({code:h.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r,s){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(h.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:h.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return re(this,void 0,void 0,(function(){var n;return se(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===h.SUCCESS?[2,{code:h.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},t.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}n({code:h.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},t.prototype.getFileToken=function(e,t,n,o){var r=this;return n=n||"",o=o||"",new Promise((function(s){var i;i=o&&"uploads"!==o?t||"":j(e,t),r._callCppProxy("getUploadToken",e,i,n,o,(function(e,t,n,o,r,a,c,u,p,l,d,f,g,v,C,S,_,y){s({code:h.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:a,ossSign:c,ossBucketName:u,fileName:i,s3Credential:p,s3Algorithm:l,s3Date:d,s3Policy:f,s3Signature:g,s3BucketName:v,stcAuthorization:C,stcContentSha256:S,stcDate:_,stcBucketName:y}})}),(function(e){s({code:e})}))}))},t.prototype.getFileUrl=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("getDownloadUrl",e,n,o,t-1,(function(e){s({code:h.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},t.prototype.clearData=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("clearData");t({code:h.SUCCESS,data:o})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(u.getPath("userData"));return He(e)},t.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:h.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},t.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,o){var r=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",r,s,(function(){n(h.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getGroupMessageDeliverList=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("getGroupMessageDeliverList",e,n,t,(function(e,t){var n=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));r({code:h.SUCCESS,data:{totalCount:t,list:n}})}),(function(e){r({code:e})}))}))},t.prototype.getPrivateMessageDeliverTime=function(e,t){var n=this;return new Promise((function(o,r){var s=n._callCppProxy("getMessageDeliverTime",e);if(s)o({code:h.SUCCESS,data:s});else{n._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,n=JSON.parse(e).list;n.length>0&&(t=JSON.parse(n[0].obj).time);o({code:h.SUCCESS,data:t})}),(function(e){o({code:e})}))}}))},t.prototype.rtcSignaling=function(e,t,n,o){var r=this,s=Array.prototype.slice.call(new Uint8Array(o));return new Promise((function(o){r._callCppProxy("rtcSignaling",e,t,n,s,(function(e){var t=new Uint8Array(e).buffer;o({code:h.SUCCESS,buffer:t})}),(function(e){o({code:e})}))}))},t.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,n){var o=e.rtcHeartbeatResolves[t];if(o){var r=o.find((function(e){return""===e.seqId}));r&&(r.seqId=n)}}),(function(t,n,o,r){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===o}));-1!==i&&s.splice(i,1)[0].resolve({code:n,data:{version:Number(r)}})}}))},t.prototype.rtcPing=function(e,t,n){var o=this;return new Promise((function(t){var n={resolve:t,seqId:""},r=o.rtcHeartbeatResolves[e];r?r.push(n):o.rtcHeartbeatResolves[e]=[n],o._callCppProxy("sendRTCHeartbeat",[e])}))},t.prototype.createTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:h.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteTag",e,(function(){n({code:h.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.updateTag=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:h.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var o=e._callCppProxy("getTags"),r=e._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:h.SUCCESS,data:r})}))},t.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:h.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o,r){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:h.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:h.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getConversationListByTag=function(e,t,n,o){var r=this;return new Promise((function(s){var i=r._callCppProxy("getConversationsForTagByPage",e,t,n||20,o||""),a=r._convertResultList(i,(function(e){return oe(oe({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:h.SUCCESS,data:a})}))},t.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o,r){var s=n._callCppProxy("getConversationUnreadCountForTag",e,t);o({code:h.SUCCESS,data:s})}))},t.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:h.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n,o){var r=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),s=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:h.SUCCESS,data:s})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(e,t){var n=this;return new Promise((function(o){var r=U(t)?n._callCppProxy("getTopConversations",e):n._callCppProxy("getTopConversations",e,t),s=JSON.parse(r).list.map((function(e){return n._buildConversation(e.obj)}));o({code:h.SUCCESS,data:s})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},t.prototype.getOSInfo=function(){return re(this,void 0,void 0,(function(){var t;return se(this,(function(n){return t={arch:e.arch(),platform:e.platform(),type:e.type(),version:e.version(),release:e.release(),uptime:e.uptime(),cpus:e.cpus(),freemem:e.freemem(),totalmem:e.totalmem(),networkInterfaces:e.networkInterfaces()},[2,{code:h.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return re(this,void 0,void 0,(function(){return se(this,(function(e){return[2,{code:h.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},t.prototype.setCallInfo=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("callInfoSignaling",e,t,n,(function(e,t){r({code:h.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t.prototype.setProxy=function(e){var t=this;return this.tcpMgr.getConnectionStatus()!==T.DISCONNECTED?new Promise((function(e){e({code:h.RC_CONN_PROXY_UNAVAILABLE})})):new Promise((function(n){n(be(e,t.logger))}))},t.prototype.getProxy=function(){return new Promise((function(e){e(xe())}))},t.prototype.testProxy=function(e,t){return function(e,t,n){return new Promise((function(o){var r=/^https/.test(t)?Oe:Te;n.info(v.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var s=r(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var n="";e.on("data",(function(e){n+=e})),e.once("end",(function(){o({status:t||0,data:n})}))}));s.once("timeout",(function(){return o({status:0})})),s.once("error",(function(e){return o({status:0,data:e.stack})})),s.end()}))}(e,t,this.logger)},t.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(n){t._callCppProxy("checkDuplicateMessage",e),n({code:h.SUCCESS})}))},t.prototype.subscribeAccount=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("subscribeAccount",13,e,t,n,(function(){r(h.SUCCESS)}),(function(e){r(e)}))}))},t}(),We=function(){function e(e,t,n,o){void 0===n&&(n=""),this._cppService=new Ke(e,t,n,o)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e.prototype.__createLogger=function(e,t){return this._cppService.createLogger(e,t)},e}(),Xe=function(e){return function(e,t,n){if(we)return we;if(!t)throw new Error("Initializ failed, `appkey` is required!");return we=new We(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.logOutputLevel)}(Z,e.appkey,e)};export{Xe as default};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),r=require("child_process"),n=require("electron"),s=require("fs"),i=require("http"),a=require("https"),c=require("url"),u=require("net"),p=require("events"),d=require("tls"),l=require("crypto");function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var h=f(e),C=process.versions.electron.replace(/\.\d+$/,""),g=t.resolve(__dirname,"binding","electron-v".concat(C,"-").concat(e.platform(),"-").concat(e.arch(),".node")),v={addon:null};try{v.addon=require(g)}catch(e){console.error("error ->",g,"\n",e)}var _=v.addon,S=function(e,t){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},S(e,t)};function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var m,E=function(){return E=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},E.apply(this,arguments)};function P(e,t,o,r){return new(o||(o=Promise))((function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function T(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function I(e,t,o){if(o||2===arguments.length)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_O="P-connect-O",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R"}(m||(m={}));var R,O={flushTimestamp:Date.now(),queue:[],locked:!1};function M(){R&&clearInterval(R)}function N(e,t){M(),R=setInterval((function(){return b(e,t)}),1e4)}function U(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=O.queue).push.apply(e,t)}var w=200;function b(e,t){var o=O.queue,r=O.flushTimestamp;if(!(O.locked||0===o.length||Date.now()-r<3e4&&o.length<w)){O.locked=!0;var n=t.createTraceId(),s=o.splice(0,w).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:r,type:n,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(m.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),n);var i=JSON.stringify(s);e.writeLog(i),t.debug(m.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),n),O.flushTimestamp=Date.now(),O.locked=!1,setTimeout((function(){return b(e,t)}))}}var x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return y(t,e),t.prototype.flush=function(e){U(e)},t}(o.BasicLogger),L=function(e,t){var o,r=Buffer.from(e),n=r.length;for(t.push(n),o=0;o<n;o++)t.push(r[o])},A=function(e){return"string"==typeof e},D=function(e){return A(e)?e.toUpperCase():""},k=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},J=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},j=function(e){var t=D(e.method)||"GET",o=e.pathname||"/",r=e.headers||{},n=e.search||"";r.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(o+n," HTTP/1.1\n"),r)if(Object.hasOwnProperty.call(r,i)){var a=r[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},H=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,s=k(r,o);if(!s)return 2===r[1]?(e.socket.once("data",(function(o){var r=J(o);r?e.emit("error",new Error("SOCKS authentication failed. ".concat(r))):t()})),n=[1],L(e.socksUsername,n),L(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),o=[0],e.socksUsername&&o.push(2),(r=Buffer.alloc(2+o.length))[0]=5,r[1]=o.length,o.forEach((function(e,t){r[2+t]=e})),e.write(r)}))},B=function(e,t,o){return new Promise((function(r){var n,s;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):r()})),(n=[]).push(5),n.push(1),n.push(0),u.isIP(t)){case 0:n.push(3),L(t,n);break;case 4:n.push(1),function(e,t){var o,r,n=e.split(".");for(o=0;o<4;o++)r=parseInt(n[o],10),t.push(r)}(t,n);break;case 6:e.emit("error",new Error("Does not support IPV6"))}n.length+=2,(s=Buffer.from(n)).writeUInt16BE(o,s.length-2),e.write(s)}))},F=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new u.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return y(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return P(o,void 0,void 0,(function(){var o;return T(this,(function(r){switch(r.label){case 0:return[4,H(this)];case 1:return r.sent(),[4,B(this,t,e)];case 2:return r.sent(),this.onProxied(),o=j(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(p.EventEmitter),G=function(e){var t,o=e.hostname,r=e.port;return!e.host||o&&r||(t=e.host.split(":")),!r&&t&&(r=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new F(e).connect(r,o)},q=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=G,o}return y(t,e),t}(i.Agent),V=function(e,t,o){return(t=E(E({},t),c.parse(e))).port||(t.port=80),t.agent=new q(t),i.request(t,o)},K=function(e){var t,o;return t=G(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=d.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},W=function(e){function t(t,o){var r=e.call(this,o)||this;return r.url=t,r.socksHost=o.socksHost||"localhost",r.socksPort=o.socksPort||1080,r.createConnection=K,r}return y(t,e),t}(a.Agent),Y=function(e,t,o,r){var n,s;return t.protocol="https:",!t.port&&t.host&&(n=t.host.split(":"),t.port=n[0],t.port=n[1]),t.port||(t.port=443),s=new W(e,t),t.agent=s,a.request(e,t,o)},X=null;function Q(e,t,r){void 0===r&&(r=!1);var n=t.url,s=t.headers,c=t.body,u=t.method,p=t.query,d=t.timeout,l=void 0===d?o.HTTP_TIMEOUT:d;return new Promise((function(t){var d=/^https/.test(n),f={headers:s,method:u};d&&(f.rejectUnauthorized=r);var h=null;X?((f=E(E({},f),X)).body=c,h=d?Y:V):(h=i.request,d&&(f.agent=new a.Agent(f),h=a.request));var C=h(o.appendUrl(n,p),f,(function(e){var o=e.statusCode,r="";e.setEncoding("utf8"),e.on("data",(function(e){r+=e})),e.once("end",(function(){t({status:o||0,data:r})}))}));C.once("timeout",(function(){e.warn(m.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:n,method:u,query:p,timeout:l})),t({status:0})})),C.setTimeout(l),C.once("error",(function(o){e.warn(m.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:n,method:u,query:p,timeout:l})),t({status:0})})),C.write(c),C.end()}))}function z(e,t){return e?(X=E(E({},X),e),t.info(o.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:X})),{code:o.ErrorCode.SUCCESS}):(X=null,t.info(o.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:o.ErrorCode.SUCCESS})}function $(){var e=X||void 0;return{code:o.ErrorCode.SUCCESS,data:e}}var Z,ee=[],te=function(e){return P(void 0,void 0,void 0,(function(){return T(this,(function(t){return[2,new Promise((function(t){ee.push({resolve:t,args:e}),re()}))]}))}))},oe=!1,re=function(){return P(void 0,void 0,void 0,(function(){var e,t,r,n,s,i,a,c,u,p,d;return T(this,(function(l){return oe||0===ee.length||(oe=!0,e=ee.shift(),t=e.args,r=e.resolve,n=t.addon,s=t.startTime,i=t.endTime,a=t.level,c=t.realtimeReport,u=0,p=0,d=[],n.setLogEventListener((function(e){u+=e.length;var t=e.split(","),n=t[0],s=t[1],i=t[2],l=t[3],f=t[4],h=t.slice(5);if(u>o.REAT_TIME_LOG_SIZE&&parseInt(s,10)!==p)r(d);else{p=parseInt(s,10);try{var C=JSON.parse(decodeURIComponent(h.join(","))),g=C.loggerId,v=C.sessionId,_=C.content,S=C.traceId;if(!c&&a<0)return;var y={time:parseInt(s,10),level:parseInt(l,10),sessionId:"".concat(n,":").concat(v),type:i,tag:f,loggerId:g,content:_,traceId:S};d.push(y)}catch(e){console.error(e)}}}),(function(e){r(d),oe=!1,re()}),(function(e,t,o){})),n.pullFullLog(a,s,i,!1)),[2]}))}))},ne=function(e){function t(t,r,n,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,r,n,u,{getLogs:function(e,o,r,n){return P(this,void 0,void 0,(function(){return T(this,(function(s){switch(s.label){case 0:return[4,te({startTime:e,endTime:o,level:r,realtimeReport:n,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP,e.toString())}},s)||this).subProcess=i,a}return y(t,e),t.prototype.send=function(e){return Q(this.logger,e)},t.prototype.compressLogs=function(e){return P(this,void 0,void 0,(function(){var t,o,r;return T(this,(function(n){switch(n.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=n.sent(),o=t.success,r=t.data,o?[2,{success:o,data:r}]:[2,{success:o,data:""}]}}))}))},t}(o.BasicReporter),se=null,ie=function(){var t,o=Date.now(),r=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=r,l.createHash("md5").update(t).digest("hex")},ae=function(e){if(se)return se;var o=t.resolve(e,"deviceId");return s.existsSync(o)?se=s.readFileSync(o).toString():(se=ie(),s.writeFileSync(o,se),se)},ce=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,s){var i=JSON.stringify(n);"{}"!==i&&e.info(m.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._cppProto.setMessageExtension(t,o,r,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,r,n,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var f=d[l];f&&f.ts<i-this._setTime?(f.v=c[l],f.ts=i-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,r,n,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}(),ue=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var o=e.reqId,r=e.success,n=e.data,s=t.maps[o];s&&(s({success:r,data:n}),delete t.maps[o])}))}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return P(this,void 0,void 0,(function(){var o=this;return T(this,(function(r){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(r){var n=++o.count;o.maps[n]=r;var s={reqId:n,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),pe=function(e){function t(t,o,r,n){var s=e.call(this,t,o,[])||this;return s.addon=n,s.naviPath="",s._caches={},s.naviPath="".concat(r,"/navi-cache.json"),s}return y(t,e),t.prototype.updateCustomNavis=function(e){var t;e.length&&(t=this.navigators).splice.apply(t,I([0,this.navigators.length],e,!1))},t.prototype.httpRequest=function(e,t,r,n,s,i){return P(this,void 0,void 0,(function(){var a,c,u,p,d;return T(this,(function(l){switch(l.label){case 0:return a="token=".concat(encodeURIComponent(r),"&v=").concat(n,"&p=PC&ev=").concat("5.7.3"),c="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(o.LogTagId.L_REQUEST_T,JSON.stringify({url:c,body:a}),i),[4,Q(this.logger,{method:"POST",headers:{appId:t},body:a,url:c,timeout:s})];case 1:if(200!==(u=l.sent()).status)return this.logger.warn(o.LogTagId.L_REQUEST_R,JSON.stringify({url:c,code:u.status}),i),[2,{code:this.transHttpCode(u.status)}];try{return p=JSON.parse(u.data),d=/^https/.test(c)?"https":"http",p.protocol=d,[2,{code:o.ErrorCode.SUCCESS,data:p}]}catch(e){return this.logger.error(o.LogTagId.L_PARSE_NAVI_E,u.data,i),[2,{code:o.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!s.existsSync(this.naviPath))return null;var r=s.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(r),this._caches[e]}catch(e){this.logger.error(o.LogTagId.L_PARSE_NAVI_E,r)}return null},t.prototype.setNaviCache=function(e,t){var r=Date.now();if(o.notEmptyObject(this._caches))for(var n in this._caches){var i=this._caches[n];(r-i.timestamp>o.NAVI_CACHE_DURATION||e===i.token)&&delete this._caches[n]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},s.writeFileSync(this.naviPath,JSON.stringify(this._caches))},t}(o.BasicNavi),de=function(e){function t(t,r,n,s,i){var a=e.call(this,t,n,s,i)||this;return a.addon=r,a._connectedTime=0,a.connectResolve=null,a.pingResolve=null,a.addon.setConnectionStatusListener(a._onConnectionStatusChange.bind(a),(function(e){a.logger.info(m.P_DB_OPEN_O,e)}),(function(){return a.recvPong(o.ErrorCode.SUCCESS)}),a._onConnectionStatusChange.bind(a)),a}return y(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,r,n){var s=this;return new Promise((function(i){s.connectResolve={resolve:i,traceId:n,userId:t.userId};var a=null,c=$().data;c&&(a=JSON.stringify({proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0}));try{s.addon.connectWithToken(e,o.FORMATED_VERSION,JSON.stringify(t),r,a)}catch(e){s.logger.error(m.P_CALL_ADDON_E,null==e?void 0:e.stack,n),s.recvConnectRes(o.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(r){t.pingResolve=r,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(o.ErrorCode.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e){switch(this.logger.info(m.P_CONNECT_S,e),e){case o.ErrorCode.SUCCESS:this.recvConnectRes(o.ErrorCode.SUCCESS);break;case o.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(o.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case o.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case o.ErrorCode.RC_SOCKET_NOT_CREATED:case o.ErrorCode.RC_CONN_ACK_TIMEOUT:case o.ErrorCode.RC_TCP_RESET:this.recvConnectRes(e);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t){if(this.connectResolve){var r=this.connectResolve,n=r.resolve,s=r.userId;return e===o.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),n({code:e,data:s}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e);else{if(e===o.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(e)}},t}(o.AConnectionMgr),le=function(e){if(!s.existsSync(e)){var o=t.resolve(e,"..");s.existsSync(o)||le(o),s.mkdirSync(e)}},fe=function(){function e(e,s,i,a){var c=this;this._appkey=e,this._cppProtocol=s,this._dbpath=i,this._logOutputLevel=a,this._customMessageType={},this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(n.app.getPath("userData")),p=ae(u);this._cppProtocol.initWithAppkey(e,u,o.FORMATED_VERSION);var d=r.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new ue(d);var l=t.resolve(u,"RongCloud/rclogs",e);le(l),function(e,t,r){r.initLogModule(t,e,o.getUUID())}(e,l,this._cppProtocol),this.logger=new x(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),N(this._cppProtocol,this.logger),this.reporter=new ne(this._cppProtocol,e,p,this.logger,this.subProxy),this.logger.info(m.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"220aab3f259b3e6bad2f34423d46543464baa635"})),this._callCppProxy("setDeviceId",p);var f=t.resolve(u,"RongCloud/navis",e);le(f),this.navi=new pe(e,this.logger,f,this._cppProtocol),this.tcpMgr=new de(e,this._cppProtocol,this.navi,this.logger,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return P(c,void 0,void 0,(function(){var n,s,i;return T(this,(function(a){switch(a.label){case 0:if("function"!=typeof(n=this[t]))return this.logger.error(m.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];s=o.ErrorCode.EXTRA_METHOD_UNDEFINED,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.call.apply(n,I([this],r,!1))];case 2:return s=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(m.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==i?void 0:i.stack,method:t})),[3,4];case 4:return e.returnValue=s,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,r){for(var n=[],s=3;s<arguments.length;s++)n[s-3]=arguments[s];return P(c,void 0,void 0,(function(){var s,i,a,c,u=this;return T(this,(function(p){switch(p.label){case 0:if("function"!=typeof(s=this[r]))return this.logger.error(m.P_CALL_MAIN_E,JSON.stringify({method:r,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===r&&(i=n[3],n[3]=function(t){u._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}),a=o.ErrorCode.EXTRA_METHOD_UNDEFINED,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,s.call.apply(s,I([this],n,!1))];case 2:return a=p.sent(),[3,4];case 3:return c=p.sent(),this.logger.error(m.P_CALL_MAIN_E,JSON.stringify({error:null==c?void 0:c.stack,method:r})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var n=c[t];if("function"==typeof n)try{n.call.apply(n,I([c],o,!1))}catch(e){c.logger.error(m.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(m.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new ce(this._cppProtocol)}return e.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},e.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},e.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},e.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},e.prototype._callCppProxy=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this.logger.createTraceId();try{return(t=this._cppProtocol)[e].apply(t,o)}catch(t){this.logger.error(m.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n)}},e.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},e.prototype.sendHTTPRequest=function(e){return Q(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){U.apply(void 0,e)},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){M(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=this[e];if(!n)return this.logger.warn(m.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return n.call.apply(n,I([this],t,!1))}catch(t){this.logger.error(m.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,r,n){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,r,n||"");try{s=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getUnreadConversationList=function(e){var t,r=this,n=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:t})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,r=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],n=this._callCppProxy("getConversationListWithAllChannel",r);try{e=JSON.parse(n).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var r,n=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{r=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,r,n,s,i,a){var c=0===i,u=n+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,r,u,s,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);d[f]=h}}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:n<d.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,r,n){void 0===n&&(n="");var s=this._callCppProxy("updateMessageReceiptStatus",e,t,r,n);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new x(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},e.prototype._send2Renderer=function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,I([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var s=r._senders[n];o.includes(s)||r._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:r,naviInfo:o,connectionStatus:t}},e.prototype._registerRenderers=function(e,t){var o=this,r=e.sender,n=r.id;this.navi.updateCustomNavis(t.navigators),this._senders[n]||(this._senders[n]=r,r.once("destroyed",(function(){delete o._senders[n]})))},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],r=t.isCounted,n=t.isPersited,s=t.searchProps,i=0;n&&(i|=1),r&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,s||[])}},e.prototype._buildIsMentioned=function(e,t){var r,n=!1;if(o.isObject(e))r=e;else try{r=e?JSON.parse(e):e}catch(o){r=e,this.logger.error(m.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return o.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},e.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in o.SEND_MESSAGE_TYPE_OPTION?t=o.SEND_MESSAGE_TYPE_OPTION[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},e.prototype._buildSupportExt=function(e,t,o){var r=null;return e&&(r=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(r=this._msgExpansionHandler.parseConverOrHisExpansion(o))),r},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var r=t.isOffLineMessage,n=t.buildFrom,s=JSON.parse(e),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,p=s.content,d=s.objectName,l=s.messageUid,f=s.direction,h=s.status,C=s.messageId,g=s.sentTime,v=s.readReceiptRequest,_=s.supportExt,S=s.pushContent,y=s.pushTitle,m=s.pushId,P=s.pushConfig,T=s.templateId,I=s.disableTitle,R=s.forcePushDetail,O=this._buildIsMentioned(p,C),M=O.isMentioned,N=O.msgContent,U=this._buildMsgOption(d),w=this._buildSupportExt(_,n,s),b=o.isUndefined(r)?g<this.tcpMgr.getConnectedTime():r,x={};P&&(x=o.pushJSONToConfigs(this.logger,P,m));var L=E(E({},x),{pushTitle:y,pushContent:S,pushData:S,disablePushTitle:I,forceShowDetailContent:R,templateId:T}),A={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:N||{},messageType:d,messageUId:l||"",messageDirection:f,isOffLineMessage:b,sentTime:g,receivedTime:0,isPersited:U.isPersited,isCounted:U.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:_,expansion:_?w:null,receivedStatus:h,messageId:C,pushConfig:L};if(f===o.MessageDirection.RECEIVE?A.receivedStatus=h:f===o.MessageDirection.SEND&&(A.sentStatus=h),v){var D=JSON.parse(v),k=D.hasRespond,J=D.readerInfo,j={hasRespond:k,readCount:D.readCount,totalCount:D.totalCount},H=[];if(J)for(var B in J)H.push({userId:B,readTime:J[B]});j.readerList=H,A.readReceiptInfo=j}return A},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},s=E(E({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),r=t.channelId,n=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,d=t.hasUnreadMention,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,r,n,s){var i,a=e._buildMessage(t,{isOffLineMessage:n}),c=a.messageType,u=a.channelId,p=void 0===u?"":u;if(c!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(c===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var d=a.content,l=d.msgId,f=d.rrn,h=d.tmn;e._updateReadReceiptInfo(l,{readCount:f,totalCount:h})}if("RC:MsgExMsg"===c)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,a),void e._sendMessageExpansion(a);if(a.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(e.logger,a),c!==o.MessageType.SYNC_READ_STATUS||a.senderUserId===e.tcpMgr.getCurrentUserId()){c===o.MessageType.SYNC_READ_STATUS&&e._callCppProxy("clearUnreadCountByTimestamp",a.conversationType,a.targetId,a.content.lastMessageSendTime,p);var C=!0;if(0!==r||s||(C=!1),c===o.MessageType.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(a.content)),void e._sendMessageDelivered(a.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c!==o.MessageType.DELIVERED_MSG){var g=a.conversationType,v=a.targetId;if(c===o.MessageType.RECALL){e.handleRecalledMessage(a);var _=e._fixRecallContentInfo(a);g=_.conversationType,v=_.targetId}e._sendMessageNotification(Object.assign(a,{hasMoreMsg:C,conversationType:g,targetId:v}))}else{var S={totalCount:a.content.tmn,list:null===(i=a.content.dl)||void 0===i?void 0:i.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(S)}}}else{var y=a.content,m=y.startTime,E=y.endTime,P=y.platform,T=y.logId,I=y.uri;e.reporter.report(parseInt(m,10),parseInt(E,10),P,I,T,a.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},e.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var r=this._callCppProxy("getMessage",t),n=this._buildMessage(r,{isOffLineMessage:!1});if(n.messageId){var s={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:n.messageType,originalMessageContent:n.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(s.user=e.content.user),e.content.extra&&(s.extra=e.content.extra),n.messageType===o.MessageType.TextMessage&&(s.recallContent=n.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[n.messageId]):(n.receivedStatus||this.setMessageReceivedStatus(n.messageId,1),this._callCppProxy("setMessageContent",n.messageId,JSON.stringify(s),o.MessageType.RECALL_NOTIFICATION_MESSAGE))}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,r=e.content,n=r.put,s=r.del,i=r.mid,a={};n&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:n}),s&&(a.deletedExpansion={channelId:o,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},e.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},e.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var r=JSON.parse(t).list,n=[];r.forEach((function(e){var t=JSON.parse(e.obj),r=t.conversationType,s=t.targetId,i=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),n.push({channelId:a,conversationType:r,targetId:s,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",n)}),(function(t){e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},e.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",o)}},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._updateMentionedInfo=function(e,t,r){var n,s,i;return{userIdList:(null===(n=e.mentionedInfo)||void 0===n?void 0:n.userIdList)||t,type:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.type)||r||o.MentionedType.ALL,mentionedContent:(null===(i=e.mentionedInfo)||void 0===i?void 0:i.mentionedContent)||""}},e.prototype.registerMessageType=function(e,t,o,r){void 0===r&&(r=[]);var n=0;t&&(n|=1),o&&(n|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(m.P_REGTYP_O,JSON.stringify({type:e,opt:n,search:r})),this._callCppProxy("registerMessageType",e,n,r)},e.prototype.connect=function(e,t,o){return this.tcpMgr.connect(e,t,o)},e.prototype.reportSDKInfo=function(e){var t,o,r=JSON.stringify(E(E({},e),{"electron-main":"5.7.3"}));this.logger.info(m.P_REPORT_VER_O,r),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,r)},e.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),z(null,this.logger),this.tcpMgr.disconnect(e)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("subscribeUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("setUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("getUserStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){r({code:e})}))}))},e.prototype.sendMessage=function(e,t,r,n,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,p=r.pushConfig,d=r.isMentioned,l=r.mentionedType,f=r.mentionedUserIdList,h=void 0===f?[]:f,C=r.pushContent,g=void 0===C?"":C,v=r.pushData,_=void 0===v?"":v,S=r.directionalUserIdList,y=void 0===S?[]:S,E=r.disableNotification,P=void 0!==E&&E,T=r.canIncludeExpansion,I=void 0!==T&&T,R=r.isVoipPush,O=void 0!==R&&R,M=r.channelId,N=void 0===M?"":M,U=r.messageId,w=void 0===U?0:U,b=p||{},x=b.iOSConfig,L=b.androidConfig,A=b.templateId,D=void 0===A?"":A,k=b.pushTitle,J=void 0===k?"":k,j=b.pushContent,H=void 0===j?g:j,B=b.pushData,F=void 0===B?_:B,G=b.disablePushTitle,q=void 0!==G&&G,V=b.forceShowDetailContent,K=void 0!==V&&V,W=o.pushConfigsToJSON(x,L);return new Promise((function(r){g=H,_=F;var p=(null==L?void 0:L.notificationId)||"";if(e===o.ConversationType.GROUP&&d&&c&&(c.mentionedInfo=i._updateMentionedInfo(c,h,l)),e===o.ConversationType.GROUP&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)y.push(f);var C={};for(var f in u)C[f]={v:""},C[f].v=u[f];var v=D;i.logger.info(m.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:N}),s);var S=i._callCppProxy("sendMessage",(function(e,t){var n=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(m.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:n.messageUId}),s),t===o.ErrorCode.SENSITIVE_REPLACE?r({code:t}):("RC:MsgExMsg"===n.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,n),n.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,n),r({code:o.ErrorCode.SUCCESS,data:n}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(m.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),r({code:t,data:o})}),e,t,a,JSON.stringify(c),y,P,q,K,g,_,p,J,W,v,I,JSON.stringify(C),O,N,w),E=JSON.parse(S);null==n||n(E.messageId)}))},e.prototype.recallMsg=function(e,t,r,n,s){var i=this;return new Promise((function(a,c){var u,p=s.user,d=s.pushContent,l=s.channelId,f=s.extra,h=s.pushConfig,C=s.disableNotification,g=s.isDelete,v={conversationType:e,targetId:t,messageUId:r,sentTime:n,user:p,extra:f,channelId:l,isDelete:g||!1};p&&(v.user=p),f&&(v.extra=f);var _={conversationType:e,targetId:t,senderUserId:i.tcpMgr.getCurrentUserId(),content:v,objectName:o.MessageType.RECALL,messageUid:r,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:n,channelId:l},S=i._buildMessage(JSON.stringify(_),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){i.handleRecalledMessage(S),a({code:o.ErrorCode.SUCCESS,data:S})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(v),C||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,d||"",(null==h?void 0:h.pushData)||"",(null===(u=null==h?void 0:h.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==h?void 0:h.pushTitle)||"",o.pushConfigsToJSON(null==h?void 0:h.iOSConfig,null==h?void 0:h.androidConfig),(null==h?void 0:h.templateId)||"",l)}))},e.prototype.getHistoryMessage=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u,p){r=r||0;var d=0===s,l=n+1,f=c._callCppProxy("getHistoryMessages",e,t,r,l,a,d,i),h=JSON.parse(f).list,C=[];h.reverse();for(var g=0;g<h.length;g++){var v=c._buildMessage(h[g].obj);C[g]=v}u({code:o.ErrorCode.SUCCESS,data:{list:l===C.length?C.slice(1,l):C,hasMore:n<C.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,r,n,s,i){var a=this;return new Promise((function(c,u){r=r||0;a._callCppProxy("getRemoteHistoryMessages",e,t,r,n,(function(e,t){var r=JSON.parse(e).list,n=[];r.reverse();for(var s=0;s<r.length;s++){var i=a._buildMessage(r[s].obj);n[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:n,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,r,n){var s=this;return new Promise((function(i,a){var c=JSON.stringify(r);s._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,n,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i,a){s._callCppProxy("clearRemoteHistoryMessages",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),n)}))},e.prototype.clearMessages=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("clearMessages",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,r,n,s){var i=this;return void 0===s&&(s=""),new Promise((function(e,t){for(var r=i._callCppProxy("getConversationList",[1,3,6,7],s),n=JSON.parse(r).list,a=[],c=0;c<n.length;c++)a.push(i._buildConversation(n[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,r){var n=this;return new Promise((function(s,i){var a=n._callCppProxy("getConversation",e,t,r);if(a)s({code:o.ErrorCode.SUCCESS,data:n._buildConversation(a)});else{var c=n._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,r),u=void 0;try{u=JSON.parse(c).list}catch(e){n.logger.error(m.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),u=[]}var p=null;u.length>0&&(p=n._buildMessage(u[0].obj));var d=n._callCppProxy("getConversationNotificationStatus",e,t,r),l=n._callCppProxy("getConversationTopStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:r,unreadMessageCount:0,latestMessage:p,notificationStatus:d?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(l),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,r){var n=this._callCppProxy("removeConversation",e,t,r);return Promise.resolve(n?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var r=this;return new Promise((function(n,s){var i=[];i=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",i,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,r){var n=this._callCppProxy("getTotalUnreadCount",t,r,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){var i=n._callCppProxy("getUnreadCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s,i){n._callCppProxy("clearUnreadCount",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i,a){s._callCppProxy("clearUnreadCountByTimestamp",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,r){var n=this;return new Promise((function(s,i){var a=n._callCppProxy("getTheFirstUnreadMessage",e,t,r),c=n._buildMessage(a);s({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i,a){s._callCppProxy("setConversationToTop",e,t,r,n,!0),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,r,n){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationHidden",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,r,n){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationNotificationStatus",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),i,n)}))},e.prototype.setConversationStatus=function(e,t,r,n,s){var i=this;return new Promise((function(a,c){i._callCppProxy("setConversationStatus",e,t,r,n,(function(){a(o.ErrorCode.SUCCESS)}),a,s,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,r){var n=this;return new Promise((function(s,i){var a=n._callCppProxy("getConversationNotificationStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,r,n){var s=this;return new Promise((function(i,a){n=n||[1,3,6,7];for(var c=s._callCppProxy("searchConversationByContent",n,e,t,r),u=JSON.parse(c).list,p=[],d=0;d<u.length;d++)p[d]=s._buildConversation(u[d].obj);i({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,r){var n=this;return new Promise((function(s,i){r=r||[1,3,6,7];for(var a=n._callCppProxy("searchConversationByContentWithAllChannel",r,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=n._buildConversation(c[p].obj);s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=c._buildMessage(r[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,r,n,s){var i=this;return new Promise((function(a,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=i._buildMessage(r[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,r,n,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],r=[],n=0;n<t.length;n++)r[n]=c._buildMessage(t[n].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:r}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var r=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,n=0;n<r.length;n++)r[n]=this._buildMessage(r[n].obj);return r},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("addToBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("removeFromBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,r){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("getBlacklistStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.insertMessage=function(e,t,r){var n=this,s=r.content,i=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,p=r.sentStatus,d=r.sentTime,l=r.searchContent,f=r.isUnread,h=r.messageUId,C=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,_=r.channelId;s=JSON.stringify(s);var S={};if(v){var y=JSON.parse(v);for(var m in y)S[m]={v:"",ts:0},S[m].v=y[m],S[m].ts=d||0}return new Promise((function(r,v){var y=f?0:1,m=n._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){r({code:e})}),c,u||0,p||10,d||0,l||"",y||0,h||"",C||!1,g||!1,JSON.stringify(S)||"",_||""),E=n._buildMessage(m,{isOffLineMessage:!1});E.messageUId=h,E.sentTime=d,r({code:-1===E.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:E})}))},e.prototype.batchInsertMessage=function(e,t){var r=this;return new Promise((function(n){var s=e.map((function(e){var t=e.content,o=e.senderUserId,r=e.messageType,n=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,d=e.disableNotification,l=e.canIncludeExpansion,f=e.expansion,h=e.channelId,C=e.conversationType,g=e.targetId,v=e.source,_=e.isMentioned,S={};if(f)for(var y in f)S[y]={v:"",ts:0},S[y].v=f[y],S[y].ts=a||0;return{conversationType:C,targetId:g,channelId:h||"",direction:n,senderUserId:o,status:i||10,sentTime:a||0,objectName:r,content:JSON.stringify(t),messageUid:p||"",noNotification:d||!1,supportExt:l||!1,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:u||!1,source:v||"",isMention:_}})),i=r._callCppProxy("insertMessages",JSON.stringify(s),t||!1);n({code:i?o.ErrorCode.SUCCESS:o.ErrorCode.MSG_INSERT_ERROR,data:i||!1})}))},e.prototype.getMessageCount=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getMessageCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("deleteMessages",e),r(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,r,n,s){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,r,n,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(r,n){var s=t._callCppProxy("getMessage",e),i=t._buildMessage(s,{isOffLineMessage:!1});r({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,r){var n=this;return new Promise((function(s,i){t=JSON.stringify(t),n._callCppProxy("setMessageContent",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("setMessageSearchField",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var r=this;return new Promise((function(n,s){r._callCppProxy("setMessageSentStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var r=this;return new Promise((function(n,s){r._callCppProxy("setMessageReceivedStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,r){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],r=t.conversationType,n=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId,c=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),u=this._callCppProxy("getConversationTopStatus",r,n,a||""),p=o.isUndefined(i)?Boolean(c):i===o.NotificationStatus.OPEN,d=o.isUndefined(s)?Boolean(u):s;return this.setConversationStatus(r,n,p,d,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("sendReadReceipt",e,r||"",t,(function(){t.forEach((function(e){n._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(n._callCppProxy("getMessage",e)).messageId;n.setMessageReceivedStatus(t,1)}catch(t){n.logger.error(m.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReader=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("getMessageReader",e,r,t,(function(e,r){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:r};n._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:r}})}),(function(e){s({code:e})}))}))},e.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},e.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},e.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return P(e,void 0,void 0,(function(){var e,n,s,i;return T(this,(function(a){switch(a.label){case 0:return e=r.chatroomId,n=r.joinExist,s=r.count,this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,s,n,!1)];case 1:return(i=a.sent())===o.ErrorCode.SUCCESS?(this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,count:s}}),[2]):(i===o.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:i}}),this.logger.warn(o.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(i),t),[2])}}))}))}))}},e.prototype._joinChrm=function(e,t,r,n){var s=this,i=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){n&&s._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),s._callCppProxy(i,e,t,(function(){s._addChatroomCache(e,t,r),a(o.ErrorCode.SUCCESS)}),a)}))},e.prototype.joinChatroom=function(e,t){return this._joinChrm(e,t,!1,!0)},e.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},e.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(r,n){t._callCppProxy("quitChatRoom",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getChatroomInfo=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("getChatroomInfo",e,t,r,(function(e,t){var r=e?JSON.parse(e).list:[],n=[];if(r.length>0)for(var i=0;i<r.length;i++)n.push(JSON.parse(r[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:n,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,r,n){var s=this;return new Promise((function(i,a){s._callCppProxy("getChatroomHistoryMessage",e,t,r,n,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var r=t.list;if(r&&r.length)try{t.list=r.map((function(e){return s._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var r=this;return new Promise((function(n,s){var i='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');r._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var r=this,n=[t.key];return new Promise((function(s,i){r._callCppProxy("deleteChatroomKV",e,n,!!t.isOverwrite,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var r=this;return new Promise((function(n){var s=t.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return P(this,void 0,void 0,(function(){var r;return T(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(r=n.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:r.data?r.data[t]:null}]:[2,{code:r.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}r({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}))},e.prototype.getFileToken=function(e,t,r,n){var s=this;return r=r||"",n=n||"",new Promise((function(i){var a;a=n&&"uploads"!==n?t||"":o.getUploadFileName(e,t),s._callCppProxy("getUploadToken",e,a,r,n,(function(e,t,r,n,s,c,u,p,d,l,f,h,C,g,v,_,S,y){i({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:r,path:n,osskeyId:s,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:d,s3Algorithm:l,s3Date:f,s3Policy:h,s3Signature:C,s3BucketName:g,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,r,n,t-1,(function(e){i({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,r){var n=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:n})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return ae(e)},e.prototype.getVoIPKey=function(e,t){var r=this;return new Promise((function(n,s){r._callCppProxy("getVoIPKey",e,t,"",(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(r,n){var s=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",s,i,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("getGroupMessageDeliverList",e,r,t,(function(e,t){var r=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));s({code:o.ErrorCode.SUCCESS,data:{totalCount:t,list:r}})}),(function(e){s({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var r=this;return new Promise((function(n,s){var i=r._callCppProxy("getMessageDeliverTime",e);if(i)n({code:o.ErrorCode.SUCCESS,data:i});else{r._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,r=JSON.parse(e).list;r.length>0&&(t=JSON.parse(r[0].obj).time);n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,r,n){var s=this,i=Array.prototype.slice.call(new Uint8Array(n));return new Promise((function(n){s._callCppProxy("rtcSignaling",e,t,r,i,(function(e){var t=new Uint8Array(e).buffer;n({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){n({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var r=e.rtcHeartbeatResolves[t];if(r){var n=r.find((function(e){return""===e.seqId}));n&&(n.seqId=o)}}),(function(t,o,r,n){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===r}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},e.prototype.rtcPing=function(e,t,o){var r=this;return new Promise((function(t){var o={resolve:t,seqId:""},n=r.rtcHeartbeatResolves[e];n?n.push(o):r.rtcHeartbeatResolves[e]=[o],r._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("deleteTag",e,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(r,n){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,r){var n=e._callCppProxy("getTags"),s=e._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.addTagForConversations=function(e,t){var r=this;return new Promise((function(n,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var r=this;return new Promise((function(n,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var r=this;return new Promise((function(n,s){r._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,r,n){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",e,t,r||20,n||""),c=s._convertResultList(a,(function(e){return E(E({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var r=this;return new Promise((function(n,s){var i=r._callCppProxy("getConversationUnreadCountForTag",e,t);n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,r){var n=this;return new Promise((function(s,i){n._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",r.isTop||!1,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(r,n){var s=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),i=t._convertResultList(s,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var r=this;return new Promise((function(n){var s=o.isUndefined(t)?r._callCppProxy("getTopConversations",e):r._callCppProxy("getTopConversations",e,t),i=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.getOSInfo=function(){return P(this,void 0,void 0,(function(){var e;return T(this,(function(t){return e={arch:h.arch(),platform:h.platform(),type:h.type(),version:h.version(),release:h.release(),uptime:h.uptime(),cpus:h.cpus(),freemem:h.freemem(),totalmem:h.totalmem(),networkInterfaces:h.networkInterfaces()},[2,{code:o.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return P(this,void 0,void 0,(function(){return T(this,(function(e){return[2,{code:o.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},e.prototype.setCallInfo=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("callInfoSignaling",e,t,r,(function(e,t){s({code:o.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){s({code:e})}))}))},e.prototype.setProxy=function(e){var t=this;return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.DISCONNECTED?new Promise((function(e){e({code:o.ErrorCode.RC_CONN_PROXY_UNAVAILABLE})})):new Promise((function(o){o(z(e,t.logger))}))},e.prototype.getProxy=function(){return new Promise((function(e){e($())}))},e.prototype.testProxy=function(e,t){return function(e,t,r){return new Promise((function(n){var s=/^https/.test(t)?Y:V;r.info(o.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var i=s(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){n({status:t||0,data:o})}))}));i.once("timeout",(function(){return n({status:0})})),i.once("error",(function(e){return n({status:0,data:e.stack})})),i.end()}))}(e,t,this.logger)},e.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(r){t._callCppProxy("checkDuplicateMessage",e),r({code:o.ErrorCode.SUCCESS})}))},e}(),he=function(){function e(e,t,o,r){void 0===o&&(o=""),this._cppService=new fe(e,t,o,r)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e.prototype.__createLogger=function(e,t){return null},e}();module.exports=function(e){return function(e,t,o){if(Z)return Z;if(!t)throw new Error("Initializ failed, `appkey` is required!");return Z=new he(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.logOutputLevel)}(_,e.appkey,e)};
|
|
1
|
+
"use strict";var e=require("os"),t=require("path"),o=require("child_process"),r=require("fs"),n=require("electron"),s=require("@rongcloud/engine"),i=require("http"),a=require("https"),c=require("url"),u=require("net"),p=require("events"),d=require("tls"),l=require("crypto");function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var h=f(e),C=process.versions.electron.replace(/\.\d+$/,""),g=t.resolve(__dirname,"binding","electron-v".concat(C,"-").concat(e.platform(),"-").concat(e.arch(),".node")),v={addon:null};try{v.addon=require(g)}catch(e){console.error("error ->",g,"\n",e)}var S=v.addon,y=function(e,t){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},y(e,t)};function _(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}y(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var m,E=function(){return E=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},E.apply(this,arguments)};function P(e,t,o,r){return new(o||(o=Promise))((function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function T(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function I(e,t,o){if(o||2===arguments.length)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_O="P-connect-O",e.P_REPORT_VER_O="P-report_version-O",e.P_PARSE_JSON_MSGS_E="P-parse_json_messsages-E",e.P_HTTP_REQ_E="P-http_request-E",e.P_SET_MSG_EXTEN_O="P-set_msg_extension-O",e.P_SEND_MSG_T="P-send_msg-T",e.P_SEND_MSG_R="P-send_msg-R",e.P_WRITE_LOG_T="P_WRITE_LOG_T",e.P_WRITE_LOG_R="P_WRITE_LOG_R"}(m||(m={}));var M,R={flushTimestamp:Date.now(),queue:[],locked:!1};function O(){M&&clearInterval(M)}function N(e,t){O(),M=setInterval((function(){return b(e,t)}),1e4)}function U(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=R.queue).push.apply(e,t)}function b(e,t){var o=R.queue,r=R.flushTimestamp;if(!(R.locked||0===o.length||Date.now()-r<3e4&&o.length<200)){R.locked=!0;var n=t.createTraceId(),s=o.splice(0,200).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:r,type:n,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(m.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),n);var i=JSON.stringify(s);e.writeLog(i),t.debug(m.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),n),R.flushTimestamp=Date.now(),R.locked=!1,setTimeout((function(){return b(e,t)}))}}var x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _(t,e),t.prototype.flush=function(e){U(e)},t}(s.BasicLogger),w=function(e,t){var o,r=Buffer.from(e),n=r.length;for(t.push(n),o=0;o<n;o++)t.push(r[o])},L=function(e){return"string"==typeof e},A=function(e){return L(e)?e.toUpperCase():""},D=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},k=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},J=function(e){var t=A(e.method)||"GET",o=e.pathname||"/",r=e.headers||{},n=e.search||"";r.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(o+n," HTTP/1.1\n"),r)if(Object.hasOwnProperty.call(r,i)){var a=r[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},j=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,s=D(r,o);if(!s)return 2===r[1]?(e.socket.once("data",(function(o){var r=k(o);r?e.emit("error",new Error("SOCKS authentication failed. ".concat(r))):t()})),n=[1],w(e.socksUsername,n),w(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),o=[0],e.socksUsername&&o.push(2),(r=Buffer.alloc(2+o.length))[0]=5,r[1]=o.length,o.forEach((function(e,t){r[2+t]=e})),e.write(r)}))},H=function(e,t,o){return new Promise((function(r){var n,s;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):r()})),(n=[]).push(5),n.push(1),n.push(0),u.isIP(t)){case 0:n.push(3),w(t,n);break;case 4:n.push(1),function(e,t){var o,r,n=e.split(".");for(o=0;o<4;o++)r=parseInt(n[o],10),t.push(r)}(t,n);break;case 6:e.emit("error",new Error("Does not support IPV6"))}n.length+=2,(s=Buffer.from(n)).writeUInt16BE(o,s.length-2),e.write(s)}))},F=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new u.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return _(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return P(o,void 0,void 0,(function(){var o;return T(this,(function(r){switch(r.label){case 0:return[4,j(this)];case 1:return r.sent(),[4,H(this,t,e)];case 2:return r.sent(),this.onProxied(),o=J(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(p.EventEmitter),B=function(e){var t,o=e.hostname,r=e.port;return!e.host||o&&r||(t=e.host.split(":")),!r&&t&&(r=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new F(e).connect(r,o)},V=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=B,o}return _(t,e),t}(i.Agent),G=function(e,t,o){return(t=E(E({},t),c.parse(e))).port||(t.port=80),t.agent=new V(t),i.request(t,o)},q=function(e){var t,o;return t=B(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=d.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},K=function(e){function t(t,o){var r=e.call(this,o)||this;return r.url=t,r.socksHost=o.socksHost||"localhost",r.socksPort=o.socksPort||1080,r.createConnection=q,r}return _(t,e),t}(a.Agent),W=function(e,t,o,r){var n,s;return t.protocol="https:",!t.port&&t.host&&(n=t.host.split(":"),t.port=n[0],t.port=n[1]),t.port||(t.port=443),s=new K(e,t),t.agent=s,a.request(e,t,o)},Y=null;function X(e,t,o){void 0===o&&(o=!1);var r=t.url,n=t.headers,c=t.body,u=t.method,p=t.query,d=t.timeout,l=void 0===d?s.HTTP_TIMEOUT:d;return new Promise((function(t){var d=/^https/.test(r),f={headers:n,method:u};d&&(f.rejectUnauthorized=o);var h=null;Y?((f=E(E({},f),Y)).body=c,h=d?W:G):(h=i.request,d&&(f.agent=new a.Agent(f),h=a.request));var C=h(s.appendUrl(r,p),f,(function(e){var o=e.statusCode,r="";e.setEncoding("utf8"),e.on("data",(function(e){r+=e})),e.once("end",(function(){t({status:o||0,data:r})}))}));C.once("timeout",(function(){e.warn(m.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:r,method:u,query:p,timeout:l})),t({status:0})})),C.setTimeout(l),C.once("error",(function(o){e.warn(m.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:r,method:u,query:p,timeout:l})),t({status:0})})),C.write(c),C.end()}))}function Q(e,t){return e?(Y=E(E({},Y),e),t.info(s.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Y})),{code:s.ErrorCode.SUCCESS}):(Y=null,t.info(s.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:s.ErrorCode.SUCCESS})}function z(){var e=Y||void 0;return{code:s.ErrorCode.SUCCESS,data:e}}var $,Z=[],ee=!1,te=function(){return P(void 0,void 0,void 0,(function(){var e,t,o,r,n,i,a,c,u,p,d;return T(this,(function(l){return ee||0===Z.length||(ee=!0,e=Z.shift(),t=e.args,o=e.resolve,r=t.addon,n=t.startTime,i=t.endTime,a=t.level,c=t.realtimeReport,u=0,p=0,d=[],r.setLogEventListener((function(e){u+=e.length;var t=e.split(","),r=t[0],n=t[1],i=t[2],l=t[3],f=t[4],h=t.slice(5);if(u>s.REAT_TIME_LOG_SIZE&&parseInt(n,10)!==p)o(d);else{p=parseInt(n,10);try{var C=JSON.parse(decodeURIComponent(h.join(","))),g=C.loggerId,v=C.sessionId,S=C.content,y=C.traceId;if(!c&&a<0)return;var _={time:parseInt(n,10),level:parseInt(l,10),sessionId:"".concat(r,":").concat(v),type:i,tag:f,loggerId:g,content:S,traceId:y};d.push(_)}catch(e){console.error(e)}}}),(function(e){o(d),ee=!1,te()}),(function(e,t,o){})),r.pullFullLog(a,n,i,!1)),[2]}))}))},oe=function(e){function t(t,o,r,n,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,o,r,u,{getLogs:function(e,o,r,n){return P(this,void 0,void 0,(function(){return T(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:o,level:r,realtimeReport:n,addon:t},P(void 0,void 0,void 0,(function(){return T(this,(function(e){return[2,new Promise((function(e){Z.push({resolve:e,args:i}),te()}))]}))})))];case 1:return[2,{logs:s.sent(),dbReady:!0}]}var i}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(s.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(s.StoreKeys.REALTIME_LOG_TIMESTAMP,e.toString())}},n)||this).subProcess=i,a}return _(t,e),t.prototype.send=function(e){return X(this.logger,e)},t.prototype.compressLogs=function(e){return P(this,void 0,void 0,(function(){var t,o,r;return T(this,(function(n){switch(n.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=n.sent(),o=t.success,r=t.data,o?[2,{success:o,data:r}]:[2,{success:o,data:""}]}}))}))},t}(s.BasicReporter),re=null,ne=function(){var t,o=Date.now(),r=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=r,l.createHash("md5").update(t).digest("hex")},se=function(e){if(re)return re;var o=t.resolve(e,"deviceId");return r.existsSync(o)?re=r.readFileSync(o).toString():(re=ne(),r.writeFileSync(o,re),re)},ie=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,s){var i=JSON.stringify(n);"{}"!==i&&e.info(m.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._cppProto.setMessageExtension(t,o,r,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,r,n,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var f=d[l];f&&f.ts<i-this._setTime?(f.v=c[l],f.ts=i-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,r,n,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}(),ae=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var o=e.reqId,r=e.success,n=e.data,s=t.maps[o];s&&(s({success:r,data:n}),delete t.maps[o])}))}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return P(this,void 0,void 0,(function(){var o=this;return T(this,(function(r){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(r){var n=++o.count;o.maps[n]=r;var s={reqId:n,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),ce=function(e){function t(t,o,r,n){var s=e.call(this,t,o,[])||this;return s.addon=n,s.naviPath="",s._caches={},s.naviPath="".concat(r,"/navi-cache.json"),s}return _(t,e),t.prototype.updateCustomNavis=function(e){var t;e.length&&(t=this.navigators).splice.apply(t,I([0,this.navigators.length],e,!1))},t.prototype.httpRequest=function(e,t,o,r){return P(this,void 0,void 0,(function(){var n,i,a,c,u;return T(this,(function(p){switch(p.label){case 0:return n="token=".concat(encodeURIComponent(o),"&v=").concat(s.FORMATED_VERSION,"&p=PC&ev=").concat("5.7.4-beem.1"),i="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(s.LogTagId.L_REQUEST_T,JSON.stringify({url:i,body:n}),r),[4,X(this.logger,{method:"POST",headers:{appId:t},body:n,url:i,timeout:s.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=p.sent()).status)return this.logger.warn(s.LogTagId.L_REQUEST_R,JSON.stringify({url:i,code:a.status}),r),[2,{code:this.transHttpCode(a.status)}];try{return c=JSON.parse(a.data),u=/^https/.test(i)?"https":"http",c.protocol=u,[2,{code:s.ErrorCode.SUCCESS,data:c}]}catch(e){return this.logger.error(s.LogTagId.L_PARSE_NAVI_E,a.data,r),[2,{code:s.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.httpRequestV2=function(e,t,o,r){return P(this,void 0,void 0,(function(){var n,i,a,c;return T(this,(function(u){switch(u.label){case 0:return n=this.getNaviV2RequestOption({appkey:t,token:o,uri:e,platform:"electron",isTcp:!0}),this.logger.debug(s.LogTagId.L_REQUEST_T,JSON.stringify({url:n.url,body:n.body,headers:n.headers}),r),[4,X(this.logger,n)];case 1:if(200!==(i=u.sent()).status)return this.logger.warn(s.LogTagId.L_REQUEST_R,JSON.stringify({url:n.url,code:i.status}),r),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(n.url)?"https":"http",a.protocol=c,[2,{code:s.ErrorCode.SUCCESS,data:a}]}catch(e){return this.logger.error(s.LogTagId.L_PARSE_NAVI_E,i.data,r),[2,{code:s.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!r.existsSync(this.naviPath))return null;var o=r.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(o),this._caches[e]}catch(e){this.logger.error(s.LogTagId.L_PARSE_NAVI_E,o)}return null},t.prototype.setNaviCache=function(e,t){var o=Date.now();if(s.notEmptyObject(this._caches))for(var n in this._caches){var i=this._caches[n];(o-i.timestamp>s.NAVI_CACHE_DURATION||e===i.token)&&delete this._caches[n]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},r.writeFileSync(this.naviPath,JSON.stringify(this._caches))},t}(s.BasicNavi),ue=function(e){function t(t,o,r,n,i){var a=e.call(this,t,r,n,i)||this;return a.addon=o,a._connectedTime=0,a._curCmpUrl="",a.connectResolve=null,a.pingResolve=null,a.addon.setConnectionStatusListener(a._onConnectionStatusChange.bind(a),(function(e){a.logger.info(m.P_DB_OPEN_O,e)}),(function(){return a.recvPong(s.ErrorCode.SUCCESS)}),a._onConnectionStatusChange.bind(a),a._onTcpConnectResponse.bind(a)),a}return _(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,o,r){var n=this;return new Promise((function(i){n.connectResolve={resolve:i,traceId:r,userId:t.userId};var a=null,c=z().data;c&&(a=JSON.stringify({proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0}));var u=n.getCmpList(t,!0).sort((function(e,t){return e.weight>t.weight?-1:1}));try{n.addon.connectWithToken(e,s.FORMATED_VERSION,JSON.stringify(E(E({},t),{serverAddr:u})),o,a)}catch(e){n.logger.error(m.P_CALL_ADDON_E,null==e?void 0:e.stack,r),n.recvConnectRes(s.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(o){t.pingResolve=o,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(s.ErrorCode.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e){switch(this.logger.info(m.P_CONNECT_S,e),e){case s.ErrorCode.SUCCESS:this.recvConnectRes(s.ErrorCode.SUCCESS);break;case s.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(s.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case s.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case s.ErrorCode.RC_SOCKET_NOT_CREATED:case s.ErrorCode.RC_CONN_ACK_TIMEOUT:case s.ErrorCode.RC_TCP_RESET:this.recvConnectRes(e);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t){if(this.connectResolve){var o=this.connectResolve,r=o.resolve,n=o.userId;return e===s.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),r({code:e,data:n}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e);else{if(e===s.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==s.RCConnectionStatus.CONNECTED)return;e===s.ErrorCode.RC_TCP_RESET&&this.updateCmpWeight(this._curCmpUrl,!1),this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,o,r,n,i,a){e===s.ErrorCode.SUCCESS&&(this._curCmpUrl="".concat(t,":").concat(o),this.updateCmpWeight("".concat(t,":").concat(o)))},t}(s.AConnectionMgr),pe=function(e){if(!r.existsSync(e)){var o=t.resolve(e,"..");r.existsSync(o)||pe(o),r.mkdirSync(e)}},de=function(){function e(e,r,i,a){var c=this;this._appkey=e,this._cppProtocol=r,this._dbpath=i,this._logOutputLevel=a,this._customMessageType={},this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(n.app.getPath("userData")),p=se(u);this._cppProtocol.initWithAppkey(e,u,s.FORMATED_VERSION);var d=o.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new ae(d);var l=t.resolve(u,"RongCloud/rclogs",e);pe(l),function(e,t,o){o.initLogModule(t,e,s.getUUID())}(e,l,this._cppProtocol),this.logger=new x(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),N(this._cppProtocol,this.logger),this.reporter=new oe(this._cppProtocol,e,p,this.logger,this.subProxy),this.logger.info(m.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"d99bbfee11594dfbe4a84452e1b654ca0fb130ca"})),this._callCppProxy("setDeviceId",p);var f=t.resolve(u,"RongCloud/navis",e);pe(f),this.navi=new ce(e,this.logger,f,this._cppProtocol),this.tcpMgr=new ue(e,this._cppProtocol,this.navi,this.logger,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return P(c,void 0,void 0,(function(){var r,n,i;return T(this,(function(a){switch(a.label){case 0:if("function"!=typeof(r=this[t]))return this.logger.error(m.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=s.ErrorCode.NOT_SUPPORT,[2];n=s.ErrorCode.EXTRA_METHOD_UNDEFINED,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r.call.apply(r,I([this],o,!1))];case 2:return n=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(m.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==i?void 0:i.stack,method:t})),[3,4];case 4:return e.returnValue=n,[2]}}))}))})),n.ipcMain.handle("__RC_CHANNEL_CALL_MAIN__",(function(e,t,o){for(var r=[],n=3;n<arguments.length;n++)r[n-3]=arguments[n];return P(c,void 0,void 0,(function(){var t,n,i,a=this;return T(this,(function(c){if("function"!=typeof(t=this[o]))return this.logger.error(m.P_CALL_MAIN_E,JSON.stringify({method:o,error:"not found"})),[2,s.ErrorCode.NOT_SUPPORT];"sendMessage"===o&&(n=r[3],r[3]=function(t){a._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",n,t)});try{return i=t.call.apply(t,I([this],r,!1)),[2,Promise.resolve(i).catch((function(e){return a.logger.error(m.P_CALL_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:o})),s.ErrorCode.EXTRA_METHOD_UNDEFINED}))]}catch(e){return this.logger.error(m.P_CALL_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:o})),[2,Promise.resolve(s.ErrorCode.EXTRA_METHOD_UNDEFINED)]}return[2]}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var n=c[t];if("function"==typeof n)try{n.call.apply(n,I([c],o,!1))}catch(e){c.logger.error(m.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(m.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new ie(this._cppProtocol)}return e.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},e.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},e.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},e.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},e.prototype._callCppProxy=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this.logger.createTraceId();try{var s=(t=this._cppProtocol)[e].apply(t,o);return s}catch(t){this.logger.error(m.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n)}},e.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},e.prototype.sendHTTPRequest=function(e){return X(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){U.apply(void 0,e)},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){O(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];var r=this[e];if(!r)return this.logger.warn(m.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:s.ErrorCode.EXTRA_METHOD_UNDEFINED});try{var n=r.call.apply(r,I([this],t,!1));return n}catch(t){this.logger.error(m.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,o,r){var n,i=this,a=this._callCppProxy("getConversationListByPage",e,t,o,r||"");try{n=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.ErrorCode.SUCCESS,data:n})},e.prototype.getUnreadConversationList=function(e){var t,o=this,r=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(r).list.map((function(e){return o._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.ErrorCode.SUCCESS,data:t})},e.prototype.getConversationListWithAllChannel=function(e){var t=this;void 0===e&&(e=[1,3,13]);var o,r=this._callCppProxy("getConversationListWithAllChannel",e);try{o=JSON.parse(r).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.ErrorCode.SUCCESS,data:o})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var o,r=this,n=[s.ConversationType.PRIVATE,s.ConversationType.GROUP,s.ConversationType.OFFICIAL],i=this._callCppProxy("getConversationListWithAllChannelByPage",n,e,t);try{o=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.ErrorCode.SUCCESS,data:o})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,o,r,n,i,a){var c=0===i,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,o,u,n,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);d[f]=h}}catch(e){return Promise.resolve({code:s.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:s.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:r<d.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,o,r){void 0===r&&(r="");var n=this._callCppProxy("updateMessageReceiptStatus",e,t,o,r);return Promise.resolve({code:s.ErrorCode.SUCCESS,data:n})},e.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==s.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new x(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},e.prototype._send2Renderer=function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,I([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var s=r._senders[n];o.includes(s)||r._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:r,naviInfo:o,connectionStatus:t}},e.prototype._registerRenderers=function(e,t){var o=this,r=e.sender,n=r.id;this.navi.updateCustomNavis(t.navigators),this._senders[n]||(this._senders[n]=r,r.once("destroyed",(function(){delete o._senders[n]})))},e.prototype._registerMsgTypes=function(){for(var e in s.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},s.SEND_MESSAGE_TYPE_OPTION){var t=s.SEND_MESSAGE_TYPE_OPTION[e],o=t.isCounted,r=t.isPersited,n=t.searchProps,i=0;r&&(i|=1),o&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,n||[])}},e.prototype._buildIsMentioned=function(e,t){var o,r=!1;if(s.isObject(e))o=e;else try{o=e?JSON.parse(e):e}catch(r){o=e,this.logger.error(m.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return s.isObject(o)&&(r=!!o.mentionedInfo),{isMentioned:r,msgContent:o}},e.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in s.SEND_MESSAGE_TYPE_OPTION?t=s.SEND_MESSAGE_TYPE_OPTION[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},e.prototype._buildSupportExt=function(e,t,o){var r=null;return e&&(r=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(r=this._msgExpansionHandler.parseConverOrHisExpansion(o))),r},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var o=t.isOffLineMessage,r=t.buildFrom,n=JSON.parse(e),i=n.channelId,a=n.conversationType,c=n.targetId,u=n.senderUserId,p=n.content,d=n.objectName,l=n.messageUid,f=n.direction,h=n.status,C=n.messageId,g=n.sentTime,v=n.readReceiptRequest,S=n.supportExt;n.extMsg;var y=n.extraContent,_=n.pushContent,m=n.pushTitle,P=n.pushId,T=n.pushConfig,I=n.templateId,M=n.disableTitle,R=n.forcePushDetail,O=n.ftsHighlight,N=this._buildIsMentioned(p,C),U=N.isMentioned,b=N.msgContent,x=this._buildMsgOption(d),w=this._buildSupportExt(S,r,n),L=s.isUndefined(o)?g<this.tcpMgr.getConnectedTime():o,A={};T&&(A=s.pushJSONToConfigs(this.logger,T,P));var D=E(E({},A),{pushTitle:m,pushContent:_,pushData:_,disablePushTitle:M,forceShowDetailContent:R,templateId:I}),k={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:b||{},messageType:d,messageUId:l||"",messageDirection:f,isOffLineMessage:L,sentTime:g,extraContent:y,receivedTime:0,isPersited:x.isPersited,isCounted:x.isCounted,isMentioned:U,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:S,expansion:S?w:null,receivedStatus:h,messageId:C,pushConfig:D,ftsHighlight:O};if(f===s.MessageDirection.RECEIVE?k.receivedStatus=h:f===s.MessageDirection.SEND&&(k.sentStatus=h),v){var J=JSON.parse(v),j=J.hasRespond,H=J.readerInfo,F={hasRespond:j,readCount:J.readCount,totalCount:J.totalCount},B=[];if(H)for(var V in H)B.push({userId:V,readTime:H[V]});F.readerList=B,k.readReceiptInfo=F}return k},e.prototype._buildMessageV2=function(e,t){void 0===t&&(t={});var o=t.isOffLineMessage,r=t.buildFrom,n=e,i=n.channelId,a=n.conversationType,c=n.targetId,u=n.senderUserId,p=n.content,d=n.objectName,l=n.messageUid,f=n.direction,h=n.status,C=n.messageId,g=n.sentTime,v=n.readReceiptRequest,S=n.supportExt;n.extMsg;var y=n.extraContent,_=n.pushContent,m=n.pushTitle,P=n.pushId,T=n.pushConfig,I=n.templateId,M=n.disableTitle,R=n.forcePushDetail,O=this._buildIsMentioned(p,C),N=O.isMentioned,U=O.msgContent,b=this._buildMsgOption(d),x=this._buildSupportExt(S,r,n),w=s.isUndefined(o)?g<this.tcpMgr.getConnectedTime():o,L={};T&&(L=s.pushJSONToConfigs(this.logger,T,P));var A=E(E({},L),{pushTitle:m,pushContent:_,pushData:_,disablePushTitle:M,forceShowDetailContent:R,templateId:I}),D={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:U||{},messageType:d,messageUId:l||"",messageDirection:f,isOffLineMessage:w,sentTime:g,extraContent:y,receivedTime:0,isPersited:b.isPersited,isCounted:b.isCounted,isMentioned:N,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:S,expansion:S?x:null,receivedStatus:h,messageId:C,pushConfig:A};if(f===s.MessageDirection.RECEIVE?D.receivedStatus=h:f===s.MessageDirection.SEND&&(D.sentStatus=h),v){var k=JSON.parse(v),J=k.hasRespond,j=k.readerInfo,H={hasRespond:J,readCount:k.readCount,totalCount:k.totalCount},F=[];if(j)for(var B in j)F.push({userId:B,readTime:j[B]});H.readerList=F,D.readReceiptInfo=H}return D},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},s=E(E({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),o=t.channelId,r=t.conversationType,n=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,d=t.hasUnreadMention,l=t.sortTime,f=u?s.NotificationStatus.OPEN:s.NotificationStatus.CLOSE;return{channelId:o,conversationType:r,targetId:n,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:f,isTop:c,lastUnreadTime:0,matchCount:p,sortTime:l}},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,o,r,n){var i,a=e._buildMessage(t,{isOffLineMessage:r}),c=a.messageType,u=a.channelId,p=void 0===u?"":u;if(c!==s.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(c===s.MessageType.GROUP_READ_RECEIPT_REQUEST){var d=a.content,l=d.msgId,f=d.rrn,h=d.tmn;e._updateReadReceiptInfo(l,{readCount:f,totalCount:h})}if("RC:MsgExMsg"===c)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,a),void e._sendMessageExpansion(a);if(a.canIncludeExpansion&&e._msgExpansionHandler.setLocalFromReceiveMsg(e.logger,a),c!==s.MessageType.SYNC_READ_STATUS||a.senderUserId===e.tcpMgr.getCurrentUserId()){c===s.MessageType.SYNC_READ_STATUS&&e._callCppProxy("clearUnreadCountByTimestamp",a.conversationType,a.targetId,a.content.lastMessageSendTime,p);var C=!0;if(0!==o||n||(C=!1),c===s.MessageType.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(a.content)),void e._sendMessageDelivered(a.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c!==s.MessageType.DELIVERED_MSG){var g=a.conversationType,v=a.targetId;if(c===s.MessageType.RECALL){e.handleRecalledMessage(a);var S=e._fixRecallContentInfo(a);g=S.conversationType,v=S.targetId}e._sendMessageNotification(Object.assign(a,{hasMoreMsg:C,conversationType:g,targetId:v}))}else{var y={totalCount:a.content.tmn,list:null===(i=a.content.dl)||void 0===i?void 0:i.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(y)}}}else{var _=a.content,m=_.startTime,E=_.endTime,P=_.platform,T=_.logId,I=_.uri;e.reporter.report(parseInt(m,10),parseInt(E,10),P,I,T,a.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},e.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var o=this._callCppProxy("getMessage",t),r=this._buildMessage(o,{isOffLineMessage:!1});if(r.messageId){var n={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:r.messageType,originalMessageContent:r.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(n.user=e.content.user),e.content.extra&&(n.extra=e.content.extra),r.messageType===s.MessageType.TextMessage&&(n.recallContent=r.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[r.messageId]):(r.receivedStatus||this.setMessageReceivedStatus(r.messageId,1),this._callCppProxy("setMessageContent",r.messageId,JSON.stringify(n),s.MessageType.RECALL_NOTIFICATION_MESSAGE))}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,r=e.content,n=r.put,s=r.del,i=r.mid,a={};n&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:n}),s&&(a.deletedExpansion={channelId:o,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},e.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},e.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var o=JSON.parse(t).list,r=[];o.forEach((function(e){var t=JSON.parse(e.obj),o=t.conversationType,n=t.targetId,i=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?s.NotificationStatus.OPEN:s.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),r.push({channelId:a,conversationType:o,targetId:n,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",r)}),(function(t){e._send2AllRenderer("conversationTag",t)}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},e.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",o)}},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",o)}),(function(t,o){e._send2AllRenderer("onMeetingEvent",{eventType:t,buffer:o})}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._updateMentionedInfo=function(e,t,o){var r,n,i;return{userIdList:(null===(r=e.mentionedInfo)||void 0===r?void 0:r.userIdList)||t,type:(null===(n=e.mentionedInfo)||void 0===n?void 0:n.type)||o||s.MentionedType.ALL,mentionedContent:(null===(i=e.mentionedInfo)||void 0===i?void 0:i.mentionedContent)||""}},e.prototype.registerMessageType=function(e,t,o,r){void 0===r&&(r=[]);var n=0;t&&(n|=1),o&&(n|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(m.P_REGTYP_O,JSON.stringify({type:e,opt:n,search:r})),this._callCppProxy("registerMessageType",e,n,r)},e.prototype.connect=function(e,t,o){return this.tcpMgr.connect(e,t,o)},e.prototype.reportSDKInfo=function(e){var t,o,r=JSON.stringify(E(E({},e),{"electron-main":"5.7.4-beem.1"}));this.logger.info(m.P_REPORT_VER_O,r),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,r)},e.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),Q(null,this.logger),this.tcpMgr.disconnect(e)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("subscribeUserStatus",e,(function(){o(s.ErrorCode.SUCCESS)}),o)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("setUserStatus",e,(function(){o(s.ErrorCode.SUCCESS)}),o)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("getUserStatus",e,(function(e){o({code:s.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){o({code:e})}))}))},e.prototype.sendMessage=function(e,t,o,r,n){var i=this;void 0===n&&(n=this.logger.createTraceId());var a=o.messageType,c=o.content,u=o.expansion,p=o.pushConfig,d=o.isMentioned,l=o.mentionedType,f=o.mentionedUserIdList,h=void 0===f?[]:f,C=o.pushContent,g=void 0===C?"":C,v=o.pushData,S=void 0===v?"":v,y=o.directionalUserIdList,_=void 0===y?[]:y,E=o.disableNotification,P=void 0!==E&&E,T=o.canIncludeExpansion,I=void 0!==T&&T,M=o.isVoipPush,R=void 0!==M&&M,O=o.channelId,N=void 0===O?"":O,U=o.messageId,b=void 0===U?0:U,x=o.isResend,w=void 0!==x&&x,L=o.sessionTag,A=void 0===L?0:L,D=o.isBroadcast,k=void 0!==D&&D,J=p||{},j=J.iOSConfig,H=J.androidConfig,F=J.templateId,B=void 0===F?"":F,V=J.pushTitle,G=void 0===V?"":V,q=J.pushContent,K=void 0===q?g:q,W=J.pushData,Y=void 0===W?S:W,X=J.disablePushTitle,Q=void 0!==X&&X,z=J.forceShowDetailContent,$=void 0!==z&&z,Z=s.pushConfigsToJSON(j,H);return new Promise((function(o){g=K,S=Y;var p=(null==H?void 0:H.notificationId)||"";if(e===s.ConversationType.GROUP&&d&&c&&(c.mentionedInfo=i._updateMentionedInfo(c,h,l)),e===s.ConversationType.GROUP&&a===s.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)_.push(f);var C={};for(var f in u)C[f]={v:""},C[f].v=u[f];var v=B;i.logger.info(m.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:N,messageId:b,isResend:w}),n);var y=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(m.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:r.messageUId}),n),t===s.ErrorCode.SENSITIVE_REPLACE?o({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,r),o({code:s.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(m.P_SEND_MSG_R,JSON.stringify({code:t,messageId:r.messageId}),n),r.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),o({code:t,data:r})}),e,t,a,JSON.stringify(c),_,P,Q,$,g,S,p,G,Z,v,I,JSON.stringify(C),R,N,b,w,A,k),E=JSON.parse(y);null==r||r(E.messageId)}))},e.prototype.recallMsg=function(e,t,o,r,n){var i=this;return new Promise((function(a,c){var u,p=n.user,d=n.pushContent,l=n.channelId,f=n.extra,h=n.pushConfig,C=n.disableNotification,g=n.isDelete,v={conversationType:e,targetId:t,messageUId:o,sentTime:r,user:p,extra:f,channelId:l,isDelete:g||!1};p&&(v.user=p),f&&(v.extra=f);var S={conversationType:e,targetId:t,senderUserId:i.tcpMgr.getCurrentUserId(),content:v,objectName:s.MessageType.RECALL,messageUid:o,direction:s.MessageDirection.SEND,status:s.ReceivedStatus.UNREAD,sentTime:r,channelId:l},y=i._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){i.handleRecalledMessage(y),a({code:s.ErrorCode.SUCCESS,data:y})}),(function(e){a({code:e})}),s.MessageType.RECALL,JSON.stringify(v),C||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,d||"",(null==h?void 0:h.pushData)||"",(null===(u=null==h?void 0:h.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==h?void 0:h.pushTitle)||"",s.pushConfigsToJSON(null==h?void 0:h.iOSConfig,null==h?void 0:h.androidConfig),(null==h?void 0:h.templateId)||"",l)}))},e.prototype.getHistoryMessage=function(e,t,o,r,n,i,a){var c=this;return new Promise((function(u,p){o=o||0;var d=0===n,l=r+1,f=c._callCppProxy("getHistoryMessagesV2",e,t,o,l,a,d,i),h=[];f.reverse();for(var C=0;C<f.length;C++){f[C].content=JSON.parse(f[C].content);var g=c._buildMessageV2(f[C]);h[C]=g}u({code:s.ErrorCode.SUCCESS,data:{list:l===h.length?h.slice(1,l):h,hasMore:r<h.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,o,r,n,i){var a=this;return new Promise((function(c,u){o=o||0;a._callCppProxy("getRemoteHistoryMessages",e,t,o,r,(function(e,t){var o=JSON.parse(e).list,r=[];o.reverse();for(var n=0;n<o.length;n++){var i=a._buildMessage(o[n].obj);r[n]=i}c({code:s.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),n,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,o,r){var n=this;return new Promise((function(i,a){var c=JSON.stringify(o);n._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){i(s.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,o,r){var n=this;return new Promise((function(i,a){n._callCppProxy("clearRemoteHistoryMessages",e,t,o,(function(){i(s.ErrorCode.SUCCESS)}),(function(e){i(e)}),r)}))},e.prototype.clearMessages=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("clearMessages",e,t,o),n(s.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,o,r,n){var i=this;return void 0===n&&(n=""),new Promise((function(e,t){for(var o=i._callCppProxy("getConversationList",[1,3,6,7],n),r=JSON.parse(o).list,a=[],c=0;c<r.length;c++)a.push(i._buildConversation(r[c].obj));e({code:s.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,o){var r=this;return new Promise((function(n,i){var a=r._callCppProxy("getConversation",e,t,o);if(a)n({code:s.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,o),u=void 0;try{u=JSON.parse(c).list}catch(e){r.logger.error(m.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),u=[]}var p=null;u.length>0&&(p=r._buildMessage(u[0].obj));var d=r._callCppProxy("getConversationNotificationStatus",e,t,o),l=r._callCppProxy("getConversationTopStatus",e,t,o);n({code:s.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:o,unreadMessageCount:0,latestMessage:p,notificationStatus:d?s.NotificationStatus.OPEN:s.NotificationStatus.CLOSE,isTop:Boolean(l),lastUnreadTime:0,sortTime:(null==p?void 0:p.sentTime)||0}})}}))},e.prototype.removeConversation=function(e,t,o){var r=this._callCppProxy("removeConversation",e,t,o);return Promise.resolve(r?s.ErrorCode.SUCCESS:s.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var o=this;return new Promise((function(r,n){var i=[];i=s.isArray(e)?e:[s.ConversationType.PRIVATE,s.ConversationType.GROUP,s.ConversationType.SYSTEM,s.ConversationType.PUBLIC_SERVICE,s.ConversationType.OFFICIAL],o._callCppProxy("clearConversations",i,t),r(s.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,o){var r=this._callCppProxy("getTotalUnreadCount",t,o,e);return Promise.resolve({code:s.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,o){var r=this;return void 0===o&&(o=""),new Promise((function(n){var i=r._callCppProxy("getUnreadCount",e,t,o);n({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,o){var r=this;return void 0===o&&(o=""),new Promise((function(n,i){r._callCppProxy("clearUnreadCount",e,t,o),n(s.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,o,r){var n=this;return new Promise((function(i,a){n._callCppProxy("clearUnreadCountByTimestamp",e,t,o,r),i(s.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,o){var r=this;return new Promise((function(n,i){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,o),c=r._buildMessage(a);n({code:s.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.getMessageByUids=function(e){var t,o=this,r=this._callCppProxy("getMessageByUids",e);try{t=JSON.parse(r).list.map((function(e){return o._buildMessage(e.obj)}))}catch(e){t=[]}return t},e.prototype.setMessageSearchContent=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("setMessageSearchContent",e,t),r(s.ErrorCode.SUCCESS)}))},e.prototype.getMessageByMsgUids=function(e,t,o,r){var n,s=this,i=this._callCppProxy("getMessageByMsgUids",e,t,o,r);try{n=JSON.parse(i).list.map((function(e){return s._buildMessage(e.obj)}))}catch(e){n=[]}return n},e.prototype.setConversationToTop=function(e,t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(i,a){n._callCppProxy("setConversationToTop",e,t,o,r,!0),i(s.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,o,r){var n=this;return new Promise((function(i,a){n._callCppProxy("setConversationHidden",e,t,o,r),i(s.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,o,r){var n=this;return new Promise((function(i,a){n._callCppProxy("setConversationNotificationStatus",e,t,o,(function(){i(s.ErrorCode.SUCCESS)}),i,r)}))},e.prototype.setConversationStatus=function(e,t,o,r,n){var i=this;return new Promise((function(a,c){i._callCppProxy("setConversationStatus",e,t,o,r,(function(){a(s.ErrorCode.SUCCESS)}),a,n,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,o){var r=this;return new Promise((function(n,i){var a=r._callCppProxy("getConversationNotificationStatus",e,t,o);n({code:s.ErrorCode.SUCCESS,data:a?s.NotificationStatus.OPEN:s.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,o,r){var n=this;return new Promise((function(i,a){r=r||[1,3,6,7];for(var c=n._callCppProxy("searchConversationByContent",r,e,t,o),u=JSON.parse(c).list,p=[],d=0;d<u.length;d++)p[d]=n._buildConversation(u[d].obj);i({code:s.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,o){var r=this;return new Promise((function(n,i){o=o||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContentWithAllChannel",o,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);n({code:s.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,o,r,n,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,o,r,n,1,(function(e,t){for(var o=e?JSON.parse(e).list:[],r=[],n=0;n<o.length;n++)r[n]=c._buildMessage(o[n].obj);i({code:s.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,o,r,n){var i=this;return new Promise((function(a,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,o,r,n,1,(function(e,t){for(var o=e?JSON.parse(e).list:[],r=[],n=0;n<o.length;n++)r[n]=i._buildMessage(o[n].obj);a({code:s.ErrorCode.SUCCESS,data:{messages:r,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,o,r,n,i,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,o,r,n,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],o=[],r=0;r<t.length;r++)o[r]=c._buildMessage(t[r].obj);u({code:s.ErrorCode.SUCCESS,data:{messages:o}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var r=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,n=0;n<r.length;n++)r[n]=this._buildMessage(r[n].obj);return r},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("addToBlacklist",e,(function(){o(s.ErrorCode.SUCCESS)}),o)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("removeFromBlacklist",e,(function(){o(s.ErrorCode.SUCCESS)}),o)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,o){e._callCppProxy("getBlacklist",(function(e){t({code:s.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("getBlacklistStatus",e,(function(e){o({code:s.ErrorCode.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},e.prototype.insertMessage=function(e,t,o){var r=this,n=o.content,i=o.senderUserId,a=o.messageType,c=o.messageDirection,u=o.readStatus,p=o.sentStatus,d=o.sentTime,l=o.searchContent,f=o.isUnread,h=o.messageUId,C=o.disableNotification,g=o.canIncludeExpansion,v=o.expansionMsg,S=o.channelId,y=o.sessionTag,_=void 0===y?0:y;n=JSON.stringify(n);var m={};if(v){var E=JSON.parse(v);for(var P in E)m[P]={v:"",ts:0},m[P].v=E[P],m[P].ts=d||0}return new Promise((function(o,v){var y=f?0:1,E=r._callCppProxy("insertMessage",e,t,i,a,n,(function(){}),(function(e){o({code:e})}),c,u||0,p||10,d||0,l||"",y||0,h||"",C||!1,g||!1,JSON.stringify(m)||"",S||"",_),P=r._buildMessage(E,{isOffLineMessage:!1});P.messageUId=h,P.sentTime=d,o({code:-1===P.messageId?s.ErrorCode.MSG_INSERT_ERROR:s.ErrorCode.SUCCESS,data:P})}))},e.prototype.batchInsertMessage=function(e,t){var o=this;return new Promise((function(r){var n=e.map((function(e){var t=e.content,o=e.senderUserId,r=e.messageType,n=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,d=e.disableNotification,l=e.canIncludeExpansion,f=e.expansion,h=e.channelId,C=e.conversationType,g=e.targetId,v=e.source,S=e.isMentioned,y={};if(f)for(var _ in f)y[_]={v:"",ts:0},y[_].v=f[_],y[_].ts=a||0;return{conversationType:C,targetId:g,channelId:h||"",direction:n,senderUserId:o,status:i||10,sentTime:a||0,objectName:r,content:JSON.stringify(t),messageUid:p||"",noNotification:d||!1,supportExt:l||!1,extMsg:JSON.stringify(y),readStatus:s||0,searchContent:c||"",isUnread:u||!1,source:v||"",isMention:S}})),i=o._callCppProxy("insertMessages",JSON.stringify(n),t||!1);r({code:i?s.ErrorCode.SUCCESS:s.ErrorCode.MSG_INSERT_ERROR,data:i||!1})}))},e.prototype.getMessageCount=function(e,t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("getMessageCount",e,t,o);n({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("deleteMessages",e),o(s.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,o,r,n){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,o,r,n),a(s.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(o,r){var n=t._callCppProxy("getMessage",e),i=t._buildMessage(n,{isOffLineMessage:!1});o({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.setTextMessageExtra=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("setTextMessageExtra",e,t),r(s.ErrorCode.SUCCESS)}))},e.prototype.setMessageContent=function(e,t,o){var r=this;return new Promise((function(n,i){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,o),n(s.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("setMessageSearchField",e,t,o),n(s.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("setMessageSentStatus",e,t),r(s.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("setMessageReceivedStatus",e,t),r(s.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,r){throw new Error("Method not implemented.")},e.prototype.getConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.clearConversationMessageDraft=function(e,t,o){throw new Error("Method not implemented.")},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],o=t.conversationType,r=t.targetId,n=t.isTop,i=t.notificationStatus,a=t.channelId,c=this._callCppProxy("getConversationNotificationStatus",o,r,a||""),u=this._callCppProxy("getConversationTopStatus",o,r,a||""),p=s.isUndefined(i)?Boolean(c):i===s.NotificationStatus.OPEN,d=s.isUndefined(n)?Boolean(u):n;return this.setConversationStatus(o,r,p,d,a)},e.prototype.setConversationsMuteStatus=function(e){var t=this;return new Promise((function(o){var r=[];e.forEach((function(e){var t=1===e.notificationStatus?"1":"0";r.push({conversationType:e.conversationType,channelId:e.channelId||"",targetId:e.targetId,statusType:1,statusValue:t})})),t._callCppProxy("setConversationsMuteStatus",JSON.stringify(r),(function(){o(s.ErrorCode.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.setConversationsTopStatus=function(e){var t=this;return new Promise((function(o){var r=[];e.forEach((function(e){var t=e.isTop?"1":"0";r.push({conversationType:e.conversationType,channelId:e.channelId||"",targetId:e.targetId,statusType:2,statusValue:t})})),t._callCppProxy("setConversationsTopStatus",JSON.stringify(r),!0,(function(){o(s.ErrorCode.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,o){var r=this;return new Promise((function(n){r._callCppProxy("sendReadReceipt",e,o||"",t,(function(){t.forEach((function(e){r._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(r._callCppProxy("getMessage",e)).messageId;r.setMessageReceivedStatus(t,1)}catch(t){r.logger.error(m.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),n({code:s.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getMessageReader=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("getMessageReader",e,o,t,(function(e,o){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:o};r._updateReadReceiptInfo(t,c),n({code:s.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:o}})}),(function(e){n({code:e})}))}))},e.prototype.setGroupVoiceMessagePlayed=function(e,t,o){var r=this;return new Promise((function(n){r._callCppProxy("setGroupVoiceMessagePlayed",e,t,o,(function(){n({code:s.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getGroupVoiceMessageReader=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("getGroupVoiceMessageReader",e,t,o,(function(e,t){var o=[];(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),r=t.id,n=t.time;o.push({userId:r,readTime:n})})),n({code:s.ErrorCode.SUCCESS,data:{list:o,totalMemberCount:t}})}),(function(e){n({code:e})}))}))},e.prototype.setReadMessages=function(e,t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("setReadMessages",e,t,o,r,(function(){i({code:s.ErrorCode.SUCCESS})}),(function(e){i({code:e})}))}))},e.prototype.getMessageReceiptInfo=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("getMessageReceiptInfo",e,o,t,(function(e,o){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:o};r._updateReadReceiptInfo(t,c),n({code:s.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:o}})}),(function(e){n({code:e})}))}))},e.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},e.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},e.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(o){return P(e,void 0,void 0,(function(){var e,r,n,i;return T(this,(function(a){switch(a.label){case 0:return e=o.chatroomId,r=o.joinExist,n=o.count,this.logger.info(s.LogTagId.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,n,r,!1)];case 1:return(i=a.sent())===s.ErrorCode.SUCCESS?(this.logger.info(s.LogTagId.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,count:n}}),[2]):(i===s.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:i}}),this.logger.warn(s.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(i),t),[2])}}))}))}))}},e.prototype._joinChrm=function(e,t,o,r){var n=this,i=o?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){r&&n._callCppProxy("clearMessages",s.ConversationType.CHATROOM,e,""),n._callCppProxy(i,e,t,(function(){n._addChatroomCache(e,t,o),a(s.ErrorCode.SUCCESS)}),a)}))},e.prototype.joinChatroom=function(e,t){return this._joinChrm(e,t,!1,!0)},e.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},e.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(o,r){t._callCppProxy("quitChatRoom",e,(function(){o(s.ErrorCode.SUCCESS)}),o)}))},e.prototype.getChatroomInfo=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("getChatroomInfo",e,t,o,(function(e,t){var o=e?JSON.parse(e).list:[],r=[];if(o.length>0)for(var i=0;i<o.length;i++)r.push(JSON.parse(o[i].obj));n({code:s.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){n({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,o,r){var n=this;return new Promise((function(i,a){n._callCppProxy("getChatroomHistoryMessage",e,t,o,r,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var o=t.list;if(o&&o.length)try{t.list=o.map((function(e){return n._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:s.ErrorCode.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var o=this;return new Promise((function(r,n){var i='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');o._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(s.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var o=this;return new Promise((function(r){o._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:s.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var o=this,r=[t.key];return new Promise((function(n,i){o._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){n(s.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var o=this;return new Promise((function(r){var n=t.entries.map((function(e){return e.key}));o._callCppProxy("deleteChatroomKV",e,n,!!t.isOverwrite,(function(){r({code:s.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return P(this,void 0,void 0,(function(){var o;return T(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(o=r.sent()).code===s.ErrorCode.SUCCESS?[2,{code:s.ErrorCode.SUCCESS,data:o.data?o.data[t]:null}]:[2,{code:o.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}o({code:s.ErrorCode.SUCCESS,data:t})}),(function(e){o({code:e})}))}))},e.prototype.getFileToken=function(e,t,o,r){var n=this;return o=o||"",r=r||"",new Promise((function(i){var a;a=r&&"uploads"!==r?t||"":s.getUploadFileName(e,t),n._callCppProxy("getUploadToken",e,a,o,r,(function(e,t,o,r,n,c,u,p,d,l,f,h,C,g,v,S,y,_){i({code:s.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:o,path:r,osskeyId:n,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:d,s3Algorithm:l,s3Date:f,s3Policy:h,s3Signature:C,s3BucketName:g,stcAuthorization:v,stcContentSha256:S,stcDate:y,stcBucketName:_}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getDownloadUrl",e,o,r,t-1,(function(e){i({code:s.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t,o){var r=e._callCppProxy("clearData");t({code:s.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return se(e)},e.prototype.getVoIPKey=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:s.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(o,r){var n=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",n,i,(function(){o(s.ErrorCode.SUCCESS)}),(function(e){o(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("getGroupMessageDeliverList",e,o,t,(function(e,t){var o=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));n({code:s.ErrorCode.SUCCESS,data:{totalCount:t,list:o}})}),(function(e){n({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var o=this;return new Promise((function(r,n){var i=o._callCppProxy("getMessageDeliverTime",e);if(i)r({code:s.ErrorCode.SUCCESS,data:i});else{o._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,o=JSON.parse(e).list;o.length>0&&(t=JSON.parse(o[0].obj).time);r({code:s.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,o,r){var n=this,i=Array.prototype.slice.call(new Uint8Array(r));return new Promise((function(r){n._callCppProxy("rtcSignaling",e,t,o,i,(function(e){var t=new Uint8Array(e).buffer;r({code:s.ErrorCode.SUCCESS,buffer:t})}),(function(e){r({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var r=e.rtcHeartbeatResolves[t];if(r){var n=r.find((function(e){return""===e.seqId}));n&&(n.seqId=o)}}),(function(t,o,r,n){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===r}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},e.prototype.rtcPing=function(e,t,o){var r=this;return new Promise((function(t){var o={resolve:t,seqId:""},n=r.rtcHeartbeatResolves[e];n?n.push(o):r.rtcHeartbeatResolves[e]=[o],r._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){o({code:s.ErrorCode.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("deleteTag",e,(function(){o({code:s.ErrorCode.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(o,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){o({code:s.ErrorCode.SUCCESS})}),(function(e){o({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,o){var r=e._callCppProxy("getTags"),n=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:s.ErrorCode.SUCCESS,data:n})}))},e.prototype.addTagForConversations=function(e,t){var o=this;return new Promise((function(r,n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));o._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:s.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var o=this;return new Promise((function(r,n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),o._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:s.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var o=this;return new Promise((function(r,n){o._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:s.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,o,r){var n=this;return new Promise((function(i){var a=n._callCppProxy("getConversationsForTagByPage",e,t,o||20,r||""),c=n._convertResultList(a,(function(e){return E(E({},n._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:s.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var o=this;return new Promise((function(r,n){var i=o._callCppProxy("getConversationUnreadCountForTag",e,t);r({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",o.isTop||!1,(function(){n({code:s.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(o,r){var n=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),i=t._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));o({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var o=this;return new Promise((function(r){var n=s.isUndefined(t)?o._callCppProxy("getTopConversations",e):o._callCppProxy("getTopConversations",e,t),i=JSON.parse(n).list.map((function(e){return o._buildConversation(e.obj)}));r({code:s.ErrorCode.SUCCESS,data:i})}))},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.getOSInfo=function(){return P(this,void 0,void 0,(function(){var e;return T(this,(function(t){return e={arch:h.arch(),platform:h.platform(),type:h.type(),version:h.version(),release:h.release(),uptime:h.uptime(),cpus:h.cpus(),freemem:h.freemem(),totalmem:h.totalmem(),networkInterfaces:h.networkInterfaces()},[2,{code:s.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return P(this,void 0,void 0,(function(){return T(this,(function(e){return[2,{code:s.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},e.prototype.setCallInfo=function(e,t,o){var r=this;return new Promise((function(n){r._callCppProxy("callInfoSignaling",e,t,o,(function(e,t){n({code:s.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){n({code:e})}))}))},e.prototype.setProxy=function(e){var t=this;return this.tcpMgr.getConnectionStatus()!==s.RCConnectionStatus.DISCONNECTED?new Promise((function(e){e({code:s.ErrorCode.RC_CONN_PROXY_UNAVAILABLE})})):new Promise((function(o){o(Q(e,t.logger))}))},e.prototype.getProxy=function(){return new Promise((function(e){e(z())}))},e.prototype.testProxy=function(e,t){return function(e,t,o){return new Promise((function(r){var n=/^https/.test(t)?W:G;o.info(s.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var i=n(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){r({status:t||0,data:o})}))}));i.once("timeout",(function(){return r({status:0})})),i.once("error",(function(e){return r({status:0,data:e.stack})})),i.end()}))}(e,t,this.logger)},e.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(o){t._callCppProxy("checkDuplicateMessage",e),o({code:s.ErrorCode.SUCCESS})}))},e.prototype.subscribeAccount=function(e,t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("subscribeAccount",13,e,t,o,(function(){n(s.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e}(),le=function(){function e(e,t,o,r){void 0===o&&(o=""),this._cppService=new de(e,t,o,r)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e.prototype.__createLogger=function(e,t){return this._cppService.createLogger(e,t)},e}();module.exports=function(e){return function(e,t,o){if($)return $;if(!t)throw new Error("Initializ failed, `appkey` is required!");return $=new le(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.logOutputLevel)}(S,e.appkey,e)};
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rongcloud/electron",
|
|
3
3
|
"main": "index.js",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"postinstall": "node scripts/postinstall.js"
|
|
6
|
-
},
|
|
4
|
+
"scripts": {},
|
|
7
5
|
"files": [
|
|
6
|
+
"binding",
|
|
8
7
|
"README.md",
|
|
9
8
|
"bin/rc-install.js",
|
|
10
9
|
"scripts/tools.js",
|
|
@@ -20,7 +19,7 @@
|
|
|
20
19
|
},
|
|
21
20
|
"types": "index.d.ts",
|
|
22
21
|
"module": "index.esm.js",
|
|
23
|
-
"version": "5.7.
|
|
22
|
+
"version": "5.7.4-beem.1",
|
|
24
23
|
"author": "pass-web@rongcloud.cn",
|
|
25
24
|
"license": "LGPL 2.1",
|
|
26
25
|
"homepage": "https://www.rongcloud.cn",
|
|
@@ -31,6 +30,6 @@
|
|
|
31
30
|
"globals": "RCMain"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"@rongcloud/engine": "=5.7.
|
|
33
|
+
"@rongcloud/engine": "=5.7.4-beem.1"
|
|
35
34
|
}
|
|
36
35
|
}
|