@rongcloud/electron 5.6.1 → 5.6.2-alpha.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/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
- package/sub-process.js +1 -1
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,HTTP_TIMEOUT as a,StoreKeys as c,BasicReporter as u,LogTagId as p,ConnectionStatus as l,ErrorCode as d,ConversationType as f,SEND_MESSAGE_TYPE_OPTION as _,isObject as h,isUndefined as v,pushJSONToConfigs as g,MessageDirection as C,NotificationStatus as S,MessageType as y,pushConfigsToJSON as m,MentionedType as P,ReceivedStatus as E,isArray as I,getUploadFileName as T}from"@rongcloud/engine";import{fork as R}from"child_process";import{app as N,ipcMain as O}from"electron";import{existsSync as M,readFileSync as U,writeFileSync as b,mkdirSync as L}from"fs";import{request as w}from"http";import{Agent as x,request as A}from"https";import{createHash as D}from"crypto";var J=process.versions.electron.replace(/\.\d+$/,""),k=o(__dirname,"binding","electron-v".concat(J,"-").concat(t(),"-").concat(n(),".node")),H={addon:null};try{H.addon=require(k)}catch(e){console.error("error ->",k,"\n",e)}var B=H.addon,j=function(e,t){return j=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])},j(e,t)};function F(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}j(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var G,q=function(){return q=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},q.apply(this,arguments)};function V(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 K(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 W(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"}(G||(G={}));var Y,X={flushTimestamp:Date.now(),queue:[],locked:!1};function Q(){Y&&clearInterval(Y)}function z(e,t){Q(),Y=setInterval((function(){return Z(e,t)}),1e4)}function $(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=X.queue).push.apply(e,t)}function Z(e,t){var n=X.queue,o=X.flushTimestamp;if(!(X.locked||0===n.length||Date.now()-o<3e4&&n.length<200)){X.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(G.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(G.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),X.flushTimestamp=Date.now(),X.locked=!1,setTimeout((function(){return Z(e,t)}))}}var ee=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return F(t,e),t.prototype.flush=function(e){$(e)},t}(s);function te(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,c=t.method,u=t.query,p=t.timeout,l=void 0===p?a:p;return new Promise((function(t){var a=/^https/.test(o),p={headers:r,method:c};a&&(p.rejectUnauthorized=n,p.agent=new x(p));var d=(a?A:w)(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})}))}));d.once("timeout",(function(){e.warn(G.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:c,query:u,timeout:l})),t({status:0})})),d.setTimeout(l),d.once("error",(function(n){e.warn(G.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:c,query:u,timeout:l})),t({status:0})})),d.write(s),d.end()}))}var ne,oe=[],re=!1,se=function(){return V(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c;return K(this,(function(u){return re||0===oe.length||(re=!0,e=oe.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=[],o.setLogEventListener((function(e){var t=e.split(","),n=t[0],o=t[1],r=t[2],s=t[3],u=t[4],p=t.slice(5);try{var l=JSON.parse(decodeURIComponent(p.join(","))),d=l.loggerId,f=l.sessionId,_=l.content,h=l.traceId;if(!a&&i<0)return;var v={time:parseInt(o,10),level:parseInt(s,10),sessionId:"".concat(n,":").concat(f),type:r,tag:u,loggerId:d,content:_,traceId:h};c.push(v)}catch(e){console.error(e)}}),(function(e){n(c),re=!1,se()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},ie=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,u="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return i=e.call(this,n,o,u,{getLogs:function(e,n,o,r){return V(this,void 0,void 0,(function(){return K(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:n,level:o,realtimeReport:r,addon:t},V(void 0,void 0,void 0,(function(){return K(this,(function(e){return[2,new Promise((function(e){oe.push({resolve:e,args:i}),se()}))]}))})))];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 F(t,e),t.prototype.send=function(e){return te(this.logger,e)},t.prototype.compressLogs=function(e){return V(this,void 0,void 0,(function(){var t,n,o;return K(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}(u),ae=null,ce=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,D("md5").update(e).digest("hex")},ue=function(e){if(ae)return ae;var t=o(e,"deviceId");return M(t)?ae=U(t).toString():(ae=ce(),b(t,ae),ae)},pe=function(){function e(e,t){this._hasPingRes=e,this._reconnect=t,this._timerId=0,this._isFirstPing=!0,this._lossCount=0}return e.init=function(t,n){return ne?(ne.stop(),ne):ne=new e(t,n)},e.prototype.start=function(e){var t=this,n=this._isFirstPing?0:15e3;this._timerId=setTimeout((function(){return t._isFirstPing=!1,t._hasPingRes?(e(),t._hasPingRes=!1,t.start(e)):t._lossCount<4?(t._lossCount++,e(),t.start(e)):void t._reconnect()}),n)},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(){this._hasPingRes=!0,this._lossCount=0},e}(),le=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(G.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;t.messageUId;var 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}(),de=null;function fe(e,t,n,o,r){return void 0===r&&(r=!0),V(this,void 0,void 0,(function(){var s;return K(this,(function(i){switch(i.label){case 0:return de?[2,de]:(de=function(e,t,n,o,r){return void 0===r&&(r=!0),V(this,void 0,void 0,(function(){var s,i,a,c,u,l,d;return K(this,(function(f){switch(f.label){case 0:s="token=".concat(encodeURIComponent(o),"&v=").concat((_="5.6.1",_.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.6.1"),i=0,a=t.length,f.label=1;case 1:return i<a?(c="".concat(t[i],"/navi.json?r=").concat(Date.now()),e.info(p.O,"request navi -> url: ".concat(c,", body: ").concat(s)),[4,te(e,{method:"POST",headers:{appId:n},body:s,url:c},r)]):[3,4];case 2:if(200!==(u=f.sent()).status)return e.error("request navi failed -> ".concat(c)),u.data&&e.error(u.data),[3,3];e.info(p.O,"request navi success -> ".concat(c));try{return l=JSON.parse(u.data),d=/^https/.test(c)?"https":"http",l.protocol=d,[2,l]}catch(t){e.error("parse navi err => ".concat(u.data))}f.label=3;case 3:return i+=1,[3,1];case 4:return[2,null]}var _}))}))}(e,t,n,o,r),[4,de]);case 1:return s=i.sent(),de=null,[2,s]}}))}))}var _e,he=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 V(this,void 0,void 0,(function(){var n=this;return K(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){if(!M(e)){var t=o(e,"..");M(t)||ve(t),L(e)}},ge=function(){function t(e,t,n,s){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._reconnectKickEnable=s,this._currentToken="",this._connectionStatus=l.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._connectedTime=0,this._currentUserId="",this._naviInfo=null,this._version="5.6.1",this._senders={},this.rtcHeartbeatResolves={};var a=this._dbpath||o(N.getPath("userData")),c=ue(a);this._cppProtocol.initWithAppkey(e,a,this._version.replace(/-.*/,""));var u=R(o(__dirname,"sub-process.js"));this.subProxy=new he(u);var p=o(a,"RongCloud/rclogs",e);ve(p),function(e,t,n){n.initLogModule(t,e,r())}(e,p,this._cppProtocol),this.logger=new ee(this._appkey,"RC-M","IM"),z(this._cppProtocol,this.logger),this.reporter=new ie(this._cppProtocol,e,c,this.logger,this.subProxy),this.logger.info(G.P_INIT_O,JSON.stringify({appkey:e,dbpath:a,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:c,commit:"530541cfdb452c4336fef8ab544c0f14e4445d32"})),this._callCppProxy("setDeviceId",c),this._registerMsgTypes(),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),O.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return V(i,void 0,void 0,(function(){var o,r,s;return K(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(G.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=d.NOT_SUPPORT,[2];r=d.EXTRA_METHOD_UNDEFINED,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,W([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(G.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]}}))}))})),O.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return V(i,void 0,void 0,(function(){var r,s,i,a,c=this;return K(this,(function(u){switch(u.label){case 0:if("function"!=typeof(r=this[n]))return this.logger.error(G.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,d.NOT_SUPPORT),[2];"sendMessage"===n&&(s=o[3],o[3]=function(t){c._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=d.EXTRA_METHOD_UNDEFINED,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,r.call.apply(r,W([this],o,!1))];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),this.logger.error(G.P_CALL_MAIN_E,JSON.stringify({error:null==a?void 0:a.stack,method:n})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i),[2]}}))}))})),O.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,W([i],n,!1))}catch(e){i.logger.error(G.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(G.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),O.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new le(this._cppProtocol)}return 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(G.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.sendHTTPRequest=function(e){return te(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){$.apply(void 0,e)},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){Q(),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(G.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:d.EXTRA_METHOD_UNDEFINED});try{var r=o.call.apply(o,W([this],t,!1));return r}catch(t){this.logger.error(G.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:d.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.SUCCESS,data:r})},t.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[f.PRIVATE,f.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.SUCCESS,data:e})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[f.PRIVATE,f.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.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 f=0;f<l.length;f++){var _=this._buildMessage(l[f].obj);p[f]=_}}catch(e){return Promise.resolve({code:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.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:d.SUCCESS,data:r})},t.prototype.requestNaviInfo=function(e,t,n,o){return V(this,void 0,void 0,(function(){var r;return K(this,(function(s){switch(s.label){case 0:return[4,fe(this.logger,e,t,n,o)];case 1:return(r=s.sent())&&(this._naviInfo=r),[2,r]}}))}))},t.prototype.getNaviInfoFromCache=function(){return this._naviInfo?q({},this._naviInfo):null},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new ee(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},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,W([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._registerRenderers=function(e){var t=this,n=e.sender,o=n.id;this._senders[o]||(this._senders[o]=n,n.once("destroyed",(function(){delete t._senders[o]})))},t.prototype._registerMsgTypes=function(){for(var e in _["RC:RcCmd"]={isCounted:!1,isPersited:!1},_){var t=_[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._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;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,P=r.supportExt;r.extMsg;var E,I=r.pushContent,T=r.pushTitle,R=r.pushId,N=r.pushConfig,O=r.templateId,M=r.disableTitle,U=r.forcePushDetail;if(h(u))E=u;else try{E=u?JSON.parse(u):u}catch(e){E=u,this.logger.error(G.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:S}))}var b={isCounted:!1,isPersited:!1};p in _?b=_[p]:p in this._customMessageType&&(b=this._customMessageType[p]);var L=null;P&&(L=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==o&&"history"!==o||(L=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var w=v(n)?y<this._connectedTime:n,x={};N&&(x=g(this.logger,N,R));var A=q(q({},x),{pushTitle:T,pushContent:I,pushData:I,disablePushTitle:M,forceShowDetailContent:U,templateId:O}),D={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:E||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:w,sentTime:y,receivedTime:0,isPersited:b.isPersited,isCounted:b.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:P,expansion:P?L:null,receivedStatus:f,messageId:S,pushConfig:A};if(d===C.RECEIVE?D.receivedStatus=f:d===C.SEND&&(D.sentStatus=f),m){var J=JSON.parse(m),k=J.hasRespond,H=J.readerInfo,B={hasRespond:k,readCount:J.readCount,totalCount:J.totalCount},j=[];if(H)for(var F in H)j.push({userId:F,readTime:H[F]});B.readerList=j,D.readReceiptInfo=B}return D},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=q(q({},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=c?S.OPEN:S.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},t.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},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._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},t.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n,o;switch(e.logger.info(G.P_CONNECT_S,t),t){case 10:o=l.CONNECTING;break;case 31004:setTimeout((function(){e._connectResolve(d.RC_CONN_USER_OR_PASSWD_ERROR)})),o=l.RC_CONN_USER_OR_PASSWD_ERROR;break;case 12:o=l.DISCONNECTED;break;case 13:o=l.BLOCKED,setTimeout((function(){e._connectResolve(d.RC_CONN_USER_BLOCKED)}));break;case 31023:o=l.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(d.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 31029:o=l.USER_LOGOUT;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:o=l.NETWORK_UNAVAILABLE;break;case 30010:o=l.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===l.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:e.reporter.checkStart(e._naviInfo),o=l.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(d.SUCCESS),e._heartbeat=pe.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case l.KICKED_OFFLINE_BY_OTHER_CLIENT:o=l.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 31030:o=l.RC_LICENSE_EXPIRED,setTimeout((function(){e._connectResolve(d.RC_LICENSE_EXPIRED)}));break;case 30004:return;case 8:case 31006:case 32061:case 32012:o=l.REDIRECT;break;default:o=t}o!==l.CONNECTED&&(null===(n=e._heartbeat)||void 0===n||n.stop()),e._connectionStatus=o,e._sendConnectionStatus2Renderer(o)}),this._dbOpenCallback.bind(this),(function(){var t;null===(t=e._heartbeat)||void 0===t||t.setHeartbeatRes()}))},t.prototype._handleHeartTimeout=function(){var e,t=this;this._sendConnectionStatus2Renderer(l.NETWORK_UNAVAILABLE),null===(e=this._heartbeat)||void 0===e||e.stop(),setTimeout((function(){return t._doConnect()}),5e3)},t.prototype._dbOpenCallback=function(e){this.logger.info(G.P_DB_OPEN_O,e)},t.prototype._sendHeartbeat=function(){this._cppProtocol.sendHeartbeat()},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;if(a!==y.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===y.GROUP_READ_RECEIPT_REQUEST){var c=i.content,u=c.msgId,p=c.rrn,l=c.tmn;e._updateReadReceiptInfo(u,{readCount:p,totalCount:l})}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===y.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var d=!0;if(0!==n||r||(d=!1),a!==y.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===y.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!==y.DELIVERED_MSG){a===y.RECALL&&e.handleRecalledMessage(i);var f=i.conversationType,_=i.targetId;a===y.RECALL&&i.senderUserId===e._currentUserId&&(f=i.content.conversationType||f,_=i.content.targetId||_),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:d,conversationType:f,targetId:_}))}else{var h={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(h)}}else{var v=Object.keys(e._senders).map((function(t){return e._senders[t]}));v.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:d}),v.slice(1))}}else{var g=i.content,C=g.startTime,S=g.endTime,m=g.platform,P=g.logId,E=g.uri;e.reporter.report(parseInt(C,10),parseInt(S,10),m,E,P,i.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},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===y.TextMessage&&(r.recallContent=o.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[o.messageId]):this._callCppProxy("setMessageContent",o.messageId,JSON.stringify(r),y.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._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)?S.OPEN:S.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&&this._naviInfo&&this._naviInfo.voipCallInfo!==e){var t=q(q({},this._naviInfo),{voipCallInfo:e});this._naviInfo=t,this._send2AllRenderer("onNaviDataChange",t)}},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._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},t.prototype.registerMessageType=function(e,t,n,o){var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(G.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:o})),this._callCppProxy("registerMessageType",e,r,o)},t.prototype.connect=function(e,t,n,o){var r=this;return this.logger.info(G.P_CONNECT_O,JSON.stringify({reconnectKickEnable:n,version:this._version}),o),this._currentToken===e&&this._connectionStatus===l.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(d.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._promiseHandler.connect||this._doConnect(n),new Promise((function(e,t){r._promiseHandler.connect?r._promiseHandler.connect.push({resolve:e,reject:t}):r._promiseHandler.connect=[{resolve:e,reject:t}]})))},t.prototype._doConnect=function(e){var t=v(e)?!!this._reconnectKickEnable:!!e;this._callCppProxy("connectWithToken",this._currentToken,this._version,JSON.stringify(this._naviInfo),t)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(q(q({},e),{"electron-main":"5.6.1"}));this.logger.info(G.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o)},t.prototype.disconnect=function(){var e;this.reporter.stop(),this._cppProtocol.disconnect(!0),null===(e=this._heartbeat)||void 0===e||e.stop(),this._connectResolve(d.TIMEOUT)},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(d.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(d.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:d.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.pushContent,u=n.pushData,p=n.directionalUserIdList,l=n.disableNotification,_=n.canIncludeExpansion,h=n.expansion,v=n.isVoipPush,g=n.pushConfig,C=n.channelId,S=n.isMentioned,E=n.mentionedType,I=n.mentionedUserIdList,T=n.messageId,R=g||{},N=R.iOSConfig,O=R.androidConfig,M=R.pushTitle,U=R.pushContent,b=R.pushData,L=R.disablePushTitle,w=R.forceShowDetailContent,x=R.templateId,A=m(N,O);return new Promise((function(n){var g,m,R;c=U||c||"",u=b||u||"",l=l||!1,v=v||!1,M=M||"",U=U||"",b=b||"",L=L||!1,w=w||!1,_=_||!1;var N=(null==O?void 0:O.notificationId)||"";if(p=p||[],T=T||0,C=C||"",e===f.GROUP&&S&&a&&(a.mentionedInfo={userIdList:(null===(g=a.mentionedInfo)||void 0===g?void 0:g.userIdList)||I||[],type:(null===(m=a.mentionedInfo)||void 0===m?void 0:m.type)||E||P.ALL,mentionedContent:(null===(R=a.mentionedInfo)||void 0===R?void 0:R.mentionedContent)||""}),e===f.GROUP&&i===y.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var D in a.receiptMessageDic)p.push(D);var J={};for(var D in h)J[D]={v:""},J[D].v=h[D];var k=x||"";s.logger.info(G.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:C}),r);var H=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(G.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===d.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:d.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(G.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),p,l,L,w,c,u,N,M,A,k,_,JSON.stringify(J),v,C,T),B=JSON.parse(H);null==o||o(B.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,f=r.extra,_=r.pushConfig,h=r.disableNotification,v=r.isDelete,g={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:u,extra:f,channelId:l,isDelete:v||!1};u&&(g.user=u),f&&(g.extra=f);var S={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:g,objectName:y.RECALL,messageUid:n,direction:C.SEND,status:E.UNREAD,sentTime:o,channelId:l},P=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(P),i({code:d.SUCCESS,data:P})}),(function(e){i({code:e})}),y.RECALL,JSON.stringify(g),h||!1,(null==_?void 0:_.disablePushTitle)||!1,(null==_?void 0:_.forceShowDetailContent)||!1,p||"",(null==_?void 0:_.pushData)||"",(null===(c=null==_?void 0:_.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==_?void 0:_.pushTitle)||"",m(null==_?void 0:_.iOSConfig,null==_?void 0:_.androidConfig),(null==_?void 0:_.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,f=a._callCppProxy("getHistoryMessages",e,t,n,l,i,p,s),_=JSON.parse(f).list,h=[];_.reverse();for(var v=0;v<_.length;v++){var g=a._buildMessage(_[v].obj);h[v]=g}c({code:d.SUCCESS,data:{list:l===h.length?h.slice(1,l):h,hasMore:o<h.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:d.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(d.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(d.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(d.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:d.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:d.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(G.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:d.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:u,notificationStatus:p?S.OPEN:S.CLOSE,isTop:Boolean(l),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(o?d.SUCCESS:d.UNKNOWN)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var s=[];s=I(e)?e:[f.PRIVATE,f.GROUP,f.SYSTEM,f.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),o(d.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:d.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:d.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(d.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(d.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:d.SUCCESS,data:-1!==a.messageId?a: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(d.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(d.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(d.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(d.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:d.SUCCESS,data:i?S.OPEN:S.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:d.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:d.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:d.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:d.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:d.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(d.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(d.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:d.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:d.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,f=n.isUnread,_=n.messageUId,h=n.disableNotification,v=n.canIncludeExpansion,g=n.expansionMsg,C=n.channelId;return r=JSON.stringify(r),new Promise((function(n,S){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),a,c,u,p,l,y,_,h,v,g,C),P=o._buildMessage(m,{isOffLineMessage:!1});P.messageUId=_,P.sentTime=p,n({code:-1===P.messageId?d.MSG_INSERT_ERROR:d.SUCCESS,data:P})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteMessages",e),n(d.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(d.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:d.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(d.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setMessageSearchField",e,t,n),r(d.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(d.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(d.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;if(void 0!==r&&void 0===s)return this.setConversationToTop(n,o,r,i);if(void 0!==s&&void 0===r){var a=s===S.OPEN;return this.setConversationNotificationStatus(n,o,a,i)}var c=s===S.OPEN;return this.setConversationStatus(n,o,c,r,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(G.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:d.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:d.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("clearMessages",f.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){o(d.SUCCESS)}),o)}))},t.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},t.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(d.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:d.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:d.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(d.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:d.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,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(d.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,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:d.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return V(this,void 0,void 0,(function(){var n;return K(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===d.SUCCESS?[2,{code:d.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:d.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||"":T(e,t),r._callCppProxy("getUploadToken",e,i,n,o,(function(e,t,n,o,r,a,c,u,p,l,f,_,h,v,g,C,S,y){s({code:d.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:f,s3Policy:_,s3Signature:h,s3BucketName:v,stcAuthorization:g,stcContentSha256:C,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:d.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:d.SUCCESS,data:o})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(N.getPath("userData"));return ue(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:d.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(d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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 q(q({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:d.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:d.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:d.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:d.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=v(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:d.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 V(this,void 0,void 0,(function(){var t;return K(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:d.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return V(this,void 0,void 0,(function(){return K(this,(function(e){return[2,{code:d.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:d.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t}(),Ce=function(){function e(e,t,n,o){void 0===n&&(n=""),void 0===o&&(o=!1),this._cppService=new ge(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}(),Se=function(e){return function(e,t,n){if(_e)return _e;if(!t)throw new Error("Initializ failed, `appkey` is required!");return _e=new Ce(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.reconnectKickEnable)}(B,e.appkey,e)};export{Se as default};
|
|
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,HTTP_TIMEOUT as a,StoreKeys as c,BasicReporter as u,LogTagId as p,ConnectionStatus as l,ErrorCode as d,ConversationType as f,SEND_MESSAGE_TYPE_OPTION as h,isObject as _,isUndefined as v,pushJSONToConfigs as g,MessageDirection as C,NotificationStatus as S,MessageType as y,pushConfigsToJSON as m,MentionedType as P,ReceivedStatus as E,isArray as I,getUploadFileName as T}from"@rongcloud/engine";import{fork as R}from"child_process";import{app as N,ipcMain as O}from"electron";import{existsSync as M,readFileSync as U,writeFileSync as b,mkdirSync as L}from"fs";import{request as w}from"http";import{Agent as x,request as A}from"https";import{createHash as D}from"crypto";var J=process.versions.electron.replace(/\.\d+$/,""),k=o(__dirname,"binding","electron-v".concat(J,"-").concat(t(),"-").concat(n(),".node")),H={addon:null};try{H.addon=require(k)}catch(e){console.error("error ->",k,"\n",e)}var B=H.addon,j=function(e,t){return j=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])},j(e,t)};function F(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}j(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var G,q=function(){return q=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},q.apply(this,arguments)};function V(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 K(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 W(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"==typeof SuppressedError&&SuppressedError,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"}(G||(G={}));var Y,X={flushTimestamp:Date.now(),queue:[],locked:!1};function Q(){Y&&clearInterval(Y)}function z(e,t){Q(),Y=setInterval((function(){return ee(e,t)}),1e4)}function $(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=X.queue).push.apply(e,t)}var Z=200;function ee(e,t){var n=X.queue,o=X.flushTimestamp;if(!(X.locked||0===n.length||Date.now()-o<3e4&&n.length<Z)){X.locked=!0;var r=t.createTraceId(),s=n.splice(0,Z).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(G.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(G.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),X.flushTimestamp=Date.now(),X.locked=!1,setTimeout((function(){return ee(e,t)}))}}var te=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return F(t,e),t.prototype.flush=function(e){$(e)},t}(s);function ne(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,c=t.method,u=t.query,p=t.timeout,l=void 0===p?a:p;return new Promise((function(t){var a=/^https/.test(o),p={headers:r,method:c};a&&(p.rejectUnauthorized=n,p.agent=new x(p));var d=(a?A:w)(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})}))}));d.once("timeout",(function(){e.warn(G.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:c,query:u,timeout:l})),t({status:0})})),d.setTimeout(l),d.once("error",(function(n){e.warn(G.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:c,query:u,timeout:l})),t({status:0})})),d.write(s),d.end()}))}var oe,re=[],se=!1,ie=function(){return V(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c;return K(this,(function(u){return se||0===re.length||(se=!0,e=re.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=[],o.setLogEventListener((function(e){var t=e.split(","),n=t[0],o=t[1],r=t[2],s=t[3],u=t[4],p=t.slice(5);try{var l=JSON.parse(decodeURIComponent(p.join(","))),d=l.loggerId,f=l.sessionId,h=l.content,_=l.traceId;if(!a&&i<0)return;var v={time:parseInt(o,10),level:parseInt(s,10),sessionId:"".concat(n,":").concat(f),type:r,tag:u,loggerId:d,content:h,traceId:_};c.push(v)}catch(e){console.error(e)}}),(function(e){n(c),se=!1,ie()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},ae=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,u="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return i=e.call(this,n,o,u,{getLogs:function(e,n,o,r){return V(this,void 0,void 0,(function(){return K(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:n,level:o,realtimeReport:r,addon:t},V(void 0,void 0,void 0,(function(){return K(this,(function(e){return[2,new Promise((function(e){re.push({resolve:e,args:i}),ie()}))]}))})))];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 F(t,e),t.prototype.send=function(e){return ne(this.logger,e)},t.prototype.compressLogs=function(e){return V(this,void 0,void 0,(function(){var t,n,o;return K(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}(u),ce=null,ue=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,D("md5").update(e).digest("hex")},pe=function(e){if(ce)return ce;var t=o(e,"deviceId");return M(t)?ce=U(t).toString():(ce=ue(),b(t,ce),ce)},le=function(){function e(e,t){this._hasPingRes=e,this._reconnect=t,this._timerId=0,this._isFirstPing=!0,this._lossCount=0}return e.init=function(t,n){return oe?(oe.stop(),oe):oe=new e(t,n)},e.prototype.start=function(e){var t=this,n=this._isFirstPing?0:15e3;this._timerId=setTimeout((function(){return t._isFirstPing=!1,t._hasPingRes?(e(),t._hasPingRes=!1,t.start(e)):t._lossCount<4?(t._lossCount++,e(),t.start(e)):void t._reconnect()}),n)},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(){this._hasPingRes=!0,this._lossCount=0},e}(),de=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(G.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;t.messageUId;var 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=null;function he(e,t,n,o,r){return void 0===r&&(r=!0),V(this,void 0,void 0,(function(){var s;return K(this,(function(i){switch(i.label){case 0:return fe?[2,fe]:(fe=function(e,t,n,o,r){return void 0===r&&(r=!0),V(this,void 0,void 0,(function(){var s,i,a,c,u,l,d;return K(this,(function(f){switch(f.label){case 0:s="token=".concat(encodeURIComponent(o),"&v=").concat((h="5.6.2-alpha.1",h.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.6.2-alpha.1"),i=0,a=t.length,f.label=1;case 1:return i<a?(c="".concat(t[i],"/navi.json?r=").concat(Date.now()),e.info(p.O,"request navi -> url: ".concat(c,", body: ").concat(s)),[4,ne(e,{method:"POST",headers:{appId:n},body:s,url:c},r)]):[3,4];case 2:if(200!==(u=f.sent()).status)return e.error("request navi failed -> ".concat(c)),u.data&&e.error(u.data),[3,3];e.info(p.O,"request navi success -> ".concat(c));try{return l=JSON.parse(u.data),d=/^https/.test(c)?"https":"http",l.protocol=d,[2,l]}catch(t){e.error("parse navi err => ".concat(u.data))}f.label=3;case 3:return i+=1,[3,1];case 4:return[2,null]}var h}))}))}(e,t,n,o,r),[4,fe]);case 1:return s=i.sent(),fe=null,[2,s]}}))}))}var _e,ve=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 V(this,void 0,void 0,(function(){var n=this;return K(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}(),ge=function(e){if(!M(e)){var t=o(e,"..");M(t)||ge(t),L(e)}},Ce=function(){function t(e,t,n,s){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._reconnectKickEnable=s,this._currentToken="",this._connectionStatus=l.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._connectedTime=0,this._currentUserId="",this._naviInfo=null,this._version="5.6.2-alpha.1",this._senders={},this.rtcHeartbeatResolves={};var a=this._dbpath||o(N.getPath("userData")),c=pe(a);this._cppProtocol.initWithAppkey(e,a,this._version.replace(/-.*/,""));var u=R(o(__dirname,"sub-process.js"));this.subProxy=new ve(u);var p=o(a,"RongCloud/rclogs",e);ge(p),function(e,t,n){n.initLogModule(t,e,r())}(e,p,this._cppProtocol),this.logger=new te(this._appkey,"RC-M","IM"),z(this._cppProtocol,this.logger),this.reporter=new ae(this._cppProtocol,e,c,this.logger,this.subProxy),this.logger.info(G.P_INIT_O,JSON.stringify({appkey:e,dbpath:a,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:c,commit:"321edb741e02b6bb78a735b1dea30910977ad77e"})),this._callCppProxy("setDeviceId",c),this._registerMsgTypes(),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),O.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return V(i,void 0,void 0,(function(){var o,r,s;return K(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(G.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=d.NOT_SUPPORT,[2];r=d.EXTRA_METHOD_UNDEFINED,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,W([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(G.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]}}))}))})),O.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return V(i,void 0,void 0,(function(){var r,s,i,a,c=this;return K(this,(function(u){switch(u.label){case 0:if("function"!=typeof(r=this[n]))return this.logger.error(G.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,d.NOT_SUPPORT),[2];"sendMessage"===n&&(s=o[3],o[3]=function(t){c._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=d.EXTRA_METHOD_UNDEFINED,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,r.call.apply(r,W([this],o,!1))];case 2:return i=u.sent(),[3,4];case 3:return a=u.sent(),this.logger.error(G.P_CALL_MAIN_E,JSON.stringify({error:null==a?void 0:a.stack,method:n})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i),[2]}}))}))})),O.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,W([i],n,!1))}catch(e){i.logger.error(G.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(G.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),O.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new de(this._cppProtocol)}return 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(G.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.sendHTTPRequest=function(e){return ne(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){$.apply(void 0,e)},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){Q(),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(G.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:d.EXTRA_METHOD_UNDEFINED});try{return o.call.apply(o,W([this],t,!1))}catch(t){this.logger.error(G.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:d.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.SUCCESS,data:r})},t.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[f.PRIVATE,f.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.SUCCESS,data:e})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[f.PRIVATE,f.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:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.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 f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);p[f]=h}}catch(e){return Promise.resolve({code:d.MAIN_PROCESS_ERROR})}return Promise.resolve({code:d.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:d.SUCCESS,data:r})},t.prototype.requestNaviInfo=function(e,t,n,o){return V(this,void 0,void 0,(function(){var r;return K(this,(function(s){switch(s.label){case 0:return[4,he(this.logger,e,t,n,o)];case 1:return(r=s.sent())&&(this._naviInfo=r),[2,r]}}))}))},t.prototype.getNaviInfoFromCache=function(){return this._naviInfo?q({},this._naviInfo):null},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new te(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},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,W([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._registerRenderers=function(e){var t=this,n=e.sender,o=n.id;this._senders[o]||(this._senders[o]=n,n.once("destroyed",(function(){delete t._senders[o]})))},t.prototype._registerMsgTypes=function(){for(var e in h["RC:RcCmd"]={isCounted:!1,isPersited:!1},h){var t=h[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._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;r.source;var S=r.messageId,y=r.sentTime,m=r.readReceiptRequest,P=r.supportExt;r.extMsg;var E,I=r.pushContent,T=r.pushTitle,R=r.pushId,N=r.pushConfig,O=r.templateId,M=r.disableTitle,U=r.forcePushDetail;if(_(u))E=u;else try{E=u?JSON.parse(u):u}catch(e){E=u,this.logger.error(G.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:S}))}var b={isCounted:!1,isPersited:!1};p in h?b=h[p]:p in this._customMessageType&&(b=this._customMessageType[p]);var L=null;P&&(L=this._msgExpansionHandler.parseReceiveExpansion(r),"conversation"!==o&&"history"!==o||(L=this._msgExpansionHandler.parseConverOrHisExpansion(r)));var w=v(n)?y<this._connectedTime:n,x={};N&&(x=g(this.logger,N,R));var A=q(q({},x),{pushTitle:T,pushContent:I,pushData:I,disablePushTitle:M,forceShowDetailContent:U,templateId:O}),D={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:E||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:w,sentTime:y,receivedTime:0,isPersited:b.isPersited,isCounted:b.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:P,expansion:P?L:null,receivedStatus:f,messageId:S,pushConfig:A};if(d===C.RECEIVE?D.receivedStatus=f:d===C.SEND&&(D.sentStatus=f),m){var J=JSON.parse(m),k=J.hasRespond,H=J.readerInfo,B={hasRespond:k,readCount:J.readCount,totalCount:J.totalCount},j=[];if(H)for(var F in H)j.push({userId:F,readTime:H[F]});B.readerList=j,D.readReceiptInfo=B}return D},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=q(q({},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=c?S.OPEN:S.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:!1,mentionedInfo:null,notificationStatus:p,isTop:a,lastUnreadTime:0,matchCount:u}},t.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},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._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},t.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n,o;switch(e.logger.info(G.P_CONNECT_S,t),t){case 10:o=l.CONNECTING;break;case 31004:setTimeout((function(){e._connectResolve(d.RC_CONN_USER_OR_PASSWD_ERROR)})),o=l.RC_CONN_USER_OR_PASSWD_ERROR;break;case 12:o=l.DISCONNECTED;break;case 13:o=l.BLOCKED,setTimeout((function(){e._connectResolve(d.RC_CONN_USER_BLOCKED)}));break;case 31023:o=l.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(d.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 31029:o=l.USER_LOGOUT;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:o=l.NETWORK_UNAVAILABLE;break;case 30010:o=l.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===l.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:e.reporter.checkStart(e._naviInfo),o=l.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(d.SUCCESS),e._heartbeat=le.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case l.KICKED_OFFLINE_BY_OTHER_CLIENT:o=l.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 31030:o=l.RC_LICENSE_EXPIRED,setTimeout((function(){e._connectResolve(d.RC_LICENSE_EXPIRED)}));break;case 30004:return;case 8:case 31006:case 32061:case 32012:o=l.REDIRECT;break;default:o=t}o!==l.CONNECTED&&(null===(n=e._heartbeat)||void 0===n||n.stop()),e._connectionStatus=o,e._sendConnectionStatus2Renderer(o)}),this._dbOpenCallback.bind(this),(function(){var t;null===(t=e._heartbeat)||void 0===t||t.setHeartbeatRes()}))},t.prototype._handleHeartTimeout=function(){var e,t=this;this._sendConnectionStatus2Renderer(l.NETWORK_UNAVAILABLE),null===(e=this._heartbeat)||void 0===e||e.stop(),setTimeout((function(){return t._doConnect()}),5e3)},t.prototype._dbOpenCallback=function(e){this.logger.info(G.P_DB_OPEN_O,e)},t.prototype._sendHeartbeat=function(){this._cppProtocol.sendHeartbeat()},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;if(a!==y.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===y.GROUP_READ_RECEIPT_REQUEST){var c=i.content,u=c.msgId,p=c.rrn,l=c.tmn;e._updateReadReceiptInfo(u,{readCount:p,totalCount:l})}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===y.SYNC_READ_STATUS){if(i.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",i.conversationType,i.targetId,i.content.lastMessageSendTime,i.channelId||"")}var d=!0;if(0!==n||r||(d=!1),a!==y.LOG_COMMAND||"rongcloudsystem"!==i.senderUserId){if(a===y.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!==y.DELIVERED_MSG){a===y.RECALL&&e.handleRecalledMessage(i);var f=i.conversationType,h=i.targetId;a===y.RECALL&&i.senderUserId===e._currentUserId&&(f=i.content.conversationType||f,h=i.content.targetId||h),e._sendMessageNotification(Object.assign(i,{hasMoreMsg:d,conversationType:f,targetId:h}))}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 v=Object.keys(e._senders).map((function(t){return e._senders[t]}));v.length>0&&e._sendMessageNotification(Object.assign(i,{hasMoreMsg:d}),v.slice(1))}}else{var g=i.content,C=g.startTime,S=g.endTime,m=g.platform,P=g.logId,E=g.uri;e.reporter.report(parseInt(C,10),parseInt(S,10),m,E,P,i.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},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===y.TextMessage&&(r.recallContent=o.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[o.messageId]):this._callCppProxy("setMessageContent",o.messageId,JSON.stringify(r),y.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._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)?S.OPEN:S.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&&this._naviInfo&&this._naviInfo.voipCallInfo!==e){var t=q(q({},this._naviInfo),{voipCallInfo:e});this._naviInfo=t,this._send2AllRenderer("onNaviDataChange",t)}},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._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},t.prototype.registerMessageType=function(e,t,n,o){var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(G.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:o})),this._callCppProxy("registerMessageType",e,r,o)},t.prototype.connect=function(e,t,n,o){var r=this;return this.logger.info(G.P_CONNECT_O,JSON.stringify({reconnectKickEnable:n,version:this._version}),o),this._currentToken===e&&this._connectionStatus===l.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(d.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._promiseHandler.connect||this._doConnect(n),new Promise((function(e,t){r._promiseHandler.connect?r._promiseHandler.connect.push({resolve:e,reject:t}):r._promiseHandler.connect=[{resolve:e,reject:t}]})))},t.prototype._doConnect=function(e){var t=v(e)?!!this._reconnectKickEnable:!!e;this._callCppProxy("connectWithToken",this._currentToken,this._version,JSON.stringify(this._naviInfo),t)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(q(q({},e),{"electron-main":"5.6.2-alpha.1"}));this.logger.info(G.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o)},t.prototype.disconnect=function(){var e;this.reporter.stop(),this._cppProtocol.disconnect(!0),null===(e=this._heartbeat)||void 0===e||e.stop(),this._connectResolve(d.TIMEOUT)},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(d.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("setUserStatus",e,(function(){n(d.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("getUserStatus",e,(function(e){n({code:d.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.pushContent,u=n.pushData,p=n.directionalUserIdList,l=n.disableNotification,h=n.canIncludeExpansion,_=n.expansion,v=n.isVoipPush,g=n.pushConfig,C=n.channelId,S=n.isMentioned,E=n.mentionedType,I=n.mentionedUserIdList,T=n.messageId,R=g||{},N=R.iOSConfig,O=R.androidConfig,M=R.pushTitle,U=R.pushContent,b=R.pushData,L=R.disablePushTitle,w=R.forceShowDetailContent,x=R.templateId,A=m(N,O);return new Promise((function(n){var g,m,R;c=U||c||"",u=b||u||"",l=l||!1,v=v||!1,M=M||"",U=U||"",b=b||"",L=L||!1,w=w||!1,h=h||!1;var N=(null==O?void 0:O.notificationId)||"";if(p=p||[],T=T||0,C=C||"",e===f.GROUP&&S&&a&&(a.mentionedInfo={userIdList:(null===(g=a.mentionedInfo)||void 0===g?void 0:g.userIdList)||I||[],type:(null===(m=a.mentionedInfo)||void 0===m?void 0:m.type)||E||P.ALL,mentionedContent:(null===(R=a.mentionedInfo)||void 0===R?void 0:R.mentionedContent)||""}),e===f.GROUP&&i===y.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var D in a.receiptMessageDic)p.push(D);var J={};for(var D in _)J[D]={v:""},J[D].v=_[D];var k=x||"";s.logger.info(G.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:C}),r);var H=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(G.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===d.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:d.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(G.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),p,l,L,w,c,u,N,M,A,k,h,JSON.stringify(J),v,C,T),B=JSON.parse(H);null==o||o(B.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,f=r.extra,h=r.pushConfig,_=r.disableNotification,v=r.isDelete,g={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:u,extra:f,channelId:l,isDelete:v||!1};u&&(g.user=u),f&&(g.extra=f);var S={conversationType:e,targetId:t,senderUserId:s._currentUserId,content:g,objectName:y.RECALL,messageUid:n,direction:C.SEND,status:E.UNREAD,sentTime:o,channelId:l},P=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(P),i({code:d.SUCCESS,data:P})}),(function(e){i({code:e})}),y.RECALL,JSON.stringify(g),_||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,p||"",(null==h?void 0:h.pushData)||"",(null===(c=null==h?void 0:h.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==h?void 0:h.pushTitle)||"",m(null==h?void 0:h.iOSConfig,null==h?void 0:h.androidConfig),(null==h?void 0:h.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,f=a._callCppProxy("getHistoryMessages",e,t,n,l,i,p,s),h=JSON.parse(f).list,_=[];h.reverse();for(var v=0;v<h.length;v++){var g=a._buildMessage(h[v].obj);_[v]=g}c({code:d.SUCCESS,data:{list:l===_.length?_.slice(1,l):_,hasMore:o<_.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:d.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(d.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(d.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(d.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:d.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:d.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(G.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:d.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:u,notificationStatus:p?S.OPEN:S.CLOSE,isTop:Boolean(l),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(e,t,n){var o=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(o?d.SUCCESS:d.UNKNOWN)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o,r){var s=[];s=I(e)?e:[f.PRIVATE,f.GROUP,f.SYSTEM,f.PUBLIC_SERVICE],n._callCppProxy("clearConversations",s,t),o(d.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:d.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:d.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(d.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(d.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:d.SUCCESS,data:-1!==a.messageId?a: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(d.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(d.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(d.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(d.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:d.SUCCESS,data:i?S.OPEN:S.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:d.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:d.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:d.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:d.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:d.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(d.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("removeFromBlacklist",e,(function(){n(d.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){e._callCppProxy("getBlacklist",(function(e){t({code:d.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:d.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,f=n.isUnread,h=n.messageUId,_=n.disableNotification,v=n.canIncludeExpansion,g=n.expansionMsg,C=n.channelId;return r=JSON.stringify(r),new Promise((function(n,S){var y=f?0:1,m=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),a,c,u,p,l,y,h,_,v,g,C),P=o._buildMessage(m,{isOffLineMessage:!1});P.messageUId=h,P.sentTime=p,n({code:-1===P.messageId?d.MSG_INSERT_ERROR:d.SUCCESS,data:P})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("deleteMessages",e),n(d.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(d.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:d.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(d.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r,s){o._callCppProxy("setMessageSearchField",e,t,n),r(d.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageSentStatus",e,t),o(d.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("setMessageReceivedStatus",e,t),o(d.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;if(void 0!==r&&void 0===s)return this.setConversationToTop(n,o,r,i);if(void 0!==s&&void 0===r){var a=s===S.OPEN;return this.setConversationNotificationStatus(n,o,a,i)}var c=s===S.OPEN;return this.setConversationStatus(n,o,c,r,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(G.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:d.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:d.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(o,r){n._callCppProxy("clearMessages",f.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){o(d.SUCCESS)}),o)}))},t.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},t.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,o){t._callCppProxy("quitChatRoom",e,(function(){n(d.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:d.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:d.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(d.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:d.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,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(d.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,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:d.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return V(this,void 0,void 0,(function(){var n;return K(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===d.SUCCESS?[2,{code:d.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:d.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||"":T(e,t),r._callCppProxy("getUploadToken",e,i,n,o,(function(e,t,n,o,r,a,c,u,p,l,f,h,_,v,g,C,S,y){s({code:d.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:f,s3Policy:h,s3Signature:_,s3BucketName:v,stcAuthorization:g,stcContentSha256:C,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:d.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:d.SUCCESS,data:o})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(N.getPath("userData"));return pe(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:d.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(d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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:d.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 q(q({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:d.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:d.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:d.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:d.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=v(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:d.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 V(this,void 0,void 0,(function(){var t;return K(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:d.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return V(this,void 0,void 0,(function(){return K(this,(function(e){return[2,{code:d.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:d.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t}(),Se=function(){function e(e,t,n,o){void 0===n&&(n=""),void 0===o&&(o=!1),this._cppService=new Ce(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}(),ye=function(e){return function(e,t,n){if(_e)return _e;if(!t)throw new Error("Initializ failed, `appkey` is required!");return _e=new Se(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.reconnectKickEnable)}(B,e.appkey,e)};export{ye as default};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("child_process"),r=require("electron"),s=require("fs"),i=require("http"),a=require("https"),c=require("crypto");function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var p=u(e),l=process.versions.electron.replace(/\.\d+$/,""),d=t.resolve(__dirname,"binding","electron-v".concat(l,"-").concat(e.platform(),"-").concat(e.arch(),".node")),f={addon:null};try{f.addon=require(d)}catch(e){console.error("error ->",d,"\n",e)}var C=f.addon,_=function(e,t){return _=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])},_(e,t)};function v(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}_(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var h,g=function(){return g=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},g.apply(this,arguments)};function S(e,t,o,n){return new(o||(o=Promise))((function(r,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function y(e,t){var o,n,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(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=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++,n=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],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function E(e,t,o){if(o||2===arguments.length)for(var n,r=0,s=t.length;r<s;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||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"}(h||(h={}));var m,P={flushTimestamp:Date.now(),queue:[],locked:!1};function T(){m&&clearInterval(m)}function I(e,t){T(),m=setInterval((function(){return R(e,t)}),1e4)}function N(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=P.queue).push.apply(e,t)}function R(e,t){var o=P.queue,n=P.flushTimestamp;if(!(P.locked||0===o.length||Date.now()-n<3e4&&o.length<200)){P.locked=!0;var r=t.createTraceId(),s=o.splice(0,200).map((function(e){var t=e.sessionId,o=e.level,n=e.time,r=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:n,type:r,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(h.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(h.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),r),P.flushTimestamp=Date.now(),P.locked=!1,setTimeout((function(){return R(e,t)}))}}var O=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return v(t,e),t.prototype.flush=function(e){N(e)},t}(o.BasicLogger);function M(e,t,n){void 0===n&&(n=!1);var r=t.url,s=t.headers,c=t.body,u=t.method,p=t.query,l=t.timeout,d=void 0===l?o.HTTP_TIMEOUT:l;return new Promise((function(t){var l=/^https/.test(r),f={headers:s,method:u};l&&(f.rejectUnauthorized=n,f.agent=new a.Agent(f));var C=(l?a.request:i.request)(o.appendUrl(r,p),f,(function(e){var o=e.statusCode,n="";e.setEncoding("utf8"),e.on("data",(function(e){n+=e})),e.once("end",(function(){t({status:o||0,data:n})}))}));C.once("timeout",(function(){e.warn(h.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:r,method:u,query:p,timeout:d})),t({status:0})})),C.setTimeout(d),C.once("error",(function(o){e.warn(h.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:r,method:u,query:p,timeout:d})),t({status:0})})),C.write(c),C.end()}))}var U,b=[],L=!1,w=function(){return S(void 0,void 0,void 0,(function(){var e,t,o,n,r,s,i,a,c;return y(this,(function(u){return L||0===b.length||(L=!0,e=b.shift(),t=e.args,o=e.resolve,n=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=[],n.setLogEventListener((function(e){var t=e.split(","),o=t[0],n=t[1],r=t[2],s=t[3],u=t[4],p=t.slice(5);try{var l=JSON.parse(decodeURIComponent(p.join(","))),d=l.loggerId,f=l.sessionId,C=l.content,_=l.traceId;if(!a&&i<0)return;var v={time:parseInt(n,10),level:parseInt(s,10),sessionId:"".concat(o,":").concat(f),type:r,tag:u,loggerId:d,content:C,traceId:_};c.push(v)}catch(e){console.error(e)}}),(function(e){o(c),L=!1,w()}),(function(e,t,o){})),n.pullFullLog(i,r,s,!1)),[2]}))}))},x=function(e){function t(t,n,r,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,n,r,u,{getLogs:function(e,o,n,r){return S(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:o,level:n,realtimeReport:r,addon:t},S(void 0,void 0,void 0,(function(){return y(this,(function(e){return[2,new Promise((function(e){b.push({resolve:e,args:i}),w()}))]}))})))];case 1:return[2,{logs:s.sent(),dbReady:!0}]}var i}))}))},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 v(t,e),t.prototype.send=function(e){return M(this.logger,e)},t.prototype.compressLogs=function(e){return S(this,void 0,void 0,(function(){var t,o,n;return y(this,(function(r){switch(r.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=r.sent(),o=t.success,n=t.data,o?[2,{success:o,data:n}]:[2,{success:o,data:""}]}}))}))},t}(o.BasicReporter),A=null,D=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,c.createHash("md5").update(t).digest("hex")},J=function(e){if(A)return A;var o=t.resolve(e,"deviceId");return s.existsSync(o)?A=s.readFileSync(o).toString():(A=D(),s.writeFileSync(o,A),A)},k=function(){function e(e,t){this._hasPingRes=e,this._reconnect=t,this._timerId=0,this._isFirstPing=!0,this._lossCount=0}return e.init=function(t,o){return U?(U.stop(),U):U=new e(t,o)},e.prototype.start=function(e){var t=this,o=this._isFirstPing?0:15e3;this._timerId=setTimeout((function(){return t._isFirstPing=!1,t._hasPingRes?(e(),t._hasPingRes=!1,t.start(e)):t._lossCount<4?(t._lossCount++,e(),t.start(e)):void t._reconnect()}),o)},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(){this._hasPingRes=!0,this._lossCount=0},e}(),H=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,n,r,s){var i=JSON.stringify(r);"{}"!==i&&e.info(h.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:n,ext:r})),this._cppProto.setMessageExtension(t,o,n,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,n=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,n,r,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,n=t.conversationType,r=t.targetId;t.messageUId;var 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,n,r,a.mid,l,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),j=null;function B(e,t,n,r,s){return void 0===s&&(s=!0),S(this,void 0,void 0,(function(){var i;return y(this,(function(a){switch(a.label){case 0:return j?[2,j]:(j=function(e,t,n,r,s){return void 0===s&&(s=!0),S(this,void 0,void 0,(function(){var i,a,c,u,p,l,d;return y(this,(function(f){switch(f.label){case 0:i="token=".concat(encodeURIComponent(r),"&v=").concat((C="5.6.1",C.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.6.1"),a=0,c=t.length,f.label=1;case 1:return a<c?(u="".concat(t[a],"/navi.json?r=").concat(Date.now()),e.info(o.LogTagId.O,"request navi -> url: ".concat(u,", body: ").concat(i)),[4,M(e,{method:"POST",headers:{appId:n},body:i,url:u},s)]):[3,4];case 2:if(200!==(p=f.sent()).status)return e.error("request navi failed -> ".concat(u)),p.data&&e.error(p.data),[3,3];e.info(o.LogTagId.O,"request navi success -> ".concat(u));try{return l=JSON.parse(p.data),d=/^https/.test(u)?"https":"http",l.protocol=d,[2,l]}catch(t){e.error("parse navi err => ".concat(p.data))}f.label=3;case 3:return a+=1,[3,1];case 4:return[2,null]}var C}))}))}(e,t,n,r,s),[4,j]);case 1:return i=a.sent(),j=null,[2,i]}}))}))}var F,G=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,n=e.success,r=e.data,s=t.maps[o];s&&(s({success:n,data:r}),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 S(this,void 0,void 0,(function(){var o=this;return y(this,(function(n){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(n){var r=++o.count;o.maps[r]=n;var s={reqId:r,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),q=function(e){if(!s.existsSync(e)){var o=t.resolve(e,"..");s.existsSync(o)||q(o),s.mkdirSync(e)}},V=function(){function e(e,s,i,a){var c=this;this._appkey=e,this._cppProtocol=s,this._dbpath=i,this._reconnectKickEnable=a,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._connectedTime=0,this._currentUserId="",this._naviInfo=null,this._version="5.6.1",this._senders={},this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(r.app.getPath("userData")),p=J(u);this._cppProtocol.initWithAppkey(e,u,this._version.replace(/-.*/,""));var l=n.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new G(l);var d=t.resolve(u,"RongCloud/rclogs",e);q(d),function(e,t,n){n.initLogModule(t,e,o.getUUID())}(e,d,this._cppProtocol),this.logger=new O(this._appkey,"RC-M","IM"),I(this._cppProtocol,this.logger),this.reporter=new x(this._cppProtocol,e,p,this.logger,this.subProxy),this.logger.info(h.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"530541cfdb452c4336fef8ab544c0f14e4445d32"})),this._callCppProxy("setDeviceId",p),this._registerMsgTypes(),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),r.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return S(c,void 0,void 0,(function(){var r,s,i;return y(this,(function(a){switch(a.label){case 0:if("function"!=typeof(r=this[t]))return this.logger.error(h.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,r.call.apply(r,E([this],n,!1))];case 2:return s=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(h.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]}}))}))})),r.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return S(c,void 0,void 0,(function(){var s,i,a,c,u=this;return y(this,(function(p){switch(p.label){case 0:if("function"!=typeof(s=this[n]))return this.logger.error(h.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(i=r[3],r[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,E([this],r,!1))];case 2:return a=p.sent(),[3,4];case 3:return c=p.sent(),this.logger.error(h.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,a),[2]}}))}))})),r.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];var r=c[t];if("function"==typeof r)try{r.call.apply(r,E([c],o,!1))}catch(e){c.logger.error(h.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(h.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),r.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new H(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var r=this.logger.createTraceId();try{var s=(t=this._cppProtocol)[e].apply(t,o);return s}catch(t){this.logger.error(h.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},e.prototype.sendHTTPRequest=function(e){return M(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){N.apply(void 0,e)},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){T(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this[e];if(!r)return this.logger.warn(h.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{var s=r.call.apply(r,E([this],t,!1));return s}catch(t){this.logger.error(h.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,n,r){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");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.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).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 n,r=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{n=JSON.parse(i).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:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,s,i,a){var c=0===i,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,s,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var C=this._buildMessage(d[f].obj);l[f]=C}}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:r<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r="");var s=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.requestNaviInfo=function(e,t,o,n){return S(this,void 0,void 0,(function(){var r;return y(this,(function(s){switch(s.label){case 0:return[4,B(this.logger,e,t,o,n)];case 1:return(r=s.sent())&&(this._naviInfo=r),[2,r]}}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo?g({},this._naviInfo):null},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new O(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,E([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var s=n._senders[r];o.includes(s)||n._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._registerRenderers=function(e){var t=this,o=e.sender,n=o.id;this._senders[n]||(this._senders[n]=o,o.once("destroyed",(function(){delete t._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],n=t.isCounted,r=t.isPersited,s=t.searchProps,i=0;r&&(i|=1),n&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,s)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,s=JSON.parse(e),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,p=s.content,l=s.objectName,d=s.messageUid,f=s.direction,C=s.status;s.source;var _=s.messageId,v=s.sentTime,S=s.readReceiptRequest,y=s.supportExt;s.extMsg;var E,m=s.pushContent,P=s.pushTitle,T=s.pushId,I=s.pushConfig,N=s.templateId,R=s.disableTitle,O=s.forcePushDetail;if(o.isObject(p))E=p;else try{E=p?JSON.parse(p):p}catch(e){E=p,this.logger.error(h.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:_}))}var M={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?M=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(M=this._customMessageType[l]);var U=null;y&&(U=this._msgExpansionHandler.parseReceiveExpansion(s),"conversation"!==r&&"history"!==r||(U=this._msgExpansionHandler.parseConverOrHisExpansion(s)));var b=o.isUndefined(n)?v<this._connectedTime:n,L={};I&&(L=o.pushJSONToConfigs(this.logger,I,T));var w=g(g({},L),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:R,forceShowDetailContent:O,templateId:N}),x={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:d||"",messageDirection:f,isOffLineMessage:b,sentTime:v,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?U:null,receivedStatus:C,messageId:_,pushConfig:w};if(f===o.MessageDirection.RECEIVE?x.receivedStatus=C:f===o.MessageDirection.SEND&&(x.sentStatus=C),S){var A=JSON.parse(S),D=A.hasRespond,J=A.readerInfo,k={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},H=[];if(J)for(var j in J)H.push({userId:j,readTime:J[j]});k.readerList=H,x.readReceiptInfo=k}return x},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},s=g(g({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),n=t.channelId,r=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},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._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n,r;switch(e.logger.info(h.P_CONNECT_S,t),t){case 10:r=o.ConnectionStatus.CONNECTING;break;case 31004:setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)})),r=o.ConnectionStatus.RC_CONN_USER_OR_PASSWD_ERROR;break;case 12:r=o.ConnectionStatus.DISCONNECTED;break;case 13:r=o.ConnectionStatus.BLOCKED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_BLOCKED)}));break;case 31023:r=o.ConnectionStatus.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 31029:r=o.ConnectionStatus.USER_LOGOUT;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:r=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:r=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:e.reporter.checkStart(e._naviInfo),r=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(o.ErrorCode.SUCCESS),e._heartbeat=k.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:r=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 31030:r=o.ConnectionStatus.RC_LICENSE_EXPIRED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_LICENSE_EXPIRED)}));break;case 30004:return;case 8:case 31006:case 32061:case 32012:r=o.ConnectionStatus.REDIRECT;break;default:r=t}r!==o.ConnectionStatus.CONNECTED&&(null===(n=e._heartbeat)||void 0===n||n.stop()),e._connectionStatus=r,e._sendConnectionStatus2Renderer(r)}),this._dbOpenCallback.bind(this),(function(){var t;null===(t=e._heartbeat)||void 0===t||t.setHeartbeatRes()}))},e.prototype._handleHeartTimeout=function(){var e,t=this;this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),null===(e=this._heartbeat)||void 0===e||e.stop(),setTimeout((function(){return t._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){this.logger.info(h.P_DB_OPEN_O,e)},e.prototype._sendHeartbeat=function(){this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,s){var i,a=e._buildMessage(t,{isOffLineMessage:r}),c=a.messageType;if(c!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(c===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var u=a.content,p=u.msgId,l=u.rrn,d=u.tmn;e._updateReadReceiptInfo(p,{readCount:l,totalCount:d})}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){if(a.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",a.conversationType,a.targetId,a.content.lastMessageSendTime,a.channelId||"")}var f=!0;if(0!==n||s||(f=!1),c!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(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){c===o.MessageType.RECALL&&e.handleRecalledMessage(a);var C=a.conversationType,_=a.targetId;c===o.MessageType.RECALL&&a.senderUserId===e._currentUserId&&(C=a.content.conversationType||C,_=a.content.targetId||_),e._sendMessageNotification(Object.assign(a,{hasMoreMsg:f,conversationType:C,targetId:_}))}else{var v={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(v)}}else{var h=Object.keys(e._senders).map((function(t){return e._senders[t]}));h.length>0&&e._sendMessageNotification(Object.assign(a,{hasMoreMsg:f}),h.slice(1))}}else{var g=a.content,S=g.startTime,y=g.endTime,E=g.platform,m=g.logId,P=g.uri;e.reporter.report(parseInt(S,10),parseInt(y,10),E,P,m,a.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var n=this._callCppProxy("getMessage",t),r=this._buildMessage(n,{isOffLineMessage:!1});if(r.messageId){var s={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:r.messageType,originalMessageContent:r.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(s.user=e.content.user),e.content.extra&&(s.extra=e.content.extra),r.messageType===o.MessageType.TextMessage&&(s.recallContent=r.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[r.messageId]):this._callCppProxy("setMessageContent",r.messageId,JSON.stringify(s),o.MessageType.RECALL_NOTIFICATION_MESSAGE)}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,s=n.del,i=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:r}),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._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=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)})),r.push({channelId:a,conversationType:n,targetId:s,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&&this._naviInfo&&this._naviInfo.voipCallInfo!==e){var t=g(g({},this._naviInfo),{voipCallInfo:e});this._naviInfo=t,this._send2AllRenderer("onNaviDataChange",t)}},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._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,o,n){var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(h.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:n})),this._callCppProxy("registerMessageType",e,r,n)},e.prototype.connect=function(e,t,n,r){var s=this;return this.logger.info(h.P_CONNECT_O,JSON.stringify({reconnectKickEnable:n,version:this._version}),r),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._promiseHandler.connect||this._doConnect(n),new Promise((function(e,t){s._promiseHandler.connect?s._promiseHandler.connect.push({resolve:e,reject:t}):s._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?!!this._reconnectKickEnable:!!e;this._callCppProxy("connectWithToken",this._currentToken,this._version,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){var t,o,n=JSON.stringify(g(g({},e),{"electron-main":"5.6.1"}));this.logger.info(h.P_REPORT_VER_O,n),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,n)},e.prototype.disconnect=function(){var e;this.reporter.stop(),this._cppProtocol.disconnect(!0),null===(e=this._heartbeat)||void 0===e||e.stop(),this._connectResolve(o.ErrorCode.TIMEOUT)},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(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=n.messageType,c=n.content,u=n.pushContent,p=n.pushData,l=n.directionalUserIdList,d=n.disableNotification,f=n.canIncludeExpansion,C=n.expansion,_=n.isVoipPush,v=n.pushConfig,g=n.channelId,S=n.isMentioned,y=n.mentionedType,E=n.mentionedUserIdList,m=n.messageId,P=v||{},T=P.iOSConfig,I=P.androidConfig,N=P.pushTitle,R=P.pushContent,O=P.pushData,M=P.disablePushTitle,U=P.forceShowDetailContent,b=P.templateId,L=o.pushConfigsToJSON(T,I);return new Promise((function(n){var v,P,T;u=R||u||"",p=O||p||"",d=d||!1,_=_||!1,N=N||"",R=R||"",O=O||"",M=M||!1,U=U||!1,f=f||!1;var w=(null==I?void 0:I.notificationId)||"";if(l=l||[],m=m||0,g=g||"",e===o.ConversationType.GROUP&&S&&c&&(c.mentionedInfo={userIdList:(null===(v=c.mentionedInfo)||void 0===v?void 0:v.userIdList)||E||[],type:(null===(P=c.mentionedInfo)||void 0===P?void 0:P.type)||y||o.MentionedType.ALL,mentionedContent:(null===(T=c.mentionedInfo)||void 0===T?void 0:T.mentionedContent)||""}),e===o.ConversationType.GROUP&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var x in c.receiptMessageDic)l.push(x);var A={};for(var x in C)A[x]={v:""},A[x].v=C[x];var D=b||"";i.logger.info(h.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:g}),s);var J=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(h.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:r.messageUId}),s),t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(h.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,a,JSON.stringify(c),l,d,M,U,u,p,w,N,L,D,f,JSON.stringify(A),_,g,m),k=JSON.parse(J);null==r||r(k.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){var u,p=s.user,l=s.pushContent,d=s.channelId,f=s.extra,C=s.pushConfig,_=s.disableNotification,v=s.isDelete,h={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:f,channelId:d,isDelete:v||!1};p&&(h.user=p),f&&(h.extra=f);var g={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:h,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:d},S=i._buildMessage(JSON.stringify(g),{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(h),_||!1,(null==C?void 0:C.disablePushTitle)||!1,(null==C?void 0:C.forceShowDetailContent)||!1,l||"",(null==C?void 0:C.pushData)||"",(null===(u=null==C?void 0:C.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==C?void 0:C.pushTitle)||"",o.pushConfigsToJSON(null==C?void 0:C.iOSConfig,null==C?void 0:C.androidConfig),(null==C?void 0:C.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===s,d=r+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,i),C=JSON.parse(f).list,_=[];C.reverse();for(var v=0;v<C.length;v++){var h=c._buildMessage(C[v].obj);_[v]=h}u({code:o.ErrorCode.SUCCESS,data:{list:d===_.length?_.slice(1,d):_,hasMore:r<_.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,s,i){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var s=0;s<n.length;s++){var i=a._buildMessage(n[s].obj);r[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var s=this;return new Promise((function(i,a){var c=JSON.stringify(n);s._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("clearMessages",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,s){var i=this;return void 0===s&&(s=""),new Promise((function(e,t){for(var n=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(i._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversation",e,t,n);if(a)s({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r.logger.error(h.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 l=r._callCppProxy("getConversationNotificationStatus",e,t,n),d=r._callCppProxy("getConversationTopStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,s){var i=[];i=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s){var i=r._callCppProxy("getUnreadCount",e,t,n);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s,i){r._callCppProxy("clearUnreadCount",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);s({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var s=this;return void 0===r&&(r=""),new Promise((function(i,a){s._callCppProxy("setConversationToTop",e,t,n,r,!0),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationHidden",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),i,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,s,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var s=this;return new Promise((function(i,a){r=r||[1,3,6,7];for(var c=s._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=s._buildConversation(u[l].obj);i({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var r=this;return new Promise((function(s,i){n=n||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=c._buildMessage(n[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=i._buildMessage(n[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,r,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],r=0;r<t.length;r++)n[r]=c._buildMessage(t[r].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){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(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,s=n.content,i=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,C=n.messageUId,_=n.disableNotification,v=n.canIncludeExpansion,h=n.expansionMsg,g=n.channelId;return s=JSON.stringify(s),new Promise((function(n,S){var y=f?0:1,E=r._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,C,_,v,h,g),m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=C,m.sentTime=l,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var s=t._callCppProxy("getMessage",e),i=t._buildMessage(s,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(s,i){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setMessageSearchField",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){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],n=t.conversationType,r=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId;if(void 0!==s&&void 0===i)return this.setConversationToTop(n,r,s,a);if(void 0!==i&&void 0===s){var c=i===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}var u=i===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,u,s,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(s){r._callCppProxy("sendReadReceipt",e,n||"",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(h.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,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;i.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:i.length,totalCount:n};r._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:n}})}),(function(e){s({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var i=0;i<n.length;i++)r.push(JSON.parse(n[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(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 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 n=this;return new Promise((function(r,s){var i='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(s,i){n._callCppProxy("deleteChatroomKV",e,r,!!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._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var s=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return S(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,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){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var s=this;return n=n||"",r=r||"",new Promise((function(i){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),s._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,s,c,u,p,l,d,f,C,_,v,h,g,S,y){i({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:s,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:C,s3Signature:_,s3BucketName:v,stcAuthorization:h,stcContentSha256:g,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,n,r,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,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(r.app.getPath("userData"));return J(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var s=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",s,i,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,n){var r=this;return new Promise((function(s,i){r._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}}));s({code:o.ErrorCode.SUCCESS,data:{totalCount:t,list:n}})}),(function(e){s({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var n=this;return new Promise((function(r,s){var i=n._callCppProxy("getMessageDeliverTime",e);if(i)r({code:o.ErrorCode.SUCCESS,data:i});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);r({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,n,r){var s=this,i=Array.prototype.slice.call(new Uint8Array(r));return new Promise((function(r){s._callCppProxy("rtcSignaling",e,t,n,i,(function(e){var t=new Uint8Array(e).buffer;r({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){r({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var n=e.rtcHeartbeatResolves[t];if(n){var r=n.find((function(e){return""===e.seqId}));r&&(r.seqId=o)}}),(function(t,o,n,r){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===n}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(r)}})}}))},e.prototype.rtcPing=function(e,t,o){var n=this;return new Promise((function(t){var o={resolve:t,seqId:""},r=n.rtcHeartbeatResolves[e];r?r.push(o):n.rtcHeartbeatResolves[e]=[o],n._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags"),s=e._convertResultList(r,(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 n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||""),c=s._convertResultList(a,(function(e){return g(g({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,s){var i=n._callCppProxy("getConversationUnreadCountForTag",e,t);r({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.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(n,r){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}}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var n=this;return new Promise((function(r){var s=o.isUndefined(t)?n._callCppProxy("getTopConversations",e):n._callCppProxy("getTopConversations",e,t),i=JSON.parse(s).list.map((function(e){return n._buildConversation(e.obj)}));r({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 S(this,void 0,void 0,(function(){var e;return y(this,(function(t){return e={arch:p.arch(),platform:p.platform(),type:p.type(),version:p.version(),release:p.release(),uptime:p.uptime(),cpus:p.cpus(),freemem:p.freemem(),totalmem:p.totalmem(),networkInterfaces:p.networkInterfaces()},[2,{code:o.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return S(this,void 0,void 0,(function(){return y(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,n){var r=this;return new Promise((function(s){r._callCppProxy("callInfoSignaling",e,t,n,(function(e,t){s({code:o.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){s({code:e})}))}))},e}(),K=function(){function e(e,t,o,n){void 0===o&&(o=""),void 0===n&&(n=!1),this._cppService=new V(e,t,o,n)}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(F)return F;if(!t)throw new Error("Initializ failed, `appkey` is required!");return F=new K(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.reconnectKickEnable)}(C,e.appkey,e)};
|
|
1
|
+
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),n=require("child_process"),r=require("electron"),s=require("fs"),i=require("http"),a=require("https"),c=require("crypto");function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var p=u(e),l=process.versions.electron.replace(/\.\d+$/,""),d=t.resolve(__dirname,"binding","electron-v".concat(l,"-").concat(e.platform(),"-").concat(e.arch(),".node")),f={addon:null};try{f.addon=require(d)}catch(e){console.error("error ->",d,"\n",e)}var C=f.addon,_=function(e,t){return _=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])},_(e,t)};function h(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}_(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var v,g=function(){return g=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},g.apply(this,arguments)};function S(e,t,o,n){return new(o||(o=Promise))((function(r,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function y(e,t){var o,n,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(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=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++,n=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],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function E(e,t,o){if(o||2===arguments.length)for(var n,r=0,s=t.length;r<s;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,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"}(v||(v={}));var m,P={flushTimestamp:Date.now(),queue:[],locked:!1};function T(){m&&clearInterval(m)}function I(e,t){T(),m=setInterval((function(){return O(e,t)}),1e4)}function N(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=P.queue).push.apply(e,t)}var R=200;function O(e,t){var o=P.queue,n=P.flushTimestamp;if(!(P.locked||0===o.length||Date.now()-n<3e4&&o.length<R)){P.locked=!0;var r=t.createTraceId(),s=o.splice(0,R).map((function(e){var t=e.sessionId,o=e.level,n=e.time,r=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:n,type:r,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(v.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(v.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),r),P.flushTimestamp=Date.now(),P.locked=!1,setTimeout((function(){return O(e,t)}))}}var M=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return h(t,e),t.prototype.flush=function(e){N(e)},t}(o.BasicLogger);function U(e,t,n){void 0===n&&(n=!1);var r=t.url,s=t.headers,c=t.body,u=t.method,p=t.query,l=t.timeout,d=void 0===l?o.HTTP_TIMEOUT:l;return new Promise((function(t){var l=/^https/.test(r),f={headers:s,method:u};l&&(f.rejectUnauthorized=n,f.agent=new a.Agent(f));var C=(l?a.request:i.request)(o.appendUrl(r,p),f,(function(e){var o=e.statusCode,n="";e.setEncoding("utf8"),e.on("data",(function(e){n+=e})),e.once("end",(function(){t({status:o||0,data:n})}))}));C.once("timeout",(function(){e.warn(v.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:r,method:u,query:p,timeout:d})),t({status:0})})),C.setTimeout(d),C.once("error",(function(o){e.warn(v.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:r,method:u,query:p,timeout:d})),t({status:0})})),C.write(c),C.end()}))}var b,L=[],w=!1,x=function(){return S(void 0,void 0,void 0,(function(){var e,t,o,n,r,s,i,a,c;return y(this,(function(u){return w||0===L.length||(w=!0,e=L.shift(),t=e.args,o=e.resolve,n=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=[],n.setLogEventListener((function(e){var t=e.split(","),o=t[0],n=t[1],r=t[2],s=t[3],u=t[4],p=t.slice(5);try{var l=JSON.parse(decodeURIComponent(p.join(","))),d=l.loggerId,f=l.sessionId,C=l.content,_=l.traceId;if(!a&&i<0)return;var h={time:parseInt(n,10),level:parseInt(s,10),sessionId:"".concat(o,":").concat(f),type:r,tag:u,loggerId:d,content:C,traceId:_};c.push(h)}catch(e){console.error(e)}}),(function(e){o(c),w=!1,x()}),(function(e,t,o){})),n.pullFullLog(i,r,s,!1)),[2]}))}))},A=function(e){function t(t,n,r,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,n,r,u,{getLogs:function(e,o,n,r){return S(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,(i={startTime:e,endTime:o,level:n,realtimeReport:r,addon:t},S(void 0,void 0,void 0,(function(){return y(this,(function(e){return[2,new Promise((function(e){L.push({resolve:e,args:i}),x()}))]}))})))];case 1:return[2,{logs:s.sent(),dbReady:!0}]}var i}))}))},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 h(t,e),t.prototype.send=function(e){return U(this.logger,e)},t.prototype.compressLogs=function(e){return S(this,void 0,void 0,(function(){var t,o,n;return y(this,(function(r){switch(r.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=r.sent(),o=t.success,n=t.data,o?[2,{success:o,data:n}]:[2,{success:o,data:""}]}}))}))},t}(o.BasicReporter),D=null,J=function(){var t,o=Date.now(),n=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=n,c.createHash("md5").update(t).digest("hex")},k=function(e){if(D)return D;var o=t.resolve(e,"deviceId");return s.existsSync(o)?D=s.readFileSync(o).toString():(D=J(),s.writeFileSync(o,D),D)},H=function(){function e(e,t){this._hasPingRes=e,this._reconnect=t,this._timerId=0,this._isFirstPing=!0,this._lossCount=0}return e.init=function(t,o){return b?(b.stop(),b):b=new e(t,o)},e.prototype.start=function(e){var t=this,o=this._isFirstPing?0:15e3;this._timerId=setTimeout((function(){return t._isFirstPing=!1,t._hasPingRes?(e(),t._hasPingRes=!1,t.start(e)):t._lossCount<4?(t._lossCount++,e(),t.start(e)):void t._reconnect()}),o)},e.prototype.stop=function(){this._lossCount=0,clearTimeout(this._timerId)},e.prototype.setHeartbeatRes=function(){this._hasPingRes=!0,this._lossCount=0},e}(),j=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,n,r,s){var i=JSON.stringify(r);"{}"!==i&&e.info(v.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:n,ext:r})),this._cppProto.setMessageExtension(t,o,n,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,n=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,n,r,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,n=t.conversationType,r=t.targetId;t.messageUId;var 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,n,r,a.mid,l,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var n in t)o[n]=t[n].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),n={};for(var r in o)n[r]=o[r].v;return n},e}(),B=null;function F(e,t,n,r,s){return void 0===s&&(s=!0),S(this,void 0,void 0,(function(){var i;return y(this,(function(a){switch(a.label){case 0:return B?[2,B]:(B=function(e,t,n,r,s){return void 0===s&&(s=!0),S(this,void 0,void 0,(function(){var i,a,c,u,p,l,d;return y(this,(function(f){switch(f.label){case 0:i="token=".concat(encodeURIComponent(r),"&v=").concat((C="5.6.2-alpha.1",C.match(/\d+(\.\d+){2}/)[0]),"&p=PC&ev=").concat("5.6.2-alpha.1"),a=0,c=t.length,f.label=1;case 1:return a<c?(u="".concat(t[a],"/navi.json?r=").concat(Date.now()),e.info(o.LogTagId.O,"request navi -> url: ".concat(u,", body: ").concat(i)),[4,U(e,{method:"POST",headers:{appId:n},body:i,url:u},s)]):[3,4];case 2:if(200!==(p=f.sent()).status)return e.error("request navi failed -> ".concat(u)),p.data&&e.error(p.data),[3,3];e.info(o.LogTagId.O,"request navi success -> ".concat(u));try{return l=JSON.parse(p.data),d=/^https/.test(u)?"https":"http",l.protocol=d,[2,l]}catch(t){e.error("parse navi err => ".concat(p.data))}f.label=3;case 3:return a+=1,[3,1];case 4:return[2,null]}var C}))}))}(e,t,n,r,s),[4,B]);case 1:return i=a.sent(),B=null,[2,i]}}))}))}var G,q=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,n=e.success,r=e.data,s=t.maps[o];s&&(s({success:n,data:r}),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 S(this,void 0,void 0,(function(){var o=this;return y(this,(function(n){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(n){var r=++o.count;o.maps[r]=n;var s={reqId:r,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),V=function(e){if(!s.existsSync(e)){var o=t.resolve(e,"..");s.existsSync(o)||V(o),s.mkdirSync(e)}},K=function(){function e(e,s,i,a){var c=this;this._appkey=e,this._cppProtocol=s,this._dbpath=i,this._reconnectKickEnable=a,this._currentToken="",this._connectionStatus=o.ConnectionStatus.DISCONNECTED,this._promiseHandler={},this._customMessageType={},this._connectedTime=0,this._currentUserId="",this._naviInfo=null,this._version="5.6.2-alpha.1",this._senders={},this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(r.app.getPath("userData")),p=k(u);this._cppProtocol.initWithAppkey(e,u,this._version.replace(/-.*/,""));var l=n.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new q(l);var d=t.resolve(u,"RongCloud/rclogs",e);V(d),function(e,t,n){n.initLogModule(t,e,o.getUUID())}(e,d,this._cppProtocol),this.logger=new M(this._appkey,"RC-M","IM"),I(this._cppProtocol,this.logger),this.reporter=new A(this._cppProtocol,e,p,this.logger,this.subProxy),this.logger.info(v.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"321edb741e02b6bb78a735b1dea30910977ad77e"})),this._callCppProxy("setDeviceId",p),this._registerMsgTypes(),this._setConnectionStatusListener(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),r.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return S(c,void 0,void 0,(function(){var r,s,i;return y(this,(function(a){switch(a.label){case 0:if("function"!=typeof(r=this[t]))return this.logger.error(v.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,r.call.apply(r,E([this],n,!1))];case 2:return s=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(v.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]}}))}))})),r.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var r=[],s=3;s<arguments.length;s++)r[s-3]=arguments[s];return S(c,void 0,void 0,(function(){var s,i,a,c,u=this;return y(this,(function(p){switch(p.label){case 0:if("function"!=typeof(s=this[n]))return this.logger.error(v.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===n&&(i=r[3],r[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,E([this],r,!1))];case 2:return a=p.sent(),[3,4];case 3:return c=p.sent(),this.logger.error(v.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,a),[2]}}))}))})),r.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];var r=c[t];if("function"==typeof r)try{r.call.apply(r,E([c],o,!1))}catch(e){c.logger.error(v.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(v.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),r.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new j(this._cppProtocol)}return e.prototype._callCppProxy=function(e){for(var t,o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];var r=this.logger.createTraceId();try{return(t=this._cppProtocol)[e].apply(t,o)}catch(t){this.logger.error(v.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},e.prototype.sendHTTPRequest=function(e){return U(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){N.apply(void 0,e)},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){T(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=this[e];if(!r)return this.logger.warn(v.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:o.ErrorCode.EXTRA_METHOD_UNDEFINED});try{return r.call.apply(r,E([this],t,!1))}catch(t){this.logger.error(v.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,n,r){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,n,r||"");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.getConversationListWithAllChannel=function(){var e,t=this,n=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],r=this._callCppProxy("getConversationListWithAllChannel",n);try{e=JSON.parse(r).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 n,r=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{n=JSON.parse(i).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:n})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,n,r,s,i,a){var c=0===i,u=r+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,u,s,c,a||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var f=0;f<d.length;f++){var C=this._buildMessage(d[f].obj);l[f]=C}}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===l.length?l.slice(1,u):l,hasMore:r<l.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,n,r){void 0===r&&(r="");var s=this._callCppProxy("updateMessageReceiptStatus",e,t,n,r);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.requestNaviInfo=function(e,t,o,n){return S(this,void 0,void 0,(function(){var r;return y(this,(function(s){switch(s.label){case 0:return[4,F(this.logger,e,t,o,n)];case 1:return(r=s.sent())&&(this._naviInfo=r),[2,r]}}))}))},e.prototype.getNaviInfoFromCache=function(){return this._naviInfo?g({},this._naviInfo):null},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new M(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this._connectedTime},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){var e;return(null===(e=this._naviInfo)||void 0===e?void 0:e.userId)||""},e.prototype._send2Renderer=function(e,t){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,E([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var n=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(r){var s=n._senders[r];o.includes(s)||n._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype._registerRenderers=function(e){var t=this,o=e.sender,n=o.id;this._senders[n]||(this._senders[n]=o,o.once("destroyed",(function(){delete t._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],n=t.isCounted,r=t.isPersited,s=t.searchProps,i=0;r&&(i|=1),n&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,s)}},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,r=t.buildFrom,s=JSON.parse(e),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,p=s.content,l=s.objectName,d=s.messageUid,f=s.direction,C=s.status;s.source;var _=s.messageId,h=s.sentTime,S=s.readReceiptRequest,y=s.supportExt;s.extMsg;var E,m=s.pushContent,P=s.pushTitle,T=s.pushId,I=s.pushConfig,N=s.templateId,R=s.disableTitle,O=s.forcePushDetail;if(o.isObject(p))E=p;else try{E=p?JSON.parse(p):p}catch(e){E=p,this.logger.error(v.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:_}))}var M={isCounted:!1,isPersited:!1};l in o.SEND_MESSAGE_TYPE_OPTION?M=o.SEND_MESSAGE_TYPE_OPTION[l]:l in this._customMessageType&&(M=this._customMessageType[l]);var U=null;y&&(U=this._msgExpansionHandler.parseReceiveExpansion(s),"conversation"!==r&&"history"!==r||(U=this._msgExpansionHandler.parseConverOrHisExpansion(s)));var b=o.isUndefined(n)?h<this._connectedTime:n,L={};I&&(L=o.pushJSONToConfigs(this.logger,I,T));var w=g(g({},L),{pushTitle:P,pushContent:m,pushData:m,disablePushTitle:R,forceShowDetailContent:O,templateId:N}),x={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:E||{},messageType:l,messageUId:d||"",messageDirection:f,isOffLineMessage:b,sentTime:h,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:!1,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:y,expansion:y?U:null,receivedStatus:C,messageId:_,pushConfig:w};if(f===o.MessageDirection.RECEIVE?x.receivedStatus=C:f===o.MessageDirection.SEND&&(x.sentStatus=C),S){var A=JSON.parse(S),D=A.hasRespond,J=A.readerInfo,k={hasRespond:D,readCount:A.readCount,totalCount:A.totalCount},H=[];if(J)for(var j in J)H.push({userId:j,readTime:J[j]});k.readerList=H,x.readReceiptInfo=k}return x},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),n=JSON.parse(o),r=n.readReceiptRequest?JSON.parse(n.readReceiptRequest):{},s=g(g({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),n=t.channelId,r=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.isBlocked,p=t.matchCount,l=u?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:n,conversationType:r,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:!1,mentionedInfo:null,notificationStatus:l,isTop:c,lastUnreadTime:0,matchCount:p}},e.prototype._sendConnectionStatus2Renderer=function(e){this._send2AllRenderer("status",e)},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._connectResolve=function(e){this._promiseHandler.connect&&this._promiseHandler.connect.length>0&&(this._promiseHandler.connect.forEach((function(t){t.resolve(e)})),delete this._promiseHandler.connect)},e.prototype._setConnectionStatusListener=function(){var e=this;this._cppProtocol.setConnectionStatusListener((function(t){var n,r;switch(e.logger.info(v.P_CONNECT_S,t),t){case 10:r=o.ConnectionStatus.CONNECTING;break;case 31004:setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_OR_PASSWD_ERROR)})),r=o.ConnectionStatus.RC_CONN_USER_OR_PASSWD_ERROR;break;case 12:r=o.ConnectionStatus.DISCONNECTED;break;case 13:r=o.ConnectionStatus.BLOCKED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_CONN_USER_BLOCKED)}));break;case 31023:r=o.ConnectionStatus.FORBID_RECONNECT_BY_OTHER_SAME_CLIENT,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_DISCONN_SAME_CLIENT_ON_LINE)}));break;case 31029:r=o.ConnectionStatus.USER_LOGOUT;break;case 1:case 9:case 11:case 31011:case 3e4:case 30002:r=o.ConnectionStatus.NETWORK_UNAVAILABLE;break;case 30010:r=o.ConnectionStatus.NETWORK_UNAVAILABLE,setTimeout((function(){e._connectionStatus===o.ConnectionStatus.NETWORK_UNAVAILABLE&&e._doConnect()}),5e3);break;case 0:case 33005:e.reporter.checkStart(e._naviInfo),r=o.ConnectionStatus.CONNECTED,e._connectedTime=Date.now()-e._cppProtocol.getDeltaTime(),setTimeout((function(){e._connectResolve(o.ErrorCode.SUCCESS),e._heartbeat=H.init(!0,e._handleHeartTimeout.bind(e)),e._heartbeat.start(e._sendHeartbeat.bind(e))}));break;case o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT:r=o.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT;break;case 31030:r=o.ConnectionStatus.RC_LICENSE_EXPIRED,setTimeout((function(){e._connectResolve(o.ErrorCode.RC_LICENSE_EXPIRED)}));break;case 30004:return;case 8:case 31006:case 32061:case 32012:r=o.ConnectionStatus.REDIRECT;break;default:r=t}r!==o.ConnectionStatus.CONNECTED&&(null===(n=e._heartbeat)||void 0===n||n.stop()),e._connectionStatus=r,e._sendConnectionStatus2Renderer(r)}),this._dbOpenCallback.bind(this),(function(){var t;null===(t=e._heartbeat)||void 0===t||t.setHeartbeatRes()}))},e.prototype._handleHeartTimeout=function(){var e,t=this;this._sendConnectionStatus2Renderer(o.ConnectionStatus.NETWORK_UNAVAILABLE),null===(e=this._heartbeat)||void 0===e||e.stop(),setTimeout((function(){return t._doConnect()}),5e3)},e.prototype._dbOpenCallback=function(e){this.logger.info(v.P_DB_OPEN_O,e)},e.prototype._sendHeartbeat=function(){this._cppProtocol.sendHeartbeat()},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,r,s){var i,a=e._buildMessage(t,{isOffLineMessage:r}),c=a.messageType;if(c!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(c===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var u=a.content,p=u.msgId,l=u.rrn,d=u.tmn;e._updateReadReceiptInfo(p,{readCount:l,totalCount:d})}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){if(a.senderUserId!==e._currentUserId)return;e._callCppProxy("clearUnreadCountByTimestamp",a.conversationType,a.targetId,a.content.lastMessageSendTime,a.channelId||"")}var f=!0;if(0!==n||s||(f=!1),c!==o.MessageType.LOG_COMMAND||"rongcloudsystem"!==a.senderUserId){if(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){c===o.MessageType.RECALL&&e.handleRecalledMessage(a);var C=a.conversationType,_=a.targetId;c===o.MessageType.RECALL&&a.senderUserId===e._currentUserId&&(C=a.content.conversationType||C,_=a.content.targetId||_),e._sendMessageNotification(Object.assign(a,{hasMoreMsg:f,conversationType:C,targetId:_}))}else{var h={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(h)}}else{var v=Object.keys(e._senders).map((function(t){return e._senders[t]}));v.length>0&&e._sendMessageNotification(Object.assign(a,{hasMoreMsg:f}),v.slice(1))}}else{var g=a.content,S=g.startTime,y=g.endTime,E=g.platform,m=g.logId,P=g.uri;e.reporter.report(parseInt(S,10),parseInt(y,10),E,P,m,a.messageUId)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype.handleRecalledMessage=function(e){var t=e.content.messageUId;if(t){var n=this._callCppProxy("getMessage",t),r=this._buildMessage(n,{isOffLineMessage:!1});if(r.messageId){var s={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:r.messageType,originalMessageContent:r.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};e.content.user&&(s.user=e.content.user),e.content.extra&&(s.extra=e.content.extra),r.messageType===o.MessageType.TextMessage&&(s.recallContent=r.content.content),e.content.isDelete?this._callCppProxy("deleteMessages",[r.messageId]):this._callCppProxy("setMessageContent",r.messageId,JSON.stringify(s),o.MessageType.RECALL_NOTIFICATION_MESSAGE)}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,n=e.content,r=n.put,s=n.del,i=n.mid,a={};r&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:r}),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._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var n=JSON.parse(t).list,r=[];n.forEach((function(e){var t=JSON.parse(e.obj),n=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)})),r.push({channelId:a,conversationType:n,targetId:s,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&&this._naviInfo&&this._naviInfo.voipCallInfo!==e){var t=g(g({},this._naviInfo),{voipCallInfo:e});this._naviInfo=t,this._send2AllRenderer("onNaviDataChange",t)}},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._send2AllRenderer("chatroom",{chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._clearListener=function(){this._cppProtocol.setOnReceiveMessageListener(),this._cppProtocol.setConnectionStatusListener(),this._cppProtocol.setOnReceiveStatusListener(),this._cppProtocol.setUserProfileListener()},e.prototype.registerMessageType=function(e,t,o,n){var r=0;t&&(r|=1),o&&(r|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(v.P_REGTYP_O,JSON.stringify({type:e,opt:r,search:n})),this._callCppProxy("registerMessageType",e,r,n)},e.prototype.connect=function(e,t,n,r){var s=this;return this.logger.info(v.P_CONNECT_O,JSON.stringify({reconnectKickEnable:n,version:this._version}),r),this._currentToken===e&&this._connectionStatus===o.ConnectionStatus.CONNECTED?(this._sendConnectionStatus2Renderer(this._connectionStatus),Promise.resolve(o.ErrorCode.SUCCESS)):(this._currentToken=e,this._naviInfo=t,this._currentUserId=t.userId,this._promiseHandler.connect||this._doConnect(n),new Promise((function(e,t){s._promiseHandler.connect?s._promiseHandler.connect.push({resolve:e,reject:t}):s._promiseHandler.connect=[{resolve:e,reject:t}]})))},e.prototype._doConnect=function(e){var t=o.isUndefined(e)?!!this._reconnectKickEnable:!!e;this._callCppProxy("connectWithToken",this._currentToken,this._version,JSON.stringify(this._naviInfo),t)},e.prototype.reportSDKInfo=function(e){var t,o,n=JSON.stringify(g(g({},e),{"electron-main":"5.6.2-alpha.1"}));this.logger.info(v.P_REPORT_VER_O,n),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,n)},e.prototype.disconnect=function(){var e;this.reporter.stop(),this._cppProtocol.disconnect(!0),null===(e=this._heartbeat)||void 0===e||e.stop(),this._connectResolve(o.ErrorCode.TIMEOUT)},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(n,r){t._callCppProxy("subscribeUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("setUserStatus",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("getUserStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},e.prototype.sendMessage=function(e,t,n,r,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=n.messageType,c=n.content,u=n.pushContent,p=n.pushData,l=n.directionalUserIdList,d=n.disableNotification,f=n.canIncludeExpansion,C=n.expansion,_=n.isVoipPush,h=n.pushConfig,g=n.channelId,S=n.isMentioned,y=n.mentionedType,E=n.mentionedUserIdList,m=n.messageId,P=h||{},T=P.iOSConfig,I=P.androidConfig,N=P.pushTitle,R=P.pushContent,O=P.pushData,M=P.disablePushTitle,U=P.forceShowDetailContent,b=P.templateId,L=o.pushConfigsToJSON(T,I);return new Promise((function(n){var h,P,T;u=R||u||"",p=O||p||"",d=d||!1,_=_||!1,N=N||"",R=R||"",O=O||"",M=M||!1,U=U||!1,f=f||!1;var w=(null==I?void 0:I.notificationId)||"";if(l=l||[],m=m||0,g=g||"",e===o.ConversationType.GROUP&&S&&c&&(c.mentionedInfo={userIdList:(null===(h=c.mentionedInfo)||void 0===h?void 0:h.userIdList)||E||[],type:(null===(P=c.mentionedInfo)||void 0===P?void 0:P.type)||y||o.MentionedType.ALL,mentionedContent:(null===(T=c.mentionedInfo)||void 0===T?void 0:T.mentionedContent)||""}),e===o.ConversationType.GROUP&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var x in c.receiptMessageDic)l.push(x);var A={};for(var x in C)A[x]={v:""},A[x].v=C[x];var D=b||"";i.logger.info(v.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:g}),s);var J=i._callCppProxy("sendMessage",(function(e,t){var r=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(v.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:r.messageUId}),s),t===o.ErrorCode.SENSITIVE_REPLACE?n({code:t}):("RC:MsgExMsg"===r.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,r),r.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,r),n({code:o.ErrorCode.SUCCESS,data:r}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(v.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,a,JSON.stringify(c),l,d,M,U,u,p,w,N,L,D,f,JSON.stringify(A),_,g,m),k=JSON.parse(J);null==r||r(k.messageId)}))},e.prototype.recallMsg=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){var u,p=s.user,l=s.pushContent,d=s.channelId,f=s.extra,C=s.pushConfig,_=s.disableNotification,h=s.isDelete,v={conversationType:e,targetId:t,messageUId:n,sentTime:r,user:p,extra:f,channelId:d,isDelete:h||!1};p&&(v.user=p),f&&(v.extra=f);var g={conversationType:e,targetId:t,senderUserId:i._currentUserId,content:v,objectName:o.MessageType.RECALL,messageUid:n,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:r,channelId:d},S=i._buildMessage(JSON.stringify(g),{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),_||!1,(null==C?void 0:C.disablePushTitle)||!1,(null==C?void 0:C.forceShowDetailContent)||!1,l||"",(null==C?void 0:C.pushData)||"",(null===(u=null==C?void 0:C.androidConfig)||void 0===u?void 0:u.notificationId)||"",(null==C?void 0:C.pushTitle)||"",o.pushConfigsToJSON(null==C?void 0:C.iOSConfig,null==C?void 0:C.androidConfig),(null==C?void 0:C.templateId)||"",d)}))},e.prototype.getHistoryMessage=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){n=n||0;var l=0===s,d=r+1,f=c._callCppProxy("getHistoryMessages",e,t,n,d,a,l,i),C=JSON.parse(f).list,_=[];C.reverse();for(var h=0;h<C.length;h++){var v=c._buildMessage(C[h].obj);_[h]=v}u({code:o.ErrorCode.SUCCESS,data:{list:d===_.length?_.slice(1,d):_,hasMore:r<_.length}})}))},e.prototype.getRemoteHistoryMessages=function(e,t,n,r,s,i){var a=this;return new Promise((function(c,u){n=n||0;a._callCppProxy("getRemoteHistoryMessages",e,t,n,r,(function(e,t){var n=JSON.parse(e).list,r=[];n.reverse();for(var s=0;s<n.length;s++){var i=a._buildMessage(n[s].obj);r[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:r,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,n,r){var s=this;return new Promise((function(i,a){var c=JSON.stringify(n);s._callCppProxy("deleteRemoteHistoryMessages",e,t,c,!1,r,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),r)}))},e.prototype.clearMessages=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("clearMessages",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,n,r,s){var i=this;return void 0===s&&(s=""),new Promise((function(e,t){for(var n=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(n).list,a=[],c=0;c<r.length;c++)a.push(i._buildConversation(r[c].obj));e({code:o.ErrorCode.SUCCESS,data:a})}))},e.prototype.getConversation=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversation",e,t,n);if(a)s({code:o.ErrorCode.SUCCESS,data:r._buildConversation(a)});else{var c=r._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),u=void 0;try{u=JSON.parse(c).list}catch(e){r.logger.error(v.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 l=r._callCppProxy("getConversationNotificationStatus",e,t,n),d=r._callCppProxy("getConversationTopStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:p,notificationStatus:l?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,n){var r=this._callCppProxy("removeConversation",e,t,n);return Promise.resolve(r?o.ErrorCode.SUCCESS:o.ErrorCode.UNKNOWN)},e.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(r,s){var i=[];i=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],n._callCppProxy("clearConversations",i,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,n){var r=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s){var i=r._callCppProxy("getUnreadCount",e,t,n);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,n){var r=this;return void 0===n&&(n=""),new Promise((function(s,i){r._callCppProxy("clearUnreadCount",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("clearUnreadCountByTimestamp",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getTheFirstUnreadMessage",e,t,n),c=r._buildMessage(a);s({code:o.ErrorCode.SUCCESS,data:-1!==c.messageId?c:null})}))},e.prototype.setConversationToTop=function(e,t,n,r){var s=this;return void 0===r&&(r=""),new Promise((function(i,a){s._callCppProxy("setConversationToTop",e,t,n,r,!0),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationHidden",e,t,n,r),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){i(o.ErrorCode.SUCCESS)}),i,r)}))},e.prototype.setConversationStatus=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("setConversationStatus",e,t,n,r,(function(){a(o.ErrorCode.SUCCESS)}),a,s,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,n){var r=this;return new Promise((function(s,i){var a=r._callCppProxy("getConversationNotificationStatus",e,t,n);s({code:o.ErrorCode.SUCCESS,data:a?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,n,r){var s=this;return new Promise((function(i,a){r=r||[1,3,6,7];for(var c=s._callCppProxy("searchConversationByContent",r,e,t,n),u=JSON.parse(c).list,p=[],l=0;l<u.length;l++)p[l]=s._buildConversation(u[l].obj);i({code:o.ErrorCode.SUCCESS,data:p})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var r=this;return new Promise((function(s,i){n=n||[1,3,6,7];for(var a=r._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=r._buildConversation(c[p].obj);s({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchMessageByContent=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(i,u){c._callCppProxy("searchMessageByContent",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=c._buildMessage(n[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}),a)}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,n,r,s,1,(function(e,t){for(var n=e?JSON.parse(e).list:[],r=[],s=0;s<n.length;s++)r[s]=i._buildMessage(n[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:r,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,n,r,s,i,a){var c=this;return new Promise((function(u,p){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,n,r,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],r=0;r<t.length;r++)n[r]=c._buildMessage(t[r].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:n}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var n=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,r=0;r<n.length;r++)n[r]=this._buildMessage(n[r].obj);return n},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addToBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("removeFromBlacklist",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t,n){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(n,r){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.insertMessage=function(e,t,n){var r=this,s=n.content,i=n.senderUserId,a=n.messageType,c=n.messageDirection,u=n.readStatus,p=n.sentStatus,l=n.sentTime,d=n.searchContent,f=n.isUnread,C=n.messageUId,_=n.disableNotification,h=n.canIncludeExpansion,v=n.expansionMsg,g=n.channelId;return s=JSON.stringify(s),new Promise((function(n,S){var y=f?0:1,E=r._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){n({code:e})}),c,u,p,l,d,y,C,_,h,v,g),m=r._buildMessage(E,{isOffLineMessage:!1});m.messageUId=C,m.sentTime=l,n({code:-1===m.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:m})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteMessages",e),n(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,n,r,s){var i=this;return new Promise((function(a,c){i._callCppProxy("deleteMessagesByTimestamp",e,t,n,r,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(n,r){var s=t._callCppProxy("getMessage",e),i=t._buildMessage(s,{isOffLineMessage:!1});n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setMessageContent=function(e,t,n){var r=this;return new Promise((function(s,i){t=JSON.stringify(t),r._callCppProxy("setMessageContent",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setMessageSearchField",e,t,n),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageSentStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("setMessageReceivedStatus",e,t),r(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,o,n){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],n=t.conversationType,r=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId;if(void 0!==s&&void 0===i)return this.setConversationToTop(n,r,s,a);if(void 0!==i&&void 0===s){var c=i===o.NotificationStatus.OPEN;return this.setConversationNotificationStatus(n,r,c,a)}var u=i===o.NotificationStatus.OPEN;return this.setConversationStatus(n,r,u,s,a)},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,n){var r=this;return new Promise((function(s){r._callCppProxy("sendReadReceipt",e,n||"",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(v.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,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getMessageReader",e,n,t,(function(e,n){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,n=t.time;i.push({userId:o,readTime:n}),a[o]=n}));var c={readerInfo:a,readCount:i.length,totalCount:n};r._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:n}})}),(function(e){s({code:e})}))}))},e.prototype.joinChatroom=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),n._callCppProxy("joinChatRoom",e,t,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.joinExistChatroom=function(e,t){throw new Error("Method not implemented.")},e.prototype.quitChatroom=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("quitChatRoom",e,(function(){n(o.ErrorCode.SUCCESS)}),n)}))},e.prototype.getChatroomInfo=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("getChatroomInfo",e,t,n,(function(e,t){var n=e?JSON.parse(e).list:[],r=[];if(n.length>0)for(var i=0;i<n.length;i++)r.push(JSON.parse(n[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:r,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,n,r){var s=this;return new Promise((function(i,a){s._callCppProxy("getChatroomHistoryMessage",e,t,n,r,(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 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 n=this;return new Promise((function(r,s){var i='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,i,!!t.isAutoDelete,!!t.isOverwrite,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var n=this;return new Promise((function(r){n._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this._currentUserId,this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var n=this,r=[t.key];return new Promise((function(s,i){n._callCppProxy("deleteChatroomKV",e,r,!!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._currentUserId,this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(r){var s=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return S(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=r.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:n.data?n.data[t]:null}]:[2,{code:n.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(n,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){}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.getFileToken=function(e,t,n,r){var s=this;return n=n||"",r=r||"",new Promise((function(i){var a;a=r&&"uploads"!==r?t||"":o.getUploadFileName(e,t),s._callCppProxy("getUploadToken",e,a,n,r,(function(e,t,n,r,s,c,u,p,l,d,f,C,_,h,v,g,S,y){i({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:r,osskeyId:s,ossPolicy:c,ossSign:u,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:f,s3Policy:C,s3Signature:_,s3BucketName:h,stcAuthorization:v,stcContentSha256:g,stcDate:S,stcBucketName:y}})}),(function(e){i({code:e})}))}))},e.prototype.getFileUrl=function(e,t,n,r){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,n,r,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,n){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(r.app.getPath("userData"));return k(e)},e.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("getVoIPKey",e,t,"",(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n,r){var s=e.chatRoomId,i=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",s,i,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,n){var r=this;return new Promise((function(s,i){r._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}}));s({code:o.ErrorCode.SUCCESS,data:{totalCount:t,list:n}})}),(function(e){s({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var n=this;return new Promise((function(r,s){var i=n._callCppProxy("getMessageDeliverTime",e);if(i)r({code:o.ErrorCode.SUCCESS,data:i});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);r({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,n,r){var s=this,i=Array.prototype.slice.call(new Uint8Array(r));return new Promise((function(r){s._callCppProxy("rtcSignaling",e,t,n,i,(function(e){var t=new Uint8Array(e).buffer;r({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){r({code:e})}))}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var n=e.rtcHeartbeatResolves[t];if(n){var r=n.find((function(e){return""===e.seqId}));r&&(r.seqId=o)}}),(function(t,o,n,r){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===n}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(r)}})}}))},e.prototype.rtcPing=function(e,t,o){var n=this;return new Promise((function(t){var o={resolve:t,seqId:""},r=n.rtcHeartbeatResolves[e];r?r.push(o):n.rtcHeartbeatResolves[e]=[o],n._callCppProxy("sendRTCHeartbeat",[e])}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("deleteTag",e,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(n,r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t,n){var r=e._callCppProxy("getTags"),s=e._convertResultList(r,(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 n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(r,s){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(r,s){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,n,r){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",e,t,n||20,r||""),c=s._convertResultList(a,(function(e){return g(g({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(r,s){var i=n._callCppProxy("getConversationUnreadCountForTag",e,t);r({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.setConversationStatusInTag=function(e,t,n){var r=this;return new Promise((function(s,i){r._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.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(n,r){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}}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var n=this;return new Promise((function(r){var s=o.isUndefined(t)?n._callCppProxy("getTopConversations",e):n._callCppProxy("getTopConversations",e,t),i=JSON.parse(s).list.map((function(e){return n._buildConversation(e.obj)}));r({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 S(this,void 0,void 0,(function(){var e;return y(this,(function(t){return e={arch:p.arch(),platform:p.platform(),type:p.type(),version:p.version(),release:p.release(),uptime:p.uptime(),cpus:p.cpus(),freemem:p.freemem(),totalmem:p.totalmem(),networkInterfaces:p.networkInterfaces()},[2,{code:o.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return S(this,void 0,void 0,(function(){return y(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,n){var r=this;return new Promise((function(s){r._callCppProxy("callInfoSignaling",e,t,n,(function(e,t){s({code:o.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){s({code:e})}))}))},e}(),W=function(){function e(e,t,o,n){void 0===o&&(o=""),void 0===n&&(n=!1),this._cppService=new K(e,t,o,n)}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(G)return G;if(!t)throw new Error("Initializ failed, `appkey` is required!");return G=new W(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.reconnectKickEnable)}(C,e.appkey,e)};
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"types": "index.d.ts",
|
|
22
22
|
"module": "index.esm.js",
|
|
23
|
-
"version": "5.6.1",
|
|
23
|
+
"version": "5.6.2-alpha.1",
|
|
24
24
|
"author": "pass-web@rongcloud.cn",
|
|
25
25
|
"license": "LGPL 2.1",
|
|
26
26
|
"homepage": "https://www.rongcloud.cn",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"globals": "RCMain"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@rongcloud/engine": "=5.6.1"
|
|
34
|
+
"@rongcloud/engine": "=5.6.2-alpha.1"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/sub-process.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("@rongcloud/engine");function n(e,n,r,t){return new(r||(r=Promise))((function(o,a){function h(e){try{u(t.next(e))}catch(e){a(e)}}function l(e){try{u(t.throw(e))}catch(e){a(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(h,l)}u((t=t.apply(e,n||[])).next())}))}function r(e,n){var r,t,o,a,h={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(l){return function(u){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(h=0)),h;)try{if(r=1,t&&(o=2&l[0]?t.return:l[0]?t.throw||((o=t.return)&&o.call(t),0):t.next)&&!(o=o.call(t,l[1])).done)return o;switch(t=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return h.label++,{value:l[1],done:!1};case 5:h.label++,t=l[1],l=[0];continue;case 7:l=h.ops.pop(),h.trys.pop();continue;default:if(!(o=h.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){h=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){h.label=l[1];break}if(6===l[0]&&h.label<o[1]){h.label=o[1],o=l;break}if(o&&h.label<o[2]){h.label=o[2],h.ops.push(l);break}o[2]&&h.ops.pop(),h.trys.pop();continue}l=n.call(e,h)}catch(e){l=[6,e],t=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,u])}}}"function"==typeof SuppressedError&&SuppressedError;var t=48,o=64,a=80,h=96,l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",u=function(e,n,r){var t={length:0,offset:-1};if(n.length,r>=n.length-1)return t;var o=e[n.charAt(r)+n.charAt(r+1)];if(o[0]===r)return t;for(var a=n.length-r,h=0,l=o.length;h<l;h++){var u=o[h],i=r-u;if(!(i>238327)){var s=Math.min(a,i);if(s<=t.length)break;if(!(t.length>2&&n.charAt(u+t.length-1)!==n.charAt(r+t.length-1))){for(var c=2,f=c;f<s&&n.charAt(u+f)===n.charAt(r+f);f++)c++;c>=t.length&&(t.length=c,t.offset=u)}}}return t},i=function(e){var n=[],r=0;do{r=e%62,n.push(l.charAt(r)),e=(e-r)/62}while(e>0);return n.join("")},s=function(e){process.send(e)},c=function(n){return function(e){for(var n={},r=0;r<e.length-1;r++){var l=e.charAt(r)+e.charAt(r+1);n.hasOwnProperty(l)?n[l].push(r):n[l]=[r]}for(var s=[],c=[],f=function(){if(c.length>0){var e=c.join("");if(c=[],e.length>26){var n=i(e.length),r=String.fromCharCode(a|n.length);s.push(r+n)}else{var t=String.fromCharCode(h|e.length);s.push(t)}s.push(e)}},g=0;g<e.length;){var p=u(n,e,g);if(p.length<2)c.push(e.charAt(g++));else if(p.length<4)c.push(e.substr(g,p.length)),g+=p.length;else{var v=i(g-p.offset),d=i(p.length);if(v.length+d.length>=p.length)c.push(e.substr(g,p.length)),g+=p.length;else{f();var b=String.fromCharCode(o|v.length<<2|d.length);s.push(b+v+d),g+=p.length}}}f();var y=i(e.length),m=String.fromCharCode(t|y.length);return s.push(m+y),s.join("")}(n.map(e.transcsv).join(""))};process.on("message",(function(e){return n(void 0,void 0,void 0,(function(){var n,t,o,a;return r(this,(function(r){return n=e.reqId,t=e.method,o=e.args,"compressLogs"===t?(a=c(o[0]),s({reqId:n,success:!0,data:a})):s({reqId:n,success:!1}),[2]}))}))}));
|